[前][次][番号順一覧][スレッド一覧]

ruby-changes:64382

From: Nobuyoshi <ko1@a...>
Date: Sun, 20 Dec 2020 18:34:18 +0900 (JST)
Subject: [ruby-changes:64382] 37987d9994 (master): win32: Deprecate file CP version functions

https://git.ruby-lang.org/ruby.git/commit/?id=37987d9994

From 37987d99940f10bc6fec9b4825d7ce72df391d42 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 20 Dec 2020 02:20:27 +0900
Subject: win32: Deprecate file CP version functions


diff --git a/include/ruby/defines.h b/include/ruby/defines.h
index 82e765d..d632a69 100644
--- a/include/ruby/defines.h
+++ b/include/ruby/defines.h
@@ -68,7 +68,6 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/defines.h#L68
 #endif
 
 #include "ruby/internal/dllexport.h"
-#include "ruby/internal/dosish.h"
 #include "ruby/internal/xmalloc.h"
 #include "ruby/backward/2/assume.h"
 #include "ruby/backward/2/attributes.h"
@@ -77,6 +76,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/defines.h#L76
 #include "ruby/backward/2/long_long.h"
 #include "ruby/backward/2/stdalign.h"
 #include "ruby/backward/2/stdarg.h"
+#include "ruby/internal/dosish.h"
 #include "ruby/missing.h"
 
 #define RUBY
diff --git a/include/ruby/win32.h b/include/ruby/win32.h
index b34fe33..0025948 100644
--- a/include/ruby/win32.h
+++ b/include/ruby/win32.h
@@ -286,11 +286,8 @@ extern struct servent  *WSAAPI rb_w32_getservbyport(int, const char *); https://github.com/ruby/ruby/blob/trunk/include/ruby/win32.h#L286
 extern int    socketpair(int, int, int, int *);
 extern int    getifaddrs(struct ifaddrs **);
 extern void   freeifaddrs(struct ifaddrs *);
-extern char * rb_w32_getcwd(char *, int);
 extern char * rb_w32_ugetcwd(char *, int);
 extern char * rb_w32_ugetenv(const char *);
-extern char * rb_w32_getenv(const char *);
-extern int    rb_w32_rename(const char *, const char *);
 extern int    rb_w32_urename(const char *, const char *);
 extern char **rb_w32_get_environ(void);
 extern void   rb_w32_free_environ(char **);
@@ -299,22 +296,15 @@ extern const char *WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t); https://github.com/ruby/ruby/blob/trunk/include/ruby/win32.h#L296
 extern int WSAAPI rb_w32_inet_pton(int,const char *,void *);
 extern DWORD  rb_w32_osver(void);
 
-extern int chown(const char *, int, int);
 extern int rb_w32_uchown(const char *, int, int);
-extern int link(const char *, const char *);
 extern int rb_w32_ulink(const char *, const char *);
-extern ssize_t readlink(const char *, char *, size_t);
 extern ssize_t rb_w32_ureadlink(const char *, char *, size_t);
 extern ssize_t rb_w32_wreadlink(const WCHAR *, WCHAR *, size_t);
-extern int symlink(const char *src, const char *link);
 extern int rb_w32_usymlink(const char *src, const char *link);
 extern int gettimeofday(struct timeval *, struct timezone *);
 extern int clock_gettime(clockid_t, struct timespec *);
 extern int clock_getres(clockid_t, struct timespec *);
 extern rb_pid_t waitpid (rb_pid_t, int *, int);
-extern rb_pid_t rb_w32_spawn(int, const char *, const char*);
-extern rb_pid_t rb_w32_aspawn(int, const char *, char *const *);
-extern rb_pid_t rb_w32_aspawn_flags(int, const char *, char *const *, DWORD);
 extern rb_pid_t rb_w32_uspawn(int, const char *, const char*);
 extern rb_pid_t rb_w32_uaspawn(int, const char *, char *const *);
 extern rb_pid_t rb_w32_uaspawn_flags(int, const char *, char *const *, DWORD);
@@ -325,18 +315,12 @@ extern rb_pid_t rb_w32_getpid(void); https://github.com/ruby/ruby/blob/trunk/include/ruby/win32.h#L315
 extern rb_pid_t rb_w32_getppid(void);
 extern int rb_w32_isatty(int);
 extern int rb_w32_uchdir(const char *);
