switch (c)
{ case'?': if (nc == '\0') returnFALSE; elseif (nc == G_DIR_SEPARATOR) returnFALSE; elseif (nc == '.' && component_start && no_leading_period) returnFALSE; break; case'\\': if (DO_ESCAPE)
c = get_char (&p, casefold); if (nc != c) returnFALSE; break; case'*': if (nc == '.' && component_start && no_leading_period) returnFALSE;
{ constchar *last_p;
for (last_p = p, c = get_char (&p, casefold);
c == '?' || c == '*';
last_p = p, c = get_char (&p, casefold))
{ if (c == '?')
{ if (nc == '\0') returnFALSE; elseif (nc == G_DIR_SEPARATOR) returnFALSE; else
{
last_n = n; nc = get_char (&n, casefold);
}
}
}
/* If the pattern ends with wildcards, we have a *guaranteedmatchunlessthereisadirseparator *intheremainderofthestring.
*/ if (c == '\0')
{ if (strchr (last_n, G_DIR_SEPARATOR) != NULL) returnFALSE; else returnTRUE;
}
if (DO_ESCAPE && c == '\\')
c = get_char (&p, casefold);
for (p = last_p; nc != '\0';)
{ if ((c == '[' || nc == c) &&
gtk_fnmatch_intern (p, last_n, component_start, no_leading_period, casefold)) returnTRUE;
case'[':
{ /* Nonzero if the sense of the character class is inverted. */
gboolean not;
gboolean was_escaped;
if (nc == '\0' || nc == G_DIR_SEPARATOR) returnFALSE;
if (nc == '.' && component_start && no_leading_period) returnFALSE;
not = (*p == '!' || *p == '^'); if (not)
++p;
c = get_unescaped_char (&p, &was_escaped, casefold); for (;;)
{ register gunichar cstart = c, cend = c; if (c == '\0') /* [ (unterminated) loses. */ returnFALSE;
c = get_unescaped_char (&p, &was_escaped, casefold);
if (!was_escaped && c == '-' && *p != ']')
{
cend = get_unescaped_char (&p, &was_escaped, casefold); if (cend == '\0') returnFALSE;
c = get_char (&p, casefold);
}
if (nc >= cstart && nc <= cend) goto matched;
if (!was_escaped && c == ']') break;
} if (!not) returnFALSE; break;
matched:; /* Skip the rest of the [...] that already matched. */ /* XXX 1003.2d11 is unclear if was_escaped is right. */ while (was_escaped || c != ']')
{ if (c == '\0') /* [... (unterminated) loses. */ returnFALSE;
c = get_unescaped_char (&p, &was_escaped, casefold);
} if (not) returnFALSE;
} break;
default: if (c != nc) returnFALSE;
}
component_start = (nc == G_DIR_SEPARATOR);
}
if (*n == '\0') returnTRUE;
returnFALSE;
}
/* Match STRING against the filename pattern PATTERN, returning zero if *itmatches,nonzeroifnot. * *GTK+usedtouseaoldversionofGNUfnmatch()thatwasbuggy *invariouswaysanddidn’thandleUTF-8.Thefollowingis *convertedtoUTF-8.Tosimplifytheprocessofmakingit *correct,thisisspecial-casedtothecombinationsofflags *thatgtkfilesel.cuses. * *FNM_FILE_NAME-alwaysset *FNM_LEADING_DIR-neverset *FNM_NOESCAPE-setonlyonwindows *FNM_CASEFOLD-setonlyonwindows
*/
gboolean
_gtk_fnmatch (constchar *pattern, constchar *string,
gboolean no_leading_period,
gboolean casefold)
{ return gtk_fnmatch_intern (pattern, string, TRUE, no_leading_period, casefold);
}
/* Turn a glob pattern into a case-insensitive one, by replacing *alphabeticcharactersby[xX]ranges.
*/ char *
_gtk_make_ci_glob_pattern (constchar *pattern)
{
GString *s;
gboolean in_range = FALSE;
s = g_string_new (""); for (constchar *p = pattern; *p; p = g_utf8_next_char (p))
{
gunichar c = g_utf8_get_char (p); if (in_range)
{
g_string_append_unichar (s, c); if (c == ']')
in_range = FALSE; continue;
}
#if DO_ESCAPE if (c == '\\')
{
g_string_append (s, "\\");
p = g_utf8_next_char (p); if (*p == '\0') break;
c = g_utf8_get_char (p);
g_string_append_unichar (s, c); continue;
} #endif
if (c == '[')
{
g_string_append (s, "[");
p = g_utf8_next_char (p); if (*p == '\0') break;
c = g_utf8_get_char (p);
g_string_append_unichar (s, c);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.