mirror of git://git.sv.gnu.org/nano.git
tweaks: condense some repetitious comments, and check before assigning
Check that the option argument is okay (contains no blank characters), before assigning it to the relevant variable.
This commit is contained in:
parent
3e9ef3032f
commit
c07586d9f3
11
src/nano.c
11
src/nano.c
|
@ -2440,21 +2440,18 @@ int main(int argc, char **argv)
|
|||
#endif
|
||||
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
/* If punct wasn't specified, set its default value. */
|
||||
/* Set the default value for things that weren't specified. */
|
||||
if (punct == NULL)
|
||||
punct = mallocstrcpy(NULL, "!.?");
|
||||
|
||||
/* If brackets wasn't specified, set its default value. */
|
||||
if (brackets == NULL)
|
||||
brackets = mallocstrcpy(NULL, "\"')>]}");
|
||||
|
||||
/* If quotestr wasn't specified, set its default value. */
|
||||
if (quotestr == NULL)
|
||||
quotestr = mallocstrcpy(NULL, "^([ \t]*[#:>|}])+");
|
||||
quoterc = regcomp("ereg, quotestr, NANO_REG_EXTENDED);
|
||||
|
||||
/* Compile the quoting regex, and free it when it's good; otherwise,
|
||||
* retrieve and store the error message, to be shown when justifying. */
|
||||
quoterc = regcomp("ereg, quotestr, NANO_REG_EXTENDED);
|
||||
if (quoterc == 0) {
|
||||
/* We no longer need quotestr, just quotereg. */
|
||||
free(quotestr);
|
||||
quotestr = NULL;
|
||||
} else {
|
||||
|
|
18
src/rcfile.c
18
src/rcfile.c
|
@ -1146,19 +1146,17 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
|
|||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
if (strcasecmp(rcopts[i].name, "punct") == 0) {
|
||||
punct = option;
|
||||
if (has_blank_mbchars(punct)) {
|
||||
if (has_blank_mbchars(option)) {
|
||||
rcfile_error(N_("Non-blank characters required"));
|
||||
free(punct);
|
||||
punct = NULL;
|
||||
}
|
||||
free(option);
|
||||
} else
|
||||
punct = option;
|
||||
} else if (strcasecmp(rcopts[i].name, "brackets") == 0) {
|
||||
brackets = option;
|
||||
if (has_blank_mbchars(brackets)) {
|
||||
if (has_blank_mbchars(option)) {
|
||||
rcfile_error(N_("Non-blank characters required"));
|
||||
free(brackets);
|
||||
brackets = NULL;
|
||||
}
|
||||
free(option);
|
||||
} else
|
||||
brackets = option;
|
||||
} else if (strcasecmp(rcopts[i].name, "quotestr") == 0)
|
||||
quotestr = option;
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue