diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-01 18:03:10 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-06 20:28:20 +0200 |
| commit | f09e17c3c564e8310125a10c03397cbf473ff643 (patch) | |
| tree | 8d0fd4a28e3686c33aaa140d07ddba26ab28bdc2 /src/filename_match.cxx | |
| parent | b0e0c355edaa2e23148cb0260ada907aec930f05 (diff) | |
Remove $Id$ tags, update URL's, and more
- remove obsolete svn '$Id$' tags from all source files
- update .fl files and generated files accordingly
- replace 'http://www.fltk.org' URL's with 'https://...'
- replace bug report URL 'str.php' with 'bugs.php'
- remove trailing whitespace
- fix other whitespace errors flagged by Git
- add and/or fix missing or wrong standard headers
- convert tabs to spaces in all source files
The only relevant code changes are in the fluid/ folder where
some .fl files and other source files were used to generate
the '$Id' headers and footers.
Diffstat (limited to 'src/filename_match.cxx')
| -rw-r--r-- | src/filename_match.cxx | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/src/filename_match.cxx b/src/filename_match.cxx index d793b6b1c..debc9d909 100644 --- a/src/filename_match.cxx +++ b/src/filename_match.cxx @@ -1,6 +1,4 @@ // -// "$Id$" -// // Pattern matching routines for the Fast Light Tool Kit (FLTK). // // Copyright 1998-2010 by Bill Spitzak and others. @@ -9,11 +7,11 @@ // the file "COPYING" which should have been included with this file. If this // file is missing or damaged, see the license at: // -// http://www.fltk.org/COPYING.php +// https://www.fltk.org/COPYING.php // -// Please report all bugs and problems on the following page: +// Please see the following page on how to report bugs and issues: // -// http://www.fltk.org/str.php +// https://www.fltk.org/bugs.php // /* Adapted from Rich Salz. */ @@ -21,11 +19,11 @@ #include <ctype.h> /** - Checks if a string \p s matches a pattern \p p. + Checks if a string \p s matches a pattern \p p. The following syntax is used for the pattern: - * matches any sequence of 0 or more characters. - ? matches any single character. - - [set] matches any character in the set. Set can contain any single characters, or a-z to represent a range. + - [set] matches any character in the set. Set can contain any single characters, or a-z to represent a range. To match ] or - they must be the first characters. To match ^ or ! they must not be the first characters. - [^set] or [!set] matches any character not in the set. - {X|Y|Z} or {X,Y,Z} matches any one of the subexpressions literally. @@ -38,7 +36,7 @@ \endcode \param[in] s the string to check for a match - \param[in] p the string pattern + \param[in] p the string pattern \return non zero if the string matches the pattern */ int fl_filename_match(const char *s, const char *p) { @@ -47,29 +45,29 @@ int fl_filename_match(const char *s, const char *p) { for (;;) { switch(*p++) { - case '?' : // match any single character + case '?' : // match any single character if (!*s++) return 0; break; - case '*' : // match 0-n of any characters + case '*' : // match 0-n of any characters if (!*p) return 1; // do trailing * quickly while (!fl_filename_match(s, p)) if (!*s++) return 0; return 1; - case '[': { // match one character in set of form [abc-d] or [^a-b] + case '[': { // match one character in set of form [abc-d] or [^a-b] if (!*s) return 0; int reverse = (*p=='^' || *p=='!'); if (reverse) p++; matched = 0; char last = 0; while (*p) { - if (*p=='-' && last) { - if (*s <= *++p && *s >= last ) matched = 1; - last = 0; - } else { - if (*s == *p) matched = 1; - } - last = *p++; - if (*p==']') break; + if (*p=='-' && last) { + if (*s <= *++p && *s >= last ) matched = 1; + last = 0; + } else { + if (*s == *p) matched = 1; + } + last = *p++; + if (*p==']') break; } if (matched == reverse) return 0; s++; p++;} @@ -87,23 +85,23 @@ int fl_filename_match(const char *s, const char *p) { case 0: return 0; } } - case '|': // skip rest of |pattern|pattern} when called recursively + case '|': // skip rest of |pattern|pattern} when called recursively case ',': for (matched = 0; *p && matched >= 0;) { - switch (*p++) { - case '\\': if (*p) p++; break; - case '{': matched++; break; - case '}': matched--; break; - } + switch (*p++) { + case '\\': if (*p) p++; break; + case '{': matched++; break; + case '}': matched--; break; + } } break; case '}': break; - case 0: // end of pattern + case 0: // end of pattern return !*s; - case '\\': // quote next character + case '\\': // quote next character if (*p) p++; /* FALLTHROUGH */ default: @@ -113,7 +111,3 @@ int fl_filename_match(const char *s, const char *p) { } } } - -// -// End of "$Id$". -// |
