From 661ecf3c48e16a9add216287eb969d7615e47968 Mon Sep 17 00:00:00 2001 From: "Marc G. Fournier" Date: Sun, 15 Mar 1998 07:39:04 +0000 Subject: From: t-ishii@sra.co.jp Included are patches intended for allowing PostgreSQL to handle multi-byte charachter sets such as EUC(Extende Unix Code), Unicode and Mule internal code. With the MB patch you can use multi-byte character sets in regexp and LIKE. The encoding system chosen is determined at the compile time. To enable the MB extension, you need to define a variable "MB" in Makefile.global or in Makefile.custom. For further information please take a look at README.mb under doc directory. (Note that unlike "jp patch" I do not use modified GNU regexp any more. I changed Henry Spencer's regexp coming with PostgreSQL.) --- src/backend/regex/regexec.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/backend/regex/regexec.c') diff --git a/src/backend/regex/regexec.c b/src/backend/regex/regexec.c index e3ac5cd0644..8a51810a203 100644 --- a/src/backend/regex/regexec.c +++ b/src/backend/regex/regexec.c @@ -164,6 +164,11 @@ int eflags; { struct re_guts *g = preg->re_g; +#ifdef MB + pg_wchar *str; + int sts; +#endif + #ifdef REDEBUG #define GOODFLAGS(f) (f) #else @@ -177,8 +182,24 @@ int eflags; return (REG_BADPAT); eflags = GOODFLAGS(eflags); +#ifdef MB + str = (pg_wchar *)malloc((strlen(string)+1) * sizeof(pg_wchar)); + if (!str) { + return(REG_ESPACE); + } + (void)pg_mb2wchar((unsigned char *)string,str); if (g->nstates <= CHAR_BIT * sizeof(states1) && !(eflags & REG_LARGE)) - return (smatcher(g, (char *) string, nmatch, pmatch, eflags)); + sts = smatcher(g, str, nmatch, pmatch, eflags); else - return (lmatcher(g, (char *) string, nmatch, pmatch, eflags)); + sts = lmatcher(g, str, nmatch, pmatch, eflags); + free((char *)str); + return(sts); + +# else + + if (g->nstates <= CHAR_BIT * sizeof(states1) && !(eflags & REG_LARGE)) + return (smatcher(g, (pg_wchar *) string, nmatch, pmatch, eflags)); + else + return (lmatcher(g, (pg_wchar *) string, nmatch, pmatch, eflags)); +#endif } -- cgit v1.2.3