tweaks: reduce the scope of two variables, and rename one of them
Also, swap the order of the 'if', and don't bother setting a freed string pointer to NULL as it will never be used again.master
parent
6e3b9ac058
commit
38ca2a41f4
|
@ -142,10 +142,6 @@ char *quotestr = NULL;
|
|||
/* The quoting string. The default value is set in main(). */
|
||||
regex_t quotereg;
|
||||
/* The compiled regular expression from the quoting string. */
|
||||
int quoterc;
|
||||
/* Whether it was compiled successfully. */
|
||||
char *quoteerr = NULL;
|
||||
/* The error message, if it didn't. */
|
||||
#endif
|
||||
|
||||
char *word_chars = NULL;
|
||||
|
|
22
src/nano.c
22
src/nano.c
|
@ -1953,6 +1953,10 @@ int main(int argc, char **argv)
|
|||
#ifdef ENABLE_WRAPPING
|
||||
bool forced_wrapping = FALSE;
|
||||
/* Should long lines be automatically hard wrapped? */
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
int quoterc;
|
||||
/* Whether the quoting regex was compiled successfully. */
|
||||
#endif
|
||||
const struct option long_options[] = {
|
||||
{"boldtext", 0, NULL, 'D'},
|
||||
|
@ -2470,20 +2474,16 @@ int main(int argc, char **argv)
|
|||
if (quotestr == NULL)
|
||||
quotestr = mallocstrcpy(NULL, "^([ \t]*([#:>|}]|/{2}))+");
|
||||
|
||||
/* Compile the quoting regex, and free it when it's good; otherwise,
|
||||
* retrieve and store the error message, to be shown when justifying. */
|
||||
/* Compile the quoting regex, and exit when it's invalid. */
|
||||
quoterc = regcomp("ereg, quotestr, NANO_REG_EXTENDED);
|
||||
if (quoterc == 0) {
|
||||
free(quotestr);
|
||||
quotestr = NULL;
|
||||
} else {
|
||||
if (quoterc != 0) {
|
||||
size_t size = regerror(quoterc, "ereg, NULL, 0);
|
||||
char *message = charalloc(size);
|
||||
|
||||
quoteerr = charalloc(size);
|
||||
regerror(quoterc, "ereg, quoteerr, size);
|
||||
|
||||
die(_("Bad quoting regex \"%s\": %s\n"), quotestr, quoteerr);
|
||||
}
|
||||
regerror(quoterc, "ereg, message, size);
|
||||
die(_("Bad quoting regex \"%s\": %s\n"), quotestr, message);
|
||||
} else
|
||||
free(quotestr);
|
||||
#endif /* ENABLE_JUSTIFY */
|
||||
|
||||
#ifdef ENABLE_SPELLER
|
||||
|
|
|
@ -108,8 +108,6 @@ extern char *punct;
|
|||
extern char *brackets;
|
||||
extern char *quotestr;
|
||||
extern regex_t quotereg;
|
||||
extern int quoterc;
|
||||
extern char *quoteerr;
|
||||
#endif
|
||||
|
||||
extern char *word_chars;
|
||||
|
|
Loading…
Reference in New Issue