[macruby-changes] [685] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Oct 29 19:32:21 PDT 2008
Revision: 685
http://trac.macosforge.org/projects/ruby/changeset/685
Author: lsansonetti at apple.com
Date: 2008-10-29 19:32:21 -0700 (Wed, 29 Oct 2008)
Log Message:
-----------
move the cmdline arguments/options as autozone memory and connect the script name to it
Modified Paths:
--------------
MacRuby/trunk/array.c
MacRuby/trunk/ruby.c
Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c 2008-10-30 02:08:24 UTC (rev 684)
+++ MacRuby/trunk/array.c 2008-10-30 02:32:21 UTC (rev 685)
@@ -169,11 +169,12 @@
VALUE ary;
ary = rb_ary_new2(n);
- if (n > 0 && elts) {
+ if (n > 0 && elts != NULL) {
long i;
void **vals = (void **)alloca(n * sizeof(void *));
- for (i = 0; i < n; i++)
+ for (i = 0; i < n; i++) {
vals[i] = RB2OC(elts[i]);
+ }
CFArrayReplaceValues((CFMutableArrayRef)ary, CFRangeMake(0, 0), (const void **)vals, n);
}
Modified: MacRuby/trunk/ruby.c
===================================================================
--- MacRuby/trunk/ruby.c 2008-10-30 02:08:24 UTC (rev 684)
+++ MacRuby/trunk/ruby.c 2008-10-30 02:32:21 UTC (rev 685)
@@ -1122,8 +1122,8 @@
#if defined DOSISH || defined __CYGWIN__
translate_char(RSTRING_PTR(rb_progname), '\\', '/');
#endif
- opt->script_name = rb_str_new4(rb_progname);
- opt->script = RSTRING_BYTEPTR(opt->script_name);
+ GC_WB(&opt->script_name, rb_str_new4(rb_progname));
+ opt->script = RSTRING_PTR(opt->script_name);
ruby_set_argv(argc, argv);
process_sflag(opt);
@@ -1630,30 +1630,28 @@
void *
ruby_process_options(int argc, char **argv)
{
- struct cmdline_arguments args;
- struct cmdline_options opt;
+ struct cmdline_arguments *args;
+ struct cmdline_options *opt;
NODE *tree;
- MEMZERO(&opt, opt, 1);
+ args = (struct cmdline_arguments *)xmalloc(sizeof(struct cmdline_arguments));
+ opt = (struct cmdline_options *)xmalloc(sizeof(struct cmdline_options));
+
+ MEMZERO(opt, opt, 1);
ruby_script(argv[0]); /* for the time being */
rb_argv0 = rb_progname;
- args.argc = argc;
- args.argv = argv;
- args.opt = &opt;
-#if WITH_OBJC
- opt.src.enc.enc = src_encoding;
- opt.ext.enc.enc = NULL;
-#else
- opt.src.enc.index = src_encoding_index;
- opt.ext.enc.index = -1;
-#endif
+ args->argc = argc;
+ args->argv = argv;
+ args->opt = opt;
+ opt->src.enc.enc = src_encoding;
+ opt->ext.enc.enc = NULL;
tree = (NODE *)rb_vm_call_cfunc(rb_vm_top_self(),
- process_options, (VALUE)&args,
+ process_options, (VALUE)args,
0, rb_progname);
- rb_define_readonly_boolean("$-p", opt.do_print);
- rb_define_readonly_boolean("$-l", opt.do_line);
- rb_define_readonly_boolean("$-a", opt.do_split);
+ rb_define_readonly_boolean("$-p", opt->do_print);
+ rb_define_readonly_boolean("$-l", opt->do_line);
+ rb_define_readonly_boolean("$-a", opt->do_split);
return tree;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20081029/91f8947e/attachment.html>
More information about the macruby-changes
mailing list