-extern int rb_w32_mkdir(const char *, int);
 extern int rb_w32_umkdir(const char *, int);
-extern int rb_w32_rmdir(const char *);
 extern int rb_w32_urmdir(const char *);
-extern int rb_w32_unlink(const char *);
 extern int rb_w32_uunlink(const char *);
 extern int rb_w32_uchmod(const char *, int);
-extern int rb_w32_stati128(const char *, struct stati128 *);
 extern int rb_w32_ustati128(const char *, struct stati128 *);
-extern int rb_w32_lstati128(const char *, struct stati128 *);
 extern int rb_w32_ulstati128(const char *, struct stati128 *);
-extern int rb_w32_access(const char *, int);
 extern int rb_w32_uaccess(const char *, int);
 extern char rb_w32_fd_is_text(int);
 extern int rb_w32_fstati128(int, struct stati128 *);
@@ -732,7 +716,6 @@ struct tm *localtime_r(const time_t *, struct tm *); https://github.com/ruby/ruby/blob/trunk/include/ruby/win32.h#L716
 
 /* thread stuff */
 int  rb_w32_sleep(unsigned long msec);
-int  rb_w32_open(const char *, int, ...);
 int  rb_w32_uopen(const char *, int, ...);
 int  rb_w32_wopen(const WCHAR *, int, ...);
 int  rb_w32_close(int);
@@ -741,11 +724,8 @@ int  rb_w32_pipe(int[2]); https://github.com/ruby/ruby/blob/trunk/include/ruby/win32.h#L724
 ssize_t rb_w32_read(int, void *, size_t);
 ssize_t rb_w32_write(int, const void *, size_t);
 off_t  rb_w32_lseek(int, off_t, int);
-int  rb_w32_utime(const char *, const struct utimbuf *);
 int  rb_w32_uutime(const char *, const struct utimbuf *);
-int  rb_w32_utimes(const char *, const struct timeval *);
 int  rb_w32_uutimes(const char *, const struct timeval *);
-int  rb_w32_utimensat(int /* must be AT_FDCWD */, const char *, const struct timespec *, int /* must be 0 */);
 int  rb_w32_uutimensat(int /* must be AT_FDCWD */, const char *, const struct timespec *, int /* must be 0 */);
 long rb_w32_write_console(uintptr_t, int);	/* use uintptr_t instead of VALUE because it's not defined yet here */
 int  WINAPI rb_w32_Sleep(unsigned long msec);
@@ -756,6 +736,27 @@ int  rb_w32_unwrap_io_handle(int); https://github.com/ruby/ruby/blob/trunk/include/ruby/win32.h#L736
 WCHAR *rb_w32_mbstr_to_wstr(UINT, const char *, int, long *);
 char *rb_w32_wstr_to_mbstr(UINT, const WCHAR *, int, long *);
 
