oops: that doesn't work -- you can't break out of two for loops at once
This effectively reverts the previous commit.master
parent
c1cd813dcb
commit
a45e1f89c0
21
src/color.c
21
src/color.c
|
@ -115,12 +115,22 @@ void prepare_palette(void)
|
||||||
have_palette = TRUE;
|
have_palette = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Try to match the given shibboleth string with one of the regexes in
|
||||||
|
* the list starting at head. Return TRUE upon success. */
|
||||||
|
bool found_in_list(regexlisttype *head, const char *shibboleth)
|
||||||
|
{
|
||||||
|
for (regexlisttype *item = head; item != NULL; item = item->next)
|
||||||
|
if (regexec(item->one_rgx, shibboleth, 0, NULL, 0) == 0)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Find a syntax that applies to the current buffer, based upon filename
|
/* Find a syntax that applies to the current buffer, based upon filename
|
||||||
* or buffer content, and load and prime this syntax when needed. */
|
* or buffer content, and load and prime this syntax when needed. */
|
||||||
void find_and_prime_applicable_syntax(void)
|
void find_and_prime_applicable_syntax(void)
|
||||||
{
|
{
|
||||||
syntaxtype *sntx = NULL;
|
syntaxtype *sntx = NULL;
|
||||||
regexlisttype *item;
|
|
||||||
|
|
||||||
/* If the rcfiles were not read, or contained no syntaxes, get out. */
|
/* If the rcfiles were not read, or contained no syntaxes, get out. */
|
||||||
if (syntaxes == NULL)
|
if (syntaxes == NULL)
|
||||||
|
@ -149,8 +159,7 @@ void find_and_prime_applicable_syntax(void)
|
||||||
fullname = mallocstrcpy(fullname, openfile->filename);
|
fullname = mallocstrcpy(fullname, openfile->filename);
|
||||||
|
|
||||||
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
|
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
|
||||||
for (item = sntx->extensions; item != NULL; item = item->next)
|
if (found_in_list(sntx->extensions, fullname))
|
||||||
if (regexec(item->one_rgx, fullname, 0, NULL, 0) == 0)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
free(fullname);
|
free(fullname);
|
||||||
|
@ -159,8 +168,7 @@ void find_and_prime_applicable_syntax(void)
|
||||||
/* If the filename didn't match anything, try the first line. */
|
/* If the filename didn't match anything, try the first line. */
|
||||||
if (sntx == NULL && !inhelp) {
|
if (sntx == NULL && !inhelp) {
|
||||||
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
|
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
|
||||||
for (item = sntx->headers; item != NULL; item = item->next)
|
if (found_in_list(sntx->headers, openfile->filetop->data))
|
||||||
if (regexec(item->one_rgx, openfile->filetop->data, 0, NULL, 0) == 0)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,8 +199,7 @@ void find_and_prime_applicable_syntax(void)
|
||||||
/* Now try and find a syntax that matches the magic string. */
|
/* Now try and find a syntax that matches the magic string. */
|
||||||
if (magicstring != NULL) {
|
if (magicstring != NULL) {
|
||||||
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
|
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
|
||||||
for (item = sntx->magics; item != NULL; item = item->next)
|
if (found_in_list(sntx->magics, magicstring))
|
||||||
if (regexec(item->one_rgx, magicstring, 0, NULL, 0) == 0)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue