25
25
#include "mysqlnd_charset.h"
26
26
27
27
/* {{{ utf8 functions */
28
- static unsigned int check_mb_utf8mb3_sequence (const char * start , const char * end )
28
+ static unsigned int check_mb_utf8mb3_sequence (const char * const start , const char * const end )
29
29
{
30
30
zend_uchar c ;
31
31
@@ -64,7 +64,7 @@ static unsigned int check_mb_utf8mb3_sequence(const char *start, const char *end
64
64
}
65
65
66
66
67
- static unsigned int check_mb_utf8_sequence (const char * start , const char * end )
67
+ static unsigned int check_mb_utf8_sequence (const char * const start , const char * const end )
68
68
{
69
69
zend_uchar c ;
70
70
@@ -136,20 +136,20 @@ static unsigned int check_mb_utf8_sequence(const char *start, const char *end)
136
136
return 0 ;
137
137
}
138
138
139
- static unsigned int check_mb_utf8mb3_valid (const char * start , const char * end )
139
+ static unsigned int check_mb_utf8mb3_valid (const char * const start , const char * const end )
140
140
{
141
141
unsigned int len = check_mb_utf8mb3_sequence (start , end );
142
142
return (len > 1 )? len :0 ;
143
143
}
144
144
145
- static unsigned int check_mb_utf8_valid (const char * start , const char * end )
145
+ static unsigned int check_mb_utf8_valid (const char * const start , const char * const end )
146
146
{
147
147
unsigned int len = check_mb_utf8_sequence (start , end );
148
148
return (len > 1 )? len :0 ;
149
149
}
150
150
151
151
152
- static unsigned int mysqlnd_mbcharlen_utf8mb3 (unsigned int utf8 )
152
+ static unsigned int mysqlnd_mbcharlen_utf8mb3 (const unsigned int utf8 )
153
153
{
154
154
if (utf8 < 0x80 ) {
155
155
return 1 ; /* single byte character */
@@ -167,7 +167,7 @@ static unsigned int mysqlnd_mbcharlen_utf8mb3(unsigned int utf8)
167
167
}
168
168
169
169
170
- static unsigned int mysqlnd_mbcharlen_utf8 (unsigned int utf8 )
170
+ static unsigned int mysqlnd_mbcharlen_utf8 (const unsigned int utf8 )
171
171
{
172
172
if (utf8 < 0x80 ) {
173
173
return 1 ; /* single byte character */
@@ -196,13 +196,13 @@ static unsigned int mysqlnd_mbcharlen_utf8(unsigned int utf8)
196
196
197
197
#define isbig5code (c ,d ) (isbig5head(c) && isbig5tail(d))
198
198
199
- static unsigned int check_mb_big5 (const char * start , const char * end )
199
+ static unsigned int check_mb_big5 (const char * const start , const char * const end )
200
200
{
201
201
return (valid_big5head (* (start )) && (end - start ) > 1 && valid_big5tail (* (start + 1 )) ? 2 : 0 );
202
202
}
203
203
204
204
205
- static unsigned int mysqlnd_mbcharlen_big5 (unsigned int big5 )
205
+ static unsigned int mysqlnd_mbcharlen_big5 (const unsigned int big5 )
206
206
{
207
207
return (valid_big5head (big5 )) ? 2 : 1 ;
208
208
}
@@ -214,14 +214,14 @@ static unsigned int mysqlnd_mbcharlen_big5(unsigned int big5)
214
214
#define valid_cp932tail (c ) ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && c <= 0xFC))
215
215
216
216
217
- static unsigned int check_mb_cp932 (const char * start , const char * end )
217
+ static unsigned int check_mb_cp932 (const char * const start , const char * const end )
218
218
{
219
219
return (valid_cp932head ((zend_uchar )start [0 ]) && (end - start > 1 ) &&
220
220
valid_cp932tail ((zend_uchar )start [1 ])) ? 2 : 0 ;
221
221
}
222
222
223
223
224
- static unsigned int mysqlnd_mbcharlen_cp932 (unsigned int cp932 )
224
+ static unsigned int mysqlnd_mbcharlen_cp932 (const unsigned int cp932 )
225
225
{
226
226
return (valid_cp932head ((zend_uchar )cp932 )) ? 2 : 1 ;
227
227
}
@@ -231,7 +231,7 @@ static unsigned int mysqlnd_mbcharlen_cp932(unsigned int cp932)
231
231
/* {{{ euckr functions */
232
232
#define valid_euckr (c ) ((0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE))
233
233
234
- static unsigned int check_mb_euckr (const char * start , const char * end )
234
+ static unsigned int check_mb_euckr (const char * const start , const char * const end )
235
235
{
236
236
if (end - start <= 1 ) {
237
237
return 0 ; /* invalid length */
@@ -246,7 +246,7 @@ static unsigned int check_mb_euckr(const char *start, const char *end)
246
246
}
247
247
248
248
249
- static unsigned int mysqlnd_mbcharlen_euckr (unsigned int kr )
249
+ static unsigned int mysqlnd_mbcharlen_euckr (const unsigned int kr )
250
250
{
251
251
return (valid_euckr (kr )) ? 2 : 1 ;
252
252
}
@@ -259,7 +259,7 @@ static unsigned int mysqlnd_mbcharlen_euckr(unsigned int kr)
259
259
#define valid_eucjpms_ss2 (c ) (((c) & 0xFF) == 0x8E)
260
260
#define valid_eucjpms_ss3 (c ) (((c) & 0xFF) == 0x8F)
261
261
262
- static unsigned int check_mb_eucjpms (const char * start , const char * end )
262
+ static unsigned int check_mb_eucjpms (const char * const start , const char * const end )
263
263
{
264
264
if (* ((zend_uchar * )start ) < 0x80 ) {
265
265
return 0 ; /* invalid eucjpms character */
@@ -278,7 +278,7 @@ static unsigned int check_mb_eucjpms(const char *start, const char *end)
278
278
}
279
279
280
280
281
- static unsigned int mysqlnd_mbcharlen_eucjpms (unsigned int jpms )
281
+ static unsigned int mysqlnd_mbcharlen_eucjpms (const unsigned int jpms )
282
282
{
283
283
if (valid_eucjpms (jpms ) || valid_eucjpms_ss2 (jpms )) {
284
284
return 2 ;
@@ -296,14 +296,14 @@ static unsigned int mysqlnd_mbcharlen_eucjpms(unsigned int jpms)
296
296
#define valid_gb2312_tail (c ) (0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE)
297
297
298
298
299
- static unsigned int check_mb_gb2312 (const char * start , const char * end )
299
+ static unsigned int check_mb_gb2312 (const char * const start , const char * const end )
300
300
{
301
301
return (valid_gb2312_head ((unsigned int )start [0 ]) && end - start > 1 &&
302
302
valid_gb2312_tail ((unsigned int )start [1 ])) ? 2 : 0 ;
303
303
}
304
304
305
305
306
- static unsigned int mysqlnd_mbcharlen_gb2312 (unsigned int gb )
306
+ static unsigned int mysqlnd_mbcharlen_gb2312 (const unsigned int gb )
307
307
{
308
308
return (valid_gb2312_head (gb )) ? 2 : 1 ;
309
309
}
@@ -314,12 +314,12 @@ static unsigned int mysqlnd_mbcharlen_gb2312(unsigned int gb)
314
314
#define valid_gbk_head (c ) (0x81<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE)
315
315
#define valid_gbk_tail (c ) ((0x40<=(zend_uchar)(c) && (zend_uchar)(c)<=0x7E) || (0x80<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE))
316
316
317
- static unsigned int check_mb_gbk (const char * start , const char * end )
317
+ static unsigned int check_mb_gbk (const char * const start , const char * const end )
318
318
{
319
319
return (valid_gbk_head (start [0 ]) && (end ) - (start ) > 1 && valid_gbk_tail (start [1 ])) ? 2 : 0 ;
320
320
}
321
321
322
- static unsigned int mysqlnd_mbcharlen_gbk (unsigned int gbk )
322
+ static unsigned int mysqlnd_mbcharlen_gbk (const unsigned int gbk )
323
323
{
324
324
return (valid_gbk_head (gbk ) ? 2 : 1 );
325
325
}
@@ -331,26 +331,26 @@ static unsigned int mysqlnd_mbcharlen_gbk(unsigned int gbk)
331
331
#define valid_sjis_tail (c ) ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && (c) <= 0xFC))
332
332
333
333
334
- static unsigned int check_mb_sjis (const char * start , const char * end )
334
+ static unsigned int check_mb_sjis (const char * const start , const char * const end )
335
335
{
336
336
return (valid_sjis_head ((zend_uchar )start [0 ]) && (end - start ) > 1 && valid_sjis_tail ((zend_uchar )start [1 ])) ? 2 : 0 ;
337
337
}
338
338
339
339
340
- static unsigned int mysqlnd_mbcharlen_sjis (unsigned int sjis )
340
+ static unsigned int mysqlnd_mbcharlen_sjis (const unsigned int sjis )
341
341
{
342
342
return (valid_sjis_head ((zend_uchar )sjis )) ? 2 : 1 ;
343
343
}
344
344
/* }}} */
345
345
346
346
347
347
/* {{{ ucs2 functions */
348
- static unsigned int check_mb_ucs2 (const char * start __attribute((unused )), const char * end __attribute((unused )))
348
+ static unsigned int check_mb_ucs2 (const char * const start __attribute((unused )), const char * const end __attribute((unused )))
349
349
{
350
350
return 2 ; /* always 2 */
351
351
}
352
352
353
- static unsigned int mysqlnd_mbcharlen_ucs2 (unsigned int ucs2 __attribute((unused )))
353
+ static unsigned int mysqlnd_mbcharlen_ucs2 (const unsigned int ucs2 __attribute((unused )))
354
354
{
355
355
return 2 ; /* always 2 */
356
356
}
@@ -363,7 +363,7 @@ static unsigned int mysqlnd_mbcharlen_ucs2(unsigned int ucs2 __attribute((unused
363
363
#define valid_ujis_ss2 (c ) (((c)&0xFF) == 0x8E)
364
364
#define valid_ujis_ss3 (c ) (((c)&0xFF) == 0x8F)
365
365
366
- static unsigned int check_mb_ujis (const char * start , const char * end )
366
+ static unsigned int check_mb_ujis (const char * const start , const char * const end )
367
367
{
368
368
if (* (zend_uchar * )start < 0x80 ) {
369
369
return 0 ; /* invalid ujis character */
@@ -381,7 +381,7 @@ static unsigned int check_mb_ujis(const char *start, const char *end)
381
381
}
382
382
383
383
384
- static unsigned int mysqlnd_mbcharlen_ujis (unsigned int ujis )
384
+ static unsigned int mysqlnd_mbcharlen_ujis (const unsigned int ujis )
385
385
{
386
386
return (valid_ujis (ujis )? 2 : valid_ujis_ss2 (ujis )? 2 : valid_ujis_ss3 (ujis )? 3 : 1 );
387
387
}
@@ -393,7 +393,7 @@ static unsigned int mysqlnd_mbcharlen_ujis(unsigned int ujis)
393
393
#define UTF16_HIGH_HEAD (x ) ((((zend_uchar) (x)) & 0xFC) == 0xD8)
394
394
#define UTF16_LOW_HEAD (x ) ((((zend_uchar) (x)) & 0xFC) == 0xDC)
395
395
396
- static unsigned int check_mb_utf16 (const char * start , const char * end )
396
+ static unsigned int check_mb_utf16 (const char * const start , const char * const end )
397
397
{
398
398
if (start + 2 > end ) {
399
399
return 0 ;
@@ -410,21 +410,21 @@ static unsigned int check_mb_utf16(const char *start, const char *end)
410
410
}
411
411
412
412
413
- static uint32_t mysqlnd_mbcharlen_utf16 (unsigned int utf16 )
413
+ static uint32_t mysqlnd_mbcharlen_utf16 (const unsigned int utf16 )
414
414
{
415
415
return UTF16_HIGH_HEAD (utf16 ) ? 4 : 2 ;
416
416
}
417
417
/* }}} */
418
418
419
419
420
420
/* {{{ utf32 functions */
421
- static unsigned int check_mb_utf32 (const char * start __attribute((unused )), const char * end __attribute((unused )))
421
+ static unsigned int check_mb_utf32 (const char * const start __attribute((unused )), const char * const end __attribute((unused )))
422
422
{
423
423
return 4 ;
424
424
}
425
425
426
426
427
- static unsigned int mysqlnd_mbcharlen_utf32 (unsigned int utf32 __attribute((unused )))
427
+ static unsigned int mysqlnd_mbcharlen_utf32 (const unsigned int utf32 __attribute((unused )))
428
428
{
429
429
return 4 ;
430
430
}
@@ -437,7 +437,7 @@ static unsigned int mysqlnd_mbcharlen_utf32(unsigned int utf32 __attribute((unus
437
437
#define is_gb18030_even_4 (c ) (0x30 <= (zend_uchar) (c) && (zend_uchar) (c) <= 0x39)
438
438
439
439
440
- static unsigned int mysqlnd_mbcharlen_gb18030 (unsigned int c )
440
+ static unsigned int mysqlnd_mbcharlen_gb18030 (const unsigned int c )
441
441
{
442
442
if (c <= 0xFF ) {
443
443
return !is_gb18030_odd (c );
@@ -740,7 +740,7 @@ const MYSQLND_CHARSET mysqlnd_charsets[] =
740
740
741
741
742
742
/* {{{ mysqlnd_find_charset_nr */
743
- PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_nr (unsigned int charsetnr )
743
+ PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_nr (const unsigned int charsetnr )
744
744
{
745
745
const MYSQLND_CHARSET * c = mysqlnd_charsets ;
746
746
@@ -773,8 +773,8 @@ PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_name(const char * const name
773
773
774
774
775
775
/* {{{ mysqlnd_cset_escape_quotes */
776
- PHPAPI zend_ulong mysqlnd_cset_escape_quotes (const MYSQLND_CHARSET * const cset , char * newstr ,
777
- const char * escapestr , size_t escapestr_len )
776
+ PHPAPI zend_ulong mysqlnd_cset_escape_quotes (const MYSQLND_CHARSET * const cset , char * newstr ,
777
+ const char * escapestr , const size_t escapestr_len )
778
778
{
779
779
const char * newstr_s = newstr ;
780
780
const char * newstr_e = newstr + 2 * escapestr_len ;
@@ -828,7 +828,7 @@ PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const cset,
828
828
829
829
/* {{{ mysqlnd_cset_escape_slashes */
830
830
PHPAPI zend_ulong mysqlnd_cset_escape_slashes (const MYSQLND_CHARSET * const cset , char * newstr ,
831
- const char * escapestr , size_t escapestr_len )
831
+ const char * escapestr , const size_t escapestr_len )
832
832
{
833
833
const char * newstr_s = newstr ;
834
834
const char * newstr_e = newstr + 2 * escapestr_len ;
0 commit comments