Skip to content

Commit 3d0c8ca

Browse files
committed
use IS_SLASH
1 parent fad4323 commit 3d0c8ca

4 files changed

Lines changed: 9 additions & 15 deletions

File tree

ext/mysqlnd/mysqlnd_debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ MYSQLND_METHOD(mysqlnd_debug, set_mode)(MYSQLND_DEBUG * self, const char * const
511511
if (i + 1 < mode_len && mode[i+1] == ',') {
512512
unsigned int j = i + 2;
513513
#ifdef PHP_WIN32
514-
if (i+4 < mode_len && mode[i+3] == ':' && (mode[i+4] == '\\' || mode[i+4] == '/')) {
514+
if (i+4 < mode_len && mode[i+3] == ':' && IS_SLASH(mode[i+4])) {
515515
j = i + 5;
516516
}
517517
#endif

ext/phar/phar_object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */
15301530

15311531
str_key = fname + base_len;
15321532

1533-
if (*str_key == '/' || *str_key == '\\') {
1533+
if (IS_SLASH(*str_key)) {
15341534
str_key++;
15351535
str_key_len--;
15361536
}
@@ -3565,7 +3565,7 @@ static void phar_add_file(phar_archive_data **pphar, zend_string *file_name, con
35653565
) {
35663566
size_t prefix_len = (ZSTR_VAL(file_name)[0] == '/') + sizeof(".phar")-1;
35673567
char next_char = ZSTR_VAL(file_name)[prefix_len];
3568-
if (next_char == '/' || next_char == '\\' || next_char == '\0') {
3568+
if (IS_SLASH(next_char) || next_char == '\0') {
35693569
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot create any files in magic \".phar\" directory");
35703570
return;
35713571
}

ext/standard/string.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,11 +1342,10 @@ PHP_FUNCTION(str_decrement)
13421342
static bool _is_basename_start(const char *start, const char *pos)
13431343
{
13441344
if (pos - start >= 1
1345-
&& *(pos-1) != '/'
1346-
&& *(pos-1) != '\\') {
1345+
&& !IS_SLASH(*(pos-1))) {
13471346
if (pos - start == 1) {
13481347
return true;
1349-
} else if (*(pos-2) == '/' || *(pos-2) == '\\') {
1348+
} else if (IS_SLASH(*(pos-2))) {
13501349
return true;
13511350
} else if (*(pos-2) == ':'
13521351
&& _is_basename_start(start, pos - 2)) {
@@ -1369,8 +1368,7 @@ PHPAPI zend_string *php_basename(const char *s, size_t len, const char *suffix,
13691368
/* Strip trailing slashes */
13701369
while (basename_end >= s
13711370
#ifdef PHP_WIN32
1372-
&& (*basename_end == '/'
1373-
|| *basename_end == '\\'
1371+
&& (IS_SLASH(*basename_end)
13741372
|| (*basename_end == ':'
13751373
&& _is_basename_start(s, basename_end)))) {
13761374
#else
@@ -1387,8 +1385,7 @@ PHPAPI zend_string *php_basename(const char *s, size_t len, const char *suffix,
13871385
basename_end++;
13881386
while (basename_start > s
13891387
#ifdef PHP_WIN32
1390-
&& *(basename_start-1) != '/'
1391-
&& *(basename_start-1) != '\\') {
1388+
&& !IS_SLASH(*(basename_start-1))) {
13921389

13931390
if (*(basename_start-1) == ':' &&
13941391
_is_basename_start(s, basename_start - 1)) {
@@ -1414,7 +1411,7 @@ PHPAPI zend_string *php_basename(const char *s, size_t len, const char *suffix,
14141411
goto quit_loop;
14151412
case 1:
14161413
#ifdef PHP_WIN32
1417-
if (*s == '/' || *s == '\\') {
1414+
if (IS_SLASH(*s)) {
14181415
#else
14191416
if (*s == '/') {
14201417
#endif

sapi/cgi/cgi_main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,10 +1250,7 @@ static void init_request_info(fcgi_request *request)
12501250
*/
12511251
if (script_path_translated &&
12521252
(script_path_translated_len = strlen(script_path_translated)) > 0 &&
1253-
(script_path_translated[script_path_translated_len-1] == '/' ||
1254-
#ifdef PHP_WIN32
1255-
script_path_translated[script_path_translated_len-1] == '\\' ||
1256-
#endif
1253+
(IS_SLASH(script_path_translated[script_path_translated_len-1]) ||
12571254
(real_path = tsrm_realpath(script_path_translated, NULL)) == NULL)
12581255
) {
12591256
char *pt = estrndup(script_path_translated, script_path_translated_len);

0 commit comments

Comments
 (0)