summaryrefslogtreecommitdiff
path: root/src/backend/regex/regcomp.c
diff options
context:
space:
mode:
authorTom Lane2011-04-10 22:02:17 +0000
committerTom Lane2011-04-10 22:03:09 +0000
commit1e16a8107db9a50435b39e09c6f9c52c45e63e1a (patch)
treebf2231fc078b46004c7814ba871e3c38c1d8d52d /src/backend/regex/regcomp.c
parent210f95f1cd59c6fdfe0f84b922c19d8498ac377d (diff)
Teach regular expression operators to honor collations.
This involves getting the character classification and case-folding functions in the regex library to use the collations infrastructure. Most of this work had been done already in connection with the upper/lower and LIKE logic, so it was a simple matter of transposition. While at it, split out these functions into a separate source file regc_pg_locale.c, so that they can be correctly labeled with the Postgres project's license rather than the Scriptics license. These functions are 100% Postgres-written code whereas what remains in regc_locale.c is still mostly not ours, so lumping them both under the same copyright notice was getting more and more misleading.
Diffstat (limited to 'src/backend/regex/regcomp.c')
-rw-r--r--src/backend/regex/regcomp.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c
index 6ed466a9d97..bd4d4c37619 100644
--- a/src/backend/regex/regcomp.c
+++ b/src/backend/regex/regcomp.c
@@ -172,7 +172,7 @@ static void addrange(struct cvec *, chr, chr);
static struct cvec *getcvec(struct vars *, int, int);
static void freecvec(struct cvec *);
-/* === regc_locale.c === */
+/* === regc_pg_locale.c === */
static int pg_wc_isdigit(pg_wchar c);
static int pg_wc_isalpha(pg_wchar c);
static int pg_wc_isalnum(pg_wchar c);
@@ -184,6 +184,8 @@ static int pg_wc_ispunct(pg_wchar c);
static int pg_wc_isspace(pg_wchar c);
static pg_wchar pg_wc_toupper(pg_wchar c);
static pg_wchar pg_wc_tolower(pg_wchar c);
+
+/* === regc_locale.c === */
static celt element(struct vars *, const chr *, const chr *);
static struct cvec *range(struct vars *, celt, celt, int);
static int before(celt, celt);
@@ -281,7 +283,8 @@ int
pg_regcomp(regex_t *re,
const chr *string,
size_t len,
- int flags)
+ int flags,
+ Oid collation)
{
struct vars var;
struct vars *v = &var;
@@ -307,6 +310,9 @@ pg_regcomp(regex_t *re,
if (!(flags & REG_EXTENDED) && (flags & REG_ADVF))
return REG_INVARG;
+ /* Initialize locale-dependent support */
+ pg_set_regex_collation(collation);
+
/* initial setup (after which freev() is callable) */
v->re = re;
v->now = string;
@@ -333,6 +339,7 @@ pg_regcomp(regex_t *re,
re->re_magic = REMAGIC;
re->re_info = 0; /* bits get set during parse */
re->re_csize = sizeof(chr);
+ re->re_collation = collation;
re->re_guts = NULL;
re->re_fns = VS(&functions);
@@ -1987,4 +1994,5 @@ stid(struct subre * t,
#include "regc_color.c"
#include "regc_nfa.c"
#include "regc_cvec.c"
+#include "regc_pg_locale.c"
#include "regc_locale.c"