From: Sascha Schumann Date: Sun, 20 Aug 2000 14:02:57 +0000 (+0000) Subject: Provide PHP_SEPARATOR which expands to the default directory separator X-Git-Tag: php-4.0.2RC1~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c8b8a908ca9bed4891798e94bb1a138df2257ae7;p=php Provide PHP_SEPARATOR which expands to the default directory separator on the target platform. --- diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index cc8b7f9a66..3257186a03 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -55,12 +55,6 @@ ps_module ps_mod_files = { PS_MOD(files) }; -#ifdef PHP_WIN32 -#define DIR_DELIMITER '\\' -#else -#define DIR_DELIMITER '/' -#endif - static int _ps_files_valid_key(const char *key) { size_t len; @@ -98,10 +92,10 @@ static char *_ps_files_path_create(char *buf, size_t buflen, ps_files *data, con (strlen(data->basedir) + 2 * data->dirdepth + keylen + 5 + sizeof(FILE_PREFIX))) return NULL; p = key; - n = sprintf(buf, "%s%c", data->basedir, DIR_DELIMITER); + n = sprintf(buf, "%s%c", data->basedir, PHP_SEPARATOR); for (i = 0; i < data->dirdepth; i++) { buf[n++] = *p++; - buf[n++] = DIR_DELIMITER; + buf[n++] = PHP_SEPARATOR; } buf[n] = '\0'; strcat(buf, FILE_PREFIX); @@ -175,7 +169,7 @@ static int _ps_files_cleanup_dir(const char *dirname, int maxlifetime) /* does the file start with our prefix? */ if (!strncmp(entry->d_name, FILE_PREFIX, sizeof(FILE_PREFIX) - 1) && /* create full path */ - snprintf(buf, MAXPATHLEN, "%s%c%s", dirname, DIR_DELIMITER, + snprintf(buf, MAXPATHLEN, "%s%c%s", dirname, PHP_SEPARATOR, entry->d_name) > 0 && /* stat the directory entry */ V_STAT(buf, &sbuf) == 0 && diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index bb9cad4b4a..89a24308ff 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -80,10 +80,8 @@ * a joint header file when we move virtual_cwd to TSRM */ #ifdef ZEND_WIN32 #define IS_SLASH(c) ((c) == '/' || (c) == '\\') -#define DEFAULT_SLASH '\\' #else #define IS_SLASH(c) ((c) == '/') -#define DEFAULT_SLASH '/' #endif @@ -319,8 +317,8 @@ PHPAPI FILE *php_fopen_primary_script(void) if (pw && pw->pw_dir) { filename = emalloc(strlen(PG(user_dir)) + strlen(path_info) + strlen(pw->pw_dir) + 4); if (filename) { - sprintf(filename, "%s%c%s%c%s", pw->pw_dir, DEFAULT_SLASH, - PG(user_dir), DEFAULT_SLASH, s+1); /* Safe */ + sprintf(filename, "%s%c%s%c%s", pw->pw_dir, PHP_SEPARATOR, + PG(user_dir), PHP_SEPARATOR, s+1); /* Safe */ STR_FREE(SG(request_info).path_translated); SG(request_info).path_translated = filename; } @@ -340,7 +338,7 @@ PHPAPI FILE *php_fopen_primary_script(void) if (filename) { memcpy(filename, PG(doc_root), length); if (!IS_SLASH(filename[length - 1])) { /* length is never 0 */ - filename[length++] = DEFAULT_SLASH; + filename[length++] = PHP_SEPARATOR; } if (IS_SLASH(path_info[0])) { length--; diff --git a/main/php.h b/main/php.h index b0b25500d5..8d8b4c5034 100644 --- a/main/php.h +++ b/main/php.h @@ -65,9 +65,11 @@ extern unsigned char second_arg_allow_ref[]; # else # define PHPAPI __declspec(dllimport) # endif +#define PHP_SEPARATOR '\\' #else #define PHPAPI #define THREAD_LS +#define PHP_SEPARATOR '/' #endif #include "php_regex.h"