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;
|
||||
}
|
||||
|
||||
/* 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
|
||||
* or buffer content, and load and prime this syntax when needed. */
|
||||
void find_and_prime_applicable_syntax(void)
|
||||
{
|
||||
syntaxtype *sntx = NULL;
|
||||
regexlisttype *item;
|
||||
|
||||
/* If the rcfiles were not read, or contained no syntaxes, get out. */
|
||||
if (syntaxes == NULL)
|
||||
|
@ -149,8 +159,7 @@ void find_and_prime_applicable_syntax(void)
|
|||
fullname = mallocstrcpy(fullname, openfile->filename);
|
||||
|
||||
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
|
||||
for (item = sntx->extensions; item != NULL; item = item->next)
|
||||
if (regexec(item->one_rgx, fullname, 0, NULL, 0) == 0)
|
||||
if (found_in_list(sntx->extensions, fullname))
|
||||
break;
|
||||
|
||||
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 (sntx == NULL && !inhelp) {
|
||||
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
|
||||
for (item = sntx->headers; item != NULL; item = item->next)
|
||||
if (regexec(item->one_rgx, openfile->filetop->data, 0, NULL, 0) == 0)
|
||||
if (found_in_list(sntx->headers, openfile->filetop->data))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -191,8 +199,7 @@ void find_and_prime_applicable_syntax(void)
|
|||
/* Now try and find a syntax that matches the magic string. */
|
||||
if (magicstring != NULL) {
|
||||
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
|
||||
for (item = sntx->magics; item != NULL; item = item->next)
|
||||
if (regexec(item->one_rgx, magicstring, 0, NULL, 0) == 0)
|
||||
if (found_in_list(sntx->magics, magicstring))
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue