summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--file.c17
2 files changed, 21 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 581f0c13b1..46e3c2e5dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Sep 16 22:41:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * file.c (rb_file_s_extname): empty string for path name ending with a
+ period. fixed: [ruby-core:05651]
+
+ * file.c (rb_file_join): smarter behavior at edge cases.
+ fixed: [ruby-core:05706]
+
Fri Sep 16 18:34:01 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/syck/node.c (syck_replace_str): was using return from the
@@ -118,7 +126,7 @@ Thu Sep 15 22:35:55 2005 NAKAMURA Usaku <usa@ruby-lang.org>
Thu Sep 15 11:39:18 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/lib/tk/dialog.rb: If a dialog does not show up yet,
+ * ext/tk/lib/tk/dialog.rb: If a dialog does not show up yet,
TkDialogObj#name raises an exception. [ruby-talk:156109]
Thu Sep 15 01:39:19 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
diff --git a/file.c b/file.c
index fce522de56..818d8087be 100644
--- a/file.c
+++ b/file.c
@@ -2675,7 +2675,7 @@ rb_file_s_extname(klass, fname)
p++;
e = strrchr(p, '.'); /* get the last dot of the last component */
- if (!e || e == p) /* no dot, or the only dot is first? */
+ if (!e || e == p || !e[1]) /* no dot, or the only dot is first or end? */
return rb_str_new2("");
extname = rb_str_new(e, chompdirsep(e) - e); /* keep the dot, too! */
OBJ_INFECT(extname, fname);
@@ -2720,7 +2720,7 @@ rb_file_join(ary, sep)
long len, i;
int taint = 0;
VALUE result, tmp;
- char *name;
+ char *name, *tail;
if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
if (OBJ_TAINTED(ary)) taint = 1;
@@ -2757,11 +2757,18 @@ rb_file_join(ary, sep)
}
break;
default:
- tmp = rb_obj_as_string(tmp);
+ StringValueCStr(tmp);
}
name = StringValueCStr(result);
- if (i > 0 && !NIL_P(sep) && !*chompdirsep(name))
- rb_str_buf_append(result, sep);
+ if (i > 0 && !NIL_P(sep)) {
+ tail = chompdirsep(name);
+ if (isdirsep(RSTRING(tmp)->ptr[0])) {
+ RSTRING(result)->len = tail - name;
+ }
+ else if (!*tail) {
+ rb_str_buf_append(result, sep);
+ }
+ }
rb_str_buf_append(result, tmp);
if (OBJ_TAINTED(tmp)) taint = 1;
}