cvs: /php4/ext/standard string.c
| From: | Zeev Suraski | Date: | Sun, 26 Mar 2000 17:06:49 +0000 |
| Subject: | cvs: /php4/ext/standard string.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-12634@lists.php.net to get a copy of this message | ||
zeev Sun Mar 26 09:06:49 2000 EDT
Modified files:
/php4/ext/standard string.c
Log:
- Change new -> result. Using C++ keywords isn't too hot
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.103 php4/ext/standard/string.c:1.104
--- php4/ext/standard/string.c:1.103 Wed Mar 22 00:14:00 2000
+++ php4/ext/standard/string.c Sun Mar 26 09:06:19 2000
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.103 2000/03/22 08:14:00 thies Exp $ */
+/* $Id: string.c,v 1.104 2000/03/26 17:06:19 zeev Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -41,22 +41,22 @@
static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t *newlen)
{
- unsigned char *new = NULL;
+ unsigned char *result = NULL;
size_t i, j;
- new = (char *) emalloc(oldlen * 2 * sizeof(char));
- if(!new) {
- return new;
+ result = (char *) emalloc(oldlen * 2 * sizeof(char));
+ if(!result) {
+ return result;
}
for(i = j = 0; i < oldlen; i++) {
- new[j++] = hexconvtab[old[i] >> 4];
- new[j++] = hexconvtab[old[i] & 15];
+ result[j++] = hexconvtab[old[i] >> 4];
+ result[j++] = hexconvtab[old[i] & 15];
}
if(newlen) *newlen = oldlen * 2 * sizeof(char);
- return new;
+ return result;
}
/* {{{ proto string bin2hex(string data)
@@ -64,7 +64,7 @@
PHP_FUNCTION(bin2hex)
{
zval **data;
- char *new;
+ char *result;
size_t newlen;
if(ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &data) == FAILURE) {
@@ -73,13 +73,13 @@
convert_to_string_ex(data);
- new = php_bin2hex((*data)->value.str.val, (*data)->value.str.len, &newlen);
+ result = php_bin2hex((*data)->value.str.val, (*data)->value.str.len, &newlen);
- if(!new) {
+ if(!result) {
RETURN_FALSE;
}
- RETURN_STRINGL(new, newlen, 0);
+ RETURN_STRINGL(result, newlen, 0);
}
/* }}} */
@@ -1746,21 +1746,21 @@
char *p, *q;
char *r, *s;
char *end = haystack + length;
- char *new;
+ char *result;
char *off;
- new = emalloc(length);
+ result = emalloc(length);
/* we jump through haystack searching for the needle. hurray! */
- for(p = haystack, q = new;
+ for(p = haystack, q = result;
(r = php_memnstr(p, needle, needle_len, end));) {
/* this ain't optimal. you could call it `efficient memory usage' */
- off = erealloc(new, (q - new) + (r - p) + (str_len) + 1);
- if(off != new) {
+ off = erealloc(result, (q - result) + (r - p) + (str_len) + 1);
+ if(off != result) {
if(!off) {
goto finish;
}
- q += off - new;
- new = off;
+ q += off - result;
+ result = off;
}
memcpy(q, p, r - p);
q += r - p;
@@ -1772,13 +1772,13 @@
/* if there is a rest, copy it */
if((end - p) > 0) {
s = (q) + (end - p);
- off = erealloc(new, s - new + 1);
- if(off != new) {
+ off = erealloc(result, s - result + 1);
+ if(off != result) {
if(!off) {
goto finish;
}
- q += off - new;
- new = off;
+ q += off - result;
+ result = off;
s = q + (end - p);
}
memcpy(q, p, end - p);
@@ -1786,8 +1786,8 @@
}
finish:
*q = '\0';
- if(_new_length) *_new_length = q - new;
- return new;
+ if(_new_length) *_new_length = q - result;
+ return result;
}
@@ -1796,7 +1796,7 @@
PHP_FUNCTION(str_replace)
{
zval **haystack, **needle, **str;
- char *new;
+ char *result;
int len = 0;
if(ARG_COUNT(ht) != 3 ||
@@ -1827,10 +1827,10 @@
RETURN_FALSE;
}
- new = php_str_to_str((*haystack)->value.str.val, (*haystack)->value.str.len,
+ result = php_str_to_str((*haystack)->value.str.val, (*haystack)->value.str.len,
(*needle)->value.str.val, (*needle)->value.str.len,
(*str)->value.str.val, (*str)->value.str.len, &len);
- RETURN_STRINGL(new, len, 0);
+ RETURN_STRINGL(result, len, 0);
}
/* }}} */