summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-17 05:12:48 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-17 05:12:48 +0000
commitc2fa49a9b453621dbe80630f3be88223fe10ab29 (patch)
treeb7c9e8cc04031fd40639c05c2e96544d80934c1b
parent20e305950e9fb53e1b1cb338f9b04b1be43fd7bb (diff)
1.1c0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog17
-rw-r--r--MANIFEST1
-rw-r--r--eval.c27
-rw-r--r--gc.c9
-rw-r--r--lib/tk.rb63
-rw-r--r--lib/tkcanvas.rb14
-rw-r--r--lib/tkdialog.rb91
-rw-r--r--lib/tkfont.rb88
-rw-r--r--lib/tktext.rb14
-rw-r--r--process.c29
-rw-r--r--range.c44
-rw-r--r--version.h4
12 files changed, 323 insertions, 78 deletions
diff --git a/ChangeLog b/ChangeLog
index 859005b66f..47522c093a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Fri Jul 17 14:10:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c0 released.
+
+Fri Jul 17 08:01:49 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * process.c (f_exec): Check_SafeStr() added.
+
+ * process.c (f_system): Check_SafeStr() moved before fork().
+
Thu Jul 16 22:58:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* string.c (scan_once): substrings to the block should not be
@@ -5,6 +15,13 @@ Thu Jul 16 22:58:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* string.c (str_substr): needed to transfer taint.
+Thu Jul 16 16:15:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (xmalloc): object allocation count added to GC trigger.
+
+ * eval.c (thread_save_context): avoid marking uninitialized stack
+ in thread_mark. GC may be triggered by REALLOC_N().
+
Wed Jul 15 15:11:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* experimental release 1.1b9_31.
diff --git a/MANIFEST b/MANIFEST
index 9a9507627e..28f0c786ae 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -134,6 +134,7 @@ lib/tkmenubar.rb
lib/tkpalette.rb
lib/tkscrollbox.rb
lib/tktext.rb
+lib/tkvirtevent.rb
lib/tracer.rb
lib/weakref.rb
missing/alloca.c
diff --git a/eval.c b/eval.c
index 80f6ffddd7..7c8264598a 100644
--- a/eval.c
+++ b/eval.c
@@ -5434,12 +5434,6 @@ thread_mark(th)
struct BLOCK *block;
gc_mark(th->result);
- if (th->stk_ptr) {
- gc_mark_locations(th->stk_ptr, th->stk_ptr+th->stk_len);
-#if defined(THINK_C) || defined(__human68k__)
- gc_mark_locations(th->stk_ptr+2, th->stk_ptr+th->stk_len+2);
-#endif
- }
gc_mark(th->thread);
if (th->join) gc_mark(th->join->thread);
@@ -5450,6 +5444,13 @@ thread_mark(th)
gc_mark(th->last_match);
/* mark data in copied stack */
+ if (th->stk_len == 0) return; /* stack not active, no need to mark. */
+ if (th->stk_ptr) {
+ gc_mark_locations(th->stk_ptr, th->stk_ptr+th->stk_len);
+#if defined(THINK_C) || defined(__human68k__)
+ gc_mark_locations(th->stk_ptr+2, th->stk_ptr+th->stk_len+2);
+#endif
+ }
frame = th->frame;
while (frame && frame != top_frame) {
frame = ADJ(frame);
@@ -5504,14 +5505,16 @@ thread_save_context(th)
{
VALUE v;
- th->stk_len = stack_length();
+ int len = stack_length();
+ th->stk_len = 0;
th->stk_pos = (gc_stack_start<(VALUE*)&v)?gc_stack_start
- :gc_stack_start - th->stk_len;
- if (th->stk_len > th->stk_max) {
- th->stk_max = th->stk_len;
- REALLOC_N(th->stk_ptr, VALUE, th->stk_max);
+ :gc_stack_start - len;
+ if (len > th->stk_max) {
+ REALLOC_N(th->stk_ptr, VALUE, len);
+ th->stk_max = len;
}
- FLUSH_REGISTER_WINDOWS;
+ th->stk_len = len;
+ FLUSH_REGISTER_WINDOWS;
MEMCPY(th->stk_ptr, th->stk_pos, VALUE, th->stk_len);
th->frame = the_frame;
diff --git a/gc.c b/gc.c
index e6b001fca1..934b00ec80 100644
--- a/gc.c
+++ b/gc.c
@@ -42,8 +42,10 @@ static void run_final();
#define GC_MALLOC_LIMIT 200000
#endif
#endif
+#define GC_NEWOBJ_LIMIT 1000
static unsigned long malloc_memories = 0;
+static unsigned long alloc_objects = 0;
void *
xmalloc(size)
@@ -56,7 +58,7 @@ xmalloc(size)
}
if (size == 0) size = 1;
malloc_memories += size;
- if (malloc_memories > GC_MALLOC_LIMIT) {
+ if (malloc_memories > GC_MALLOC_LIMIT && alloc_objects > GC_NEWOBJ_LIMIT) {
gc_gc();
}
mem = malloc(size);
@@ -94,9 +96,6 @@ xrealloc(ptr, size)
}
if (!ptr) return xmalloc(size);
malloc_memories += size;
- if (malloc_memories > GC_MALLOC_LIMIT) {
- gc_gc();
- }
mem = realloc(ptr, size);
if (!mem) {
gc_gc();
@@ -253,6 +252,7 @@ rb_newobj()
retry:
obj = (VALUE)freelist;
freelist = freelist->as.free.next;
+ alloc_objects++;
return obj;
}
if (dont_gc) add_heap();
@@ -621,6 +621,7 @@ gc_sweep()
freed += n;
freelist = nfreelist;
}
+ alloc_objects = 0;
if (freed < FREE_MIN) {
add_heap();
}
diff --git a/lib/tk.rb b/lib/tk.rb
index 87a5cf19cf..dc52675d59 100644
--- a/lib/tk.rb
+++ b/lib/tk.rb
@@ -260,7 +260,18 @@ module TkComm
end
def tk_event_sequence(context)
- context = context.join("><") if context.kind_of? Array
+ if context.kind_of? TkVirtualEvent
+ context = context.path
+ end
+ if context.kind_of? Array
+ context = context.collect{|ev|
+ if context.kind_of? TkVirtualEvent
+ ev.path
+ else
+ ev
+ end
+ }.join("><")
+ end
if /,/ =~ context
context = context.split(/\s*,\s*/).join("><")
else
@@ -303,7 +314,7 @@ module TkComm
_bind_append tagOrClass, context, cmd, args
end
- def bindinfo(tagOrClass, context=nil)
+ def _bindinfo(tagOrClass, context=nil)
if context
(tk_call('bind', tagOrClass,
"<#{tk_event_sequence(context)}>")).collect{|cmdline|
@@ -320,6 +331,10 @@ module TkComm
end
end
+ def bindinfo(tagOrClass, context=nil)
+ _bindinfo tagOrClass, context
+ end
+
def pack(*args)
TkPack.configure *args
end
@@ -414,10 +429,32 @@ module TkCore
TclTkLib.mainloop
end
+ def event_generate(window, context, keys=nil)
+ window = window.path if window.kind_of? TkObject
+ if keys
+ tk_call('event', 'generate', window,
+ "<#{tk_event_sequence(context)}>", *hash_kv(keys))
+ else
+ tk_call('event', 'generate', window, "<#{tk_event_sequence(context)}>")
+ end
+ end
+
def messageBox(keys)
tk_call 'tk_messageBox', *hash_kv(keys)
end
+ def getOpenFile(keys)
+ tk_call 'tk_getOpenFile', *hash_kv(keys)
+ end
+
+ def getSaveFile(keys)
+ tk_call 'tk_getSaveFile', *hash_kv(keys)
+ end
+
+ def chooseColor(keys)
+ tk_call 'tk_chooseColor', *hash_kv(keys)
+ end
+
def tk_call(*args)
print args.join(" "), "\n" if $DEBUG
args.filter {|x|_get_eval_string(x)}
@@ -629,8 +666,8 @@ class TkVariable
if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1"
raise
else
- Hash(*tk_tcl2ruby(INTERP._eval(format('global %s; array get %s',
- @id, @id))))
+ Hash[*tk_tcl2ruby(INTERP._eval(format('global %s; array get %s',
+ @id, @id)))]
end
end
end
@@ -1528,6 +1565,19 @@ class TkObject<TkKernel
_bind_append path, context, cmd, args
end
+ def bindinfo(context=nil)
+ _bindinfo path, context
+ end
+
+ def event_generate(context, keys=nil)
+ if keys
+ tk_call('event', 'generate', path,
+ "<#{tk_event_sequence(context)}>", *hash_kv(keys))
+ else
+ tk_call('event', 'generate', path, "<#{tk_event_sequence(context)}>")
+ end
+ end
+
def tk_trace_variable(v)
unless v.kind_of?(TkVariable)
fail ArgumentError, format("requires TkVariable given %s", v.type)
@@ -1557,7 +1607,7 @@ module TkClassBind
end
def bindinfo(context=nil)
- Tk.bind to_eval, context
+ Tk.bindinfo to_eval, context
end
end
@@ -1651,7 +1701,7 @@ class TkWindow<TkObject
when 'global'
tk_call 'grab', 'set', '-global', path
else
- val = tk_call('grab', arg[0], path)
+ val = tk_call('grab', args[0], path)
end
case args[0]
when 'current'
@@ -2137,3 +2187,4 @@ autoload :TkMenubar, 'tkmenubar'
autoload :TkAfter, 'tkafter'
autoload :TkPalette, 'tkpalette'
autoload :TkFont, 'tkfont'
+autoload :TkVirtualEvent, 'tkvirtevent'
diff --git a/lib/tkcanvas.rb b/lib/tkcanvas.rb
index 613e97af38..3beb2ff1dc 100644
--- a/lib/tkcanvas.rb
+++ b/lib/tkcanvas.rb
@@ -60,8 +60,11 @@ module TkTreatCItemFont
fobj = tagfontobj(tagOrId)
if ltn.kind_of? TkFont
conf = {}
- ltn.latin_configinfo.each{|key,val| conf[key] = val}
- if keys
+ ltn.latin_configinfo.each{|key,val| conf[key] = val if val != []}
+ if conf == {}
+ fobj.latin_replace(ltn)
+ fobj.latin_configure(keys) if keys
+ elsif keys
fobj.latin_configure(conf.update(keys))
else
fobj.latin_configure(conf)
@@ -76,8 +79,11 @@ module TkTreatCItemFont
fobj = tagfontobj(tagOrId)
if knj.kind_of? TkFont
conf = {}
- knj.kanji_configinfo.each{|key,val| conf[key] = val}
- if keys
+ knj.kanji_configinfo.each{|key,val| conf[key] = val if val != []}
+ if conf == {}
+ fobj.kanji_replace(knj)
+ fobj.kanji_configure(keys) if keys
+ elsif keys
fobj.kanji_configure(conf.update(keys))
else
fobj.kanji_configure(conf)
diff --git a/lib/tkdialog.rb b/lib/tkdialog.rb
index 011d431951..1133db6ae9 100644
--- a/lib/tkdialog.rb
+++ b/lib/tkdialog.rb
@@ -1,15 +1,84 @@
require "tk"
class TkDialog < TkWindow
+ extend Tk
+
# initialize tk_dialog
- def initialize
- super
+ def initialize(keys = nil)
+ super()
@var = TkVariable.new
id = @var.id
- INTERP._eval('eval {global '+id+';'+
+
+ @title = title
+
+ @message = message
+ @message_config = message_config
+
+ @bitmap = bitmap
+ @bitmap_config = message_config
+
+ @default_button = default_button
+
+ @buttons = buttons
+ @button_configs = proc{|num| button_configs num}
+
+ if keys.kind_of? Hash
+ @title = keys['title'] if keys['title']
+ @message = keys['message'] if keys['message']
+ @bitmap = keys['bitmap'] if keys['bitmap']
+ @default_button = keys['default'] if keys['default']
+ @buttons = keys['buttons'] if keys['buttons']
+
+ @command = keys['prev_command']
+
+ @message_config = keys['message_config'] if keys['message_config']
+ @bitmap_config = keys['bitmap_config'] if keys['bitmap_config']
+ @button_configs = keys['button_configs'] if keys['button_configs']
+ end
+
+ if @title.include? ?\s
+ @title = '{' + @title + '}'
+ end
+
+ @buttons = tk_split_list(@buttons) if @buttons.kind_of? String
+ @buttons = @buttons.collect{|s|
+ if s.kind_of? Array
+ s = s.join(' ')
+ end
+ if s.include? ?\s
+ '{' + s + '}'
+ else
+ s
+ end
+ }
+
+ config = ""
+ if @message_config.kind_of? Hash
+ config << format("%s.msg configure %s\n",
+ @path, hash_kv(@message_config).join(' '))
+ end
+ if @bitmap_config.kind_of? Hash
+ config << format("%s.msg configure %s\n",
+ @path, hash_kv(@bitmap_config).join(' '))
+ end
+ if @button_configs.kind_of? Proc
+ @buttons.each_index{|i|
+ if (c = @button_configs.call(i)).kind_of? Hash
+ config << format("%s.button%s configure %s\n",
+ @path, i, hash_kv(c).join(' '))
+ end
+ }
+ end
+ config = 'after idle {' + config + '};' if config != ""
+
+ if @command.kind_of? Proc
+ @command.call(self)
+ end
+
+ INTERP._eval('eval {global '+id+';'+config+
'set '+id+' [tk_dialog '+
- @path+" "+title+" \"#{message}\" "+bitmap+" "+
- String(default_button)+" "+buttons+']}')
+ @path+" "+@title+" {#{@message}} "+@bitmap+" "+
+ String(@default_button)+" "+@buttons.join(' ')+']}')
end
def value
return @var.value.to_i
@@ -25,14 +94,24 @@ class TkDialog < TkWindow
def message
return "MESSAGE"
end
+ def message_config
+ return nil
+ end
def bitmap
return "info"
end
+ def bitmap_config
+ return nil
+ end
def default_button
return 0
end
def buttons
- return "BUTTON1 BUTTON2"
+ #return "BUTTON1 BUTTON2"
+ return ["BUTTON1", "BUTTON2"]
+ end
+ def button_configs(num)
+ return nil
end
end
diff --git a/lib/tkfont.rb b/lib/tkfont.rb
index 0d926f00c8..86114c6b62 100644
--- a/lib/tkfont.rb
+++ b/lib/tkfont.rb
@@ -65,14 +65,27 @@ class TkFont
case (Tk::TK_VERSION)
when /^4\.*/
conf = tk_split_list(tk_call(*args))
- ltn = conf.assoc('font')[4]
- ltn = nil if ltn == []
- knj = conf.assoc('kanjifont')[4]
- knj = nil if knj == []
- TkFont.new(ltn, knj).call_font_configure(path, *args)
+ if font_inf = conf.assoc('-font')
+ ltn = font_inf[4]
+ ltn = nil if ltn == []
+ else
+ #ltn = nil
+ raise RuntimeError, "unknown option '-font'"
+ end
+ if font_inf = conf.assoc('-kanjifont')
+ knj = font_inf[4]
+ knj = nil if knj == []
+ else
+ knj = nil
+ end
+ TkFont.new(ltn, knj).call_font_configure(path, *(args + [{}]))
when /^8\.*/
- fnt = tk_split_list(tk_call(*(args + ['-font'])))[4]
+ conf = tk_split_list(tk_call(*args))
+ unless font_inf = conf.assoc('-font')
+ raise RuntimeError, "unknown option '-font'"
+ end
+ fnt = font_inf[4]
if fnt == []
TkFont.new(nil, nil).call_font_configure(path, *(args + [{}]))
else
@@ -443,6 +456,28 @@ class TkFont
end
end
+ def delete_core_tk4x
+ Tk_FontNameTBL[@id] = nil
+ Tk_FontUseTBL.delete_if{|key,value| value == self}
+ end
+
+ def delete_core_tk8x
+ begin
+ tk_call('font', 'delete', @latinfont)
+ rescue
+ end
+ begin
+ tk_call('font', 'delete', @kanjifont)
+ rescue
+ end
+ begin
+ tk_call('font', 'delete', @compoundfont)
+ rescue
+ end
+ Tk_FontNameTBL[@id] = nil
+ Tk_FontUseTBL.delete_if{|key,value| value == self}
+ end
+
def latin_replace_core_tk4x(ltn)
create_latinfont_tk4x(ltn)
@compoundfont[0] = [@latinfont] if JAPANIZED_TK
@@ -453,9 +488,17 @@ class TkFont
if w.include?(';')
win, tag = w.split(';')
winobj = tk_tcl2ruby(win)
- winobj.tagfont_configure(tag, {'font'=>@latinfont})
+# winobj.tagfont_configure(tag, {'font'=>@latinfont})
+ if winobj.kind_of? TkText
+ tk_call(win, 'tag', 'configure', tag, '-font', @latinfont)
+ elsif winobj.kind_of? TkCanvas
+ tk_call(win, 'itemconfigure', tag, '-font', @latinfont)
+ else
+ raise RuntimeError, "unknown widget type"
+ end
else
- tk_tcl2ruby(w).configure('font', @latinfont)
+# tk_tcl2ruby(w).font_configure('font'=>@latinfont)
+ tk_call(w, 'configure', '-font', @latinfont)
end
rescue
Tk_FontUseTBL[w] = nil
@@ -477,9 +520,17 @@ class TkFont
if w.include?(';')
win, tag = w.split(';')
winobj = tk_tcl2ruby(win)
- winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont})
+# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont})
+ if winobj.kind_of? TkText
+ tk_call(win, 'tag', 'configure', tag, '-kanjifont', @kanjifont)
+ elsif winobj.kind_of? TkCanvas
+ tk_call(win, 'itemconfigure', tag, '-kanjifont', @kanjifont)
+ else
+ raise RuntimeError, "unknown widget type"
+ end
else
- tk_tcl2ruby(w).configure('kanjifont', @kanjifont)
+# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont)
+ tk_call(w, 'configure', '-kanjifont', @kanjifont)
end
rescue
Tk_FontUseTBL[w] = nil
@@ -490,7 +541,10 @@ class TkFont
end
def latin_replace_core_tk8x(ltn)
- tk_call('font', 'delete', @latinfont)
+ begin
+ tk_call('font', 'delete', @latinfont)
+ rescue
+ end
create_latinfont(ltn)
self
end
@@ -498,7 +552,10 @@ class TkFont
def kanji_replace_core_tk80(knj)
return self unless JAPANIZED_TK
- tk_call('font', 'delete', @kanjifont)
+ begin
+ tk_call('font', 'delete', @kanjifont)
+ rescue
+ end
create_kanjifont(knj)
self
end
@@ -575,6 +632,7 @@ class TkFont
alias actual_core actual_core_tk4x
alias configure_core configure_core_tk4x
alias configinfo_core configinfo_core_tk4x
+ alias delete_core delete_core_tk4x
alias latin_replace_core latin_replace_core_tk4x
alias kanji_replace_core kanji_replace_core_tk4x
alias measure_core measure_core_tk4x
@@ -587,6 +645,7 @@ class TkFont
alias actual_core actual_core_tk8x
alias configure_core configure_core_tk8x
alias configinfo_core configinfo_core_tk8x
+ alias delete_core delete_core_tk8x
alias latin_replace_core latin_replace_core_tk8x
alias kanji_replace_core kanji_replace_core_tk80
alias measure_core measure_core_tk8x
@@ -599,6 +658,7 @@ class TkFont
alias actual_core actual_core_tk8x
alias configure_core configure_core_tk8x
alias configinfo_core configinfo_core_tk8x
+ alias delete_core delete_core_tk8x
alias latin_replace_core latin_replace_core_tk8x
alias kanji_replace_core kanji_replace_core_tk81
alias measure_core measure_core_tk8x
@@ -715,6 +775,10 @@ class TkFont
configinfo_core(@compoundfont, slot)
end
+ def delete
+ delete_core
+ end
+
def latin_configure(slot, value=None)
if JAPANIZED_TK
configure_core(@latinfont, slot, value)
diff --git a/lib/tktext.rb b/lib/tktext.rb
index 8ffc626046..e0b4f9641e 100644
--- a/lib/tktext.rb
+++ b/lib/tktext.rb
@@ -58,8 +58,11 @@ module TkTreatTextTagFont
fobj = tagfontobj(tag)
if ltn.kind_of? TkFont
conf = {}
- ltn.latin_configinfo.each{|key,val| conf[key] = val}
- if keys
+ ltn.latin_configinfo.each{|key,val| conf[key] = val if val != []}
+ if conf == {}
+ fobj.latin_replace(ltn)
+ fobj.latin_configure(keys) if keys
+ elsif keys
fobj.latin_configure(conf.update(keys))
else
fobj.latin_configure(conf)
@@ -74,8 +77,11 @@ module TkTreatTextTagFont
fobj = tagfontobj(tag)
if knj.kind_of? TkFont
conf = {}
- knj.kanji_configinfo.each{|key,val| conf[key] = val}
- if keys
+ knj.kanji_configinfo.each{|key,val| conf[key] = val if val != []}
+ if conf == {}
+ fobj.kanji_replace(knj)
+ fobj.kanji_configure(keys) if keys
+ elsif keys
fobj.kanji_configure(conf.update(keys))
else
fobj.kanji_configure(conf)
diff --git a/process.c b/process.c
index 9d01abe0a8..7f5c8fbdf8 100644
--- a/process.c
+++ b/process.c
@@ -324,12 +324,10 @@ proc_exec_n(argc, argv, progv)
int i;
if (progv) {
- Check_SafeStr(progv);
prog = RSTRING(progv)->ptr;
}
args = ALLOCA_N(char*, argc+1);
for (i=0; i<argc; i++) {
- Check_SafeStr(argv[i]);
args[i] = RSTRING(argv[i])->ptr;
}
args[i] = 0;
@@ -466,13 +464,16 @@ proc_spawn_n(argc, argv, prog)
}
static int
-proc_spawn(str)
- char *str;
+proc_spawn(sv)
+ VALUE sv;
{
- char *s = str, *t;
+ char *str;
+ char *s, *t;
char **argv, **a;
int state;
+ Check_SafeStr(sv);
+ str = s = RSTRING(sv)->ptr;
for (s = str; *s; s++) {
if (*s != ' ' && !ISALPHA(*s) && strchr("*?{}[]<>()~&|\\$;'`\"\n",*s)) {
char *shell = dln_find_exe("sh", 0);
@@ -500,6 +501,7 @@ f_exec(argc, argv)
VALUE *argv;
{
VALUE prog = 0;
+ int i;
if (TYPE(argv[0]) == T_ARRAY) {
if (RARRAY(argv[0])->len != 2) {
@@ -516,8 +518,13 @@ f_exec(argc, argv)
prog = RARRAY(argv[0])->ptr[0];
argv[0] = RARRAY(argv[0])->ptr[1];
}
+ if (prog) {
+ Check_SafeStr(prog);
+ }
+ for (i = 0; i < argc; i++) {
+ Check_SafeStr(argv[i]);
+ }
if (argc == 1 && prog == 0) {
- Check_SafeStr(argv[0]);
rb_proc_exec(RSTRING(argv[0])->ptr);
}
else {
@@ -671,17 +678,17 @@ f_system(argc, argv)
}
if (argc == 1 && prog == 0) {
- state = proc_spawn(RSTRING(argv[0])->ptr);
+ state = proc_spawn(argv[0]);
}
else {
state = proc_spawn_n(argc, argv, prog);
}
last_status = state == -1 ? INT2FIX(127) : INT2FIX(state);
-
return state == 0 ? TRUE : FALSE ;
#else
volatile VALUE prog = 0;
int pid;
+ int i;
fflush(stdin); /* is it really needed? */
fflush(stdout);
@@ -699,6 +706,12 @@ f_system(argc, argv)
argv[0] = RARRAY(argv[0])->ptr[1];
}
+ if (prog) {
+ Check_SafeStr(prog);
+ }
+ for (i = 0; i < argc; i++) {
+ Check_SafeStr(argv[i]);
+ }
retry:
switch (pid = vfork()) {
case 0:
diff --git a/range.c b/range.c
index 759dc8f0ab..e1d89e5a09 100644
--- a/range.c
+++ b/range.c
@@ -13,13 +13,14 @@
#include "ruby.h"
static VALUE cRange;
-static ID upto;
+static ID id_upto, id_cmp;
+static ID id_beg, id_end;
static VALUE
range_check(args)
VALUE *args;
{
- rb_funcall(args[0], rb_intern("<=>"), 1, args[1]);
+ rb_funcall(args[0], id_cmp, 1, args[1]);
return Qnil;
}
@@ -41,8 +42,8 @@ range_s_new(klass, first, last)
obj = obj_alloc(klass);
- rb_iv_set(obj, "first", first);
- rb_iv_set(obj, "last", last);
+ rb_ivar_set(obj, id_beg, first);
+ rb_ivar_set(obj, id_end, last);
obj_call_init(obj);
return obj;
@@ -61,8 +62,8 @@ range_eqq(rng, obj)
{
VALUE first, last;
- first = rb_iv_get(rng, "first");
- last = rb_iv_get(rng, "last");
+ first = rb_ivar_get(rng, id_beg);
+ last = rb_ivar_get(rng, id_end);
if (FIXNUM_P(first) && FIXNUM_P(obj) && FIXNUM_P(last)) {
if (FIX2INT(first) <= FIX2INT(obj) && FIX2INT(obj) <= FIX2INT(last)) {
@@ -88,7 +89,7 @@ static VALUE
range_upto(data)
struct upto_data *data;
{
- return rb_funcall(data->first, upto, 1, data->last);
+ return rb_funcall(data->first, id_upto, 1, data->last);
}
static VALUE
@@ -97,8 +98,8 @@ range_each(obj)
{
VALUE b, e;
- b = rb_iv_get(obj, "first");
- e = rb_iv_get(obj, "last");
+ b = rb_ivar_get(obj, id_beg);
+ e = rb_ivar_get(obj, id_end);
if (FIXNUM_P(b)) { /* fixnum is a special case(for performance) */
num_upto(b, e);
@@ -121,7 +122,7 @@ range_first(obj)
{
VALUE b;
- b = rb_iv_get(obj, "first");
+ b = rb_ivar_get(obj, id_beg);
return b;
}
@@ -131,7 +132,7 @@ range_last(obj)
{
VALUE e;
- e = rb_iv_get(obj, "last");
+ e = rb_ivar_get(obj, id_end);
return e;
}
@@ -144,8 +145,8 @@ range_beg_end(range, begp, endp)
if (!obj_is_kind_of(range, cRange)) return FALSE;
- first = rb_iv_get(range, "first"); *begp = NUM2INT(first);
- last = rb_iv_get(range, "last"); *endp = NUM2INT(last);
+ first = rb_ivar_get(range, id_beg); *begp = NUM2INT(first);
+ last = rb_ivar_get(range, id_end); *endp = NUM2INT(last);
return TRUE;
}
@@ -155,8 +156,8 @@ range_to_s(range)
{
VALUE str, str2;
- str = obj_as_string(rb_iv_get(range, "first"));
- str2 = obj_as_string(rb_iv_get(range, "last"));
+ str = obj_as_string(rb_ivar_get(range, id_beg));
+ str2 = obj_as_string(rb_ivar_get(range, id_end));
str_cat(str, "..", 2);
str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
@@ -169,8 +170,8 @@ range_inspect(range)
{
VALUE str, str2;
- str = rb_inspect(rb_iv_get(range, "first"));
- str2 = rb_inspect(rb_iv_get(range, "last"));
+ str = rb_inspect(rb_ivar_get(range, id_beg));
+ str2 = rb_inspect(rb_ivar_get(range, id_end));
str_cat(str, "..", 2);
str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
@@ -186,8 +187,8 @@ range_length(rng)
VALUE first, last;
VALUE size;
- first = rb_iv_get(rng, "first");
- last = rb_iv_get(rng, "last");
+ first = rb_ivar_get(rng, id_beg);
+ last = rb_ivar_get(rng, id_end);
if (RTEST(rb_funcall(first, '>', 1, last))) {
return INT2FIX(0);
@@ -217,5 +218,8 @@ Init_Range()
rb_define_method(cRange, "length", range_length, 0);
rb_define_method(cRange, "size", range_length, 0);
- upto = rb_intern("upto");
+ id_upto = rb_intern("upto");
+ id_cmp = rb_intern("<=>");
+ id_beg = rb_intern("first");
+ id_end = rb_intern("last");
}
diff --git a/version.h b/version.h
index 16b65cd994..2b437af4e9 100644
--- a/version.h
+++ b/version.h
@@ -1,2 +1,2 @@
-#define RUBY_VERSION "1.1b9_31"
-#define VERSION_DATE "98/07/15"
+#define RUBY_VERSION "1.1c0"
+#define VERSION_DATE "98/07/17"