@@ -249,53 +249,60 @@ static inline unsigned php_unicode_tofold_simple(unsigned code, enum mbfl_no_enc
249
249
return code ;
250
250
}
251
251
252
- static inline unsigned php_unicode_tolower_full (
253
- unsigned code , enum mbfl_no_encoding enc , unsigned * out ) {
252
+ static inline void php_unicode_tolower_full (unsigned code , enum mbfl_no_encoding enc ,
253
+ mbfl_convert_filter * next_filter ) {
254
254
code = php_unicode_tolower_raw (code , enc );
255
255
if (UNEXPECTED (code > 0xffffff )) {
256
256
unsigned len = code >> 24 ;
257
257
const unsigned * p = & _uccase_extra_table [code & 0xffffff ];
258
- memcpy (out , p + 1 , len * sizeof (unsigned ));
259
- return len ;
258
+ while (len -- ) {
259
+ (next_filter -> filter_function )(* ++ p , next_filter );
260
+ }
261
+ } else {
262
+ (next_filter -> filter_function )(code , next_filter );
260
263
}
261
- * out = code ;
262
- return 1 ;
263
264
}
264
- static inline unsigned php_unicode_toupper_full (
265
- unsigned code , enum mbfl_no_encoding enc , unsigned * out ) {
265
+
266
+ static inline void php_unicode_toupper_full (unsigned code , enum mbfl_no_encoding enc ,
267
+ mbfl_convert_filter * next_filter ) {
266
268
code = php_unicode_toupper_raw (code , enc );
267
269
if (UNEXPECTED (code > 0xffffff )) {
268
270
unsigned len = code >> 24 ;
269
271
const unsigned * p = & _uccase_extra_table [code & 0xffffff ];
270
- memcpy (out , p + 1 , len * sizeof (unsigned ));
271
- return len ;
272
+ while (len -- ) {
273
+ (next_filter -> filter_function )(* ++ p , next_filter );
274
+ }
275
+ } else {
276
+ (next_filter -> filter_function )(code , next_filter );
272
277
}
273
- * out = code ;
274
- return 1 ;
275
278
}
276
- static inline unsigned php_unicode_totitle_full (
277
- unsigned code , enum mbfl_no_encoding enc , unsigned * out ) {
279
+
280
+ static inline void php_unicode_totitle_full (unsigned code , enum mbfl_no_encoding enc ,
281
+ mbfl_convert_filter * next_filter ) {
278
282
code = php_unicode_totitle_raw (code , enc );
279
283
if (UNEXPECTED (code > 0xffffff )) {
280
284
unsigned len = code >> 24 ;
281
285
const unsigned * p = & _uccase_extra_table [code & 0xffffff ];
282
- memcpy (out , p + 1 , len * sizeof (unsigned ));
283
- return len ;
286
+ while (len -- ) {
287
+ (next_filter -> filter_function )(* ++ p , next_filter );
288
+ }
289
+ } else {
290
+ (next_filter -> filter_function )(code , next_filter );
284
291
}
285
- * out = code ;
286
- return 1 ;
287
292
}
288
- static inline unsigned php_unicode_tofold_full (
289
- unsigned code , enum mbfl_no_encoding enc , unsigned * out ) {
293
+
294
+ static inline void php_unicode_tofold_full (unsigned code , enum mbfl_no_encoding enc ,
295
+ mbfl_convert_filter * next_filter ) {
290
296
code = php_unicode_tofold_raw (code , enc );
291
297
if (UNEXPECTED (code > 0xffffff )) {
292
298
unsigned len = code >> 24 ;
293
299
const unsigned * p = & _uccase_extra_table [code & 0xffffff ];
294
- memcpy (out , p + 1 , len * sizeof (unsigned ));
295
- return len ;
300
+ while (len -- ) {
301
+ (next_filter -> filter_function )(* ++ p , next_filter );
302
+ }
303
+ } else {
304
+ (next_filter -> filter_function )(code , next_filter );
296
305
}
297
- * out = code ;
298
- return 1 ;
299
306
}
300
307
301
308
struct convert_case_data {
@@ -308,8 +315,7 @@ struct convert_case_data {
308
315
static int convert_case_filter (int c , void * void_data )
309
316
{
310
317
struct convert_case_data * data = (struct convert_case_data * ) void_data ;
311
- unsigned out [3 ];
312
- unsigned len , i ;
318
+ unsigned code ;
313
319
314
320
/* Handle invalid characters early, as we assign special meaning to
315
321
* codepoints above 0xffffff. */
@@ -320,48 +326,48 @@ static int convert_case_filter(int c, void *void_data)
320
326
321
327
switch (data -> case_mode ) {
322
328
case PHP_UNICODE_CASE_UPPER_SIMPLE :
323
- out [ 0 ] = php_unicode_toupper_simple (c , data -> no_encoding );
324
- len = 1 ;
329
+ code = php_unicode_toupper_simple (c , data -> no_encoding );
330
+ ( data -> next_filter -> filter_function )( code , data -> next_filter ) ;
325
331
break ;
326
332
327
333
case PHP_UNICODE_CASE_UPPER :
328
- len = php_unicode_toupper_full (c , data -> no_encoding , out );
334
+ php_unicode_toupper_full (c , data -> no_encoding , data -> next_filter );
329
335
break ;
330
336
331
337
case PHP_UNICODE_CASE_LOWER_SIMPLE :
332
- out [ 0 ] = php_unicode_tolower_simple (c , data -> no_encoding );
333
- len = 1 ;
338
+ code = php_unicode_tolower_simple (c , data -> no_encoding );
339
+ ( data -> next_filter -> filter_function )( code , data -> next_filter ) ;
334
340
break ;
335
341
336
342
case PHP_UNICODE_CASE_LOWER :
337
- len = php_unicode_tolower_full (c , data -> no_encoding , out );
343
+ php_unicode_tolower_full (c , data -> no_encoding , data -> next_filter );
338
344
break ;
339
345
340
346
case PHP_UNICODE_CASE_FOLD :
341
- len = php_unicode_tofold_full (c , data -> no_encoding , out );
347
+ php_unicode_tofold_full (c , data -> no_encoding , data -> next_filter );
342
348
break ;
343
349
344
350
case PHP_UNICODE_CASE_FOLD_SIMPLE :
345
- out [ 0 ] = php_unicode_tofold_simple (c , data -> no_encoding );
346
- len = 1 ;
351
+ code = php_unicode_tofold_simple (c , data -> no_encoding );
352
+ ( data -> next_filter -> filter_function )( code , data -> next_filter ) ;
347
353
break ;
348
354
349
355
case PHP_UNICODE_CASE_TITLE_SIMPLE :
350
356
case PHP_UNICODE_CASE_TITLE :
351
357
{
352
358
if (data -> title_mode ) {
353
359
if (data -> case_mode == PHP_UNICODE_CASE_TITLE_SIMPLE ) {
354
- out [ 0 ] = php_unicode_tolower_simple (c , data -> no_encoding );
355
- len = 1 ;
360
+ code = php_unicode_tolower_simple (c , data -> no_encoding );
361
+ ( data -> next_filter -> filter_function )( code , data -> next_filter ) ;
356
362
} else {
357
- len = php_unicode_tolower_full (c , data -> no_encoding , out );
363
+ php_unicode_tolower_full (c , data -> no_encoding , data -> next_filter );
358
364
}
359
365
} else {
360
366
if (data -> case_mode == PHP_UNICODE_CASE_TITLE_SIMPLE ) {
361
- out [ 0 ] = php_unicode_totitle_simple (c , data -> no_encoding );
362
- len = 1 ;
367
+ code = php_unicode_totitle_simple (c , data -> no_encoding );
368
+ ( data -> next_filter -> filter_function )( code , data -> next_filter ) ;
363
369
} else {
364
- len = php_unicode_totitle_full (c , data -> no_encoding , out );
370
+ php_unicode_totitle_full (c , data -> no_encoding , data -> next_filter );
365
371
}
366
372
}
367
373
if (!php_unicode_is_case_ignorable (c )) {
@@ -372,9 +378,6 @@ static int convert_case_filter(int c, void *void_data)
372
378
EMPTY_SWITCH_DEFAULT_CASE ()
373
379
}
374
380
375
- for (i = 0 ; i < len ; i ++ ) {
376
- (* data -> next_filter -> filter_function )(out [i ], data -> next_filter );
377
- }
378
381
return 0 ;
379
382
}
380
383
0 commit comments