Don't truncate the history file when history size is unlimited
We still do not handle "set history size unlimited" correctly. In
particular, after writing to the history file, we truncate the history
even if it is unlimited.
This patch makes sure that we do not call history_truncate_file() if the
history is not stifled (i.e. if it's unlimited). This bug causes the
history file to be truncated to zero on exit when one has "set history
size unlimited" in their gdbinit file. Although this code exists in GDB
7.8, the bug is masked by a pre-existing bug that's been only fixed in
GDB 7.9 (PR gdb/17820).
gdb/ChangeLog:
* top.c (gdb_safe_append_history): Do not call
history_truncate_file if the history is not stifled.
gdb/testsuite/ChangeLog:
* gdb.base/gdbinit-history.exp: Add test case to check that
an unlimited history file does not get truncated on exit.