tweaks: rename a function and swap its two parameters
parent
067a920517
commit
231fe4bf01
|
@ -358,23 +358,21 @@ void load_history(void)
|
||||||
free(legacyhist);
|
free(legacyhist);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the lines of a history list, starting with the line at head, to
|
/* Write the lines of a history list, starting at head, from oldest to newest,
|
||||||
* the open file at hist. Return TRUE if the write succeeded, and FALSE
|
* to the given file. Return TRUE if writing succeeded, and FALSE otherwise. */
|
||||||
* otherwise. */
|
bool write_list(const filestruct *head, FILE *histfile)
|
||||||
bool writehist(FILE *hist, const filestruct *head)
|
|
||||||
{
|
{
|
||||||
const filestruct *item;
|
const filestruct *item;
|
||||||
|
|
||||||
/* Write a history list, from the oldest item to the newest. */
|
|
||||||
for (item = head; item != NULL; item = item->next) {
|
for (item = head; item != NULL; item = item->next) {
|
||||||
size_t length = strlen(item->data);
|
size_t length = strlen(item->data);
|
||||||
|
|
||||||
/* Decode 0x0A bytes as embedded NULs. */
|
/* Decode 0x0A bytes as embedded NULs. */
|
||||||
sunder(item->data);
|
sunder(item->data);
|
||||||
|
|
||||||
if (fwrite(item->data, sizeof(char), length, hist) < length)
|
if (fwrite(item->data, sizeof(char), length, histfile) < length)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (putc('\n', hist) == EOF)
|
if (putc('\n', histfile) == EOF)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,8 +403,8 @@ void save_history(void)
|
||||||
/* Don't allow others to read or write the history file. */
|
/* Don't allow others to read or write the history file. */
|
||||||
chmod(searchhist, S_IRUSR | S_IWUSR);
|
chmod(searchhist, S_IRUSR | S_IWUSR);
|
||||||
|
|
||||||
if (!writehist(hist, searchtop) || !writehist(hist, replacetop) ||
|
if (!write_list(searchtop, hist) || !write_list(replacetop, hist) ||
|
||||||
!writehist(hist, executetop))
|
!write_list(executetop, hist))
|
||||||
fprintf(stderr, _("Error writing %s: %s\n"), searchhist,
|
fprintf(stderr, _("Error writing %s: %s\n"), searchhist,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue