@@ -142,8 +142,8 @@ static PHP_MINFO_FUNCTION(ctype)
142
142
143
143
/* {{{ ctype
144
144
*/
145
- #define CTYPE (iswhat ) \
146
- zval *c, tmp ; \
145
+ #define CTYPE (iswhat , allow_digits , allow_minus ) \
146
+ zval *c; \
147
147
ZEND_PARSE_PARAMETERS_START(1, 1); \
148
148
Z_PARAM_ZVAL(c) \
149
149
ZEND_PARSE_PARAMETERS_END(); \
@@ -152,24 +152,21 @@ static PHP_MINFO_FUNCTION(ctype)
152
152
RETURN_BOOL(iswhat((int)Z_LVAL_P(c))); \
153
153
} else if (Z_LVAL_P(c) >= -128 && Z_LVAL_P(c) < 0) { \
154
154
RETURN_BOOL(iswhat((int)Z_LVAL_P(c) + 256)); \
155
+ } else if (Z_LVAL_P(c) >= 0) { \
156
+ RETURN_BOOL(allow_digits); \
157
+ } else { \
158
+ RETURN_BOOL(allow_minus); \
155
159
} \
156
- ZVAL_STR(&tmp, zval_get_string_func(c)); \
157
- } else { \
158
- ZVAL_COPY_VALUE(&tmp, c); \
159
- } \
160
- if (Z_TYPE(tmp) == IS_STRING) { \
161
- char *p = Z_STRVAL(tmp), *e = Z_STRVAL(tmp) + Z_STRLEN(tmp); \
160
+ } else if (Z_TYPE_P(c) == IS_STRING) { \
161
+ char *p = Z_STRVAL_P(c), *e = Z_STRVAL_P(c) + Z_STRLEN_P(c); \
162
162
if (e == p) { \
163
- if (Z_TYPE_P(c) == IS_LONG) zval_dtor(&tmp); \
164
163
RETURN_FALSE; \
165
164
} \
166
165
while (p < e) { \
167
166
if(!iswhat((int)*(unsigned char *)(p++))) { \
168
- if (Z_TYPE_P(c) == IS_LONG) zval_dtor(&tmp); \
169
167
RETURN_FALSE; \
170
168
} \
171
169
} \
172
- if (Z_TYPE_P(c) == IS_LONG) zval_dtor(&tmp); \
173
170
RETURN_TRUE; \
174
171
} else { \
175
172
RETURN_FALSE; \
@@ -181,87 +178,87 @@ static PHP_MINFO_FUNCTION(ctype)
181
178
Checks for alphanumeric character(s) */
182
179
static PHP_FUNCTION (ctype_alnum )
183
180
{
184
- CTYPE (isalnum );
181
+ CTYPE (isalnum , 1 , 0 );
185
182
}
186
183
/* }}} */
187
184
188
185
/* {{{ proto bool ctype_alpha(mixed c)
189
186
Checks for alphabetic character(s) */
190
187
static PHP_FUNCTION (ctype_alpha )
191
188
{
192
- CTYPE (isalpha );
189
+ CTYPE (isalpha , 0 , 0 );
193
190
}
194
191
/* }}} */
195
192
196
193
/* {{{ proto bool ctype_cntrl(mixed c)
197
194
Checks for control character(s) */
198
195
static PHP_FUNCTION (ctype_cntrl )
199
196
{
200
- CTYPE (iscntrl );
197
+ CTYPE (iscntrl , 0 , 0 );
201
198
}
202
199
/* }}} */
203
200
204
201
/* {{{ proto bool ctype_digit(mixed c)
205
202
Checks for numeric character(s) */
206
203
static PHP_FUNCTION (ctype_digit )
207
204
{
208
- CTYPE (isdigit );
205
+ CTYPE (isdigit , 1 , 0 );
209
206
}
210
207
/* }}} */
211
208
212
209
/* {{{ proto bool ctype_lower(mixed c)
213
210
Checks for lowercase character(s) */
214
211
static PHP_FUNCTION (ctype_lower )
215
212
{
216
- CTYPE (islower );
213
+ CTYPE (islower , 0 , 0 );
217
214
}
218
215
/* }}} */
219
216
220
217
/* {{{ proto bool ctype_graph(mixed c)
221
218
Checks for any printable character(s) except space */
222
219
static PHP_FUNCTION (ctype_graph )
223
220
{
224
- CTYPE (isgraph );
221
+ CTYPE (isgraph , 1 , 1 );
225
222
}
226
223
/* }}} */
227
224
228
225
/* {{{ proto bool ctype_print(mixed c)
229
226
Checks for printable character(s) */
230
227
static PHP_FUNCTION (ctype_print )
231
228
{
232
- CTYPE (isprint );
229
+ CTYPE (isprint , 1 , 1 );
233
230
}
234
231
/* }}} */
235
232
236
233
/* {{{ proto bool ctype_punct(mixed c)
237
234
Checks for any printable character which is not whitespace or an alphanumeric character */
238
235
static PHP_FUNCTION (ctype_punct )
239
236
{
240
- CTYPE (ispunct );
237
+ CTYPE (ispunct , 0 , 0 );
241
238
}
242
239
/* }}} */
243
240
244
241
/* {{{ proto bool ctype_space(mixed c)
245
242
Checks for whitespace character(s)*/
246
243
static PHP_FUNCTION (ctype_space )
247
244
{
248
- CTYPE (isspace );
245
+ CTYPE (isspace , 0 , 0 );
249
246
}
250
247
/* }}} */
251
248
252
249
/* {{{ proto bool ctype_upper(mixed c)
253
250
Checks for uppercase character(s) */
254
251
static PHP_FUNCTION (ctype_upper )
255
252
{
256
- CTYPE (isupper );
253
+ CTYPE (isupper , 0 , 0 );
257
254
}
258
255
/* }}} */
259
256
260
257
/* {{{ proto bool ctype_xdigit(mixed c)
261
258
Checks for character(s) representing a hexadecimal digit */
262
259
static PHP_FUNCTION (ctype_xdigit )
263
260
{
264
- CTYPE (isxdigit );
261
+ CTYPE (isxdigit , 1 , 0 );
265
262
}
266
263
/* }}} */
267
264
0 commit comments