]> granicus.if.org Git - php/commitdiff
use const keyword where possible
authorNuno Lopes <nlopess@php.net>
Sat, 22 Jul 2006 12:49:36 +0000 (12:49 +0000)
committerNuno Lopes <nlopess@php.net>
Sat, 22 Jul 2006 12:49:36 +0000 (12:49 +0000)
ext/filter/filter.c
ext/filter/logical_filters.c
ext/filter/sanitizing_filters.c

index 6c975263d389f54c901f34d8c266c81fba29bb7b..93be9af9a0c8c36227424d810894752a5ab3db27 100644 (file)
@@ -31,7 +31,7 @@ ZEND_DECLARE_MODULE_GLOBALS(filter)
 #include "filter_private.h"
 
 typedef struct filter_list_entry {
-       char  *name;
+       const char *name;
        int    id;
        void (*function)(PHP_INPUT_FILTER_PARAM_DECL);
 } filter_list_entry;
index 2631a8ced757c2a4b361a6c867ec3747c552d9cf..4887c64d70c49e179e87f833b2eb4d312a38cfda 100644 (file)
@@ -515,7 +515,7 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 {
        /* From http://cvs.php.net/co.php/pear/HTML_QuickForm/QuickForm/Rule/Email.php?r=1.4 */
-       const char *regexp = "/^((\\\"[^\\\"\\f\\n\\r\\t\\v\\b]+\\\")|([\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\\-])+\\.)+[A-Za-z\\-]+))$/";
+       const char regexp[] = "/^((\\\"[^\\\"\\f\\n\\r\\t\\v\\b]+\\\")|([\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\\-])+\\.)+[A-Za-z\\-]+))$/";
 
        pcre       *re = NULL;
        pcre_extra *pcre_extra = NULL;
index d295b94ca2be9633c56cd6446ddb492c415f1f8d..50341f13254dd1d46cec1250bc5c0b15d022fd06 100644 (file)
@@ -27,7 +27,7 @@ typedef unsigned long filter_map[256];
 /* }}} */
 
 /* {{{ HELPER FUNCTIONS */
-static void php_filter_encode_html(zval *value, char* chars, int encode_nul)
+static void php_filter_encode_html(zval *value, const char* chars, int encode_nul)
 {
        register int x, y;
        smart_str str = {0};
@@ -79,7 +79,7 @@ static void php_filter_encode_html_high_low(zval *value, long flags)
        Z_STRLEN_P(value) = str.len;
 }
 
-static unsigned char hexchars[] = "0123456789ABCDEF";
+static const unsigned char hexchars[] = "0123456789ABCDEF";
 
 #define LOWALPHA    "abcdefghijklmnopqrstuvwxyz"
 #define HIALPHA     "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -87,7 +87,7 @@ static unsigned char hexchars[] = "0123456789ABCDEF";
 
 #define DEFAULT_URL_ENCODE    LOWALPHA HIALPHA DIGIT "-._"
 
-static void php_filter_encode_url(zval *value, char* chars, int high, int low, int encode_nul)
+static void php_filter_encode_url(zval *value, const char* chars, int high, int low, int encode_nul)
 {
        register int x, y;
        unsigned char *str;
@@ -145,11 +145,11 @@ static void filter_map_init(filter_map *map)
        memset(map, 0, sizeof(filter_map));
 }
 
-static void filter_map_update(filter_map *map, int flag, unsigned char *allowed_list)
+static void filter_map_update(filter_map *map, int flag, const unsigned char *allowed_list)
 {
        int l, i;
 
-       l = strlen((char*)allowed_list);
+       l = strlen((const char*)allowed_list);
        for (i = 0; i < l; ++i) {
                (*map)[allowed_list[i]] = flag;
        }
@@ -255,7 +255,7 @@ void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL)
 void php_filter_email(PHP_INPUT_FILTER_PARAM_DECL)
 {
        /* Check section 6 of rfc 822 http://www.faqs.org/rfcs/rfc822.html */
-       unsigned char allowed_list[] = LOWALPHA HIALPHA DIGIT "!#$%&'*+-/=?^_`{|}~@.[]";
+       const unsigned char allowed_list[] = LOWALPHA HIALPHA DIGIT "!#$%&'*+-/=?^_`{|}~@.[]";
        filter_map     map;
 
        filter_map_init(&map);
@@ -269,7 +269,7 @@ void php_filter_url(PHP_INPUT_FILTER_PARAM_DECL)
 {
        /* Strip all chars not part of section 5 of
         * http://www.faqs.org/rfcs/rfc1738.html */
-       unsigned char allowed_list[] = LOWALPHA HIALPHA DIGIT SAFE EXTRA NATIONAL PUNCTUATION RESERVED;
+       const unsigned char allowed_list[] = LOWALPHA HIALPHA DIGIT SAFE EXTRA NATIONAL PUNCTUATION RESERVED;
        filter_map     map;
 
        filter_map_init(&map);
@@ -282,7 +282,7 @@ void php_filter_url(PHP_INPUT_FILTER_PARAM_DECL)
 void php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL)
 {
        /* strip everything [^0-9+-] */
-       unsigned char allowed_list[] = "+-" DIGIT;
+       const unsigned char allowed_list[] = "+-" DIGIT;
        filter_map     map;
 
        filter_map_init(&map);
@@ -295,7 +295,7 @@ void php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL)
 void php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL)
 {
        /* strip everything [^0-9+-] */
-       unsigned char allowed_list[] = "+-" DIGIT;
+       const unsigned char allowed_list[] = "+-" DIGIT;
        filter_map     map;
 
        filter_map_init(&map);