]> granicus.if.org Git - php/commitdiff
Removed some duplicate code out of addclashes
authorJeroen van Wolffelaar <jeroen@php.net>
Sun, 5 Aug 2001 23:08:19 +0000 (23:08 +0000)
committerJeroen van Wolffelaar <jeroen@php.net>
Sun, 5 Aug 2001 23:08:19 +0000 (23:08 +0000)
# Not TSRM-safe, I am afraid...
@- addcslashes now warns when charlist is invalid. The returned string
@  remained the same (Jeroen)

ext/standard/string.c

index bcbdccda9a30c1c88e36e7c8dd79d7dc62edbabc..7cba634ce5753f8a19916243301ac2dea84a368e 100644 (file)
@@ -2316,6 +2316,8 @@ PHPAPI void php_stripcslashes(char *str, int *len)
  */
 PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int should_free, char *what, int wlength)
 {
+       /* TSRMLS_FETCH(); (causes parse error -> ?) */
+
        char flags[256];
        char *new_str = emalloc((length?length:(length=strlen(str)))*4+1); 
        char *source,*target;
@@ -2331,14 +2333,7 @@ PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int should_
                length = strlen(str);
        }
 
-       memset(flags, '\0', sizeof(flags));
-       for (source=what,end=source+wlength; (c=*source) || source<end; source++) {
-               if (source+3<end && *(source+1) == '.' && *(source+2) == '.' && (unsigned char)*(source+3)>=(unsigned char)c) {
-                       memset(flags+c, 1, (unsigned char)*(source+3)-(unsigned char)c+1);
-                       source+=3;
-               } else
-                       flags[(unsigned char)c]=1;
-       }
+       php_charmask(what, wlength, flags TSRMLS_CC);
 
        for (source=str,end=source+length,target=new_str; (c=*source) || source<end; source++) {
                if (flags[(unsigned char)c]) {