port over Brand Huntsman's reserved "none" syntax to counteract his

"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
master
David Lawrence Ramsey 2005-08-01 04:59:34 +00:00
parent 5a584ccda3
commit d152ad378b
4 changed files with 21 additions and 6 deletions

View File

@ -53,9 +53,10 @@ CVS code -
regex strings constantly, and to actually compile them on an regex strings constantly, and to actually compile them on an
as-needed basis. Also, make a color syntax specified on the as-needed basis. Also, make a color syntax specified on the
command line override the syntax associated with the current 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 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 thanks_for_all_the_fish(), nregcomp(), parse_syntax(), and
parse_colors(). (Brand Huntsman and DLR) parse_colors(). (Brand Huntsman and DLR)
- Various other color fixes. Handle unspecified foreground - Various other color fixes. Handle unspecified foreground

View File

@ -147,9 +147,10 @@
## ##
## syntax "short description" ["filename regex" ...] ## syntax "short description" ["filename regex" ...]
## ##
## (The syntax "default" is reserved: it takes no filename regexes, and ## (The "none" syntax is reserved; specifying it on the command line is
## applies to files that don't match any other syntax's filename ## the same as not having a syntax at all. The "default" syntax is
## regexes.) ## 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"...] ## color foreground,background "regex" ["regex"...]
## or ## or

View File

@ -117,6 +117,11 @@ void color_update(void)
/* If we specified a syntax override string, use it. */ /* If we specified a syntax override string, use it. */
if (syntaxstr != NULL) { 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; for (tmpsyntax = syntaxes; tmpsyntax != NULL;
tmpsyntax = tmpsyntax->next) { tmpsyntax = tmpsyntax->next) {
if (strcmp(tmpsyntax->desc, syntaxstr) == 0) if (strcmp(tmpsyntax->desc, syntaxstr) == 0)

View File

@ -322,9 +322,17 @@ void parse_syntax(char *ptr)
fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr); fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr);
#endif #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. */ /* The default syntax should have no associated extensions. */
if (strcmp(endsyntax->desc, "default") == 0 && *ptr != '\0') { 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; return;
} }