mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
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.
This commit is contained in:
@ -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"
|
||||
|
Reference in New Issue
Block a user