summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-20 02:20:27 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-20 18:34:04 +0900
commit37987d99940f10bc6fec9b4825d7ce72df391d42 (patch)
tree178d2db9bd2f4c8268ef2bcaa4a4b23a919bfde5
parent95862ae44046cfc66c474ce534c204d276ea704d (diff)
win32: Deprecate file CP version functions
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3948
-rw-r--r--include/ruby/defines.h2
-rw-r--r--include/ruby/win32.h41
-rw-r--r--win32/win32.c67
3 files changed, 55 insertions, 55 deletions
diff --git a/include/ruby/defines.h b/include/ruby/defines.h
index 82e765d3b2..d632a69fc1 100644
--- a/include/ruby/defines.h
+++ b/include/ruby/defines.h
@@ -68,7 +68,6 @@
#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 @@
#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 b34fe33fcb..00259485a2 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 *);
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);
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);
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 *);
/* 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]);
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);
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 fcf1855440..5934d7de28 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)
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)
{
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)
}
/* 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)
/* 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
}
/* 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)
ts[0].tv_nsec = 0;
ts[1].tv_sec = times->modtime;
ts[1].tv_nsec = 0;
- return rb_w32_uutimensat(AT_FDCWD, path, ts, 0);
+ return w32_utimensat(AT_FDCWD, path, ts, 0, CP_UTF8);
}
/* License: Ruby's */
@@ -7408,7 +7421,7 @@ rb_w32_utime(const char *path, const struct utimbuf *times)
ts[0].tv_nsec = 0;
ts[1].tv_sec = times->modtime;
ts[1].tv_nsec = 0;
- return rb_w32_utimensat(AT_FDCWD, path, ts, 0);
+ return w32_utimensat(AT_FDCWD, path, ts, 0, filecp());
}
/* License: Ruby's */
@@ -7421,7 +7434,7 @@ rb_w32_uutimes(const char *path, const struct timeval *times)
ts[0].tv_nsec = times[0].tv_usec * 1000;
ts[1].tv_sec = times[1].tv_sec;
ts[1].tv_nsec = times[1].tv_usec * 1000;
- return rb_w32_uutimensat(AT_FDCWD, path, ts, 0);
+ return w32_utimensat(AT_FDCWD, path, ts, 0, CP_UTF8);
}
/* License: Ruby's */
@@ -7434,35 +7447,21 @@ rb_w32_utimes(const char *path, const struct timeval *times)
ts[0].tv_nsec = times[0].tv_usec * 1000;
ts[1].tv_sec = times[1].tv_sec;
ts[1].tv_nsec = times[1].tv_usec * 1000;
- return rb_w32_utimensat(AT_FDCWD, path, ts, 0);
+ return w32_utimensat(AT_FDCWD, path, ts, 0, filecp());
}
/* License: Ruby's */
int
rb_w32_uutimensat(int dirfd, const char *path, const struct timespec *times, int flags)
{
- WCHAR *wpath;
- int ret;
-
- if (!(wpath = utf8_to_wstr(path, NULL)))
- return -1;
- ret = wutimensat(dirfd, wpath, times, flags);
- free(wpath);
- return ret;
+ return w32_utimensat(dirfd, path, times, flags, CP_UTF8);
}
/* License: Ruby's */
int
rb_w32_utimensat(int dirfd, const char *path, const struct timespec *times, int flags)
{
- WCHAR *wpath;
- int ret;
-
- if (!(wpath = filecp_to_wstr(path, NULL)))
- return -1;
- ret = wutimensat(dirfd, wpath, times, flags);
- free(wpath);
- return ret;
+ return w32_utimensat(dirfd, path, times, flags, filecp());
}
/* License: Ruby's */