summaryrefslogtreecommitdiff
path: root/src/backend/regex/regcomp.c
diff options
context:
space:
mode:
authorTom Lane2002-05-05 00:50:31 +0000
committerTom Lane2002-05-05 00:50:31 +0000
commit3e48c661366a0cd20bd38fc006b90d01d4c997a0 (patch)
tree401efedabeea7775542a8d0db640184e4a86cdda /src/backend/regex/regcomp.c
parent72a3902a664c7fbceb2034e28e444b28f96fa717 (diff)
Fix code to work when isalpha and friends are macros, not functions.
Diffstat (limited to 'src/backend/regex/regcomp.c')
-rw-r--r--src/backend/regex/regcomp.c71
1 files changed, 63 insertions, 8 deletions
diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c
index 5392953c6a9..bea464bd2ae 100644
--- a/src/backend/regex/regcomp.c
+++ b/src/backend/regex/regcomp.c
@@ -124,8 +124,13 @@ static void findmust(struct parse * p, struct re_guts * g);
static sopno pluscount(struct parse * p, struct re_guts * g);
static int pg_isdigit(int c);
static int pg_isalpha(int c);
+static int pg_isalnum(int c);
static int pg_isupper(int c);
static int pg_islower(int c);
+static int pg_iscntrl(int c);
+static int pg_isgraph(int c);
+static int pg_isprint(int c);
+static int pg_ispunct(int c);
static pg_wchar nuls[10]; /* place to point scanner in event of
* error */
@@ -1710,6 +1715,16 @@ pg_isalpha(int c)
}
static int
+pg_isalnum(int c)
+{
+#ifdef MULTIBYTE
+ return (c >= 0 && c <= UCHAR_MAX && isalnum((unsigned char) c));
+#else
+ return (isalnum((unsigned char) c));
+#endif
+}
+
+static int
pg_isupper(int c)
{
#ifdef MULTIBYTE
@@ -1729,6 +1744,46 @@ pg_islower(int c)
#endif
}
+static int
+pg_iscntrl(int c)
+{
+#ifdef MULTIBYTE
+ return (c >= 0 && c <= UCHAR_MAX && iscntrl((unsigned char) c));
+#else
+ return (iscntrl((unsigned char) c));
+#endif
+}
+
+static int
+pg_isgraph(int c)
+{
+#ifdef MULTIBYTE
+ return (c >= 0 && c <= UCHAR_MAX && isgraph((unsigned char) c));
+#else
+ return (isgraph((unsigned char) c));
+#endif
+}
+
+static int
+pg_isprint(int c)
+{
+#ifdef MULTIBYTE
+ return (c >= 0 && c <= UCHAR_MAX && isprint((unsigned char) c));
+#else
+ return (isprint((unsigned char) c));
+#endif
+}
+
+static int
+pg_ispunct(int c)
+{
+#ifdef MULTIBYTE
+ return (c >= 0 && c <= UCHAR_MAX && ispunct((unsigned char) c));
+#else
+ return (ispunct((unsigned char) c));
+#endif
+}
+
static struct cclass *
cclass_init(void)
{
@@ -1756,17 +1811,17 @@ cclass_init(void)
char *chars;
} cclass_factories [] =
{
- { "alnum", isalnum, NULL },
- { "alpha", isalpha, NULL },
+ { "alnum", pg_isalnum, NULL },
+ { "alpha", pg_isalpha, NULL },
{ "blank", NULL, " \t" },
- { "cntrl", iscntrl, NULL },
+ { "cntrl", pg_iscntrl, NULL },
{ "digit", NULL, "0123456789" },
- { "graph", isgraph, NULL },
- { "lower", islower, NULL },
- { "print", isprint, NULL },
- { "punct", ispunct, NULL },
+ { "graph", pg_isgraph, NULL },
+ { "lower", pg_islower, NULL },
+ { "print", pg_isprint, NULL },
+ { "punct", pg_ispunct, NULL },
{ "space", NULL, "\t\n\v\f\r " },
- { "upper", isupper, NULL },
+ { "upper", pg_isupper, NULL },
{ "xdigit", NULL, "0123456789ABCDEFabcdef" },
{ NULL, NULL, NULL }
};