summaryrefslogtreecommitdiff
path: root/src/backend/regex/regcomp.c
diff options
context:
space:
mode:
authorBruce Momjian2002-09-04 20:31:48 +0000
committerBruce Momjian2002-09-04 20:31:48 +0000
commite50f52a074bdf0d6a9dc384840e641c4c0b0bb1a (patch)
treeab73e8c8ec94a6ddc774c1f9c49b87aa6b93fd13 /src/backend/regex/regcomp.c
parentc91ceec21d357d6d857163d897ac75a79c883dee (diff)
pgindent run.
Diffstat (limited to 'src/backend/regex/regcomp.c')
-rw-r--r--src/backend/regex/regcomp.c190
1 files changed, 109 insertions, 81 deletions
diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c
index 2e2d7c6ab24..71e69dea618 100644
--- a/src/backend/regex/regcomp.c
+++ b/src/backend/regex/regcomp.c
@@ -51,12 +51,12 @@
struct cclass
{
- char *name;
- char *chars;
- char *multis;
+ char *name;
+ char *chars;
+ char *multis;
};
-static struct cclass* cclasses = NULL;
-static struct cclass* cclass_init(void);
+static struct cclass *cclasses = NULL;
+static struct cclass *cclass_init(void);
/*
* parse structure, passed up and down to avoid global variables and
@@ -179,8 +179,8 @@ pg_regcomp(regex_t *preg, const char *pattern, int cflags)
size_t len;
pg_wchar *wcp;
- if ( cclasses == NULL )
- cclasses = cclass_init();
+ if (cclasses == NULL)
+ cclasses = cclass_init();
#ifdef REDEBUG
#define GOODFLAGS(f) (f)
@@ -862,7 +862,7 @@ p_b_cclass(struct parse * p, cset *cs)
struct cclass *cp;
size_t len;
char *u;
- unsigned char c;
+ unsigned char c;
while (MORE() && pg_isalpha(PEEK()))
NEXT();
@@ -1684,77 +1684,105 @@ pg_ispunct(int c)
static struct cclass *
cclass_init(void)
{
- static struct cclass cclasses_C[] = {
- { "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "" },
- { "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", "" },
- { "blank", " \t", "" },
- { "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\177", "" },
- { "digit", "0123456789", "" },
- { "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", "" },
- { "lower", "abcdefghijklmnopqrstuvwxyz", "" },
- { "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", "" },
- { "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", "" },
- { "space", "\t\n\v\f\r ", "" },
- { "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "" },
- { "xdigit", "0123456789ABCDEFabcdef", "" },
- { NULL, NULL, "" }
- };
- struct cclass *cp = NULL;
- struct cclass *classes = NULL;
- struct cclass_factory
- {
- char *name;
- int (*func)(int);
- char *chars;
- } cclass_factories [] =
- {
- { "alnum", pg_isalnum, NULL },
- { "alpha", pg_isalpha, NULL },
- { "blank", NULL, " \t" },
- { "cntrl", pg_iscntrl, NULL },
- { "digit", NULL, "0123456789" },
- { "graph", pg_isgraph, NULL },
- { "lower", pg_islower, NULL },
- { "print", pg_isprint, NULL },
- { "punct", pg_ispunct, NULL },
- { "space", NULL, "\t\n\v\f\r " },
- { "upper", pg_isupper, NULL },
- { "xdigit", NULL, "0123456789ABCDEFabcdef" },
- { NULL, NULL, NULL }
- };
- struct cclass_factory *cf = NULL;
-
- if ( strcmp( setlocale( LC_CTYPE, NULL ), "C" ) == 0 )
- return cclasses_C;
-
- classes = malloc(sizeof(struct cclass) * (sizeof(cclass_factories) / sizeof(struct cclass_factory)));
- if (classes == NULL)
- elog(ERROR,"cclass_init: out of memory");
-
- cp = classes;
- for(cf = cclass_factories; cf->name != NULL; cf++)
- {
- cp->name = strdup(cf->name);
- if ( cf->chars )
- cp->chars = strdup(cf->chars);
- else
- {
- int x = 0, y = 0;
- cp->chars = malloc(sizeof(char) * 256);
- if (cp->chars == NULL)
- elog(ERROR,"cclass_init: out of memory");
- for (x = 0; x < 256; x++)
- {
- if((cf->func)(x))
- *(cp->chars + y++) = x;
- }
- *(cp->chars + y) = '\0';
- }
- cp->multis = "";
- cp++;
- }
- cp->name = cp->chars = NULL;
- cp->multis = "";
-
- return classes;
+ static struct cclass cclasses_C[] = {
+ {"alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ""},
+ {"alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ""},
+ {"blank", " \t", ""},
+ {"cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\177", ""},
+ {"digit", "0123456789", ""},
+ {"graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", ""},
+ {"lower", "abcdefghijklmnopqrstuvwxyz", ""},
+ {"print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", ""},
+ {"punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", ""},
+ {"space", "\t\n\v\f\r ", ""},
+ {"upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", ""},
+ {"xdigit", "0123456789ABCDEFabcdef", ""},
+ {NULL, NULL, ""}
+ };
+ struct cclass *cp = NULL;
+ struct cclass *classes = NULL;
+ struct cclass_factory
+ {
+ char *name;
+ int (*func) (int);
+ char *chars;
+ } cclass_factories[] =
+ {
+ {
+ "alnum", pg_isalnum, NULL
+ },
+ {
+ "alpha", pg_isalpha, NULL
+ },
+ {
+ "blank", NULL, " \t"
+ },
+ {
+ "cntrl", pg_iscntrl, NULL
+ },
+ {
+ "digit", NULL, "0123456789"
+ },
+ {
+ "graph", pg_isgraph, NULL
+ },
+ {
+ "lower", pg_islower, NULL
+ },
+ {
+ "print", pg_isprint, NULL
+ },
+ {
+ "punct", pg_ispunct, NULL
+ },
+ {
+ "space", NULL, "\t\n\v\f\r "
+ },
+ {
+ "upper", pg_isupper, NULL
+ },
+ {
+ "xdigit", NULL, "0123456789ABCDEFabcdef"
+ },
+ {
+ NULL, NULL, NULL
+ }
+ };
+ struct cclass_factory *cf = NULL;
+
+ if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
+ return cclasses_C;
+
+ classes = malloc(sizeof(struct cclass) * (sizeof(cclass_factories) / sizeof(struct cclass_factory)));
+ if (classes == NULL)
+ elog(ERROR, "cclass_init: out of memory");
+
+ cp = classes;
+ for (cf = cclass_factories; cf->name != NULL; cf++)
+ {
+ cp->name = strdup(cf->name);
+ if (cf->chars)
+ cp->chars = strdup(cf->chars);
+ else
+ {
+ int x = 0,
+ y = 0;
+
+ cp->chars = malloc(sizeof(char) * 256);
+ if (cp->chars == NULL)
+ elog(ERROR, "cclass_init: out of memory");
+ for (x = 0; x < 256; x++)
+ {
+ if ((cf->func) (x))
+ *(cp->chars + y++) = x;
+ }
+ *(cp->chars + y) = '\0';
+ }
+ cp->multis = "";
+ cp++;
+ }
+ cp->name = cp->chars = NULL;
+ cp->multis = "";
+
+ return classes;
}