Skip to content

Commit f1ede80

Browse files
committed
const-ify some functions
1 parent 1be8b3c commit f1ede80

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed

ext/mysqlnd/mysqlnd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ PHPAPI void mysqlnd_plugin_apply_with_argument(apply_func_arg_t apply_func, void
7878
PHPAPI void mysqlnd_minfo_print_hash(zval *values);
7979
#define mysqlnd_thread_safe() TRUE
8080

81-
PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_nr(unsigned int charsetno);
81+
PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_nr(const unsigned int charsetno);
8282
PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_name(const char * const charsetname);
8383

8484

ext/mysqlnd/mysqlnd_charset.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "mysqlnd_charset.h"
2626

2727
/* {{{ 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)
2929
{
3030
zend_uchar c;
3131

@@ -64,7 +64,7 @@ static unsigned int check_mb_utf8mb3_sequence(const char *start, const char *end
6464
}
6565

6666

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)
6868
{
6969
zend_uchar c;
7070

@@ -136,20 +136,20 @@ static unsigned int check_mb_utf8_sequence(const char *start, const char *end)
136136
return 0;
137137
}
138138

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)
140140
{
141141
unsigned int len = check_mb_utf8mb3_sequence(start, end);
142142
return (len > 1)? len:0;
143143
}
144144

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)
146146
{
147147
unsigned int len = check_mb_utf8_sequence(start, end);
148148
return (len > 1)? len:0;
149149
}
150150

151151

152-
static unsigned int mysqlnd_mbcharlen_utf8mb3(unsigned int utf8)
152+
static unsigned int mysqlnd_mbcharlen_utf8mb3(const unsigned int utf8)
153153
{
154154
if (utf8 < 0x80) {
155155
return 1; /* single byte character */
@@ -167,7 +167,7 @@ static unsigned int mysqlnd_mbcharlen_utf8mb3(unsigned int utf8)
167167
}
168168

169169

170-
static unsigned int mysqlnd_mbcharlen_utf8(unsigned int utf8)
170+
static unsigned int mysqlnd_mbcharlen_utf8(const unsigned int utf8)
171171
{
172172
if (utf8 < 0x80) {
173173
return 1; /* single byte character */
@@ -196,13 +196,13 @@ static unsigned int mysqlnd_mbcharlen_utf8(unsigned int utf8)
196196

197197
#define isbig5code(c,d) (isbig5head(c) && isbig5tail(d))
198198

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)
200200
{
201201
return (valid_big5head(*(start)) && (end - start) > 1 && valid_big5tail(*(start + 1)) ? 2 : 0);
202202
}
203203

204204

205-
static unsigned int mysqlnd_mbcharlen_big5(unsigned int big5)
205+
static unsigned int mysqlnd_mbcharlen_big5(const unsigned int big5)
206206
{
207207
return (valid_big5head(big5)) ? 2 : 1;
208208
}
@@ -214,14 +214,14 @@ static unsigned int mysqlnd_mbcharlen_big5(unsigned int big5)
214214
#define valid_cp932tail(c) ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && c <= 0xFC))
215215

216216

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)
218218
{
219219
return (valid_cp932head((zend_uchar)start[0]) && (end - start > 1) &&
220220
valid_cp932tail((zend_uchar)start[1])) ? 2 : 0;
221221
}
222222

223223

