* src/rcfile.c: Improve some comments, and remove some others that
are mispasted or superfluous.
* doc/texinfo/nano.texi: Add missing parenthesis, remove blank line.
+ * src/rcfile.c (parse_magictype, parse_headers): Handle the libmagic
+ and headerline regexes in the same manner, eliding a static variable
+ while renaming some others.
2014-05-10 Chris Allegretta <chrisa@asty.org>
* src/rcfile.c (parse_color_names): Redefine false and true to
#ifndef DISABLE_COLOR
static syntaxtype *endsyntax = NULL;
/* The end of the list of syntaxes. */
-static exttype *endheader = NULL;
- /* End of header list. */
static colortype *endcolor = NULL;
/* The end of the color list for the current syntax. */
#endif
endsyntax->desc = mallocstrcpy(NULL, nameptr);
endsyntax->color = NULL;
endcolor = NULL;
- endheader = NULL;
endsyntax->extensions = NULL;
endsyntax->headers = NULL;
endsyntax->magics = NULL;
{
#ifdef HAVE_LIBMAGIC
const char *fileregptr = NULL;
- exttype *endext = NULL;
+ exttype *endmagic = NULL;
assert(ptr != NULL);
/* Now load the magic regexes into their part of the struct. */
while (*ptr != '\0') {
- exttype *newext;
+ exttype *newmagic;
while (*ptr != '"' && *ptr != '\0')
ptr++;
if (ptr == NULL)
break;
- newext = (exttype *)nmalloc(sizeof(exttype));
+ newmagic = (exttype *)nmalloc(sizeof(exttype));
- /* Save the regex if it's valid. */
+ /* Save the regex string if it's valid. */
if (nregcomp(fileregptr, REG_NOSUB)) {
- newext->ext_regex = mallocstrcpy(NULL, fileregptr);
- newext->ext = NULL;
+ newmagic->ext_regex = mallocstrcpy(NULL, fileregptr);
+ newmagic->ext = NULL;
- if (endext == NULL)
- endsyntax->magics = newext;
+ if (endmagic == NULL)
+ endsyntax->magics = newmagic;
else
- endext->next = newext;
- endext = newext;
- endext->next = NULL;
+ endmagic->next = newmagic;
+ endmagic = newmagic;
+ endmagic->next = NULL;
} else
- free(newext);
+ free(newmagic);
}
#endif /* HAVE_LIBMAGIC */
}
void parse_headers(char *ptr)
{
char *regstr;
+ exttype *endheader = NULL;
assert(ptr != NULL);
if (nregcomp(regstr, 0)) {
newheader->ext_regex = mallocstrcpy(NULL, regstr);
newheader->ext = NULL;
- newheader->next = NULL;
-
-#ifdef DEBUG
- fprintf(stderr, "Starting a new header entry: %s\n", newheader->ext_regex);
-#endif
- if (endheader == NULL) {
+ if (endheader == NULL)
endsyntax->headers = newheader;
- } else {
+ else
endheader->next = newheader;
- }
-
endheader = newheader;
+ endheader->next = NULL;
} else
free(newheader);
}