summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog20
-rw-r--r--dir.c12
-rw-r--r--eval.c14
-rw-r--r--ext/extmk.rb.in36
-rw-r--r--lib/mkmf.rb30
-rw-r--r--main.c4
-rw-r--r--ruby.h2
-rw-r--r--version.h4
-rw-r--r--win32/win32.c117
9 files changed, 161 insertions, 78 deletions
diff --git a/ChangeLog b/ChangeLog
index 248467fc83..1e53ac37dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+Sun May 28 21:37:13 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * eval.c: bug fix: DLEXT2.
+
+Sun May 28 19:21:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * win32/win32.c: use ruby's glob.
+
+ * dir.c: "glob" exported and renamed to "rb_glob".
+
+ * ruby.h: ditto.
+
+ * main.c: turn off command line mingw32's globbing.
+
+Wed May 25 22:25:13 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/extmk.rb.in: use "ftools" instead of "rm -f".
+
+ * lib/mkmf.rb: ditto.
+
Wed May 24 23:17:50 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* win32/Makefile: remove unnecessary mv and rm command call.
diff --git a/dir.c b/dir.c
index 03b0efd31d..6792ab6390 100644
--- a/dir.c
+++ b/dir.c
@@ -558,8 +558,8 @@ extract_elem(path)
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
#endif
-static void
-glob(path, func, arg)
+void
+rb_glob(path, func, arg)
char *path;
void (*func)();
VALUE arg;
@@ -598,7 +598,7 @@ glob(path, func, arg)
recursive = 1;
buf = ALLOC_N(char, strlen(base)+strlen(m)+3);
sprintf(buf, "%s%s%s", base, (*base)?"":".", m);
- glob(buf, func, arg);
+ rb_glob(buf, func, arg);
free(buf);
}
dirp = opendir(dir);
@@ -614,7 +614,7 @@ glob(path, func, arg)
continue;
buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6);
sprintf(buf, "%s%s%s/**%s", base, (BASE)?"/":"", dp->d_name, m);
- glob(buf, func, arg);
+ rb_glob(buf, func, arg);
free(buf);
continue;
}
@@ -643,7 +643,7 @@ glob(path, func, arg)
char *t = ALLOC_N(char, len+mlen+1);
sprintf(t, "%s%s", link->path, m);
- glob(t, func, arg);
+ rb_glob(t, func, arg);
free(t);
}
tmp = link;
@@ -669,7 +669,7 @@ push_globs(ary, s)
VALUE ary;
char *s;
{
- glob(s, push_pattern, ary);
+ rb_glob(s, push_pattern, ary);
}
static void
diff --git a/eval.c b/eval.c
index 8220274a04..9edf9aeb3e 100644
--- a/eval.c
+++ b/eval.c
@@ -4970,8 +4970,11 @@ rb_f_require(obj, fname)
strcpy(ext, DLEXT);
file = feature = buf;
}
+ file = rb_find_file(file);
+ if (file) goto load_dyna;
#ifdef DLEXT2
- else if (strcmp(ext, DLEXT2) != 0) {
+ file = feature = RSTRING(fname)->ptr;
+ if (strcmp(ext, DLEXT2) != 0) {
buf = ALLOCA_N(char, strlen(file)+sizeof(DLEXT2)+4);
strcpy(buf, feature);
ext = strrchr(buf, '.');
@@ -4980,15 +4983,22 @@ rb_f_require(obj, fname)
strcpy(ext, DLEXT2);
file = feature = buf;
}
-#endif
file = rb_find_file(file);
if (file) goto load_dyna;
+#endif
}
else if (strcmp(DLEXT, ext) == 0) {
feature = RSTRING(fname)->ptr;
file = rb_find_file(feature);
if (file) goto load_dyna;
}
+#ifdef DLEXT2
+ else if (strcmp(DLEXT2, ext) == 0) {
+ feature = RSTRING(fname)->ptr;
+ file = rb_find_file(feature);
+ if (file) goto load_dyna;
+ }
+#endif
}
buf = ALLOCA_N(char, strlen(RSTRING(fname)->ptr) + 5);
strcpy(buf, RSTRING(fname)->ptr);
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index 0787ae4658..44232da7a1 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -32,6 +32,17 @@ $:.push $top_srcdir+"/lib"
require 'find'
+def rm_f(*files)
+ targets = []
+ for file in files
+ targets.concat Dir[file]
+ end
+ if not targets.empty?
+ File::chmod 0777, *targets
+ File::unlink *targets
+ end
+end
+
def older(file1, file2)
if !File.exist?(file1) then
return true
@@ -85,7 +96,7 @@ def try_link(src, opt="")
begin
try_link0(src, opt)
ensure
- system "rm -f conftest*"
+ rm_f "conftest*"
end
end
@@ -96,7 +107,7 @@ def try_cpp(src, opt="")
begin
xsystem(format(CPP, $CFLAGS, opt))
ensure
- system "rm -f conftest*"
+ rm_f "conftest*"
end
end
@@ -107,7 +118,7 @@ def egrep_cpp(pat, src, opt="")
begin
xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, opt))
ensure
- system "rm -f conftest*"
+ rm_f "conftest*"
end
end
@@ -123,7 +134,7 @@ def try_run(src, opt="")
nil
end
ensure
- system "rm -f conftest*"
+ rm_f "conftest*"
end
end
@@ -318,7 +329,7 @@ end
def create_makefile(target)
$target = target
- system "rm -f conftest*"
+ rm_f "conftest*"
if "@DLEXT@" == $OBJEXT
libs = $libs.split
for lib in libs
@@ -406,15 +417,16 @@ TARGET = #{target}
DLLIB = $(TARGET).#{$static ? $LIBEXT : "@DLEXT@"}
RUBY = #{ruby_interpreter} -I$(topdir) -I$(hdrdir)/lib
+RM = $(RUBY) -r ftools -e "File::rm_f *Dir[ARGV.join ' ']"
EXEEXT = @EXEEXT@
all: $(DLLIB)
-clean:; @rm -f *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB)
- @rm -f *.ilk *.exp *.pdb *.bak
- @rm -f Makefile extconf.h conftest.*
- @rm -f core ruby$(EXEEXT) *~
+clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB)
+ @$(RM) *.ilk *.exp *.pdb *.bak
+ @$(RM) Makefile extconf.h conftest.*
+ @$(RM) core ruby$(EXEEXT) *~
realclean: clean
EOS
@@ -558,7 +570,7 @@ def extmake(target)
$extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
end
ensure
- system "rm -f conftest*"
+ rm_f "conftest*"
Dir.chdir ".."
end
end
@@ -648,7 +660,7 @@ if $extlist.size > 0
Dir.chdir ".."
if older(ruby, "#{$top_srcdir}/ext/@setup@") or older(ruby, miniruby)
- system("rm -f #{ruby}")
+ rm_f ruby
end
$extobjs = "ext/extinit.#{$OBJEXT} " + $extobjs
@@ -659,7 +671,7 @@ if $extlist.size > 0
else
Dir.chdir ".."
if older(ruby, miniruby)
- system("rm -f #{ruby}")
+ rm_f ruby
system("#{$make} #{ruby}")
end
end
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 3c51480041..c2b1fef688 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -41,6 +41,17 @@ end
LINK = "#{CONFIG['CC']} -o conftest -I#{$hdrdir} #{CFLAGS} -I#{CONFIG['includedir']} %s #{CONFIG['LDFLAGS']} %s conftest.c %s %s #{CONFIG['LIBS']}"
CPP = "#{CONFIG['CPP']} -E -I#{$hdrdir} #{CFLAGS} -I#{CONFIG['includedir']} %s %s conftest.c"
+def rm_f(*files)
+ targets = []
+ for file in files
+ targets.concat Dir[file]
+ end
+ if not targets.empty?
+ File::chmod 0777, *targets
+ File::unlink *targets
+ end
+end
+
$orgerr = $stderr.dup
$orgout = $stdout.dup
def xsystem command
@@ -67,7 +78,7 @@ def try_link(src, opt="")
begin
try_link0(src, opt)
ensure
- system "rm -f conftest*"
+ rm_f "conftest*"
end
end
@@ -78,7 +89,7 @@ def try_cpp(src, opt="")
begin
xsystem(format(CPP, $CFLAGS, opt))
ensure
- system "rm -f conftest*"
+ rm_f "conftest*"
end
end
@@ -89,7 +100,7 @@ def egrep_cpp(pat, src, opt="")
begin
xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, opt))
ensure
- system "rm -f conftest*"
+ rm_f "conftest*"
end
end
@@ -105,7 +116,7 @@ def try_run(src, opt="")
nil
end
ensure
- system "rm -f conftest*"
+ rm_f "conftest*"
end
end
@@ -317,7 +328,7 @@ end
def create_makefile(target)
print "creating Makefile\n"
- system "rm -f conftest*"
+ rm_f "conftest*"
STDOUT.flush
if CONFIG["DLEXT"] == $OBJEXT
libs = $libs.split
@@ -387,15 +398,16 @@ TARGET = #{target}
DLLIB = $(TARGET).#{CONFIG["DLEXT"]}
RUBY = #{CONFIG["ruby_install_name"]}
+RM = $(RUBY) -r ftools -e 'File::rm_f *Dir[ARGV.join " "]'
EXEEXT = #{CONFIG["EXEEXT"]}
all: $(DLLIB)
-clean:; @rm -f *.#{$OBJEXT} *.so *.sl *.a $(DLLIB)
- @rm -f $(TARGET).lib $(TARGET).exp
- @rm -f Makefile extconf.h conftest.*
- @rm -f core ruby$(EXEEXT) *~
+clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.a $(DLLIB)
+ @$(RM) $(TARGET).lib $(TARGET).exp
+ @$(RM) Makefile extconf.h conftest.*
+ @$(RM) core ruby$(EXEEXT) *~
realclean: clean
diff --git a/main.c b/main.c
index 8ee706fef0..bea1f49a82 100644
--- a/main.c
+++ b/main.c
@@ -20,6 +20,10 @@ unsigned int _stklen = 0x180000;
int _stacksize = 262144;
#endif
+#if defined __MINGW32__
+int _CRT_glob = 0;
+#endif
+
#if defined(__MACOS__) && defined(__MWERKS__)
#include <console.h>
#endif
diff --git a/ruby.h b/ruby.h
index 82d1db83b9..e208c7a113 100644
--- a/ruby.h
+++ b/ruby.h
@@ -389,6 +389,8 @@ void xfree _((void*));
#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
#define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
+void rb_glob _((char*,void(*)(),VALUE));
+
VALUE rb_define_class _((const char*,VALUE));
VALUE rb_define_module _((const char*));
VALUE rb_define_class_under _((VALUE, const char*, VALUE));
diff --git a/version.h b/version.h
index 18271e8d67..fcb2ac5527 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.4"
-#define RUBY_RELEASE_DATE "2000-05-25"
+#define RUBY_RELEASE_DATE "2000-05-28"
#define RUBY_VERSION_CODE 154
-#define RUBY_RELEASE_CODE 20000525
+#define RUBY_RELEASE_CODE 20000528
diff --git a/win32/win32.c b/win32/win32.c
index 6cafce993f..5590ea5a5d 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -194,7 +194,7 @@ NtInitialize(int *argc, char ***argv) {
char *getlogin()
{
char buffer[200];
- int len = 200;
+ DWORD len = 200;
extern char *NTLoginName;
if (NTLoginName == NULL) {
@@ -587,7 +587,7 @@ int
mypclose(FILE *fp)
{
int i;
- int exitcode;
+ DWORD exitcode;
Sleep(100);
for (i = 0; i < MYPOPENSIZE; i++) {
@@ -771,6 +771,7 @@ NtFreeCmdLine(void)
// any existing files, just leave it in the list.
//
+#if 0
void
NtCmdGlob (NtCmdLineElement *patt)
{
@@ -844,6 +845,54 @@ NtCmdGlob (NtCmdLineElement *patt)
free(patt->str);
// free(patt); //TODO: memory leak occures here. we have to fix it.
}
+#else
+typedef struct {
+ NtCmdLineElement *head;
+ NtCmdLineElement *tail;
+} ListInfo;
+
+static void
+insert(char *path, ListInfo *listinfo)
+{
+ NtCmdLineElement *tmpcurr;
+
+ tmpcurr = ALLOC(NtCmdLineElement);
+ MEMZERO(tmpcurr, NtCmdLineElement, 1);
+ tmpcurr->len = strlen(path);
+ tmpcurr->str = ALLOC_N(char, tmpcurr->len + 1);
+ tmpcurr->flags |= NTMALLOC;
+ strcpy(tmpcurr->str, path);
+ if (listinfo->tail) {
+ listinfo->tail->next = tmpcurr;
+ tmpcurr->prev = listinfo->tail;
+ listinfo->tail = tmpcurr;
+ }
+ else {
+ listinfo->tail = listinfo->head = tmpcurr;
+ }
+}
+
+NtCmdGlob (NtCmdLineElement *patt)
+{
+ ListInfo listinfo;
+
+ listinfo.head = listinfo.tail = 0;
+
+ rb_glob(patt->str, insert, (VALUE)&listinfo);
+
+ if (listinfo.head && listinfo.tail) {
+ listinfo.head->prev = patt->prev;
+ listinfo.tail->next = patt->next;
+ if (listinfo.head->prev)
+ listinfo.head->prev->next = listinfo.head;
+ if (listinfo.tail->next)
+ listinfo.tail->next->prev = listinfo.tail;
+ }
+ if (patt->flags & NTMALLOC)
+ free(patt->str);
+ // free(patt); //TODO: memory leak occures here. we have to fix it.
+}
+#endif
//
// Check a command string to determine if it has I/O redirection
@@ -913,6 +962,8 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
return 0;
}
+ cmdline = strdup(cmdline);
+
//
// strip trailing white space
//
@@ -922,36 +973,6 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
--ptr;
*++ptr = '\0';
- //
- // check for newlines and formfeeds. If we find any, make a new
- // command string that replaces them with escaped sequences (\n or \f)
- //
-
- for (ptr = cmdline, newline = 0; *ptr; ptr++) {
- if (*ptr == '\n' || *ptr == '\f')
- newline++;
- }
-
- if (newline) {
- base = ALLOC_N(char, strlen(cmdline) + 1 + newline + slashes);
- if (base == NULL) {
- fprintf(stderr, "malloc failed!\n");
- return 0;
- }
- for (i = 0, ptr = base; (unsigned) i < strlen(cmdline); i++) {
- switch (cmdline[i]) {
- case '\n':
- *ptr++ = '\\';
- *ptr++ = 'n';
- break;
- default:
- *ptr++ = cmdline[i];
- }
- }
- *ptr = '\0';
- cmdline = base;
- need_free++;
- }
//
// Ok, parse the command line, building a list of CmdLineElements.
@@ -982,6 +1003,9 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
//
switch (*ptr) {
+ case '\\':
+ if (ptr[1] == '"') ptr++;
+ break;
case ' ':
case '\t':
#if 0
@@ -1066,12 +1090,6 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
//
curr = ALLOC(NtCmdLineElement);
- if (curr == NULL) {
- NtFreeCmdLine();
- fprintf(stderr, "Out of memory!!\n");
- *vec = NULL;
- return 0;
- }
memset (curr, 0, sizeof(*curr));
len = ptr - base;
@@ -1081,9 +1099,19 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
// we can remove them.
//
- if (InputCmd &&
- ((base[0] == '\"' && base[len-1] == '\"') ||
- (base[0] == '\'' && base[len-1] == '\''))) {
+ if (InputCmd && (base[0] == '\"' && base[len-1] == '\"')) {
+ char *p;
+ base++;
+ len -= 2;
+ base[len] = 0;
+ for (p = base; p < base + len; p++) {
+ if ((p[0] == '\\' || p[0] == '\"') && p[1] == '"') {
+ strcpy(p, p + 1);
+ len--;
+ }
+ }
+ }
+ else if (InputCmd && (base[0] == '\'' && base[len-1] == '\'')) {
base++;
len -= 2;
}
@@ -1132,12 +1160,6 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
len = (elements+1)*sizeof(char *) + strsz;
buffer = ALLOC_N(char, len);
- if (buffer == NULL) {
- fprintf(stderr, "Out of memory!!\n");
- NtFreeCmdLine();
- *vec = NULL;
- return 0;
- }
memset (buffer, 0, len);
@@ -1165,6 +1187,7 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
}
NtFreeCmdLine();
*vec = (char **) buffer;
+ free(cmdline);
return elements;
}