diff --git a/src/files.c b/src/files.c
index cb8bd768942d656fdb901001f02b55224d93200f..8eed4a4990cbff3a851c006bb3128e1fffb15d22 100644
--- a/src/files.c
+++ b/src/files.c
@@ -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
  * 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
-     * the last history entry is a blank line. */
-    for (p = h; p != NULL; p = p->next) {
-	size_t p_len = strlen(p->data);
+    /* Write a history list from the oldest entry to the newest. */
+    for (item = head; item != NULL; item = item->next) {
+	size_t length = strlen(item->data);
 
-	if (fwrite(p->data, sizeof(char), p_len, hist) < p_len ||
-		putc('\n', hist) == EOF)
+	if (fwrite(item->data, sizeof(char), length, hist) < length)
+	    return FALSE;
+	if (putc('\n', hist) == EOF)
 	    return FALSE;
     }
 
@@ -3051,25 +3051,25 @@ void save_poshistory(void)
 	chmod(poshist, S_IRUSR | S_IWUSR);
 
 	for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
-	    char *path_and_location;
+	    char *path_and_place;
 	    size_t length;
 
 	    /* Assume 20 decimal positions each for line and column number,
 	     * plus two spaces, plus the line feed, plus the null byte. */
-	    path_and_location = charalloc(strlen(posptr->filename) + 44);
-	    sprintf(path_and_location, "%s %ld %ld\n", posptr->filename,
+	    path_and_place = charalloc(strlen(posptr->filename) + 44);
+	    sprintf(path_and_place, "%s %ld %ld\n", posptr->filename,
 			(long)posptr->lineno, (long)posptr->xno);
-	    length = strlen(path_and_location);
+	    length = strlen(path_and_place);
 
 	    /* Encode newlines in filenames as nulls. */
-	    sunder(path_and_location);
+	    sunder(path_and_place);
 	    /* 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"),
 					poshist, strerror(errno));
-	    free(path_and_location);
+	    free(path_and_place);
 	}
 	fclose(hist);
     }
diff --git a/src/proto.h b/src/proto.h
index 8b5556e7cb92c317a407ced2189fc931b1684050..cc9dd2086b8b5af58a2d924ba0085997fd84d154 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -346,7 +346,7 @@ const char *tail(const char *path);
 #ifndef DISABLE_HISTORIES
 char *histfilename(void);
 void load_history(void);
-bool writehist(FILE *hist, filestruct *histhead);
+bool writehist(FILE *hist, const filestruct *histhead);
 void save_history(void);
 int check_dotnano(void);
 void load_poshistory(void);