8
8
9
9
#include "dict.h"
10
10
#include "common.h"
11
+ #include "ts_locale.h"
11
12
12
13
#define CS_WAITKEY 0
13
14
#define CS_INKEY 1
@@ -30,11 +31,11 @@ nstrdup(char *ptr, int len)
30
31
cptr = ptr = res ;
31
32
while (* ptr )
32
33
{
33
- if (* ptr == '\\' )
34
+ if (t_iseq ( ptr , '\\' ) )
34
35
ptr ++ ;
35
- * cptr = * ptr ;
36
- ptr ++ ;
37
- cptr ++ ;
36
+ COPYCHAR ( cptr , ptr ) ;
37
+ cptr += pg_mblen ( ptr ) ;
38
+ ptr += pg_mblen ( ptr ) ;
38
39
}
39
40
* cptr = '\0' ;
40
41
@@ -52,9 +53,9 @@ parse_cfgdict(text *in, Map ** m)
52
53
53
54
while (ptr - VARDATA (in ) < VARSIZE (in ) - VARHDRSZ )
54
55
{
55
- if (* ptr == ',' )
56
+ if ( t_iseq ( ptr , ',' ) )
56
57
num ++ ;
57
- ptr ++ ;
58
+ ptr += pg_mblen ( ptr ) ;
58
59
}
59
60
60
61
* m = mptr = (Map * ) palloc (sizeof (Map ) * (num + 2 ));
@@ -64,93 +65,93 @@ parse_cfgdict(text *in, Map ** m)
64
65
{
65
66
if (state == CS_WAITKEY )
66
67
{
67
- if (isalpha (( unsigned char ) * ptr ))
68
+ if (t_isalpha ( ptr ))
68
69
{
69
70
begin = ptr ;
70
71
state = CS_INKEY ;
71
72
}
72
- else if (!isspace (( unsigned char ) * ptr ))
73
+ else if (!t_isspace ( ptr ))
73
74
ereport (ERROR ,
74
75
(errcode (ERRCODE_SYNTAX_ERROR ),
75
76
errmsg ("syntax error" ),
76
- errdetail ("Syntax error in position %d near \"%c\" " ,
77
- (int ) (ptr - VARDATA (in )), * ptr )));
77
+ errdetail ("Syntax error in position %d" ,
78
+ (int ) (ptr - VARDATA (in )))));
78
79
}
79
80
else if (state == CS_INKEY )
80
81
{
81
- if (isspace (( unsigned char ) * ptr ))
82
+ if (t_isspace ( ptr ))
82
83
{
83
84
mptr -> key = nstrdup (begin , ptr - begin );
84
85
state = CS_WAITEQ ;
85
86
}
86
- else if (* ptr == '=' )
87
+ else if (t_iseq ( ptr , '=' ) )
87
88
{
88
89
mptr -> key = nstrdup (begin , ptr - begin );
89
90
state = CS_WAITVALUE ;
90
91
}
91
- else if (!isalpha (( unsigned char ) * ptr ))
92
+ else if (!t_isalpha ( ptr ))
92
93
ereport (ERROR ,
93
94
(errcode (ERRCODE_SYNTAX_ERROR ),
94
95
errmsg ("syntax error" ),
95
- errdetail ("Syntax error in position %d near \"%c\" " ,
96
- (int ) (ptr - VARDATA (in )), * ptr )));
96
+ errdetail ("Syntax error in position %d" ,
97
+ (int ) (ptr - VARDATA (in )))));
97
98
}
98
99
else if (state == CS_WAITEQ )
99
100
{
100
- if (* ptr == '=' )
101
+ if (t_iseq ( ptr , '=' ) )
101
102
state = CS_WAITVALUE ;
102
- else if (!isspace (( unsigned char ) * ptr ))
103
+ else if (!t_isspace ( ptr ))
103
104
ereport (ERROR ,
104
105
(errcode (ERRCODE_SYNTAX_ERROR ),
105
106
errmsg ("syntax error" ),
106
- errdetail ("Syntax error in position %d near \"%c\" " ,
107
- (int ) (ptr - VARDATA (in )), * ptr )));
107
+ errdetail ("Syntax error in position %d" ,
108
+ (int ) (ptr - VARDATA (in )))));
108
109
}
109
110
else if (state == CS_WAITVALUE )
110
111
{
111
- if (* ptr == '"' )
112
+ if (t_iseq ( ptr , '"' ) )
112
113
{
113
114
begin = ptr + 1 ;
114
115
state = CS_INVALUE ;
115
116
}
116
- else if (!isspace (( unsigned char ) * ptr ))
117
+ else if (!t_isspace ( ptr ))
117
118
{
118
119
begin = ptr ;
119
120
state = CS_IN2VALUE ;
120
121
}
121
122
}
122
123
else if (state == CS_INVALUE )
123
124
{
124
- if (* ptr == '"' )
125
+ if (t_iseq ( ptr , '"' ) )
125
126
{
126
127
mptr -> value = nstrdup (begin , ptr - begin );
127
128
mptr ++ ;
128
129
state = CS_WAITDELIM ;
129
130
}
130
- else if (* ptr == '\\' )
131
+ else if (t_iseq ( ptr , '\\' ) )
131
132
state = CS_INESC ;
132
133
}
133
134
else if (state == CS_IN2VALUE )
134
135
{
135
- if (isspace (( unsigned char ) * ptr ) || * ptr == ',' )
136
+ if (t_isspace ( ptr ) || t_iseq ( ptr , ',' ) )
136
137
{
137
138
mptr -> value = nstrdup (begin , ptr - begin );
138
139
mptr ++ ;
139
- state = (* ptr == ',' ) ? CS_WAITKEY : CS_WAITDELIM ;
140
+ state = (t_iseq ( ptr , ',' ) ) ? CS_WAITKEY : CS_WAITDELIM ;
140
141
}
141
- else if (* ptr == '\\' )
142
+ else if (t_iseq ( ptr , '\\' ) )
142
143
state = CS_INESC ;
143
144
}
144
145
else if (state == CS_WAITDELIM )
145
146
{
146
- if (* ptr == ',' )
147
+ if (t_iseq ( ptr , ',' ) )
147
148
state = CS_WAITKEY ;
148
- else if (!isspace (( unsigned char ) * ptr ))
149
+ else if (!t_isspace ( ptr ))
149
150
ereport (ERROR ,
150
151
(errcode (ERRCODE_SYNTAX_ERROR ),
151
152
errmsg ("syntax error" ),
152
- errdetail ("Syntax error in position %d near \"%c\" " ,
153
- (int ) (ptr - VARDATA (in )), * ptr )));
153
+ errdetail ("Syntax error in position %d" ,
154
+ (int ) (ptr - VARDATA (in )))));
154
155
}
155
156
else if (state == CS_INESC )
156
157
state = CS_INVALUE ;
@@ -160,9 +161,9 @@ parse_cfgdict(text *in, Map ** m)
160
161
ereport (ERROR ,
161
162
(errcode (ERRCODE_SYNTAX_ERROR ),
162
163
errmsg ("bad parser state" ),
163
- errdetail ("%d at position %d near \"%c\" " ,
164
- state , (int ) (ptr - VARDATA (in )), * ptr )));
165
- ptr ++ ;
164
+ errdetail ("%d at position %d" ,
165
+ state , (int ) (ptr - VARDATA (in )))));
166
+ ptr += pg_mblen ( ptr ) ;
166
167
}
167
168
168
169
if (state == CS_IN2VALUE )
0 commit comments