tweaks: rename two variables, and frob some comments

Also reshuffle the newline stripping, as it's pointless for lines
that are skipped.
master
Benno Schulenberg 2019-06-14 10:02:42 +02:00
parent b55923f5ec
commit e3f18e7a6c
1 changed files with 11 additions and 11 deletions

View File

@ -966,7 +966,7 @@ static void check_vitals_mapped(void)
} }
} }
/* Parse syntax-only commands. */ /* Handle the four syntax-only commands. */
bool parse_syntax_commands(char *keyword, char *ptr) bool parse_syntax_commands(char *keyword, char *ptr)
{ {
if (strcasecmp(keyword, "color") == 0) if (strcasecmp(keyword, "color") == 0)
@ -991,26 +991,26 @@ bool parse_syntax_commands(char *keyword, char *ptr)
void parse_rcfile(FILE *rcstream, bool syntax_only, bool headers_only) void parse_rcfile(FILE *rcstream, bool syntax_only, bool headers_only)
{ {
bool seen_color_command = FALSE; bool seen_color_command = FALSE;
char *buf = NULL; char *buffer = NULL;
ssize_t len; ssize_t len;
size_t n = 0; size_t size = 0;
while ((len = getline(&buf, &n, rcstream)) > 0) { while ((len = getline(&buffer, &size, rcstream)) > 0) {
char *ptr, *keyword, *option; char *ptr, *keyword, *option;
int set = 0; int set = 0;
size_t i; size_t i;
/* Ignore the newline. */
if (buf[len - 1] == '\n')
buf[len - 1] = '\0';
lineno++; lineno++;
/* If doing a full parse, skip to after the 'syntax' command. */ /* If doing a full parse, skip to after the 'syntax' command. */
if (!headers_only && syntax_only && lineno <= live_syntax->lineno) if (!headers_only && syntax_only && lineno <= live_syntax->lineno)
continue; continue;
ptr = buf; /* Strip the terminating newline, if any. */
if (buffer[len - 1] == '\n')
buffer[len - 1] = '\0';
ptr = buffer;
while (isblank((unsigned char)*ptr)) while (isblank((unsigned char)*ptr))
ptr++; ptr++;
@ -1140,7 +1140,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only, bool headers_only)
option = ptr; option = ptr;
ptr = parse_next_word(ptr); ptr = parse_next_word(ptr);
/* Find the just read name among the existing options. */ /* Find the just parsed option name among the existing names. */
for (i = 0; rcopts[i].name != NULL; i++) { for (i = 0; rcopts[i].name != NULL; i++) {
if (strcasecmp(option, rcopts[i].name) == 0) if (strcasecmp(option, rcopts[i].name) == 0)
break; break;
@ -1294,7 +1294,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only, bool headers_only)
opensyntax = FALSE; opensyntax = FALSE;
#endif #endif
free(buf); free(buffer);
fclose(rcstream); fclose(rcstream);
lineno = 0; lineno = 0;