Commit bc8a3a50 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: rename three variables, for visibility

(I don't /see/ single-letter variables -- they are too small.)
No related merge requests found
Showing with 18 additions and 18 deletions
+18 -18
...@@ -2978,20 +2978,20 @@ void load_history(void) ...@@ -2978,20 +2978,20 @@ void load_history(void)
} }
} }
/* Write the lines of a history list, starting with the line at h, to /* Write the lines of a history list, starting with the line at head, to
* the open file at hist. Return TRUE if the write succeeded, and FALSE * the open file at hist. Return TRUE if the write succeeded, and FALSE
* otherwise. */ * otherwise. */
bool writehist(FILE *hist, filestruct *h) bool writehist(FILE *hist, const filestruct *head)
{ {
filestruct *p; const filestruct *item;
/* Write a history list from the oldest entry to the newest. Assume /* Write a history list from the oldest entry to the newest. */
* the last history entry is a blank line. */ for (item = head; item != NULL; item = item->next) {
for (p = h; p != NULL; p = p->next) { size_t length = strlen(item->data);
size_t p_len = strlen(p->data);
if (fwrite(p->data, sizeof(char), p_len, hist) < p_len || if (fwrite(item->data, sizeof(char), length, hist) < length)
putc('\n', hist) == EOF) return FALSE;
if (putc('\n', hist) == EOF)
return FALSE; return FALSE;
} }
...@@ -3051,25 +3051,25 @@ void save_poshistory(void) ...@@ -3051,25 +3051,25 @@ void save_poshistory(void)
chmod(poshist, S_IRUSR | S_IWUSR); chmod(poshist, S_IRUSR | S_IWUSR);
for (posptr = position_history; posptr != NULL; posptr = posptr->next) { for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
char *path_and_location; char *path_and_place;
size_t length; size_t length;
/* Assume 20 decimal positions each for line and column number, /* Assume 20 decimal positions each for line and column number,
* plus two spaces, plus the line feed, plus the null byte. */ * plus two spaces, plus the line feed, plus the null byte. */
path_and_location = charalloc(strlen(posptr->filename) + 44); path_and_place = charalloc(strlen(posptr->filename) + 44);
sprintf(path_and_location, "%s %ld %ld\n", posptr->filename, sprintf(path_and_place, "%s %ld %ld\n", posptr->filename,
(long)posptr->lineno, (long)posptr->xno); (long)posptr->lineno, (long)posptr->xno);
length = strlen(path_and_location); length = strlen(path_and_place);
/* Encode newlines in filenames as nulls. */ /* Encode newlines in filenames as nulls. */
sunder(path_and_location); sunder(path_and_place);
/* Restore the terminating newline. */ /* Restore the terminating newline. */
path_and_location[length - 1] = '\n'; path_and_place[length - 1] = '\n';
if (fwrite(path_and_location, sizeof(char), length, hist) < length) if (fwrite(path_and_place, sizeof(char), length, hist) < length)
fprintf(stderr, _("Error writing %s: %s\n"), fprintf(stderr, _("Error writing %s: %s\n"),
poshist, strerror(errno)); poshist, strerror(errno));
free(path_and_location); free(path_and_place);
} }
fclose(hist); fclose(hist);
} }
......
...@@ -346,7 +346,7 @@ const char *tail(const char *path); ...@@ -346,7 +346,7 @@ const char *tail(const char *path);
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
char *histfilename(void); char *histfilename(void);
void load_history(void); void load_history(void);
bool writehist(FILE *hist, filestruct *histhead); bool writehist(FILE *hist, const filestruct *histhead);
void save_history(void); void save_history(void);
int check_dotnano(void); int check_dotnano(void);
void load_poshistory(void); void load_poshistory(void);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment