{
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;
}
*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;
}
}
}
RETURN_LONG(count);
}
/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */