From: nobu.nokada@... Date: 2003-04-18T16:04:35+09:00 Subject: Re: Possible bug? Hi, At Fri, 18 Apr 2003 15:32:53 +0900, U.Nakamura wrote: > | In the admittedly small amount of time that I've spent looking through the > | source, I haven't been able to find the potential source of this error. Can > | anyone confirm that this is still an issue (or not) with a more recent win32 > | build? > > I've just committed the fix. vsnprintf() and snprintf() are used many times. And they are not provided by MSVCRT directly but defiend in win32/win32.h. I'd propose to define them in win32/win32.c instead. # prefixing with rb_w32_ is necessary for mingw32. Index: win32/win32.c =================================================================== RCS file: /pub/cvs/ruby/src/ruby/win32/win32.c,v retrieving revision 1.84 diff -u -2 -p -r1.84 win32.c --- win32/win32.c 11 Apr 2003 10:02:37 -0000 1.84 +++ win32/win32.c 18 Apr 2003 06:54:49 -0000 @@ -3275,4 +3275,24 @@ rb_w32_utime(const char *path, struct ut CloseHandle(hDir); + return ret; +} + +int +rb_w32_vsnprintf(char *buf, size_t size, const char *format, va_list va) +{ + int ret = _vsnprintf(buf, size, format, va); + if (size > 0) buf[size - 1] = 0; + return ret; +} + +int +rb_w32_snprintf(char *buf, size_t size, const char *format, ...) +{ + int ret; + va_list va; + + va_start(va, format); + ret = vsnprintf(buf, size, format, va); + va_end(va); return ret; } Index: win32/win32.h =================================================================== RCS file: /pub/cvs/ruby/src/ruby/win32/win32.h,v retrieving revision 1.38 diff -u -2 -p -r1.38 win32.h --- win32/win32.h 4 Mar 2003 14:12:19 -0000 1.38 +++ win32/win32.h 18 Apr 2003 06:54:32 -0000 @@ -118,6 +118,6 @@ extern "C++" { #define write _write #endif -#define vsnprintf _vsnprintf -#define snprintf _snprintf +#define vsnprintf rb_w32_vsnprintf +#define snprintf rb_w32_snprintf #undef stat #define stat(path,st) rb_w32_stat(path,st) @@ -166,4 +166,7 @@ extern int rb_w32_rename(const char * extern char **rb_w32_get_environ(void); extern void rb_w32_free_environ(char **); + +extern int rb_w32_vsnprintf(char *, size_t, const char *, va_list); +extern int rb_w32_snprintf(char *, size_t, const char *, ...); extern int chown(const char *, int, int); -- Nobu Nakada