summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2020-09-07 21:35:48 +0300
committerDmitry Stogov <dmitry@zend.com>2020-09-07 21:35:48 +0300
commit4a2ae84188b904d24c7c26bf2696507c2feb6947 (patch)
treecae51e7d398d5d6d9189b1c754744e972b717380
parentfd0b39905c299c24941644f22947553e0e009dbf (diff)
downloadphp-git-4a2ae84188b904d24c7c26bf2696507c2feb6947.tar.gz
Add "const". Move constant strings to read-only memory.
-rw-r--r--Zend/zend_strtod.c2
-rw-r--r--ext/calendar/calendar.c2
-rw-r--r--ext/iconv/iconv.c2
-rw-r--r--ext/session/session.c6
-rw-r--r--ext/soap/php_encoding.c2
-rw-r--r--ext/standard/crypt_blowfish.c4
-rw-r--r--ext/standard/filters.c4
-rw-r--r--ext/standard/math.c4
-rw-r--r--ext/standard/php_crypt_r.c2
-rw-r--r--ext/standard/soundex.c2
-rw-r--r--ext/standard/string.c2
-rw-r--r--ext/standard/url.c2
-rw-r--r--main/strlcat.c2
-rw-r--r--main/strlcpy.c2
14 files changed, 19 insertions, 19 deletions
diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c
index 2228e2262c..e88fbd001f 100644
--- a/Zend/zend_strtod.c
+++ b/Zend/zend_strtod.c
@@ -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,
diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c
index 4de31ccf77..5dd4f1ef49 100644
--- a/ext/calendar/calendar.c
+++ b/ext/calendar/calendar.c
@@ -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
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 92adc97b12..89ae1b43a4 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -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)]);
diff --git a/ext/session/session.c b/ext/session/session.c
index 658b7daf9b..9336c05be8 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -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"
};
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index affc771b0b..b3dd853298 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -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;
diff --git a/ext/standard/crypt_blowfish.c b/ext/standard/crypt_blowfish.c
index 1f20debf28..3806a290ae 100644
--- a/ext/standard/crypt_blowfish.c
+++ b/ext/standard/crypt_blowfish.c
@@ -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,
diff --git a/ext/standard/filters.c b/ext/standard/filters.c
index 2d5d0dd150..d5e6564443 100644
--- a/ext/standard/filters.c
+++ b/ext/standard/filters.c
@@ -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;
diff --git a/ext/standard/math.c b/ext/standard/math.c
index c5e0234fde..2aedcc259d 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -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();
diff --git a/ext/standard/php_crypt_r.c b/ext/standard/php_crypt_r.c
index 1e55f5f9b5..f8dffe9cc5 100644
--- a/ext/standard/php_crypt_r.c
+++ b/ext/standard/php_crypt_r.c
@@ -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 */
diff --git a/ext/standard/soundex.c b/ext/standard/soundex.c
index afd16142e3..5342139f98 100644
--- a/ext/standard/soundex.c
+++ b/ext/standard/soundex.c
@@ -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 */
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 915b6cff53..a50ba01fd6 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.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
diff --git a/ext/standard/url.c b/ext/standard/url.c
index f710b2fe8a..1d4869ecd4 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -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;
diff --git a/main/strlcat.c b/main/strlcat.c
index 3c18360e96..5556bc31ae 100644
--- a/main/strlcat.c
+++ b/main/strlcat.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>
diff --git a/main/strlcpy.c b/main/strlcpy.c
index 55959b2f3a..ef397e267e 100644
--- a/main/strlcpy.c
+++ b/main/strlcpy.c
@@ -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>