Skip to content

Commit 98d0bf2

Browse files
authored
Merge pull request #52 from emilengler/2021-01-more-portable-checks
use more portable character checks - thank you @emilengler
2 parents 88fd0a6 + 5bc33b6 commit 98d0bf2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

re.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "re.h"
3333
#include <stdio.h>
34+
#include <ctype.h>
3435

3536
/* Definitions: */
3637

@@ -289,15 +290,15 @@ void re_print(regex_t* pattern)
289290
/* Private functions: */
290291
static int matchdigit(char c)
291292
{
292-
return ((c >= '0') && (c <= '9'));
293+
return isdigit(c);
293294
}
294295
static int matchalpha(char c)
295296
{
296-
return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
297+
return isalpha(c);
297298
}
298299
static int matchwhitespace(char c)
299300
{
300-
return ((c == ' ') || (c == '\t') || (c == '\n') || (c == '\r') || (c == '\f') || (c == '\v'));
301+
return isspace(c);
301302
}
302303
static int matchalphanum(char c)
303304
{

0 commit comments

Comments
 (0)