nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit e3f18e7a6cef53785a17ac778283a4b1604174ce
parent b55923f5ecb7543ab033030aed50b06e5b6a6467
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri, 14 Jun 2019 10:02:42 +0200

tweaks: rename two variables, and frob some comments

Also reshuffle the newline stripping, as it's pointless for lines
that are skipped.

Diffstat:
Msrc/rcfile.c | 22+++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/rcfile.c b/src/rcfile.c @@ -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) { 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) { bool seen_color_command = FALSE; - char *buf = NULL; + char *buffer = NULL; 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; int set = 0; size_t i; - /* Ignore the newline. */ - if (buf[len - 1] == '\n') - buf[len - 1] = '\0'; - lineno++; /* If doing a full parse, skip to after the 'syntax' command. */ if (!headers_only && syntax_only && lineno <= live_syntax->lineno) 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)) ptr++; @@ -1140,7 +1140,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only, bool headers_only) option = 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++) { if (strcasecmp(option, rcopts[i].name) == 0) break; @@ -1294,7 +1294,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only, bool headers_only) opensyntax = FALSE; #endif - free(buf); + free(buffer); fclose(rcstream); lineno = 0;