cvs: php4 /ext/standard/ string.c
[email protected] ("Jouni Ahto") Thu, 01 Jun 2000 10:07:44 -0000
| Newsgroups | php.version4 |
|---|---|
| Message-ID | <cvsjah959854064@cvsserver> |
jah Thu Jun 1 03:07:44 2000 EDT
Modified files:
/php4/ext/standard string.c
Log:
(ucwords) Another try to fix #4748.
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.116 php4/ext/standard/string.c:1.117
--- php4/ext/standard/string.c:1.116 Thu Jun 1 02:56:54 2000
+++ php4/ext/standard/string.c Thu Jun 1 03:07:44 2000
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.116 2000/06/01 09:56:54 hholzgra Exp $ */
+/* $Id: string.c,v 1.117 2000/06/01 10:07:44 jah Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -1139,7 +1139,7 @@
{
zval **str;
char *r;
- char *r_end;
+ int i, new_word = 1;
if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -1151,18 +1151,18 @@
}
*return_value=**str;
zval_copy_ctor(return_value);
- *return_value->value.str.val = toupper((unsigned char)*return_value->value.str.val);
-
r=return_value->value.str.val;
- r_end = r + (*str)->value.str.len;
- while(++r<r_end){
- if(isspace(*r)) {
- if(r < r_end){
- r++;
- *r=toupper((unsigned char)*r);
- } else {
- break;
- }
+
+ for (i = 0; i < (*str)->value.str.len; i++, r++) {
+ /* Alpha char preceeded by white space? Uppercase it. */
+ if (new_word && isalpha(*r)) {
+ *r = toupper((unsigned char)*r);
+ }
+ /* Find a word boundary. */
+ if (isspace(*r)) {
+ new_word = 1;
+ } else {
+ new_word = 0;
}
}
}
@@ -2568,3 +2568,10 @@
RETURN_LONG(count);
}
/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */