Rearranging some things to reduce the indentation level by four steps,

so we can unwrap a dozen lines.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5737 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Benno Schulenberg 2016-03-14 17:14:35 +00:00
parent 7070812004
commit 8866f728a2
2 changed files with 117 additions and 128 deletions

View File

@ -1,6 +1,8 @@
2016-03-14 Benno Schulenberg <bensberg@justemail.net> 2016-03-14 Benno Schulenberg <bensberg@justemail.net>
* src/color.c (color_update): Don't dereference a possible NULL. * src/color.c (color_update): Don't dereference a possible NULL.
* src/rcfile.c (parse_colors): Make error message equal to others. * src/rcfile.c (parse_colors): Make error message equal to others.
* src/rcfile.c (parse_rcfile): Rearrange some things to reduce the
indentation level by four steps, so we can unwrap a dozen lines.
2016-03-13 Benno Schulenberg <bensberg@justemail.net> 2016-03-13 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (regexp_init): Allow using the word boundary markers * src/search.c (regexp_init): Allow using the word boundary markers

View File

@ -1046,159 +1046,146 @@ void parse_rcfile(FILE *rcstream
option = ptr; option = ptr;
ptr = parse_next_word(ptr); ptr = parse_next_word(ptr);
/* Find the just read name among the existing options. */
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;
}
if (rcopts[i].name == NULL) {
rcfile_error(N_("Unknown option \"%s\""), option);
continue;
}
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "parse_rcfile(): name = \"%s\"\n", rcopts[i].name); fprintf(stderr, "parse_rcfile(): option name = \"%s\"\n", rcopts[i].name);
#endif #endif
if (set == 1) { /* First handle unsetting. */
if (rcopts[i].flag != 0) if (set == -1) {
/* This option has a flag, so it doesn't take an if (rcopts[i].flag != 0)
* argument. */ UNSET(rcopts[i].flag);
SET(rcopts[i].flag); else
else { rcfile_error(N_("Cannot unset option \"%s\""), rcopts[i].name);
/* This option doesn't have a flag, so it takes continue;
* an argument. */ }
if (*ptr == '\0') {
rcfile_error( /* If the option has a flag, it doesn't take an argument. */
N_("Option \"%s\" requires an argument"), if (rcopts[i].flag != 0) {
SET(rcopts[i].flag);
continue;
}
/* The option doesn't have a flag, so it takes an argument. */
if (*ptr == '\0') {
rcfile_error(N_("Option \"%s\" requires an argument"),
rcopts[i].name); rcopts[i].name);
break; continue;
} }
option = ptr;
if (*option == '"')
option++;
ptr = parse_argument(ptr);
option = mallocstrcpy(NULL, option); option = ptr;
if (*option == '"')
option++;
ptr = parse_argument(ptr);
option = mallocstrcpy(NULL, option);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "option = \"%s\"\n", option); fprintf(stderr, "option argument = \"%s\"\n", option);
#endif #endif
/* Make sure the option argument is a valid multibyte string. */
/* Make sure option is a valid multibyte if (!is_valid_mbstring(option)) {
* string. */ rcfile_error(N_("Option is not a valid multibyte string"));
if (!is_valid_mbstring(option)) { continue;
rcfile_error( }
N_("Option is not a valid multibyte string"));
break;
}
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
if (strcasecmp(rcopts[i].name, "titlecolor") == 0) if (strcasecmp(rcopts[i].name, "titlecolor") == 0)
specified_color_combo[TITLE_BAR] = option; specified_color_combo[TITLE_BAR] = option;
else if (strcasecmp(rcopts[i].name, "statuscolor") == 0) else if (strcasecmp(rcopts[i].name, "statuscolor") == 0)
specified_color_combo[STATUS_BAR] = option; specified_color_combo[STATUS_BAR] = option;
else if (strcasecmp(rcopts[i].name, "keycolor") == 0) else if (strcasecmp(rcopts[i].name, "keycolor") == 0)
specified_color_combo[KEY_COMBO] = option; specified_color_combo[KEY_COMBO] = option;
else if (strcasecmp(rcopts[i].name, "functioncolor") == 0) else if (strcasecmp(rcopts[i].name, "functioncolor") == 0)
specified_color_combo[FUNCTION_TAG] = option; specified_color_combo[FUNCTION_TAG] = option;
else else
#endif #endif
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
if (strcasecmp(rcopts[i].name, "operatingdir") == 0) if (strcasecmp(rcopts[i].name, "operatingdir") == 0)
operating_dir = option; operating_dir = option;
else else
#endif #endif
#ifndef DISABLE_WRAPJUSTIFY #ifndef DISABLE_WRAPJUSTIFY
if (strcasecmp(rcopts[i].name, "fill") == 0) { if (strcasecmp(rcopts[i].name, "fill") == 0) {
if (!parse_num(option, &wrap_at)) { if (!parse_num(option, &wrap_at)) {
rcfile_error( rcfile_error(N_("Requested fill size \"%s\" is invalid"),
N_("Requested fill size \"%s\" is invalid"), option);
option); wrap_at = -CHARS_FROM_EOL;
wrap_at = -CHARS_FROM_EOL; } else
} else free(option);
free(option); } else
} else
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
if (strcasecmp(rcopts[i].name, if (strcasecmp(rcopts[i].name, "matchbrackets") == 0) {
"matchbrackets") == 0) { matchbrackets = option;
matchbrackets = option; if (has_blank_mbchars(matchbrackets)) {
if (has_blank_mbchars(matchbrackets)) { rcfile_error(N_("Non-blank characters required"));
rcfile_error( free(matchbrackets);
N_("Non-blank characters required")); matchbrackets = NULL;
free(matchbrackets); }
matchbrackets = NULL; } else if (strcasecmp(rcopts[i].name, "whitespace") == 0) {
} whitespace = option;
} else if (strcasecmp(rcopts[i].name, if (mbstrlen(whitespace) != 2 || strlenpt(whitespace) != 2) {
"whitespace") == 0) { rcfile_error(N_("Two single-column characters required"));
whitespace = option; free(whitespace);
if (mbstrlen(whitespace) != 2 || whitespace = NULL;
strlenpt(whitespace) != 2) { } else {
rcfile_error( whitespace_len[0] = parse_mbchar(whitespace, NULL, NULL);
N_("Two single-column characters required")); whitespace_len[1] = parse_mbchar(whitespace +
free(whitespace);
whitespace = NULL;
} else {
whitespace_len[0] =
parse_mbchar(whitespace, NULL,
NULL);
whitespace_len[1] =
parse_mbchar(whitespace +
whitespace_len[0], NULL, NULL); whitespace_len[0], NULL, NULL);
} }
} else } else
#endif #endif
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
if (strcasecmp(rcopts[i].name, "punct") == 0) { if (strcasecmp(rcopts[i].name, "punct") == 0) {
punct = option; punct = option;
if (has_blank_mbchars(punct)) { if (has_blank_mbchars(punct)) {
rcfile_error( rcfile_error(N_("Non-blank characters required"));
N_("Non-blank characters required")); free(punct);
free(punct); punct = NULL;
punct = NULL; }
} } else if (strcasecmp(rcopts[i].name, "brackets") == 0) {
} else if (strcasecmp(rcopts[i].name, brackets = option;
"brackets") == 0) { if (has_blank_mbchars(brackets)) {
brackets = option; rcfile_error(N_("Non-blank characters required"));
if (has_blank_mbchars(brackets)) { free(brackets);
rcfile_error( brackets = NULL;
N_("Non-blank characters required")); }
free(brackets); } else if (strcasecmp(rcopts[i].name, "quotestr") == 0)
brackets = NULL; quotestr = option;
} else
} else if (strcasecmp(rcopts[i].name,
"quotestr") == 0)
quotestr = option;
else
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
if (strcasecmp(rcopts[i].name, if (strcasecmp(rcopts[i].name, "backupdir") == 0)
"backupdir") == 0) backup_dir = option;
backup_dir = option; else
else
#endif #endif
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER
if (strcasecmp(rcopts[i].name, "speller") == 0) if (strcasecmp(rcopts[i].name, "speller") == 0)
alt_speller = option; alt_speller = option;
else else
#endif #endif
if (strcasecmp(rcopts[i].name, if (strcasecmp(rcopts[i].name, "tabsize") == 0) {
"tabsize") == 0) { if (!parse_num(option, &tabsize) || tabsize <= 0) {
if (!parse_num(option, &tabsize) || rcfile_error(N_("Requested tab size \"%s\" is invalid"),
tabsize <= 0) { option);
rcfile_error( tabsize = -1;
N_("Requested tab size \"%s\" is invalid"), } else
option); free(option);
tabsize = -1; } else
} else assert(FALSE);
free(option);
} else
assert(FALSE);
}
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "flag = %ld\n", rcopts[i].flag); fprintf(stderr, "flag = %ld\n", rcopts[i].flag);
#endif #endif
} else if (rcopts[i].flag != 0)
UNSET(rcopts[i].flag);
else
rcfile_error(N_("Cannot unset option \"%s\""),
rcopts[i].name);
break;
}
}
if (rcopts[i].name == NULL)
rcfile_error(N_("Unknown option \"%s\""), option);
} }
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR