diff options
| author | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-07-14 09:33:52 +0000 |
|---|---|---|
| committer | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-07-14 09:33:52 +0000 |
| commit | dfa8ddb7d4350f5fe9820b6d956a17b7c5e51ffd (patch) | |
| tree | 4979a775ded86c981c3d25ecbb9a78ebcf2bd0e2 /win32 | |
| parent | 50b5bdb155380b61b6487c72350bf9e9faa9fb3f (diff) | |
| download | ruby-dfa8ddb7d4350f5fe9820b6d956a17b7c5e51ffd.tar.gz ruby-dfa8ddb7d4350f5fe9820b6d956a17b7c5e51ffd.tar.xz ruby-dfa8ddb7d4350f5fe9820b6d956a17b7c5e51ffd.zip | |
* 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]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@8761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/win32.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/win32/win32.c b/win32/win32.c index ee0c22962..ff51f6053 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1705,6 +1705,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(); @@ -1713,13 +1722,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; } // |
