tweaks: rename two variables, to be more distinct

And for the second: to indicate that it isn't used.
master
Benno Schulenberg 2020-09-22 10:45:37 +02:00
parent 9709dfd563
commit 32787a9f22
1 changed files with 17 additions and 16 deletions

View File

@ -299,17 +299,17 @@ void load_history(void)
} }
linestruct **history = &search_history; linestruct **history = &search_history;
char *line = NULL; char *stanza = NULL;
size_t buf_len = 0; size_t dummy = 0;
ssize_t read; ssize_t read;
/* Load the three history lists (first search, then replace, then execute) /* Load the three history lists (first search, then replace, then execute)
* from oldest entry to newest. Between two lists there is an empty line. */ * from oldest entry to newest. Between two lists there is an empty line. */
while ((read = getline(&line, &buf_len, histfile)) > 0) { while ((read = getline(&stanza, &dummy, histfile)) > 0) {
line[--read] = '\0'; stanza[--read] = '\0';
if (read > 0) { if (read > 0) {
recode_NUL_to_LF(line, read); recode_NUL_to_LF(stanza, read);
update_history(history, line); update_history(history, stanza);
} else if (history == &search_history) } else if (history == &search_history)
history = &replace_history; history = &replace_history;
else else
@ -320,7 +320,7 @@ void load_history(void)
jot_error(N_("Error reading %s: %s"), histname, strerror(errno)); jot_error(N_("Error reading %s: %s"), histname, strerror(errno));
free(histname); free(histname);
free(line); free(stanza);
/* Reading in the lists has marked them as changed; undo this side effect. */ /* Reading in the lists has marked them as changed; undo this side effect. */
history_changed = FALSE; history_changed = FALSE;
@ -393,22 +393,23 @@ void load_poshistory(void)
if (histfile == NULL) if (histfile == NULL)
return; return;
char *line = NULL, *lineptr, *xptr;
size_t buf_len = 0;
ssize_t read, count = 0; ssize_t read, count = 0;
struct stat fileinfo; struct stat fileinfo;
poshiststruct *record_ptr = NULL, *newrecord; poshiststruct *record_ptr = NULL, *newrecord;
char *lineptr, *xptr;
char *stanza = NULL;
size_t dummy = 0;
/* Read and parse each line, and store the extracted data. */ /* Read and parse each line, and store the extracted data. */
while ((read = getline(&line, &buf_len, histfile)) > 5) { while ((read = getline(&stanza, &dummy, histfile)) > 5) {
/* Decode NULs as embedded newlines. */ /* Decode NULs as embedded newlines. */
recode_NUL_to_LF(line, read); recode_NUL_to_LF(stanza, read);
/* Find where the x index and line number are in the line. */ /* Find the spaces before column number and line number. */
xptr = revstrstr(line, " ", line + read - 3); xptr = revstrstr(stanza, " ", stanza + read - 3);
if (xptr == NULL) if (xptr == NULL)
continue; continue;
lineptr = revstrstr(line, " ", xptr - 2); lineptr = revstrstr(stanza, " ", xptr - 2);
if (lineptr == NULL) if (lineptr == NULL)
continue; continue;
@ -418,7 +419,7 @@ void load_poshistory(void)
/* Create a new position record. */ /* Create a new position record. */
newrecord = nmalloc(sizeof(poshiststruct)); newrecord = nmalloc(sizeof(poshiststruct));
newrecord->filename = copy_of(line); newrecord->filename = copy_of(stanza);
newrecord->linenumber = atoi(lineptr); newrecord->linenumber = atoi(lineptr);
newrecord->columnnumber = atoi(xptr); newrecord->columnnumber = atoi(xptr);
newrecord->next = NULL; newrecord->next = NULL;
@ -445,7 +446,7 @@ void load_poshistory(void)
if (fclose(histfile) == EOF) if (fclose(histfile) == EOF)
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno)); jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
free(line); free(stanza);
if (stat(poshistname, &fileinfo) == 0) if (stat(poshistname, &fileinfo) == 0)
latest_timestamp = fileinfo.st_mtime; latest_timestamp = fileinfo.st_mtime;