Skip to content

Commit 4ca8e2a

Browse files
committed
posix: c_lib_ext: fnmatch: added suppor for missing posix functions
Added custom implementations for islower and ispunch since there is some issue with compilenace on some platforms Signed-off-by: Harun Spago <harun.spago.code@gmail.com>
1 parent fb05052 commit 4ca8e2a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/posix/c_lib_ext/fnmatch.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,19 @@ static inline int fnm_cc_match(int c, enum fnm_char_class cc)
166166
case FNM_CC_CNTRL: return iscntrl(c);
167167
case FNM_CC_DIGIT: return isdigit(c);
168168
case FNM_CC_GRAPH: return isgraph(c);
169-
case FNM_CC_LOWER: return islower(c);
169+
case FNM_CC_LOWER: return (c >= 'a' && c <= 'z');
170170
case FNM_CC_PRINT: return isprint(c);
171-
case FNM_CC_PUNCT: return ispunct(c);
171+
case FNM_CC_PUNCT: {
172+
/** Explicit list of punctuation characters in ASCII */
173+
const char *punct_chars = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
174+
175+
for (const char *p = punct_chars; *p != '\0'; p++) {
176+
if (c == *p) {
177+
return 1;
178+
}
179+
}
180+
return 0;
181+
}
172182
case FNM_CC_SPACE: return isspace(c);
173183
case FNM_CC_UPPER: return isupper(c);
174184
case FNM_CC_XDIGIT: return isxdigit(c);

0 commit comments

Comments
 (0)