Skip to content

Commit 2eed406

Browse files
Regex library is switched to use new ctype tools
to allow usage of many character sets at a time.
1 parent 576c9b8 commit 2eed406

File tree

13 files changed

+126
-100
lines changed

13 files changed

+126
-100
lines changed

include/m_ctype.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ extern const char *compiled_charset_name(uint charset_number);
180180
#define _B 0100 /* Blank */
181181
#define _X 0200 /* heXadecimal digit */
182182

183+
#ifndef HIDE_OLD_CTYPE
183184
#define my_ctype (default_charset_info->ctype)
184185
#define my_to_upper (default_charset_info->to_upper)
185186
#define my_to_lower (default_charset_info->to_lower)
@@ -201,13 +202,17 @@ extern const char *compiled_charset_name(uint charset_number);
201202
#define isprint(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N | _B))
202203
#define isgraph(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N))
203204
#define iscntrl(c) ((my_ctype+1)[(uchar) (c)] & _C)
205+
#endif
206+
204207
#define isascii(c) (!((c) & ~0177))
205208
#define toascii(c) ((c) & 0177)
206209

207210
#ifdef ctype
208211
#undef ctype
209212
#endif /* ctype */
210213

214+
#define my_toupper(s,c) (char) ((s)->to_upper[(uchar) (c)])
215+
#define my_tolower(s,c) (char) ((s)->to_lower[(uchar) (c)])
211216
#define my_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_U | _L))
212217
#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _U)
213218
#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _L)

regex/debug.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ FILE *d;
4545
if (g->nplus > 0)
4646
fprintf(d, ", nplus %ld", (long)g->nplus);
4747
fprintf(d, "\n");
48-
s_print(g, d);
48+
s_print(r->charset, g, d);
4949
for (i = 0; i < g->ncategories; i++) {
5050
nincat[i] = 0;
5151
for (c = CHAR_MIN; c <= CHAR_MAX; c++)
@@ -58,7 +58,7 @@ FILE *d;
5858
for (c = CHAR_MIN; c <= CHAR_MAX; c++)
5959
if (g->categories[c] == i)
6060
break;
61-
fprintf(d, ", %d=%s", i, regchar(c,buf));
61+
fprintf(d, ", %d=%s", i, regchar(r->charset,c,buf));
6262
}
6363
fprintf(d, "\n");
6464
for (i = 1; i < g->ncategories; i++)
@@ -68,14 +68,14 @@ FILE *d;
6868
for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */
6969
if (c <= CHAR_MAX && g->categories[c] == i) {
7070
if (last < 0) {
71-
fprintf(d, "%s", regchar(c,buf));
71+
fprintf(d, "%s", regchar(r->charset,c,buf));
7272
last = c;
7373
}
7474
} else {
7575
if (last >= 0) {
7676
if (last != c-1)
7777
fprintf(d, "-%s",
78-
regchar(c-1,buf));
78+
regchar(r->charset,c-1,buf));
7979
last = -1;
8080
}
8181
}
@@ -88,7 +88,8 @@ FILE *d;
8888
== static void s_print(register struct re_guts *g, FILE *d);
8989
*/
9090
static void
91-
s_print(g, d)
91+
s_print(charset, g, d)
92+
CHARSET_INFO *charset;
9293
register struct re_guts *g;
9394
FILE *d;
9495
{
@@ -127,7 +128,7 @@ FILE *d;
127128
if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd) != NULL)
128129
fprintf(d, "\\%c", (char)opnd);
129130
else
130-
fprintf(d, "%s", regchar((char)opnd,buf));
131+
fprintf(d, "%s", regchar(charset,(char)opnd,buf));
131132
break;
132133
case OBOL:
133134
fprintf(d, "^");
@@ -151,14 +152,14 @@ FILE *d;
151152
for (i = 0; i < g->csetsize+1; i++) /* +1 flushes */
152153
if (CHIN(cs, i) && i < g->csetsize) {
153154
if (last < 0) {
154-
fprintf(d, "%s", regchar(i,buf));
155+
fprintf(d, "%s", regchar(charset,i,buf));
155156
last = i;
156157
}
157158
} else {
158159
if (last >= 0) {
159160
if (last != i-1)
160161
fprintf(d, "-%s",
161-
regchar(i-1,buf));
162+
regchar(charset,i-1,buf));
162163
last = -1;
163164
}
164165
}
@@ -230,12 +231,13 @@ FILE *d;
230231
== static char *regchar(int ch);
231232
*/
232233
static char * /* -> representation */
233-
regchar(ch,buf)
234+
regchar(charset,ch,buf)
235+
CHARSET_INFO *charset;
234236
int ch;
235237
char *buf;
236238
{
237239

238-
if (isprint(ch) || ch == ' ')
240+
if (my_isprint(charset,ch) || ch == ' ')
239241
sprintf(buf, "%c", ch);
240242
else
241243
sprintf(buf, "\\%o", ch);

regex/debug.ih

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ extern "C" {
55

66
/* === debug.c === */
77
void regprint(regex_t *r, FILE *d);
8-
static void s_print(register struct re_guts *g, FILE *d);
9-
static char *regchar(int ch,char *buf);
8+
static void s_print(CHARSET_INFO *charset, register struct re_guts *g, FILE *d);
9+
static char *regchar(CHARSET_INFO *charset, int ch,char *buf);
1010

1111
#ifdef __cplusplus
1212
}

0 commit comments

Comments
 (0)