mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Add "const". Move constant strings to read-only memory.
This commit is contained in:
parent
fd0b39905c
commit
4a2ae84188
@ -1563,7 +1563,7 @@ hexdig_init(void) /* Use of hexdig_init omitted 20121220 to avoid a */
|
||||
htinit(hexdig, USC "ABCDEF", 0x10 + 10);
|
||||
}
|
||||
#else
|
||||
static unsigned char hexdig[256] = {
|
||||
static const unsigned char hexdig[256] = {
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
@ -101,7 +101,7 @@ enum { CAL_MONTH_GREGORIAN_SHORT, CAL_MONTH_GREGORIAN_LONG,
|
||||
|
||||
/* For heb_number_to_chars escape sequences of אבגדהוזחטיכלמנסעפצקרשת
|
||||
ISO-8859-8 Hebrew alphabet */
|
||||
static char alef_bet[25] = "0\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEB\xEC\xEE\xF0\xF1\xF2\xF4\xF6\xF7\xF8\xF9\xFA";
|
||||
static const char alef_bet[25] = "0\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEB\xEC\xEE\xF0\xF1\xF2\xF4\xF6\xF7\xF8\xF9\xFA";
|
||||
|
||||
#define CAL_JEWISH_ADD_ALAFIM_GERESH 0x2
|
||||
#define CAL_JEWISH_ADD_ALAFIM 0x4
|
||||
|
@ -1182,7 +1182,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn
|
||||
smart_str_appendc(pretval, *(char *)p);
|
||||
char_cnt--;
|
||||
} else {
|
||||
static char qp_digits[] = "0123456789ABCDEF";
|
||||
static const char qp_digits[] = "0123456789ABCDEF";
|
||||
smart_str_appendc(pretval, '=');
|
||||
smart_str_appendc(pretval, qp_digits[(*p >> 4) & 0x0f]);
|
||||
smart_str_appendc(pretval, qp_digits[(*p & 0x0f)]);
|
||||
|
@ -260,7 +260,7 @@ static int php_session_decode(zend_string *data) /* {{{ */
|
||||
* into URLs.
|
||||
*/
|
||||
|
||||
static char hexconvtab[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,-";
|
||||
static const char hexconvtab[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,-";
|
||||
|
||||
static void bin_to_readable(unsigned char *in, size_t inlen, char *out, size_t outlen, char nbits) /* {{{ */
|
||||
{
|
||||
@ -1102,12 +1102,12 @@ typedef struct {
|
||||
#define ADD_HEADER(a) sapi_add_header(a, strlen(a), 1);
|
||||
#define MAX_STR 512
|
||||
|
||||
static char *month_names[] = {
|
||||
static const char *month_names[] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
|
||||
static char *week_days[] = {
|
||||
static const char *week_days[] = {
|
||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
|
||||
};
|
||||
|
||||
|
@ -940,7 +940,7 @@ static xmlNodePtr to_xml_base64(encodeTypePtr type, zval *data, int style, xmlNo
|
||||
|
||||
static xmlNodePtr to_xml_hexbin(encodeTypePtr type, zval *data, int style, xmlNodePtr parent)
|
||||
{
|
||||
static char hexconvtab[] = "0123456789ABCDEF";
|
||||
static const char hexconvtab[] = "0123456789ABCDEF";
|
||||
xmlNodePtr ret, text;
|
||||
unsigned char *str;
|
||||
zval tmp;
|
||||
|
@ -356,10 +356,10 @@ static BF_ctx BF_init_state = {
|
||||
}
|
||||
};
|
||||
|
||||
static unsigned char BF_itoa64[64 + 1] =
|
||||
static const unsigned char BF_itoa64[64 + 1] =
|
||||
"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
static unsigned char BF_atoi64[0x60] = {
|
||||
static const unsigned char BF_atoi64[0x60] = {
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 1,
|
||||
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 64, 64, 64, 64, 64,
|
||||
64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
|
@ -208,7 +208,7 @@ typedef struct _php_conv_base64_encode {
|
||||
static php_conv_err_t php_conv_base64_encode_convert(php_conv_base64_encode *inst, const char **in_p, size_t *in_left, char **out_p, size_t *out_left);
|
||||
static void php_conv_base64_encode_dtor(php_conv_base64_encode *inst);
|
||||
|
||||
static unsigned char b64_tbl_enc[256] = {
|
||||
static const unsigned char b64_tbl_enc[256] = {
|
||||
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
|
||||
'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
|
||||
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
|
||||
@ -656,7 +656,7 @@ static php_conv_err_t php_conv_qprint_encode_convert(php_conv_qprint_encode *ins
|
||||
unsigned int lb_cnt;
|
||||
unsigned int trail_ws;
|
||||
int opts;
|
||||
static char qp_digits[] = "0123456789ABCDEF";
|
||||
static const char qp_digits[] = "0123456789ABCDEF";
|
||||
|
||||
line_ccnt = inst->line_ccnt;
|
||||
opts = inst->opts;
|
||||
|
@ -797,7 +797,7 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret)
|
||||
*/
|
||||
PHPAPI zend_string * _php_math_longtobase(zend_long arg, int base)
|
||||
{
|
||||
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
static const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
char buf[(sizeof(zend_ulong) << 3) + 1];
|
||||
char *ptr, *end;
|
||||
zend_ulong value;
|
||||
@ -828,7 +828,7 @@ PHPAPI zend_string * _php_math_longtobase(zend_long arg, int base)
|
||||
*/
|
||||
PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base)
|
||||
{
|
||||
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
static const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
if ((Z_TYPE_P(arg) != IS_LONG && Z_TYPE_P(arg) != IS_DOUBLE) || base < 2 || base > 36) {
|
||||
return ZSTR_EMPTY_ALLOC();
|
||||
|
@ -83,7 +83,7 @@ void _crypt_extended_init_r(void)
|
||||
#define MD5_MAGIC "$1$"
|
||||
#define MD5_MAGIC_LEN 3
|
||||
|
||||
static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
|
||||
static const unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
|
||||
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
/* Convert a 16/32 bit integer to Base64 string representation */
|
||||
|
@ -28,7 +28,7 @@ PHP_FUNCTION(soundex)
|
||||
size_t i, _small, str_len, code, last;
|
||||
char soundex[4 + 1];
|
||||
|
||||
static char soundex_table[26] =
|
||||
static const char soundex_table[26] =
|
||||
{0, /* A */
|
||||
'1', /* B */
|
||||
'2', /* C */
|
||||
|
@ -88,7 +88,7 @@ void register_string_constants(INIT_FUNC_ARGS)
|
||||
int php_tag_find(char *tag, size_t len, const char *set);
|
||||
|
||||
/* this is read-only, so it's ok */
|
||||
ZEND_SET_ALIGNED(16, static char hexconvtab[]) = "0123456789abcdef";
|
||||
ZEND_SET_ALIGNED(16, static const char hexconvtab[]) = "0123456789abcdef";
|
||||
|
||||
/* localeconv mutex */
|
||||
#ifdef ZTS
|
||||
|
@ -442,7 +442,7 @@ static int php_htoi(char *s)
|
||||
For added safety, we only leave -_. unencoded.
|
||||
*/
|
||||
|
||||
static unsigned char hexchars[] = "0123456789ABCDEF";
|
||||
static const unsigned char hexchars[] = "0123456789ABCDEF";
|
||||
|
||||
static zend_always_inline zend_string *php_url_encode_impl(const char *s, size_t len, zend_bool raw) /* {{{ */ {
|
||||
register unsigned char c;
|
||||
|
@ -48,7 +48,7 @@
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char *rcsid = "$OpenBSD: strlcat.c,v 1.17 2016/10/14 18:19:04 dtucker Exp $";
|
||||
static const char *rcsid = "$OpenBSD: strlcat.c,v 1.17 2016/10/14 18:19:04 dtucker Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -48,7 +48,7 @@
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char *rcsid = "$OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtucker Exp $";
|
||||
static const char *rcsid = "$OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtucker Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
Loading…
Reference in New Issue
Block a user