224-
static unsigned int mysqlnd_mbcharlen_cp932(unsigned int cp932)
224+
static unsigned int mysqlnd_mbcharlen_cp932(const unsigned int cp932)
225225
{
226226
return (valid_cp932head((zend_uchar)cp932)) ? 2 : 1;
227227
}
@@ -231,7 +231,7 @@ static unsigned int mysqlnd_mbcharlen_cp932(unsigned int cp932)
231231
/* {{{ euckr functions */
232232
#define valid_euckr(c) ((0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE))
233233

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)
235235
{
236236
if (end - start <= 1) {
237237
return 0; /* invalid length */
@@ -246,7 +246,7 @@ static unsigned int check_mb_euckr(const char *start, const char *end)
246246
}
247247

248248

249-
static unsigned int mysqlnd_mbcharlen_euckr(unsigned int kr)
249+
static unsigned int mysqlnd_mbcharlen_euckr(const unsigned int kr)
250250
{
251251
return (valid_euckr(kr)) ? 2 : 1;
252252
}
@@ -259,7 +259,7 @@ static unsigned int mysqlnd_mbcharlen_euckr(unsigned int kr)
259259
#define valid_eucjpms_ss2(c) (((c) & 0xFF) == 0x8E)
260260
#define valid_eucjpms_ss3(c) (((c) & 0xFF) == 0x8F)
261261

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)
263263
{
264264
if (*((zend_uchar *)start) < 0x80) {
265265
return 0; /* invalid eucjpms character */
@@ -278,7 +278,7 @@ static unsigned int check_mb_eucjpms(const char *start, const char *end)
278278
}
279279

280280

281-
static unsigned int mysqlnd_mbcharlen_eucjpms(unsigned int jpms)
281+
static unsigned int mysqlnd_mbcharlen_eucjpms(const unsigned int jpms)
282282
{
283283
if (valid_eucjpms(jpms) || valid_eucjpms_ss2(jpms)) {
284284
return 2;
@@ -296,14 +296,14 @@ static unsigned int mysqlnd_mbcharlen_eucjpms(unsigned int jpms)
296296
#define valid_gb2312_tail(c) (0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE)
297297

298298

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)
300300
{
301301
return (valid_gb2312_head((unsigned int)start[0]) && end - start > 1 &&
302302
valid_gb2312_tail((unsigned int)start[1])) ? 2 : 0;
303303
}
304304

305305

306-
static unsigned int mysqlnd_mbcharlen_gb2312(unsigned int gb)
306+
static unsigned int mysqlnd_mbcharlen_gb2312(const unsigned int gb)
307307
{
308308
return (valid_gb2312_head(gb)) ? 2 : 1;
309309
}
@@ -314,12 +314,12 @@ static unsigned int mysqlnd_mbcharlen_gb2312(unsigned int gb)
314314
#define valid_gbk_head(c) (0x81<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE)
315315
#define valid_gbk_tail(c) ((0x40<=(zend_uchar)(c) && (zend_uchar)(c)<=0x7E) || (0x80<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE))
316316

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)
318318
{
319319
return (valid_gbk_head(start[0]) && (end) - (start) > 1 && valid_gbk_tail(start[1])) ? 2 : 0;
320320
}
321321

322-
static unsigned int mysqlnd_mbcharlen_gbk(unsigned int gbk)
322+
static unsigned int mysqlnd_mbcharlen_gbk(const unsigned int gbk)
323323
{
324324
return (valid_gbk_head(gbk) ? 2 : 1);
325325
}
@@ -331,26 +331,26 @@ static unsigned int mysqlnd_mbcharlen_gbk(unsigned int gbk)
331331
#define valid_sjis_tail(c) ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && (c) <= 0xFC))
332332

333333

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)
335335
{
336336
return (valid_sjis_head((zend_uchar)start[0]) && (end - start) > 1 && valid_sjis_tail((zend_uchar)start[1])) ? 2 : 0;
337337
}
338338

339339

340-
static unsigned int mysqlnd_mbcharlen_sjis(unsigned int sjis)
340+
static unsigned int mysqlnd_mbcharlen_sjis(const unsigned int sjis)
341341
{
342342
return (valid_sjis_head((zend_uchar)sjis)) ? 2 : 1;
343343
}
344344
/* }}} */
345345

346346

