Skip to content

Commit 0217784

Browse files
authored
Replace uses of php_dirname() with zend_dirname() (#15393)
This removes some needs to include the php_string.h header
1 parent 2054c3d commit 0217784

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

ext/spl/spl_directory.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "ext/standard/php_filestat.h"
2424
#include "ext/standard/flock_compat.h"
2525
#include "ext/standard/scanf.h"
26-
#include "ext/standard/php_string.h"
26+
#include "ext/standard/php_string.h" /* For php_basename() */
2727
#include "zend_attributes.h"
2828
#include "zend_exceptions.h"
2929
#include "zend_interfaces.h"
@@ -1362,7 +1362,7 @@ PHP_METHOD(SplFileInfo, getPathInfo)
13621362
path = spl_filesystem_object_get_pathname(intern);
13631363
if (path && ZSTR_LEN(path)) {
13641364
zend_string *dpath = zend_string_init(ZSTR_VAL(path), ZSTR_LEN(path), 0);
1365-
ZSTR_LEN(dpath) = php_dirname(ZSTR_VAL(dpath), ZSTR_LEN(path));
1365+
ZSTR_LEN(dpath) = zend_dirname(ZSTR_VAL(dpath), ZSTR_LEN(path));
13661366
spl_filesystem_object_create_info(dpath, ce, return_value);
13671367
zend_string_release(dpath);
13681368
}

ext/standard/link.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ PHP_FUNCTION(linkinfo)
9999
Z_PARAM_PATH(link, link_len)
100100
ZEND_PARSE_PARAMETERS_END();
101101

102+
// TODO Check for empty string
102103
dirname = estrndup(link, link_len);
103-
php_dirname(dirname, link_len);
104+
zend_dirname(dirname, link_len);
104105

105106
if (php_check_open_basedir(dirname)) {
106107
efree(dirname);
@@ -141,7 +142,7 @@ PHP_FUNCTION(symlink)
141142
}
142143

143144
memcpy(dirname, source_p, sizeof(source_p));
144-
len = php_dirname(dirname, strlen(dirname));
145+
len = zend_dirname(dirname, strlen(dirname));
145146

146147
if (!expand_filepath_ex(topath, dest_p, dirname, len)) {
147148
php_error_docref(NULL, E_WARNING, "No such file or directory");

ext/xmlwriter/php_xmlwriter.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "ext/standard/info.h"
2525
#include "php_xmlwriter.h"
2626
#include "php_xmlwriter_arginfo.h"
27-
#include "ext/standard/php_string.h" /* For php_dirname() */
2827

2928
static zend_class_entry *xmlwriter_class_entry_ce;
3029

@@ -158,7 +157,7 @@ static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, i
158157
}
159158

160159
memcpy(file_dirname, source, strlen(source));
161-
dir_len = php_dirname(file_dirname, strlen(source));
160+
dir_len = zend_dirname(file_dirname, strlen(source));
162161

163162
if (dir_len > 0) {
164163
zend_stat_t buf = {0};

ext/zip/php_zip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s
171171
is_dir_only = 1;
172172
} else {
173173
memcpy(file_dirname, path_cleaned, path_cleaned_len);
174-
dir_len = php_dirname(file_dirname, path_cleaned_len);
174+
dir_len = zend_dirname(file_dirname, path_cleaned_len);
175175

176176
if (!dir_len || (dir_len == 1 && file_dirname[0] == '.')) {
177177
len = spprintf(&file_dirname_fullpath, 0, "%s", dest);

sapi/cli/php_cli_server.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
#include "zend_smart_str.h"
9696
#include "ext/standard/html.h"
9797
#include "ext/standard/url.h" /* for php_raw_url_decode() */
98-
#include "ext/standard/php_string.h" /* for php_dirname() */
9998
#include "ext/date/php_date.h" /* for php_format_date() */
10099
#include "php_network.h"
101100

0 commit comments

Comments
 (0)