com php-src: Use cheaper ascii conversion for mode: win32/ioutil.c win32/ioutil.h
| From: | Anatol Belski | Date: | Sat, 09 Dec 2017 11:38:19 +0000 |
| Subject: | com php-src: Use cheaper ascii conversion for mode: win32/ioutil.c win32/ioutil.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100537@lists.php.net to get a copy of this message | ||
Commit: 331019c548c271aa857aac1761dd2fac9479d11c
Author: Anatol Belski <ab@php.net> Sat, 9 Dec 2017 12:38:19 +0100
Parents: f3fd860e244945cdc7add0d8c1cbfbde7382c4fe
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=331019c548c271aa857aac1761dd2fac9479d11c
Log:
Use cheaper ascii conversion for mode
Changed paths:
M win32/ioutil.c
M win32/ioutil.h
Diff:
diff --git a/win32/ioutil.c b/win32/ioutil.c
index c335913..3f56a44 100644
--- a/win32/ioutil.c
+++ b/win32/ioutil.c
@@ -669,24 +669,37 @@ PW32IO int php_win32_ioutil_access_w(const wchar_t *path, mode_t mode)
PW32IO FILE *php_win32_ioutil_fopen_w(const wchar_t *path, const wchar_t *mode)
{/*{{{*/
FILE *ret;
+ char modea[16] = {0};
+#if 0
char *modea;
- int err = 0, fd, flags;
+#endif
+ int err = 0, fd, flags, i = 0;
PHP_WIN32_IOUTIL_CHECK_PATH_W(path, NULL, 0)
/* Using the converter from streams, char only. */
+ while (i < sizeof(modea)-1 && mode[i]) {
+ modea[i] = (char)mode[i];
+ i++;
+ }
+#if 0
modea = php_win32_cp_w_to_any(mode);
if (!modea) {
err = GetLastError();
SET_ERRNO_FROM_WIN32_CODE(err);
return NULL;
}
+#endif
if (SUCCESS != php_stream_parse_fopen_modes(modea, &flags)) {
+#if 0
free(modea);
+#endif
SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
return NULL;
}
+#if 0
free(modea);
+#endif
fd = php_win32_ioutil_open_w(path, flags, 0666);
if (0 > fd) {
diff --git a/win32/ioutil.h b/win32/ioutil.h
index f3a72b3..61d3fcd 100644
--- a/win32/ioutil.h
+++ b/win32/ioutil.h
@@ -373,8 +373,11 @@ __forceinline static int php_win32_ioutil_rmdir(const char *path)
__forceinline static FILE *php_win32_ioutil_fopen(const char *patha, const char *modea)
{/*{{{*/
FILE *ret;
+ wchar_t modew[16] = {0};
+#if 0
wchar_t *modew;
- int err = 0;
+#endif
+ int err = 0, i = 0;
PHP_WIN32_IOUTIL_INIT_W(patha)
if (!pathw) {
@@ -384,24 +387,34 @@ __forceinline static FILE *php_win32_ioutil_fopen(const char *patha, const
char
PHP_WIN32_IOUTIL_CHECK_PATH_W(pathw, NULL, 1)
+ while (i < (sizeof(modew)-1)/sizeof(wchar_t) && modea[i]) {
+ modew[i] = (wchar_t)modea[i];
+ i++;
+ }
+#if 0
modew = php_win32_cp_ascii_to_w(modea);
- if (!patha) {
+ if (!modew) {
PHP_WIN32_IOUTIL_CLEANUP_W()
SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
return NULL;
}
+#endif
ret = php_win32_ioutil_fopen_w(pathw, modew);
if (!ret) {
err = GetLastError();
PHP_WIN32_IOUTIL_CLEANUP_W()
+#if 0
free(modew);
+#endif
SET_ERRNO_FROM_WIN32_CODE(err);
return NULL;
}
PHP_WIN32_IOUTIL_CLEANUP_W()
+#if 0
free(modew);
+#endif
return ret;
}/*}}}*/