summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-27 10:07:07 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-27 10:07:07 +0000
commitc4f26e46dbd3bd00f3e136fbcd7eb9f6c1e5646f (patch)
treef74dcb07b6fb5706a6ba11b556c3f7b5f5c6a21f /file.c
parent05d7f4887cfedd3a5ec8fe173359897d953e4e2b (diff)
Merge from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/file.c b/file.c
index ba00e9d..c844e3f 100644
--- a/file.c
+++ b/file.c
@@ -2474,6 +2474,7 @@ rb_path_end(path)
static char *
ntfs_tail(const char *path)
{
+ while (*path == '.') path++;
while (*path && *path != ':') {
if (istrailinggabage(*path)) {
const char *last = path++;
@@ -2496,13 +2497,13 @@ ntfs_tail(const char *path)
#define BUFCHECK(cond) do {\
long bdiff = p - buf;\
- while (cond) {\
- buflen *= 2;\
+ if (cond) {\
+ do {buflen *= 2;} while (cond);\
+ rb_str_resize(result, buflen);\
+ buf = RSTRING_PTR(result);\
+ p = buf + bdiff;\
+ pend = buf + buflen;\
}\
- rb_str_resize(result, buflen);\
- buf = RSTRING(result)->ptr;\
- p = buf + bdiff;\
- pend = buf + buflen;\
} while (0)
#define BUFINIT() (\
@@ -2738,7 +2739,6 @@ file_expand_path(fname, dname, result)
p += s-b;
}
if (p == skiproot(buf) - 1) p++;
- buflen = p - buf;
#if USE_NTFS
*p = '\0';
@@ -2784,19 +2784,20 @@ file_expand_path(fname, dname, result)
#ifdef __CYGWIN__
if (lnk_added && len > 4 &&
strcasecmp(wfd.cFileName + len - 4, ".lnk") == 0) {
- len -= 4;
+ wfd.cFileName[len -= 4] = '\0';
}
#endif
if (!p) p = buf;
- buflen = ++p - buf + len;
- rb_str_resize(result, buflen);
+ ++p;
+ BUFCHECK(bdiff + len >= buflen);
memcpy(p, wfd.cFileName, len + 1);
+ p += len;
}
}
#endif
if (tainted) OBJ_TAINT(result);
- rb_str_set_len(result, buflen);
+ rb_str_set_len(result, p - buf);
return result;
}