cvs: php4 /ext/standard/ cyr_convert.c

From: Date: Sun, 11 Jun 2000 17:23:38 +0000
Subject: cvs: php4 /ext/standard/ cyr_convert.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-170@lists.php.net to get a copy of this message
andi Sun Jun 11 10:23:38 2000 EDT Modified files: /php4/ext/standard cyr_convert.c Log: - Untested but it should fix the problem with cyr_convert() not being - binary safe and destroying other values in the script Index: php4/ext/standard/cyr_convert.c diff -u php4/ext/standard/cyr_convert.c:1.10 php4/ext/standard/cyr_convert.c:1.11 --- php4/ext/standard/cyr_convert.c:1.10 Mon Jun 5 12:47:44 2000 +++ php4/ext/standard/cyr_convert.c Sun Jun 11 10:23:38 2000 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cyr_convert.c,v 1.10 2000/06/05 19:47:44 andi Exp $ */ +/* $Id: cyr_convert.c,v 1.11 2000/06/11 17:23:38 andi Exp $ */ #include <stdlib.h> @@ -202,7 +202,7 @@ * d - x-cp866 * m - x-mac-cyrillic *****************************************************************************/ -static char * php_convert_cyr_string(unsigned char *str, char from, char to) +static char * php_convert_cyr_string(unsigned char *str, int length, char from, char to) { const unsigned char *from_table, *to_table; unsigned char tmp; @@ -259,7 +259,7 @@ if (!str) return (char *)str; - for( i = 0; str[i]; i++) + for( i = 0; i<length; i++) { tmp = (from_table == NULL)? str[i] : from_table[ str[i] ]; str[i] = (to_table == NULL) ? tmp : to_table[tmp + 256]; @@ -282,9 +282,9 @@ convert_to_string_ex(fr_cs); convert_to_string_ex(to_cs); - str = (unsigned char*) (*str_arg)->value.str.val; + str = (unsigned char*) estrndup((*str_arg)->value.str.val, (*str_arg)->value.str.len); - php_convert_cyr_string(str, (*fr_cs)->value.str.val[0],(*to_cs)->value.str.val[0]); - RETVAL_STRING((char *)str, 1) + php_convert_cyr_string(str, (*str_arg)->value.str.len, (*fr_cs)->value.str.val[0], (*to_cs)->value.str.val[0]); + RETVAL_STRING((char *)str, 0) } /* }}} */

« previous php.cvs (#170) next »