"default" syntax when necessary (the latter *is* actually ported mostly
from his patch with a few tweaks; the "default-syntax" option is
apparently something else entirely)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2961
35c25a1d-7b9e-4130-9fde-
d3aeb78583b8
regex strings constantly, and to actually compile them on an
as-needed basis. Also, make a color syntax specified on the
command line override the syntax associated with the current
- file extension, and add a "default" syntax that takes no
+ file extension, add a "default" syntax that takes no
extensions for those files that don't match any other
- syntax's extensions. Changes to update_color(),
+ syntax's extensions, and add a "none" syntax that's the same
+ as having no syntax at all. Changes to update_color(),
thanks_for_all_the_fish(), nregcomp(), parse_syntax(), and
parse_colors(). (Brand Huntsman and DLR)
- Various other color fixes. Handle unspecified foreground
##
## syntax "short description" ["filename regex" ...]
##
-## (The syntax "default" is reserved: it takes no filename regexes, and
-## applies to files that don't match any other syntax's filename
-## regexes.)
+## (The "none" syntax is reserved; specifying it on the command line is
+## the same as not having a syntax at all. The "default" syntax is
+## special: it takes no filename regexes, and applies to files that
+## don't match any other syntax's filename regexes.)
##
## color foreground,background "regex" ["regex"...]
## or
/* If we specified a syntax override string, use it. */
if (syntaxstr != NULL) {
+ /* If the syntax override is "none", it's the same as not having
+ * a syntax at all, so get out. */
+ if (strcmp(syntaxstr, "none") == 0)
+ return;
+
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
tmpsyntax = tmpsyntax->next) {
if (strcmp(tmpsyntax->desc, syntaxstr) == 0)
fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr);
#endif
+ /* The "none" syntax is the same as not having a syntax at all, so
+ * we can't assign any extensions or colors to it. */
+ if (strcmp(endsyntax->desc, "none") == 0) {
+ rcfile_error(N_("The \"none\" syntax is reserved"));
+ return;
+ }
+
/* The default syntax should have no associated extensions. */
if (strcmp(endsyntax->desc, "default") == 0 && *ptr != '\0') {
- rcfile_error(N_("The default syntax must take no extensions"));
+ rcfile_error(
+ N_("The \"default\" syntax must take no extensions"));
return;
}