diff options
author | Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com> | 2018-04-19 15:21:54 -0300 |
---|---|---|
committer | Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com> | 2018-04-19 15:21:54 -0300 |
commit | 70ae2309a84496e287d721cf88a1c916c2a2c971 (patch) | |
tree | db32edc81ee3df28aed67a192a6a0c5def226942 /posix/glob_internal.h | |
parent | 15a05fafa4d7f94ae5002803ad8384519479469b (diff) | |
parent | 49a0c33ead1b1eea5b414e9e2574a4fd96291203 (diff) | |
download | glibc-70ae2309a84496e287d721cf88a1c916c2a2c971.tar.gz glibc-70ae2309a84496e287d721cf88a1c916c2a2c971.tar.xz glibc-70ae2309a84496e287d721cf88a1c916c2a2c971.zip |
Merge branch 'release/2.22/master' into ibm/2.22/master ibm/2.22/master
Diffstat (limited to 'posix/glob_internal.h')
-rw-r--r-- | posix/glob_internal.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/posix/glob_internal.h b/posix/glob_internal.h new file mode 100644 index 0000000000..12c93660b7 --- /dev/null +++ b/posix/glob_internal.h @@ -0,0 +1,57 @@ +/* Shared definition for glob and glob_pattern_p. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#ifndef GLOB_INTERNAL_H +# define GLOB_INTERNAL_H + +static inline int +__glob_pattern_type (const char *pattern, int quote) +{ + const char *p; + int ret = 0; + + for (p = pattern; *p != '\0'; ++p) + switch (*p) + { + case '?': + case '*': + return 1; + + case '\\': + if (quote) + { + if (p[1] != '\0') + ++p; + ret |= 2; + } + break; + + case '[': + ret |= 4; + break; + + case ']': + if (ret & 4) + return 1; + break; + } + + return ret; +} + +#endif /* GLOB_INTERNAL_H */ |