summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-12 14:44:54 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-12 14:44:54 +0000
commite4dbfc4cae378b0f262e5ae6ce30f1c8cba2fa62 (patch)
tree15166c3addf31d91c1c0a175f57732ac4fa6f99a
parentaa2d3e79a3639a45022a545310a1ca5f5b4e5673 (diff)
downloadruby-e4dbfc4cae378b0f262e5ae6ce30f1c8cba2fa62.tar.gz
ruby-e4dbfc4cae378b0f262e5ae6ce30f1c8cba2fa62.tar.xz
ruby-e4dbfc4cae378b0f262e5ae6ce30f1c8cba2fa62.zip
merges r23891 from trunk into ruby_1_9_1.
-- * dln.c (dln_find_1): fix for files with dots. [ruby-dev:38588] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@24046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--dln.c31
-rw-r--r--test/ruby/test_system.rb22
-rw-r--r--version.h2
4 files changed, 45 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 087e28804..eaecb649a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Jun 29 18:55:55 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * dln.c (dln_find_1): fix for files with dots. [ruby-dev:38588]
+
Mon Jun 29 17:14:31 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (file_expand_path): should copy original encoding.
diff --git a/dln.c b/dln.c
index d3408fb0f..23df91aaa 100644
--- a/dln.c
+++ b/dln.c
@@ -1520,7 +1520,12 @@ dln_find_1(const char *fname, const char *path, char *fbuf, int size,
struct stat st;
int i, fspace;
#ifdef DOSISH
- int is_abs = 0, has_path = 0, has_ext = 0;
+ static const char extension[][5] = {
+ ".exe", ".com", ".cmd", ".bat",
+ };
+ size_t j;
+ int is_abs = 0, has_path = 0;
+ const char *ext = 0;
const char *p = fname;
#endif
@@ -1547,23 +1552,31 @@ dln_find_1(const char *fname, const char *path, char *fbuf, int size,
switch (*p) {
case '/': case '\\':
has_path = 1;
- has_ext = 0;
+ ext = 0;
p++;
break;
case '.':
- has_ext = 1;
+ ext = p;
p++;
break;
default:
p = CharNext(p);
}
}
+ if (ext) {
+ for (j = 0; STRCASECMP(ext, extension[j]); j++) {
+ if (j == sizeof(extension) / sizeof(extension[0])) {
+ ext = 0;
+ break;
+ }
+ }
+ }
ep = bp = 0;
if (!exe_flag) {
RETURN_IF(is_abs);
}
else if (has_path) {
- RETURN_IF(has_ext);
+ RETURN_IF(ext);
i = p - fname;
if (i + 1 > size) goto toolong;
fspace = size - i - 1;
@@ -1644,15 +1657,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, int size,
memcpy(bp, fname, i + 1);
#if defined(DOSISH)
- if (exe_flag && !has_ext) {
- static const char extension[][5] = {
-#if defined(__EMX__) || defined(_WIN32)
- ".exe", ".com", ".cmd", ".bat",
-/* end of __EMX__ or _WIN32 */
-#endif
- };
- int j;
-
+ if (exe_flag && !ext) {
needs_extension:
for (j = 0; j < sizeof(extension) / sizeof(extension[0]); j++) {
if (fspace < strlen(extension[j])) {
diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb
index ec8aca74c..0b3b243b1 100644
--- a/test/ruby/test_system.rb
+++ b/test/ruby/test_system.rb
@@ -59,6 +59,28 @@ class TestSystem < Test::Unit::TestCase
File.unlink tmpfilename or `/bin/rm -f "#{tmpfilename}"`
File.unlink "#{tmpfilename}.bak" or `/bin/rm -f "#{tmpfilename}.bak"`
+
+ if /mswin|mingw/ =~ RUBY_PLATFORM
+ testname = '[ruby-dev:38588]'
+ batch = "batch_tmp.#{$$}"
+ tmpfilename = "#{tmpdir}/#{batch}.bat"
+ open(tmpfilename, "wb") {|f| f.print "\r\n"}
+ assert(system(tmpfilename), testname)
+ assert(system("#{tmpdir}/#{batch}"), testname)
+ assert(system(tmpfilename, "1"), testname)
+ assert(system("#{tmpdir}/#{batch}", "1"), testname)
+ begin
+ path = ENV["PATH"]
+ ENV["PATH"] = "#{tmpdir.tr(File::SEPARATOR, File::ALT_SEPARATOR)}#{File::PATH_SEPARATOR + path if path}"
+ assert(system("#{batch}.bat"), testname)
+ assert(system(batch), testname)
+ assert(system("#{batch}.bat", "1"), testname)
+ assert(system(batch, "1"), testname)
+ ensure
+ ENV["PATH"] = path
+ end
+ File.unlink tmpfilename
+ end
}
end
diff --git a/version.h b/version.h
index 806f9ce3f..994f6caea 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "1.9.1"
#define RUBY_RELEASE_DATE "2009-07-12"
-#define RUBY_PATCHLEVEL 209
+#define RUBY_PATCHLEVEL 210
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1