Skip to content

Commit 3275cb7

Browse files
committed
Use the new toupper functions
Use the new ASCII upper case functions in ext/xml, ext/pdo_dblib and as an optimization for strtoupper() when the locale is "C".
1 parent 6d22ed3 commit 3275cb7

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

ext/pdo_dblib/dblib_stmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, zval *zv, enum pd
438438
tmp_data_len = 36;
439439
tmp_data = safe_emalloc(tmp_data_len, sizeof(char), 1);
440440
data_len = dbconvert(NULL, SQLUNIQUE, data, data_len, SQLCHAR, (LPBYTE) tmp_data, tmp_data_len);
441-
php_strtoupper(tmp_data, data_len);
441+
zend_str_toupper(tmp_data, data_len);
442442
ZVAL_STRINGL(zv, tmp_data, data_len);
443443
efree(tmp_data);
444444
} else {

ext/standard/string.c

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,29 +1362,33 @@ PHPAPI zend_string *php_string_toupper(zend_string *s)
13621362
unsigned char *c;
13631363
const unsigned char *e;
13641364

1365-
c = (unsigned char *)ZSTR_VAL(s);
1366-
e = c + ZSTR_LEN(s);
1365+
if (EXPECTED(!BG(ctype_string))) {
1366+
return zend_string_toupper(s);
1367+
} else {
1368+
c = (unsigned char *)ZSTR_VAL(s);
1369+
e = c + ZSTR_LEN(s);
13671370

1368-
while (c < e) {
1369-
if (islower(*c)) {
1370-
unsigned char *r;
1371-
zend_string *res = zend_string_alloc(ZSTR_LEN(s), 0);
1371+
while (c < e) {
1372+
if (islower(*c)) {
1373+
unsigned char *r;
1374+
zend_string *res = zend_string_alloc(ZSTR_LEN(s), 0);
13721375

1373-
if (c != (unsigned char*)ZSTR_VAL(s)) {
1374-
memcpy(ZSTR_VAL(res), ZSTR_VAL(s), c - (unsigned char*)ZSTR_VAL(s));
1375-
}
1376-
r = c + (ZSTR_VAL(res) - ZSTR_VAL(s));
1377-
while (c < e) {
1378-
*r = toupper(*c);
1379-
r++;
1380-
c++;
1376+
if (c != (unsigned char*)ZSTR_VAL(s)) {
1377+
memcpy(ZSTR_VAL(res), ZSTR_VAL(s), c - (unsigned char*)ZSTR_VAL(s));
1378+
}
1379+
r = c + (ZSTR_VAL(res) - ZSTR_VAL(s));
1380+
while (c < e) {
1381+
*r = toupper(*c);
1382+
r++;
1383+
c++;
1384+
}
1385+
*r = '\0';
1386+
return res;
13811387
}
1382-
*r = '\0';
1383-
return res;
1388+
c++;
13841389
}
1385-
c++;
1390+
return zend_string_copy(s);
13861391
}
1387-
return zend_string_copy(s);
13881392
}
13891393
/* }}} */
13901394

ext/xml/xml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ static zend_string *_xml_decode_tag(xml_parser *parser, const char *tag)
611611
str = xml_utf8_decode((const XML_Char *)tag, strlen(tag), parser->target_encoding);
612612

613613
if (parser->case_folding) {
614-
php_strtoupper(ZSTR_VAL(str), ZSTR_LEN(str));
614+
zend_str_toupper(ZSTR_VAL(str), ZSTR_LEN(str));
615615
}
616616

617617
return str;

0 commit comments

Comments
 (0)