mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
* file.c (BUFCHECK): no resize if enough room.
* file.c (file_expand_path): use BUFCHECK. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bae65bdc33
commit
d56e15200b
2 changed files with 14 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Mon May 26 18:24:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (BUFCHECK): no resize if enough room.
|
||||||
|
|
||||||
|
* file.c (file_expand_path): use BUFCHECK.
|
||||||
|
|
||||||
Mon May 26 16:46:19 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
Mon May 26 16:46:19 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* file.c (ntfs_tail): filename which starts with '.' is valid.
|
* file.c (ntfs_tail): filename which starts with '.' is valid.
|
||||||
|
|
16
file.c
16
file.c
|
@ -2497,13 +2497,13 @@ ntfs_tail(const char *path)
|
||||||
|
|
||||||
#define BUFCHECK(cond) do {\
|
#define BUFCHECK(cond) do {\
|
||||||
long bdiff = p - buf;\
|
long bdiff = p - buf;\
|
||||||
while (cond) {\
|
if (!(cond)) {\
|
||||||
buflen *= 2;\
|
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)
|
} while (0)
|
||||||
|
|
||||||
#define BUFINIT() (\
|
#define BUFINIT() (\
|
||||||
|
@ -2789,8 +2789,8 @@ file_expand_path(fname, dname, result)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!p) p = buf;
|
if (!p) p = buf;
|
||||||
buflen = ++p - buf + len;
|
++p;
|
||||||
rb_str_resize(result, buflen);
|
BUFCHECK(bdiff + len >= buflen);
|
||||||
memcpy(p, wfd.cFileName, len + 1);
|
memcpy(p, wfd.cFileName, len + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue