Commit 5594aa6a authored by Tom Lane's avatar Tom Lane

Fix broken definition of :print: character class, per Bruno Wolff.

Also, make :alnum: character class directly dependent on isalnum()
rather than guessing.
parent 3b97d9f5
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
* permission to use and distribute the software in accordance with the * permission to use and distribute the software in accordance with the
* terms specified in this license. * terms specified in this license.
* *
* $Header: /cvsroot/pgsql/src/backend/regex/regc_locale.c,v 1.3 2003/08/08 21:41:56 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/regex/regc_locale.c,v 1.4 2003/09/29 00:21:58 tgl Exp $
*/ */
/* ASCII character-name table */ /* ASCII character-name table */
...@@ -388,6 +388,12 @@ pg_isgraph(pg_wchar c) ...@@ -388,6 +388,12 @@ pg_isgraph(pg_wchar c)
return (c >= 0 && c <= UCHAR_MAX && isgraph((unsigned char) c)); return (c >= 0 && c <= UCHAR_MAX && isgraph((unsigned char) c));
} }
static int
pg_isprint(pg_wchar c)
{
return (c >= 0 && c <= UCHAR_MAX && isprint((unsigned char) c));
}
static int static int
pg_ispunct(pg_wchar c) pg_ispunct(pg_wchar c)
{ {
...@@ -657,16 +663,25 @@ cclass(struct vars * v, /* context */ ...@@ -657,16 +663,25 @@ cclass(struct vars * v, /* context */
switch ((enum classes) index) switch ((enum classes) index)
{ {
case CC_PRINT: 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: case CC_ALNUM:
cv = getcvec(v, UCHAR_MAX, 1, 0); cv = getcvec(v, UCHAR_MAX, 0, 0);
if (cv) if (cv)
{ {
for (i = 0; i <= UCHAR_MAX; i++) for (i = 0; i <= UCHAR_MAX; i++)
{ {
if (pg_isalpha((chr) i)) if (pg_isalnum((chr) i))
addchr(cv, (chr) i); addchr(cv, (chr) i);
} }
addrange(cv, (chr) '0', (chr) '9');
} }
break; break;
case CC_ALPHA: case CC_ALPHA:
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Header: /cvsroot/pgsql/src/backend/regex/regcomp.c,v 1.38 2003/08/08 21:41:56 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/regex/regcomp.c,v 1.39 2003/09/29 00:21:58 tgl Exp $
* *
*/ */
...@@ -184,6 +184,7 @@ static int pg_isalnum(pg_wchar c); ...@@ -184,6 +184,7 @@ static int pg_isalnum(pg_wchar c);
static int pg_isupper(pg_wchar c); static int pg_isupper(pg_wchar c);
static int pg_islower(pg_wchar c); static int pg_islower(pg_wchar c);
static int pg_isgraph(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_ispunct(pg_wchar c);
static int pg_isspace(pg_wchar c); static int pg_isspace(pg_wchar c);
static pg_wchar pg_toupper(pg_wchar c); static pg_wchar pg_toupper(pg_wchar c);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment