cvs: php4 /ext/standard string.c
| From: | Colin Viebrock | Date: | Tue, 05 Sep 2000 18:25:58 +0000 |
| Subject: | cvs: php4 /ext/standard string.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-1585@lists.php.net to get a copy of this message | ||
cmv Tue Sep 5 11:25:58 2000 EDT
Modified files:
/php4/ext/standard string.c
Log:
str_repeat() should be able to handle multipliers of 0 gracefully, IMHO ...
Hope no one disagrees. :)
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.146 php4/ext/standard/string.c:1.147
--- php4/ext/standard/string.c:1.146 Fri Aug 18 06:43:22 2000
+++ php4/ext/standard/string.c Tue Sep 5 11:25:58 2000
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.146 2000/08/18 13:43:22 sterling Exp $ */
+/* $Id: string.c,v 1.147 2000/09/05 18:25:58 cmv Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -2553,14 +2553,18 @@
convert_to_string_ex(input_str);
convert_to_long_ex(mult);
- if ((*mult)->value.lval < 1) {
- php_error(E_WARNING, "Second argument to %s() has to be greater than 0",
+ if ((*mult)->value.lval < 0) {
+ php_error(E_WARNING, "Second argument to %s() has to be greater than or equal to 0",
get_active_function_name());
return;
}
/* Don't waste our time if it's empty */
if ((*input_str)->value.str.len == 0)
+ RETURN_STRINGL(empty_string, 0, 1);
+
+ /* ... or if the multiplier is zero */
+ if ((*mult)->value.lval == 0)
RETURN_STRINGL(empty_string, 0, 1);
/* Initialize the result string */