diff options
author | Tom Lane | 2003-09-29 00:21:58 +0000 |
---|---|---|
committer | Tom Lane | 2003-09-29 00:21:58 +0000 |
commit | beae352c211aa3435cd8b19634b35e59cf775ce4 (patch) | |
tree | 75975fc5cd1c81aafb97c532833cc275bd377a99 | |
parent | 90b245a072f4a9162f1d3bed6b4be05de4e53855 (diff) |
Fix broken definition of :print: character class, per Bruno Wolff.
Also, make :alnum: character class directly dependent on isalnum()
rather than guessing.
-rw-r--r-- | src/backend/regex/regc_locale.c | 21 | ||||
-rw-r--r-- | src/backend/regex/regcomp.c | 1 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/backend/regex/regc_locale.c b/src/backend/regex/regc_locale.c index 3695bcb5dd..f698cf0434 100644 --- a/src/backend/regex/regc_locale.c +++ b/src/backend/regex/regc_locale.c @@ -389,6 +389,12 @@ pg_isgraph(pg_wchar c) } static int +pg_isprint(pg_wchar c) +{ + return (c >= 0 && c <= UCHAR_MAX && isprint((unsigned char) c)); +} + +static int pg_ispunct(pg_wchar c) { return (c >= 0 && c <= UCHAR_MAX && ispunct((unsigned char) c)); @@ -657,16 +663,25 @@ cclass(struct vars * v, /* context */ switch ((enum classes) index) { case CC_PRINT: + cv = getcvec(v, UCHAR_MAX, 0, 0); + if (cv) + { + for (i = 0; i <= UCHAR_MAX; i++) + { + if (pg_isprint((chr) i)) + addchr(cv, (chr) i); + } + } + break; case CC_ALNUM: - cv = getcvec(v, UCHAR_MAX, 1, 0); + cv = getcvec(v, UCHAR_MAX, 0, 0); if (cv) { for (i = 0; i <= UCHAR_MAX; i++) { - if (pg_isalpha((chr) i)) + if (pg_isalnum((chr) i)) addchr(cv, (chr) i); } - addrange(cv, (chr) '0', (chr) '9'); } break; case CC_ALPHA: diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c index 41185a2049..a6a17bd468 100644 --- a/src/backend/regex/regcomp.c +++ b/src/backend/regex/regcomp.c @@ -184,6 +184,7 @@ static int pg_isalnum(pg_wchar c); static int pg_isupper(pg_wchar c); static int pg_islower(pg_wchar c); static int pg_isgraph(pg_wchar c); +static int pg_isprint(pg_wchar c); static int pg_ispunct(pg_wchar c); static int pg_isspace(pg_wchar c); static pg_wchar pg_toupper(pg_wchar c); |