diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | win32/win32.c | 25 |
2 files changed, 27 insertions, 6 deletions
@@ -1,3 +1,11 @@ +Thu Jul 14 18:27:35 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp> + + * win32/win32.c (rb_w32_strerror): should return correct message + for ENAMETOOLONG and ENOTEMPTY. (bcc32) [ruby-dev:26533] + + * win32/win32.c (rb_w32_strerror): stripped CR LF on the tail. + (bcc32) [ruby-dev:26533] + Thu Jul 14 00:45:42 2005 Nobuyoshi Nakada <nobu@ruby-lang.org> * LEGAL (ext/nkf/nkf-utf8): updated from nkf1.7 to nkf-utf8. diff --git a/win32/win32.c b/win32/win32.c index 31677689a4..2a1fe17dcb 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1752,6 +1752,15 @@ rb_w32_strerror(int e) DWORD source = 0; char *p; +#if defined __BORLANDC__ && defined ENOTEMPTY // _sys_errlist is broken + switch (e) { + case ENAMETOOLONG: + return "Filename too long"; + case ENOTEMPTY: + return "Directory not empty"; + } +#endif + if (e < 0 || e > sys_nerr) { if (e < 0) e = GetLastError(); @@ -1760,13 +1769,17 @@ rb_w32_strerror(int e) buffer, 512, NULL) == 0) { strcpy(buffer, "Unknown Error"); } - for (p = buffer + strlen(buffer) - 1; buffer <= p; p--) { - if (*p != '\r' && *p != '\n') break; - *p = 0; - } - return buffer; } - return strerror(e); + else { + strncpy(buffer, strerror(e), sizeof(buffer)); + buffer[sizeof(buffer) - 1] = 0; + } + + for (p = buffer + strlen(buffer) - 1; buffer <= p; p--) { + if (*p != '\r' && *p != '\n') break; + *p = 0; + } + return buffer; } // |