347347
/* {{{ 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)))
349349
{
350350
return 2; /* always 2 */
351351
}
352352

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)))
354354
{
355355
return 2; /* always 2 */
356356
}
@@ -363,7 +363,7 @@ static unsigned int mysqlnd_mbcharlen_ucs2(unsigned int ucs2 __attribute((unused
363363
#define valid_ujis_ss2(c) (((c)&0xFF) == 0x8E)
364364
#define valid_ujis_ss3(c) (((c)&0xFF) == 0x8F)
365365

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)
367367
{
368368
if (*(zend_uchar*)start < 0x80) {
369369
return 0; /* invalid ujis character */
@@ -381,7 +381,7 @@ static unsigned int check_mb_ujis(const char *start, const char *end)
381381
}
382382

383383

384-
static unsigned int mysqlnd_mbcharlen_ujis(unsigned int ujis)
384+
static unsigned int mysqlnd_mbcharlen_ujis(const unsigned int ujis)
385385
{
386386
return (valid_ujis(ujis)? 2: valid_ujis_ss2(ujis)? 2: valid_ujis_ss3(ujis)? 3: 1);
387387
}
@@ -393,7 +393,7 @@ static unsigned int mysqlnd_mbcharlen_ujis(unsigned int ujis)
393393
#define UTF16_HIGH_HEAD(x) ((((zend_uchar) (x)) & 0xFC) == 0xD8)
394394
#define UTF16_LOW_HEAD(x) ((((zend_uchar) (x)) & 0xFC) == 0xDC)
395395

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)
397397
{
398398
if (start + 2 > end) {
399399
return 0;
@@ -410,21 +410,21 @@ static unsigned int check_mb_utf16(const char *start, const char *end)
410410
}
411411

412412

413-
static uint32_t mysqlnd_mbcharlen_utf16(unsigned int utf16)
413+
static uint32_t mysqlnd_mbcharlen_utf16(const unsigned int utf16)
414414
{
415415
return UTF16_HIGH_HEAD(utf16) ? 4 : 2;
416416
}
417417
/* }}} */
418418

419419

420420
/* {{{ 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)))
422422
{
423423
return 4;
424424
}
425425

426426

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)))
428428
{
429429
return 4;
430430
}
@@ -437,7 +437,7 @@ static unsigned int mysqlnd_mbcharlen_utf32(unsigned int utf32 __attribute((unus
437437
#define is_gb18030_even_4(c) (0x30 <= (zend_uchar) (c) && (zend_uchar) (c) <= 0x39)
438438

439439

440-
static unsigned int mysqlnd_mbcharlen_gb18030(unsigned int c)
440+
static unsigned int mysqlnd_mbcharlen_gb18030(const unsigned int c)
441441
{
442442
if (c <= 0xFF) {
443443
return !is_gb18030_odd(c);
@@ -740,7 +740,7 @@ const MYSQLND_CHARSET mysqlnd_charsets[] =
740740

741741

742742
/* {{{ 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)
744744
{
745745
const MYSQLND_CHARSET * c = mysqlnd_charsets;
746746

@@ -773,8 +773,8 @@ PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_name(const char * const name
773773

774774

775775
/* {{{ 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)
778778
{
779779
const char *newstr_s = newstr;
780780
const char *newstr_e = newstr + 2 * escapestr_len;
@@ -828,7 +828,7 @@ PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const cset,
828828

829829
/* {{{ mysqlnd_cset_escape_slashes */
830830
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)
832832
{
833833
const char *newstr_s = newstr;
834834
const char *newstr_e = newstr + 2 * escapestr_len;

ext/mysqlnd/mysqlnd_charset.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
#ifndef MYSQLND_CHARSET_H
2222
#define MYSQLND_CHARSET_H
2323

24-
PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const charset, char *newstr,
25-
const char *escapestr, size_t escapestr_len);
24+
PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const charset, char * newstr,
25+
const char * escapestr, const size_t escapestr_len);
2626

27-
PHPAPI zend_ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, char *newstr,
28-
const char *escapestr, size_t escapestr_len);
27+
PHPAPI zend_ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, char * newstr,
28+
const char * escapestr, const size_t escapestr_len);
2929

3030
struct st_mysqlnd_plugin_charsets
3131
{
@@ -34,8 +34,8 @@ struct st_mysqlnd_plugin_charsets
3434
{
3535
const MYSQLND_CHARSET * (*const find_charset_by_nr)(unsigned int charsetnr);
3636
const MYSQLND_CHARSET * (*const find_charset_by_name)(const char * const name);
37-
zend_ulong (*const escape_quotes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, size_t escapestr_len);
38-
zend_ulong (*const escape_slashes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, size_t escapestr_len);
37+
zend_ulong (*const escape_quotes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, const size_t escapestr_len);
38+
zend_ulong (*const escape_slashes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, const size_t escapestr_len);
3939
} methods;
4040
};
4141

ext/mysqlnd/mysqlnd_structs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ typedef struct st_mysqlnd_charset
189189
unsigned int char_minlen;
190190
unsigned int char_maxlen;
191191
const char *comment;
192-
unsigned int (*mb_charlen)(unsigned int c);
193-
unsigned int (*mb_valid)(const char *start, const char *end);
192+
unsigned int (*mb_charlen)(const unsigned int c);
193+
unsigned int (*mb_valid)(const char * const start, const char * const end);
194194
} MYSQLND_CHARSET;
195195

196196

0 commit comments

Comments
 (0)