Skip to content

Commit 3e48c66

Browse files
committed
Fix code to work when isalpha and friends are macros, not functions.
1 parent 72a3902 commit 3e48c66

File tree

1 file changed

+63
-8
lines changed

1 file changed

+63
-8
lines changed

src/backend/regex/regcomp.c

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,13 @@ static void findmust(struct parse * p, struct re_guts * g);
124124
static sopno pluscount(struct parse * p, struct re_guts * g);
125125
static int pg_isdigit(int c);
126126
static int pg_isalpha(int c);
127+
static int pg_isalnum(int c);
127128
static int pg_isupper(int c);
128129
static int pg_islower(int c);
130+
static int pg_iscntrl(int c);
131+
static int pg_isgraph(int c);
132+
static int pg_isprint(int c);
133+
static int pg_ispunct(int c);
129134

130135
static pg_wchar nuls[10]; /* place to point scanner in event of
131136
* error */
@@ -1709,6 +1714,16 @@ pg_isalpha(int c)
17091714
#endif
17101715
}
17111716

1717+
static int
1718+
pg_isalnum(int c)
1719+
{
1720+
#ifdef MULTIBYTE
1721+
return (c >= 0 && c <= UCHAR_MAX && isalnum((unsigned char) c));
1722+
#else
1723+
return (isalnum((unsigned char) c));
1724+
#endif
1725+
}
1726+
17121727
static int
17131728
pg_isupper(int c)
17141729
{
@@ -1729,6 +1744,46 @@ pg_islower(int c)
17291744
#endif
17301745
}
17311746

1747+
static int
1748+
pg_iscntrl(int c)
1749+
{
1750+
#ifdef MULTIBYTE
1751+
return (c >= 0 && c <= UCHAR_MAX && iscntrl((unsigned char) c));
1752+
#else
1753+
return (iscntrl((unsigned char) c));
1754+
#endif
1755+
}
1756+
1757+
static int
1758+
pg_isgraph(int c)
1759+
{
1760+
#ifdef MULTIBYTE
1761+
return (c >= 0 && c <= UCHAR_MAX && isgraph((unsigned char) c));
1762+
#else
1763+
return (isgraph((unsigned char) c));
1764+
#endif
1765+
}
1766+
1767+
static int
1768+
pg_isprint(int c)
1769+
{
1770+
#ifdef MULTIBYTE
1771+
return (c >= 0 && c <= UCHAR_MAX && isprint((unsigned char) c));
1772+
#else
1773+
return (isprint((unsigned char) c));
1774+
#endif
1775+
}
1776+
1777+
static int
1778+
pg_ispunct(int c)
1779+
{
1780+
#ifdef MULTIBYTE
1781+
return (c >= 0 && c <= UCHAR_MAX && ispunct((unsigned char) c));
1782+
#else
1783+
return (ispunct((unsigned char) c));
1784+
#endif
1785+
}
1786+
17321787
static struct cclass *
17331788
cclass_init(void)
17341789
{
@@ -1756,17 +1811,17 @@ cclass_init(void)
17561811
char *chars;
17571812
} cclass_factories [] =
17581813
{
1759-
{ "alnum", isalnum, NULL },
1760-
{ "alpha", isalpha, NULL },
1814+
{ "alnum", pg_isalnum, NULL },
1815+
{ "alpha", pg_isalpha, NULL },
17611816
{ "blank", NULL, " \t" },
1762-
{ "cntrl", iscntrl, NULL },
1817+
{ "cntrl", pg_iscntrl, NULL },
17631818
{ "digit", NULL, "0123456789" },
1764-
{ "graph", isgraph, NULL },
1765-
{ "lower", islower, NULL },
1766-
{ "print", isprint, NULL },
1767-
{ "punct", ispunct, NULL },
1819+
{ "graph", pg_isgraph, NULL },
1820+
{ "lower", pg_islower, NULL },
1821+
{ "print", pg_isprint, NULL },
1822+
{ "punct", pg_ispunct, NULL },
17681823
{ "space", NULL, "\t\n\v\f\r " },
1769-
{ "upper", isupper, NULL },
1824+
{ "upper", pg_isupper, NULL },
17701825
{ "xdigit", NULL, "0123456789ABCDEFabcdef" },
17711826
{ NULL, NULL, NULL }
17721827
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy