зеркало из https://github.com/github/ruby.git
* 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/trunk@16615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
71b059e070
Коммит
c3b10e7fcb
|
@ -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 17:48:42 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* enumerator.c (struct enumerator, enumerator_init)
|
||||
|
|
22
file.c
22
file.c
|
@ -2578,13 +2578,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_PTR(result);\
|
||||
p = buf + bdiff;\
|
||||
pend = buf + buflen;\
|
||||
} while (0)
|
||||
|
||||
#define BUFINIT() (\
|
||||
|
@ -2731,7 +2731,8 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
|
|||
if (p > buf && p[-1] == '/')
|
||||
--p;
|
||||
else {
|
||||
BUFCHECK(bdiff >= ++buflen);
|
||||
++buflen;
|
||||
BUFCHECK(bdiff >= buflen);
|
||||
*p = '/';
|
||||
}
|
||||
|
||||
|
@ -2866,7 +2867,6 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
|
|||
#endif
|
||||
HANDLE h = FindFirstFile(b, &wfd);
|
||||
if (h != INVALID_HANDLE_VALUE) {
|
||||
long bdiff;
|
||||
FindClose(h);
|
||||
p = strrdirsep(buf);
|
||||
len = strlen(wfd.cFileName);
|
||||
|
@ -2877,10 +2877,8 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
|
|||
}
|
||||
#endif
|
||||
if (!p) p = buf;
|
||||
buflen = ++p - buf + len;
|
||||
bdiff = p - buf;
|
||||
rb_str_resize(result, buflen);
|
||||
p = RSTRING_PTR(result) + bdiff;
|
||||
++p;
|
||||
BUFCHECK(bdiff + len >= buflen);
|
||||
memcpy(p, wfd.cFileName, len + 1);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче