1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* file.c (file_expand_path): add more space for '/'.

* file.c (file_expand_path): should reset address of p after calling
	  rb_str_resize(). [ruby-dev:34800]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2008-05-26 08:25:44 +00:00
parent c2257734e3
commit 224efac340
2 changed files with 13 additions and 1 deletions

View file

@ -1,3 +1,10 @@
Mon May 26 17:23:49 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* file.c (file_expand_path): add more space for '/'.
* file.c (file_expand_path): should reset address of p after calling
rb_str_resize(). [ruby-dev:34800]
Mon May 26 16:49:55 2008 Yukihiro Matsumoto <matz@ruby-lang.org> Mon May 26 16:49:55 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* misc/ruby-mode.el (ruby-mode): use run-hooks if run-mode-hook is * misc/ruby-mode.el (ruby-mode): use run-hooks if run-mode-hook is

7
file.c
View file

@ -2730,8 +2730,10 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
} }
if (p > buf && p[-1] == '/') if (p > buf && p[-1] == '/')
--p; --p;
else else {
BUFCHECK(bdiff >= ++buflen);
*p = '/'; *p = '/';
}
p[1] = 0; p[1] = 0;
root = skipprefix(buf); root = skipprefix(buf);
@ -2864,6 +2866,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
#endif #endif
HANDLE h = FindFirstFile(b, &wfd); HANDLE h = FindFirstFile(b, &wfd);
if (h != INVALID_HANDLE_VALUE) { if (h != INVALID_HANDLE_VALUE) {
long bdiff;
FindClose(h); FindClose(h);
p = strrdirsep(buf); p = strrdirsep(buf);
len = strlen(wfd.cFileName); len = strlen(wfd.cFileName);
@ -2875,7 +2878,9 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
#endif #endif
if (!p) p = buf; if (!p) p = buf;
buflen = ++p - buf + len; buflen = ++p - buf + len;
bdiff = p - buf;
rb_str_resize(result, buflen); rb_str_resize(result, buflen);
p = RSTRING_PTR(result) + bdiff;
memcpy(p, wfd.cFileName, len + 1); memcpy(p, wfd.cFileName, len + 1);
} }
} }