cvs: php4 /ext/standard string.c

291 views
Skip to first unread message

Hartmut Holzgraefe

unread,
Sep 5, 2002, 7:12:01 AM9/5/02
to php...@lists.php.net
hholzgra Thu Sep 5 07:12:01 2002 EDT

Modified files:
/php4/ext/standard string.c
Log:
in stristr:
this check was in the wrong place, the real version was some lines
below, this one assumed the type was 'string' in any case
now it looks like strstr



Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.286 php4/ext/standard/string.c:1.287
--- php4/ext/standard/string.c:1.286 Sun Aug 25 15:08:07 2002
+++ php4/ext/standard/string.c Thu Sep 5 07:12:01 2002
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: string.c,v 1.286 2002/08/25 19:08:07 iliaa Exp $ */
+/* $Id: string.c,v 1.287 2002/09/05 11:12:01 hholzgra Exp $ */

/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */

@@ -1290,11 +1290,6 @@
SEPARATE_ZVAL(needle);

convert_to_string_ex(haystack);
-
- if (!Z_STRLEN_PP(needle)) {
- php_error(E_WARNING, "Empty Delimiter");
- RETURN_FALSE;
- }

haystack_orig = estrndup(Z_STRVAL_PP(haystack), Z_STRLEN_PP(haystack));


Derick Rethans

unread,
Sep 5, 2002, 7:29:32 AM9/5/02
to php...@lists.php.net
derick Thu Sep 5 07:29:32 2002 EDT

Modified files:
/php4/ext/standard string.c
Log:

- php_error -> php_error_docref
- corrected proto of implode() (to match the docs)


Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.287 php4/ext/standard/string.c:1.288
--- php4/ext/standard/string.c:1.287 Thu Sep 5 07:12:01 2002
+++ php4/ext/standard/string.c Thu Sep 5 07:29:31 2002


@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: string.c,v 1.287 2002/09/05 11:12:01 hholzgra Exp $ */
+/* $Id: string.c,v 1.288 2002/09/05 11:29:31 derick Exp $ */



/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */

@@ -466,22 +466,22 @@
/* Error, try to be as helpful as possible:
(a range ending/starting with '.' won't be captured here) */
if (end-len>=input) { /* there was no 'left' char */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, no character to the left of '..'");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, no character to the left of '..'.");
result = FAILURE;
continue;
}
if (input+2>=end) { /* there is no 'right' char */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, no character to the right of '..'");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, no character to the right of '..'.");
result = FAILURE;
continue;
}
if (input[-1] > input[2]) { /* wrong order */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, '..'-range needs to be incrementing");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, '..'-range needs to be incrementing.");
result = FAILURE;
continue;
}
/* FIXME: better error (a..b..c is the only left possibility?) */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range.");
result = FAILURE;
continue;
} else {
@@ -607,7 +607,7 @@
RETURN_FALSE;

if (linelength == 0 && docut) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "can't force cut when width is zero");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't force cut when width is zero.");
RETURN_FALSE;
}

@@ -758,7 +758,7 @@
}

if (! Z_STRLEN_PP(delim)) {
- php_error(E_WARNING, "Empty delimiter");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
RETURN_FALSE;
}

@@ -821,7 +821,7 @@
}
/* }}} */

-/* {{{ proto string implode(array src, string glue)
+/* {{{ proto string implode(string glue, array pieces)
Joins array elements placing glue string between items and return one string */
PHP_FUNCTION(implode)
{
@@ -843,7 +843,7 @@
convert_to_string_ex(arg1);
delim = *arg1;
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad arguments");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad arguments.");
return;
}

@@ -1295,7 +1295,7 @@

if (Z_TYPE_PP(needle) == IS_STRING) {


if (!Z_STRLEN_PP(needle)) {
- php_error(E_WARNING, "Empty Delimiter");

+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
RETURN_FALSE;
}

@@ -1340,7 +1340,7 @@

if (Z_TYPE_PP(needle) == IS_STRING) {


if (!Z_STRLEN_PP(needle)) {
- php_error(E_WARNING, "Empty Delimiter");

+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
RETURN_FALSE;
}

@@ -1393,13 +1393,13 @@
}

if (offset < 0 || offset > Z_STRLEN_PP(haystack)) {
- php_error(E_WARNING, "Offset not contained in string");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string.");
RETURN_FALSE;
}

if (Z_TYPE_PP(needle) == IS_STRING) {


if (!Z_STRLEN_PP(needle)) {
- php_error(E_WARNING, "Empty Delimiter");

+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
RETURN_FALSE;
}

@@ -1552,7 +1552,7 @@
}

if (chunklen <= 0) {
- php_error(E_WARNING, "Chunk length should be greater than zero");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Chunk length should be greater than zero.");
RETURN_FALSE;
}

@@ -1963,7 +1963,7 @@
}

if (ac == 2 && Z_TYPE_PP(from) != IS_ARRAY) {
- php_error(E_WARNING, "arg2 must be passed an array");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The second argument is not an array.");
RETURN_FALSE;
}

@@ -3148,7 +3148,7 @@
convert_to_long_ex(pcategory);
cat = Z_LVAL_PP(pcategory);
} else { /* FIXME: The following behaviour should be removed. */
- php_error(E_NOTICE, "Passing locale category name as string is deprecated. Use the LC_* -constants instead.");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Passing locale category name as string is deprecated. Use the LC_* -constants instead.");
convert_to_string_ex(pcategory);
category = *pcategory;

@@ -3169,7 +3169,7 @@
else if (!strcasecmp ("LC_TIME", Z_STRVAL_P(category)))
cat = LC_TIME;
else {
- php_error(E_WARNING, "Invalid locale category name %s, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC or LC_TIME", Z_STRVAL_P(category));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid locale category name %s, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, or LC_TIME.", Z_STRVAL_P(category));
RETURN_FALSE;
}
}
@@ -3474,7 +3474,7 @@
convert_to_long_ex(mult);

if (Z_LVAL_PP(mult) < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Second argument has to be greater than or equal to 0");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Second argument has to be greater than or equal to 0.");
return;
}

@@ -3526,7 +3526,7 @@
mymode = Z_LVAL_PP(mode);

if (mymode < 0 || mymode > 4) {
- php_error(E_WARNING, "unknown mode");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown mode.");
RETURN_FALSE;
}
}
@@ -3720,7 +3720,7 @@
convert_to_string_ex(needle);

if (Z_STRLEN_PP(needle) == 0) {
- php_error(E_WARNING, "Empty substring");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty substring.");
RETURN_FALSE;
} else if (Z_STRLEN_PP(needle) == 1) {
/* Special optimized case to avoid calls to php_memnstr(). */
@@ -3791,7 +3791,7 @@
if (ZEND_NUM_ARGS() > 2) {
convert_to_string_ex(pad_string);
if (Z_STRLEN_PP(pad_string) == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding string cannot be empty");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding string cannot be empty.");
return;
}
pad_str_val = Z_STRVAL_PP(pad_string);
@@ -3801,7 +3801,7 @@
convert_to_long_ex(pad_type);
pad_type_val = Z_LVAL_PP(pad_type);
if (pad_type_val < STR_PAD_LEFT || pad_type_val > STR_PAD_BOTH) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH.");
return;
}
}


Ilia Alshanetsky

unread,
Sep 5, 2002, 10:00:30 AM9/5/02
to php...@lists.php.net
iliaa Thu Sep 5 10:00:30 2002 EDT

Modified files:
/php4/ext/standard string.c
Log:

Fixed a buffer overflow that occurs when wordwrap is unable to calculate
the correct number of times the multi-byte break needs to be inserted into
the string.


Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.288 php4/ext/standard/string.c:1.289
--- php4/ext/standard/string.c:1.288 Thu Sep 5 07:29:31 2002
+++ php4/ext/standard/string.c Thu Sep 5 10:00:28 2002


@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: string.c,v 1.288 2002/09/05 11:29:31 derick Exp $ */
+/* $Id: string.c,v 1.289 2002/09/05 14:00:28 iliaa Exp $ */



/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */

@@ -640,13 +640,14 @@
else {
/* Multiple character line break or forced cut */
if (linelength > 0) {
- newtextlen = textlen + (textlen/linelength + 1) * breakcharlen + 1;
+ /* Add extra 10% to accomodate strings with unpredicatable number of breaks */
+ newtextlen = textlen + (textlen/linelength + 1) * breakcharlen * 1.1 + 1;
}
else {
newtextlen = textlen * (breakcharlen + 1) + 1;
}
newtext = emalloc(newtextlen);
-
+
/* now keep track of the actual new text length */
newtextlen = 0;

@@ -705,6 +706,8 @@
}

newtext[newtextlen] = '\0';
+ /* free unused memory */
+ newtext = erealloc(newtext, newtextlen+1);

RETURN_STRINGL(newtext, newtextlen, 0);
}


Dan Kalowsky

unread,
Sep 5, 2002, 5:29:40 PM9/5/02
to php...@lists.php.net
kalowsky Thu Sep 5 17:29:40 2002 EDT

Modified files:
/php4/ext/standard string.c
Log:

silence a windows build warning


Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.289 php4/ext/standard/string.c:1.290
--- php4/ext/standard/string.c:1.289 Thu Sep 5 10:00:28 2002
+++ php4/ext/standard/string.c Thu Sep 5 17:29:39 2002


@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: string.c,v 1.289 2002/09/05 14:00:28 iliaa Exp $ */
+/* $Id: string.c,v 1.290 2002/09/05 21:29:39 kalowsky Exp $ */



/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */

@@ -641,7 +641,7 @@


/* Multiple character line break or forced cut */
if (linelength > 0) {

/* Add extra 10% to accomodate strings with unpredicatable number of breaks */

- newtextlen = textlen + (textlen/linelength + 1) * breakcharlen * 1.1 + 1;
+ newtextlen = textlen + (int)((textlen/linelength + 1) * breakcharlen * 1.1) + 1;

Jani Taskinen

unread,
Sep 11, 2002, 10:24:28 AM9/11/02
to php...@lists.php.net
sniper Wed Sep 11 10:24:28 2002 EDT

Modified files:
/php4/ext/standard string.c
Log:

fix proto


Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.290 php4/ext/standard/string.c:1.291
--- php4/ext/standard/string.c:1.290 Thu Sep 5 17:29:39 2002
+++ php4/ext/standard/string.c Wed Sep 11 10:24:27 2002


@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: string.c,v 1.290 2002/09/05 21:29:39 kalowsky Exp $ */
+/* $Id: string.c,v 1.291 2002/09/11 14:24:27 sniper Exp $ */



/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */

@@ -856,7 +856,7 @@

#define STRTOK_TABLE(p) BG(strtok_table)[(unsigned char) *p]

-/* {{{ proto string strtok([string str,] string token)
+/* {{{ proto string strtok(string str [, string token])
Tokenize a string */
PHP_FUNCTION(strtok)
{


der...@php.net

unread,
Sep 11, 2002, 10:36:46 AM9/11/02
to Jani Taskinen, php...@lists.php.net
On Wed, 11 Sep 2002, Jani Taskinen wrote:

> sniper Wed Sep 11 10:24:28 2002 EDT
>
> Modified files:
> /php4/ext/standard string.c
> Log:
> fix proto

You broke it :) The original proto was correct.

Derick

>
>
> Index: php4/ext/standard/string.c
> diff -u php4/ext/standard/string.c:1.290 php4/ext/standard/string.c:1.291
> --- php4/ext/standard/string.c:1.290 Thu Sep 5 17:29:39 2002
> +++ php4/ext/standard/string.c Wed Sep 11 10:24:27 2002
> @@ -18,7 +18,7 @@
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: string.c,v 1.290 2002/09/05 21:29:39 kalowsky Exp $ */
> +/* $Id: string.c,v 1.291 2002/09/11 14:24:27 sniper Exp $ */
>
> /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
>
> @@ -856,7 +856,7 @@
>
> #define STRTOK_TABLE(p) BG(strtok_table)[(unsigned char) *p]
>
> -/* {{{ proto string strtok([string str,] string token)
> +/* {{{ proto string strtok(string str [, string token])
> Tokenize a string */
> PHP_FUNCTION(strtok)
> {
>
>
>

> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

---------------------------------------------------------------------------
Did I help you? http://www.derickrethans.nl/link.php?url=giftlist
Frequent ranting: http://www.derickrethans.nl/
---------------------------------------------------------------------------
PHP: Scripting the Web - der...@php.net
All your branches are belong to me!
SRM: Script Running Machine - www.vl-srm.net
---------------------------------------------------------------------------

Jani Taskinen

unread,
Sep 11, 2002, 10:51:09 AM9/11/02
to php...@lists.php.net
sniper Wed Sep 11 10:51:09 2002 EDT

Modified files:
/php4/ext/standard string.c
Log:

tok tok..


Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.292 php4/ext/standard/string.c:1.293
--- php4/ext/standard/string.c:1.292 Wed Sep 11 10:40:52 2002
+++ php4/ext/standard/string.c Wed Sep 11 10:51:09 2002


@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: string.c,v 1.292 2002/09/11 14:40:52 sniper Exp $ */
+/* $Id: string.c,v 1.293 2002/09/11 14:51:09 sniper Exp $ */



/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */

@@ -854,7 +854,7 @@



#define STRTOK_TABLE(p) BG(strtok_table)[(unsigned char) *p]

-/* {{{ proto string strtok(string str [, string token])
+/* {{{ proto string strtok([string str,] string token)

Jani Taskinen

unread,
Sep 11, 2002, 10:40:52 AM9/11/02
to php...@lists.php.net
sniper Wed Sep 11 10:40:52 2002 EDT

Modified files:
/php4/ext/standard string.c
Log:

ws fix

sniper-20020911104052.txt

Sterling Hughes

unread,
Sep 11, 2002, 11:03:39 AM9/11/02
to sni...@iki.fi, php...@lists.php.net
> sniper Wed Sep 11 10:51:09 2002 EDT
>
> Modified files:
> /php4/ext/standard string.c
> Log:
> tok tok..
>

The Buddha..

-Sterling

>
> Index: php4/ext/standard/string.c
> diff -u php4/ext/standard/string.c:1.292
php4/ext/standard/string.c:1.293
> --- php4/ext/standard/string.c:1.292 Wed Sep 11 10:40:52 2002
> +++ php4/ext/standard/string.c Wed Sep 11 10:51:09 2002
> @@ -18,7 +18,7 @@
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: string.c,v 1.292 2002/09/11 14:40:52 sniper Exp $ */
> +/* $Id: string.c,v 1.293 2002/09/11 14:51:09 sniper Exp $ */
>
> /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
>
> @@ -854,7 +854,7 @@
>
> #define STRTOK_TABLE(p) BG(strtok_table)[(unsigned char) *p]
>
> -/* {{{ proto string strtok(string str [, string token])
> +/* {{{ proto string strtok([string str,] string token)
> Tokenize a string */
> PHP_FUNCTION(strtok)
> {
>
>
>

Reply all
Reply to author
Forward
0 new messages