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(). */
|
/* The quoting string. The default value is set in main(). */
|
||||||
regex_t quotereg;
|
regex_t quotereg;
|
||||||
/* The compiled regular expression from the quoting string. */
|
/* 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
|
#endif
|
||||||
|
|
||||||
char *word_chars = NULL;
|
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
|
#ifdef ENABLE_WRAPPING
|
||||||
bool forced_wrapping = FALSE;
|
bool forced_wrapping = FALSE;
|
||||||
/* Should long lines be automatically hard wrapped? */
|
/* Should long lines be automatically hard wrapped? */
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_JUSTIFY
|
||||||
|
int quoterc;
|
||||||
|
/* Whether the quoting regex was compiled successfully. */
|
||||||
#endif
|
#endif
|
||||||
const struct option long_options[] = {
|
const struct option long_options[] = {
|
||||||
{"boldtext", 0, NULL, 'D'},
|
{"boldtext", 0, NULL, 'D'},
|
||||||
|
@ -2470,20 +2474,16 @@ int main(int argc, char **argv)
|
||||||
if (quotestr == NULL)
|
if (quotestr == NULL)
|
||||||
quotestr = mallocstrcpy(NULL, "^([ \t]*([#:>|}]|/{2}))+");
|
quotestr = mallocstrcpy(NULL, "^([ \t]*([#:>|}]|/{2}))+");
|
||||||
|
|
||||||
/* Compile the quoting regex, and free it when it's good; otherwise,
|
/* Compile the quoting regex, and exit when it's invalid. */
|
||||||
* retrieve and store the error message, to be shown when justifying. */
|
|
||||||
quoterc = regcomp("ereg, quotestr, NANO_REG_EXTENDED);
|
quoterc = regcomp("ereg, quotestr, NANO_REG_EXTENDED);
|
||||||
if (quoterc == 0) {
|
if (quoterc != 0) {
|
||||||
free(quotestr);
|
|
||||||
quotestr = NULL;
|
|
||||||
} else {
|
|
||||||
size_t size = regerror(quoterc, "ereg, NULL, 0);
|
size_t size = regerror(quoterc, "ereg, NULL, 0);
|
||||||
|
char *message = charalloc(size);
|
||||||
|
|
||||||
quoteerr = charalloc(size);
|
regerror(quoterc, "ereg, message, size);
|
||||||
regerror(quoterc, "ereg, quoteerr, size);
|
die(_("Bad quoting regex \"%s\": %s\n"), quotestr, message);
|
||||||
|
} else
|
||||||
die(_("Bad quoting regex \"%s\": %s\n"), quotestr, quoteerr);
|
free(quotestr);
|
||||||
}
|
|
||||||
#endif /* ENABLE_JUSTIFY */
|
#endif /* ENABLE_JUSTIFY */
|
||||||
|
|
||||||
#ifdef ENABLE_SPELLER
|
#ifdef ENABLE_SPELLER
|
||||||
|
|
|
@ -108,8 +108,6 @@ extern char *punct;
|
||||||
extern char *brackets;
|
extern char *brackets;
|
||||||
extern char *quotestr;
|
extern char *quotestr;
|
||||||
extern regex_t quotereg;
|
extern regex_t quotereg;
|
||||||
extern int quoterc;
|
|
||||||
extern char *quoteerr;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern char *word_chars;
|
extern char *word_chars;
|
||||||
|
|
Loading…
Reference in New Issue