summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/file.c b/file.c
index 9ac2db6b35..182c6d0b42 100644
--- a/file.c
+++ b/file.c
@@ -1107,7 +1107,7 @@ rb_file_s_expand_path(argc, argv)
}
}
#endif
- else if (s[0] != '/') {
+ else if (!isdirsep(*s)) {
if (argc == 2) {
dname = rb_file_s_expand_path(1, &dname);
strcpy(buf, RSTRING(dname)->ptr);
@@ -1122,6 +1122,13 @@ rb_file_s_expand_path(argc, argv)
p = &buf[strlen(buf)];
while (p > buf && *(p - 1) == '/') p--;
}
+ else if (isdirsep(*s)) {
+ while (*s && isdirsep(*s)) {
+ *p++ = '/';
+ s++;
+ }
+ if (p > buf && *s) p--;
+ }
*p = '/';
for ( ; *s; s++) {