summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/file.c b/file.c
index 68d3a3c163..923257888f 100644
--- a/file.c
+++ b/file.c
@@ -1250,9 +1250,10 @@ file_s_basename(argc, argv)
char *name, *p, *ext;
int f;
- rb_scan_args(argc, argv, "11", &fname, &fext);
+ if (rb_scan_args(argc, argv, "11", &fname, &fext) == 2) {
+ ext = STR2CSTR(fext);
+ }
name = STR2CSTR(fname);
- if (!NIL_P(fext)) ext = STR2CSTR(fext);
p = strrchr(name, '/');
if (!p) {
if (!NIL_P(fext)) {