+DEPRECATED_BY(rb_w32_ugetcwd, char *rb_w32_getcwd(char *, int));
+DEPRECATED_BY(rb_w32_ugetenv, char *rb_w32_getenv(const char *));
+DEPRECATED_BY(rb_w32_urename, int rb_w32_rename(const char *, const char *));
+DEPRECATED_BY(rb_w32_uopen, int rb_w32_open(const char *, int, ...));
+DEPRECATED_BY(rb_w32_uchown, int chown(const char *, int, int));
+DEPRECATED_BY(rb_w32_ulink, int link(const char *, const char *));
+DEPRECATED_BY(rb_w32_ureadlink, ssize_t readlink(const char *, char *, size_t));
+DEPRECATED_BY(rb_w32_usymlink, int symlink(const char *src, const char *link));
+DEPRECATED_BY(rb_w32_umkdir, int rb_w32_mkdir(const char *, int));
+DEPRECATED_BY(rb_w32_urmdir, int rb_w32_rmdir(const char *));
+DEPRECATED_BY(rb_w32_uunlink, int rb_w32_unlink(const char *));
+DEPRECATED_BY(rb_w32_uutime, int rb_w32_utime(const char *, const struct utimbuf *));
+DEPRECATED_BY(rb_w32_uutimes, int rb_w32_utimes(const char *, const struct timeval *));
+DEPRECATED_BY(rb_w32_uutimensat, int rb_w32_utimensat(int, const char *, const struct timespec *, int));
+DEPRECATED_BY(rb_w32_ustati128, int rb_w32_stati128(const char *, struct stati128 *));
+DEPRECATED_BY(rb_w32_ulstati128, int rb_w32_lstati128(const char *, struct stati128 *));
+DEPRECATED_BY(rb_w32_uaccess, int rb_w32_access(const char *, int));
+DEPRECATED_BY(rb_w32_uspawn, rb_pid_t rb_w32_spawn(int, const char *, const char*));
+DEPRECATED_BY(rb_w32_uaspawn, rb_pid_t rb_w32_aspawn(int, const char *, char *const *));
+DEPRECATED_BY(rb_w32_uaspawn_flags, rb_pid_t rb_w32_aspawn_flags(int, const char *, char *const *, DWORD));
+
 /*
 == ***CAUTION***
 Since this function is very dangerous, ((*NEVER*))
diff --git a/win32/win32.c b/win32/win32.c
index fcf1855..5934d7d 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1569,7 +1569,7 @@ rb_w32_uaspawn_flags(int mode, const char *prog, char *const *argv, DWORD flags) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L1569
 rb_pid_t
 rb_w32_aspawn(int mode, const char *prog, char *const *argv)
 {
-    return rb_w32_aspawn_flags(mode, prog, argv, 0);
+    return w32_aspawn_flags(mode, prog, argv, 0, filecp());
 }
 
 /* License: Ruby's */
@@ -5703,7 +5703,7 @@ rb_w32_stat(const char *path, struct stat *st) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L5703
 {
     struct stati128 tmp;
 
-    if (rb_w32_stati128(path, &tmp)) return -1;
+    if (w32_stati128(path, &tmp, filecp(), FALSE)) return -1;
     COPY_STAT(tmp, *st, (_off_t));
     return 0;
 }
@@ -5820,11 +5820,11 @@ rb_w32_lseek(int fd, off_t ofs, int whence) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L5820
 }
 
 /* License: Ruby's */
-int
-rb_w32_access(const char *path, int mode)
+static int
+w32_access(const char *path, int mode, UINT cp)
 {
     struct stati128 stat;
-    if (rb_w32_stati128(path, &stat) != 0)
+    if (w32_stati128(path, &stat, cp, FALSE) != 0)
 	return -1;
     mode <<= 6;
     if ((stat.st_mode & mode) != mode) {
@@ -5836,17 +5836,16 @@ rb_w32_access(const char *path, int mode) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L5836
 
 /* License: Ruby's */
 int
+rb_w32_access(const char *path, int mode)
+{
+    return w32_access(path, mode, filecp());
+}
+
+/* License: Ruby's */
+int
 rb_w32_uaccess(const char *path, int mode)
 {
-    struct stati128 stat;
-    if (rb_w32_ustati128(path, &stat) != 0)
-	return -1;
-    mode <<= 6;
-    if ((stat.st_mode & mode) != mode) {
-	errno = EACCES;
-	return -1;
-    }
-    return 0;
+    return w32_access(path, mode, CP_UTF8);
 }
 
 /* License: Ruby's */
@@ -7386,6 +7385,20 @@ wutimensat(int dirfd, const WCHAR *path, const struct timespec *times, int flags https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L7385
 }
 
 /* License: Ruby's */
+static int
+w32_utimensat(int dirfd, const char *path, const struct timespec *times, int flags, UINT cp)
+{
+    WCHAR *wpath = mbstr_to_wstr(filecp(), path, -1, NULL);
+    int ret = -1;
+
+    if (wpath) {
+	ret = wutimensat(dirfd, wpath, times, flags);
+	free(wpath);
+    }
+    return ret;
+}
+
+/* License: Ruby's */
 int
 rb_w32_uutime(const char *path, const struct utimbuf *times)
 {
@@ -7395,7 +7408,7 @@ rb_w32_uutime(const char *path, const struct utimbuf *times) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L7408
     ts[0].tv_nsec = 0;
     ts[1].tv_sec = times->modtime;
     ts[1].tv_nsec = 0;
-    return rb_w32_uutimensat(AT_FDCWD, path, (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]