see ChangeLog.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d7fe17edf0
commit
869b1efeb4
20
ChangeLog
20
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>
|
Wed May 24 23:17:50 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
|
||||||
|
|
||||||
* win32/Makefile: remove unnecessary mv and rm command call.
|
* win32/Makefile: remove unnecessary mv and rm command call.
|
||||||
|
12
dir.c
12
dir.c
@ -558,8 +558,8 @@ extract_elem(path)
|
|||||||
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
|
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
void
|
||||||
glob(path, func, arg)
|
rb_glob(path, func, arg)
|
||||||
char *path;
|
char *path;
|
||||||
void (*func)();
|
void (*func)();
|
||||||
VALUE arg;
|
VALUE arg;
|
||||||
@ -598,7 +598,7 @@ glob(path, func, arg)
|
|||||||
recursive = 1;
|
recursive = 1;
|
||||||
buf = ALLOC_N(char, strlen(base)+strlen(m)+3);
|
buf = ALLOC_N(char, strlen(base)+strlen(m)+3);
|
||||||
sprintf(buf, "%s%s%s", base, (*base)?"":".", m);
|
sprintf(buf, "%s%s%s", base, (*base)?"":".", m);
|
||||||
glob(buf, func, arg);
|
rb_glob(buf, func, arg);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
dirp = opendir(dir);
|
dirp = opendir(dir);
|
||||||
@ -614,7 +614,7 @@ glob(path, func, arg)
|
|||||||
continue;
|
continue;
|
||||||
buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6);
|
buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6);
|
||||||
sprintf(buf, "%s%s%s/**%s", base, (BASE)?"/":"", dp->d_name, m);
|
sprintf(buf, "%s%s%s/**%s", base, (BASE)?"/":"", dp->d_name, m);
|
||||||
glob(buf, func, arg);
|
rb_glob(buf, func, arg);
|
||||||
free(buf);
|
free(buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -643,7 +643,7 @@ glob(path, func, arg)
|
|||||||
char *t = ALLOC_N(char, len+mlen+1);
|
char *t = ALLOC_N(char, len+mlen+1);
|
||||||
|
|
||||||
sprintf(t, "%s%s", link->path, m);
|
sprintf(t, "%s%s", link->path, m);
|
||||||
glob(t, func, arg);
|
rb_glob(t, func, arg);
|
||||||
free(t);
|
free(t);
|
||||||
}
|
}
|
||||||
tmp = link;
|
tmp = link;
|
||||||
@ -669,7 +669,7 @@ push_globs(ary, s)
|
|||||||
VALUE ary;
|
VALUE ary;
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
glob(s, push_pattern, ary);
|
rb_glob(s, push_pattern, ary);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
14
eval.c
14
eval.c
@ -4970,8 +4970,11 @@ rb_f_require(obj, fname)
|
|||||||
strcpy(ext, DLEXT);
|
strcpy(ext, DLEXT);
|
||||||
file = feature = buf;
|
file = feature = buf;
|
||||||
}
|
}
|
||||||
|
file = rb_find_file(file);
|
||||||
|
if (file) goto load_dyna;
|
||||||
#ifdef DLEXT2
|
#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);
|
buf = ALLOCA_N(char, strlen(file)+sizeof(DLEXT2)+4);
|
||||||
strcpy(buf, feature);
|
strcpy(buf, feature);
|
||||||
ext = strrchr(buf, '.');
|
ext = strrchr(buf, '.');
|
||||||
@ -4980,15 +4983,22 @@ rb_f_require(obj, fname)
|
|||||||
strcpy(ext, DLEXT2);
|
strcpy(ext, DLEXT2);
|
||||||
file = feature = buf;
|
file = feature = buf;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
file = rb_find_file(file);
|
file = rb_find_file(file);
|
||||||
if (file) goto load_dyna;
|
if (file) goto load_dyna;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (strcmp(DLEXT, ext) == 0) {
|
else if (strcmp(DLEXT, ext) == 0) {
|
||||||
feature = RSTRING(fname)->ptr;
|
feature = RSTRING(fname)->ptr;
|
||||||
file = rb_find_file(feature);
|
file = rb_find_file(feature);
|
||||||
if (file) goto load_dyna;
|
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);
|
buf = ALLOCA_N(char, strlen(RSTRING(fname)->ptr) + 5);
|
||||||
strcpy(buf, RSTRING(fname)->ptr);
|
strcpy(buf, RSTRING(fname)->ptr);
|
||||||
|
@ -32,6 +32,17 @@ $:.push $top_srcdir+"/lib"
|
|||||||
|
|
||||||
require 'find'
|
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)
|
def older(file1, file2)
|
||||||
if !File.exist?(file1) then
|
if !File.exist?(file1) then
|
||||||
return true
|
return true
|
||||||
@ -85,7 +96,7 @@ def try_link(src, opt="")
|
|||||||
begin
|
begin
|
||||||
try_link0(src, opt)
|
try_link0(src, opt)
|
||||||
ensure
|
ensure
|
||||||
system "rm -f conftest*"
|
rm_f "conftest*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -96,7 +107,7 @@ def try_cpp(src, opt="")
|
|||||||
begin
|
begin
|
||||||
xsystem(format(CPP, $CFLAGS, opt))
|
xsystem(format(CPP, $CFLAGS, opt))
|
||||||
ensure
|
ensure
|
||||||
system "rm -f conftest*"
|
rm_f "conftest*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -107,7 +118,7 @@ def egrep_cpp(pat, src, opt="")
|
|||||||
begin
|
begin
|
||||||
xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, opt))
|
xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, opt))
|
||||||
ensure
|
ensure
|
||||||
system "rm -f conftest*"
|
rm_f "conftest*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -123,7 +134,7 @@ def try_run(src, opt="")
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
system "rm -f conftest*"
|
rm_f "conftest*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -318,7 +329,7 @@ end
|
|||||||
def create_makefile(target)
|
def create_makefile(target)
|
||||||
$target = target
|
$target = target
|
||||||
|
|
||||||
system "rm -f conftest*"
|
rm_f "conftest*"
|
||||||
if "@DLEXT@" == $OBJEXT
|
if "@DLEXT@" == $OBJEXT
|
||||||
libs = $libs.split
|
libs = $libs.split
|
||||||
for lib in libs
|
for lib in libs
|
||||||
@ -406,15 +417,16 @@ TARGET = #{target}
|
|||||||
DLLIB = $(TARGET).#{$static ? $LIBEXT : "@DLEXT@"}
|
DLLIB = $(TARGET).#{$static ? $LIBEXT : "@DLEXT@"}
|
||||||
|
|
||||||
RUBY = #{ruby_interpreter} -I$(topdir) -I$(hdrdir)/lib
|
RUBY = #{ruby_interpreter} -I$(topdir) -I$(hdrdir)/lib
|
||||||
|
RM = $(RUBY) -r ftools -e "File::rm_f *Dir[ARGV.join ' ']"
|
||||||
|
|
||||||
EXEEXT = @EXEEXT@
|
EXEEXT = @EXEEXT@
|
||||||
|
|
||||||
all: $(DLLIB)
|
all: $(DLLIB)
|
||||||
|
|
||||||
clean:; @rm -f *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB)
|
clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB)
|
||||||
@rm -f *.ilk *.exp *.pdb *.bak
|
@$(RM) *.ilk *.exp *.pdb *.bak
|
||||||
@rm -f Makefile extconf.h conftest.*
|
@$(RM) Makefile extconf.h conftest.*
|
||||||
@rm -f core ruby$(EXEEXT) *~
|
@$(RM) core ruby$(EXEEXT) *~
|
||||||
|
|
||||||
realclean: clean
|
realclean: clean
|
||||||
EOS
|
EOS
|
||||||
@ -558,7 +570,7 @@ def extmake(target)
|
|||||||
$extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
|
$extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
system "rm -f conftest*"
|
rm_f "conftest*"
|
||||||
Dir.chdir ".."
|
Dir.chdir ".."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -648,7 +660,7 @@ if $extlist.size > 0
|
|||||||
Dir.chdir ".."
|
Dir.chdir ".."
|
||||||
|
|
||||||
if older(ruby, "#{$top_srcdir}/ext/@setup@") or older(ruby, miniruby)
|
if older(ruby, "#{$top_srcdir}/ext/@setup@") or older(ruby, miniruby)
|
||||||
system("rm -f #{ruby}")
|
rm_f ruby
|
||||||
end
|
end
|
||||||
|
|
||||||
$extobjs = "ext/extinit.#{$OBJEXT} " + $extobjs
|
$extobjs = "ext/extinit.#{$OBJEXT} " + $extobjs
|
||||||
@ -659,7 +671,7 @@ if $extlist.size > 0
|
|||||||
else
|
else
|
||||||
Dir.chdir ".."
|
Dir.chdir ".."
|
||||||
if older(ruby, miniruby)
|
if older(ruby, miniruby)
|
||||||
system("rm -f #{ruby}")
|
rm_f ruby
|
||||||
system("#{$make} #{ruby}")
|
system("#{$make} #{ruby}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
30
lib/mkmf.rb
30
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']}"
|
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"
|
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
|
$orgerr = $stderr.dup
|
||||||
$orgout = $stdout.dup
|
$orgout = $stdout.dup
|
||||||
def xsystem command
|
def xsystem command
|
||||||
@ -67,7 +78,7 @@ def try_link(src, opt="")
|
|||||||
begin
|
begin
|
||||||
try_link0(src, opt)
|
try_link0(src, opt)
|
||||||
ensure
|
ensure
|
||||||
system "rm -f conftest*"
|
rm_f "conftest*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -78,7 +89,7 @@ def try_cpp(src, opt="")
|
|||||||
begin
|
begin
|
||||||
xsystem(format(CPP, $CFLAGS, opt))
|
xsystem(format(CPP, $CFLAGS, opt))
|
||||||
ensure
|
ensure
|
||||||
system "rm -f conftest*"
|
rm_f "conftest*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -89,7 +100,7 @@ def egrep_cpp(pat, src, opt="")
|
|||||||
begin
|
begin
|
||||||
xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, opt))
|
xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, opt))
|
||||||
ensure
|
ensure
|
||||||
system "rm -f conftest*"
|
rm_f "conftest*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -105,7 +116,7 @@ def try_run(src, opt="")
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
system "rm -f conftest*"
|
rm_f "conftest*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -317,7 +328,7 @@ end
|
|||||||
|
|
||||||
def create_makefile(target)
|
def create_makefile(target)
|
||||||
print "creating Makefile\n"
|
print "creating Makefile\n"
|
||||||
system "rm -f conftest*"
|
rm_f "conftest*"
|
||||||
STDOUT.flush
|
STDOUT.flush
|
||||||
if CONFIG["DLEXT"] == $OBJEXT
|
if CONFIG["DLEXT"] == $OBJEXT
|
||||||
libs = $libs.split
|
libs = $libs.split
|
||||||
@ -387,15 +398,16 @@ TARGET = #{target}
|
|||||||
DLLIB = $(TARGET).#{CONFIG["DLEXT"]}
|
DLLIB = $(TARGET).#{CONFIG["DLEXT"]}
|
||||||
|
|
||||||
RUBY = #{CONFIG["ruby_install_name"]}
|
RUBY = #{CONFIG["ruby_install_name"]}
|
||||||
|
RM = $(RUBY) -r ftools -e 'File::rm_f *Dir[ARGV.join " "]'
|
||||||
|
|
||||||
EXEEXT = #{CONFIG["EXEEXT"]}
|
EXEEXT = #{CONFIG["EXEEXT"]}
|
||||||
|
|
||||||
all: $(DLLIB)
|
all: $(DLLIB)
|
||||||
|
|
||||||
clean:; @rm -f *.#{$OBJEXT} *.so *.sl *.a $(DLLIB)
|
clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.a $(DLLIB)
|
||||||
@rm -f $(TARGET).lib $(TARGET).exp
|
@$(RM) $(TARGET).lib $(TARGET).exp
|
||||||
@rm -f Makefile extconf.h conftest.*
|
@$(RM) Makefile extconf.h conftest.*
|
||||||
@rm -f core ruby$(EXEEXT) *~
|
@$(RM) core ruby$(EXEEXT) *~
|
||||||
|
|
||||||
realclean: clean
|
realclean: clean
|
||||||
|
|
||||||
|
4
main.c
4
main.c
@ -20,6 +20,10 @@ unsigned int _stklen = 0x180000;
|
|||||||
int _stacksize = 262144;
|
int _stacksize = 262144;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined __MINGW32__
|
||||||
|
int _CRT_glob = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__MACOS__) && defined(__MWERKS__)
|
#if defined(__MACOS__) && defined(__MWERKS__)
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#endif
|
#endif
|
||||||
|
2
ruby.h
2
ruby.h
@ -389,6 +389,8 @@ void xfree _((void*));
|
|||||||
#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
|
#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
|
||||||
#define MEMMOVE(p1,p2,type,n) memmove((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_class _((const char*,VALUE));
|
||||||
VALUE rb_define_module _((const char*));
|
VALUE rb_define_module _((const char*));
|
||||||
VALUE rb_define_class_under _((VALUE, const char*, VALUE));
|
VALUE rb_define_class_under _((VALUE, const char*, VALUE));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#define RUBY_VERSION "1.5.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_VERSION_CODE 154
|
||||||
#define RUBY_RELEASE_CODE 20000525
|
#define RUBY_RELEASE_CODE 20000528
|
||||||
|
117
win32/win32.c
117
win32/win32.c
@ -194,7 +194,7 @@ NtInitialize(int *argc, char ***argv) {
|
|||||||
char *getlogin()
|
char *getlogin()
|
||||||
{
|
{
|
||||||
char buffer[200];
|
char buffer[200];
|
||||||
int len = 200;
|
DWORD len = 200;
|
||||||
extern char *NTLoginName;
|
extern char *NTLoginName;
|
||||||
|
|
||||||
if (NTLoginName == NULL) {
|
if (NTLoginName == NULL) {
|
||||||
@ -587,7 +587,7 @@ int
|
|||||||
mypclose(FILE *fp)
|
mypclose(FILE *fp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int exitcode;
|
DWORD exitcode;
|
||||||
|
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
for (i = 0; i < MYPOPENSIZE; i++) {
|
for (i = 0; i < MYPOPENSIZE; i++) {
|
||||||
@ -771,6 +771,7 @@ NtFreeCmdLine(void)
|
|||||||
// any existing files, just leave it in the list.
|
// any existing files, just leave it in the list.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#if 0
|
||||||
void
|
void
|
||||||
NtCmdGlob (NtCmdLineElement *patt)
|
NtCmdGlob (NtCmdLineElement *patt)
|
||||||
{
|
{
|
||||||
@ -844,6 +845,54 @@ NtCmdGlob (NtCmdLineElement *patt)
|
|||||||
free(patt->str);
|
free(patt->str);
|
||||||
// free(patt); //TODO: memory leak occures here. we have to fix it.
|
// 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
|
// 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmdline = strdup(cmdline);
|
||||||
|
|
||||||
//
|
//
|
||||||
// strip trailing white space
|
// strip trailing white space
|
||||||
//
|
//
|
||||||
@ -922,36 +973,6 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
|
|||||||
--ptr;
|
--ptr;
|
||||||
*++ptr = '\0';
|
*++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.
|
// Ok, parse the command line, building a list of CmdLineElements.
|
||||||
@ -982,6 +1003,9 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
|
|||||||
//
|
//
|
||||||
|
|
||||||
switch (*ptr) {
|
switch (*ptr) {
|
||||||
|
case '\\':
|
||||||
|
if (ptr[1] == '"') ptr++;
|
||||||
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
case '\t':
|
case '\t':
|
||||||
#if 0
|
#if 0
|
||||||
@ -1066,12 +1090,6 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
|
|||||||
//
|
//
|
||||||
|
|
||||||
curr = ALLOC(NtCmdLineElement);
|
curr = ALLOC(NtCmdLineElement);
|
||||||
if (curr == NULL) {
|
|
||||||
NtFreeCmdLine();
|
|
||||||
fprintf(stderr, "Out of memory!!\n");
|
|
||||||
*vec = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memset (curr, 0, sizeof(*curr));
|
memset (curr, 0, sizeof(*curr));
|
||||||
|
|
||||||
len = ptr - base;
|
len = ptr - base;
|
||||||
@ -1081,9 +1099,19 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
|
|||||||
// we can remove them.
|
// we can remove them.
|
||||||
//
|
//
|
||||||
|
|
||||||
if (InputCmd &&
|
if (InputCmd && (base[0] == '\"' && base[len-1] == '\"')) {
|
||||||
((base[0] == '\"' && base[len-1] == '\"') ||
|
char *p;
|
||||||
(base[0] == '\'' && base[len-1] == '\''))) {
|
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++;
|
base++;
|
||||||
len -= 2;
|
len -= 2;
|
||||||
}
|
}
|
||||||
@ -1132,12 +1160,6 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
|
|||||||
|
|
||||||
len = (elements+1)*sizeof(char *) + strsz;
|
len = (elements+1)*sizeof(char *) + strsz;
|
||||||
buffer = ALLOC_N(char, len);
|
buffer = ALLOC_N(char, len);
|
||||||
if (buffer == NULL) {
|
|
||||||
fprintf(stderr, "Out of memory!!\n");
|
|
||||||
NtFreeCmdLine();
|
|
||||||
*vec = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset (buffer, 0, len);
|
memset (buffer, 0, len);
|
||||||
|
|
||||||
@ -1165,6 +1187,7 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
|
|||||||
}
|
}
|
||||||
NtFreeCmdLine();
|
NtFreeCmdLine();
|
||||||
*vec = (char **) buffer;
|
*vec = (char **) buffer;
|
||||||
|
free(cmdline);
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user