summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-14 09:33:52 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-14 09:33:52 +0000
commit0661db665ea0faf47cbd94d27d45b24efc0e7369 (patch)
tree4979a775ded86c981c3d25ecbb9a78ebcf2bd0e2
parenta290480f507e9db4c07235c1e7d9eb89fbf1b357 (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--win32/win32.c25
2 files changed, 27 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index e0d4fc6..ca74293 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Jul 14 18:27:16 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 ee0c229..ff51f60 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;
}
//