mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-21 20:31:20 +03:00
Stripping things bare to see the sameness.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5685 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
812f986f2e
commit
c3b9d29502
@ -4,6 +4,7 @@
|
||||
it to the Info document, sort it, and tweak a wording.
|
||||
* src/color.c (color_update): Look for a default syntax only when
|
||||
all else failed -- forego the small, complicating optimization.
|
||||
* src/color.c (color_update): Strip things bare to see the sameness.
|
||||
|
||||
GNU nano 2.5.3 - 2016.02.25
|
||||
|
||||
|
24
src/color.c
24
src/color.c
@ -207,28 +207,22 @@ void color_update(void)
|
||||
fullname = mallocstrcpy(fullname, openfile->filename);
|
||||
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
|
||||
for (e = tmpsyntax->extensions; e != NULL; e = e->next) {
|
||||
bool not_compiled = (e->ext == NULL);
|
||||
|
||||
/* e->ext_regex has already been checked for validity
|
||||
* elsewhere. Compile its specified regex if we haven't
|
||||
* already. */
|
||||
if (not_compiled) {
|
||||
e->ext = (regex_t *)nmalloc(sizeof(regex_t));
|
||||
regcomp(e->ext, fixbounds(e->ext_regex), REG_EXTENDED);
|
||||
}
|
||||
|
||||
/* Set colorstrings if we match the extension regex. */
|
||||
if (regexec(e->ext, fullname, 0, NULL, 0) == 0) {
|
||||
openfile->syntax = tmpsyntax;
|
||||
openfile->colorstrings = tmpsyntax->color;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Decompile e->ext_regex's specified regex if we aren't
|
||||
* going to use it. */
|
||||
if (not_compiled)
|
||||
nfreeregex(&e->ext);
|
||||
}
|
||||
@ -243,7 +237,7 @@ void color_update(void)
|
||||
fprintf(stderr, "No result from file extension, trying headerline...\n");
|
||||
#endif
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
|
||||
for (e = tmpsyntax->headers; e != NULL; e = e->next) {
|
||||
bool not_compiled = (e->ext == NULL);
|
||||
@ -252,11 +246,7 @@ void color_update(void)
|
||||
e->ext = (regex_t *)nmalloc(sizeof(regex_t));
|
||||
regcomp(e->ext, fixbounds(e->ext_regex), REG_EXTENDED);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Comparing header regex \"%s\" to fileage \"%s\"...\n",
|
||||
e->ext_regex, openfile->fileage->data);
|
||||
#endif
|
||||
/* Set colorstrings if we match the header-line regex. */
|
||||
|
||||
if (regexec(e->ext, openfile->fileage->data, 0, NULL, 0) == 0) {
|
||||
openfile->syntax = tmpsyntax;
|
||||
openfile->colorstrings = tmpsyntax->color;
|
||||
@ -301,7 +291,7 @@ void color_update(void)
|
||||
|
||||
/* Now try and find a syntax that matches the magicstring. */
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
|
||||
for (e = tmpsyntax->magics; e != NULL; e = e->next) {
|
||||
bool not_compiled = (e->ext == NULL);
|
||||
@ -310,10 +300,7 @@ void color_update(void)
|
||||
e->ext = (regex_t *)nmalloc(sizeof(regex_t));
|
||||
regcomp(e->ext, fixbounds(e->ext_regex), REG_EXTENDED);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Matching regex \"%s\" against \"%s\"\n", e->ext_regex, magicstring);
|
||||
#endif
|
||||
/* Set colorstrings if we match the magic-string regex. */
|
||||
|
||||
if (magicstring && regexec(e->ext, magicstring, 0, NULL, 0) == 0) {
|
||||
openfile->syntax = tmpsyntax;
|
||||
openfile->colorstrings = tmpsyntax->color;
|
||||
@ -323,6 +310,7 @@ void color_update(void)
|
||||
if (not_compiled)
|
||||
nfreeregex(&e->ext);
|
||||
}
|
||||
|
||||
if (openfile->syntax != NULL)
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user