commit d2f3f2194ea5e161b6b325aed30ea3e2fcc2e722
parent 4e62842f821e9dfe24577fd4d3c75dcb4a4aca1e
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 12 May 2014 19:57:12 +0000
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
Diffstat:
M | ChangeLog | | | 1 | + |
M | src/rcfile.c | | | 135 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
2 files changed, 69 insertions(+), 67 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -17,6 +17,7 @@
one with single quotes work again, and add some comments.
* doc/syntax/{man,python,fortran}.nanorc: Add regexes for comments,
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>
* src/rcfile.c (parse_color_names): Redefine false and true to
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -378,75 +378,8 @@ void parse_syntax(char *ptr)
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 */
-
int check_bad_binding(sc *s)
{
#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? */
void parse_linter(char *ptr)
{