Moving parse_magic_exp() next to its sister.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4865 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2014-05-12 19:57:12 +00:00
parent 4e62842f82
commit d2f3f2194e
2 changed files with 69 additions and 67 deletions

View File

@ -17,6 +17,7 @@
one with single quotes work again, and add some comments. one with single quotes work again, and add some comments.
* doc/syntax/{man,python,fortran}.nanorc: Add regexes for comments, * doc/syntax/{man,python,fortran}.nanorc: Add regexes for comments,
trailing whitespace and reminders, and trim some trailing spaces. trailing whitespace and reminders, and trim some trailing spaces.
* src/rcfile.c: Move parse_magic_exp() next to its sister.
2014-05-10 Chris Allegretta <chrisa@asty.org> 2014-05-10 Chris Allegretta <chrisa@asty.org>
* src/rcfile.c (parse_color_names): Redefine false and true to * src/rcfile.c (parse_color_names): Redefine false and true to

View File

@ -378,75 +378,8 @@ void parse_syntax(char *ptr)
free(newext); free(newext);
} }
} }
/* Parse the magic regexes that may influence the choice of syntax. */
void parse_magic_exp(char *ptr)
{
#ifdef HAVE_LIBMAGIC
regexlisttype *endmagic = NULL;
assert(ptr != NULL);
if (syntaxes == NULL) {
rcfile_error(
N_("Cannot add a magic string regex without a syntax command"));
return;
}
if (*ptr == '\0') {
rcfile_error(N_("Missing magic string name"));
return;
}
if (*ptr != '"') {
rcfile_error(
N_("Regex strings must begin and end with a \" character"));
return;
}
#ifdef DEBUG
fprintf(stderr, "Starting a magic type: \"%s\"\n", ptr);
#endif
/* Now load the magic regexes into their part of the struct. */
while (*ptr != '\0') {
const char *regexstring;
regexlisttype *newmagic;
while (*ptr != '"' && *ptr != '\0')
ptr++;
if (*ptr == '\0')
return;
ptr++;
regexstring = ptr;
ptr = parse_next_regex(ptr);
if (ptr == NULL)
break;
newmagic = (regexlisttype *)nmalloc(sizeof(regexlisttype));
/* Save the regex string if it's valid. */
if (nregcomp(regexstring, REG_NOSUB)) {
newmagic->ext_regex = mallocstrcpy(NULL, regexstring);
newmagic->ext = NULL;
if (endmagic == NULL)
endsyntax->magics = newmagic;
else
endmagic->next = newmagic;
endmagic = newmagic;
endmagic->next = NULL;
} else
free(newmagic);
}
#endif /* HAVE_LIBMAGIC */
}
#endif /* !DISABLE_COLOR */ #endif /* !DISABLE_COLOR */
int check_bad_binding(sc *s) int check_bad_binding(sc *s)
{ {
#define BADLISTLEN 1 #define BADLISTLEN 1
@ -927,6 +860,74 @@ void parse_header_exp(char *ptr)
} }
} }
#ifndef DISABLE_COLOR
/* Parse the magic regexes that may influence the choice of syntax. */
void parse_magic_exp(char *ptr)
{
#ifdef HAVE_LIBMAGIC
regexlisttype *endmagic = NULL;
assert(ptr != NULL);
if (syntaxes == NULL) {
rcfile_error(
N_("Cannot add a magic string regex without a syntax command"));
return;
}
if (*ptr == '\0') {
rcfile_error(N_("Missing magic string name"));
return;
}
if (*ptr != '"') {
rcfile_error(
N_("Regex strings must begin and end with a \" character"));
return;
}
#ifdef DEBUG
fprintf(stderr, "Starting a magic type: \"%s\"\n", ptr);
#endif
/* Now load the magic regexes into their part of the struct. */
while (*ptr != '\0') {
const char *regexstring;
regexlisttype *newmagic;
while (*ptr != '"' && *ptr != '\0')
ptr++;
if (*ptr == '\0')
return;
ptr++;
regexstring = ptr;
ptr = parse_next_regex(ptr);
if (ptr == NULL)
break;
newmagic = (regexlisttype *)nmalloc(sizeof(regexlisttype));
/* Save the regex string if it's valid. */
if (nregcomp(regexstring, REG_NOSUB)) {
newmagic->ext_regex = mallocstrcpy(NULL, regexstring);
newmagic->ext = NULL;
if (endmagic == NULL)
endsyntax->magics = newmagic;
else
endmagic->next = newmagic;
endmagic = newmagic;
endmagic->next = NULL;
} else
free(newmagic);
}
#endif /* HAVE_LIBMAGIC */
}
#endif /* !DISABLE_COLOR */
/* Parse the linter requested for this syntax. Simple? */ /* Parse the linter requested for this syntax. Simple? */
void parse_linter(char *ptr) void parse_linter(char *ptr)
{ {