From: E S Date: 2005-01-21T02:57:48+09:00 Subject: Re: trouble with ruby_options() on win32 and ruby 1.8.2 David Craine wrote: > > On Jan 18, 2005, at 5:18 PM, E S wrote: > >>> L�hett�j�: David Craine >>> Aihe: trouble with ruby_options() on win32 and ruby 1.8.2 >>> >>> I'm trying to embed ruby into a win32 application; however, when >>> calling the ruby_options() method my process simply hangs. I am trying >>> to use ruby_options() to pass the -C argument to ruby to set the >>> current directory. My code looks like this: >>> >>> UINT launchRuby() >>> { >>> char *argv[3] = >>> { >>> "ruby", >>> "-C..\\Release", >>> "test.rb" >>> } >>> >>> ruby_init(); >>> ruby_options(3, argv); >>> ruby_run(); >>> } >>> >>> My program compiles and links properly; however, when I run it it just >>> hangs right after the ruby_options() call (I've integrated some >>> diagnostic code to determine this). This same technique worked fine on >>> OSX, so I'm wondering if there is some issue with the Windows platform. >> >> >> See http://www.ruby-doc.org/doxygen/1.8.1/eval_8c-source.html#l01345 >> and http://www.ruby-doc.org/doxygen/1.8.1/ruby_8c-source.html#l01104 >> and http://www.ruby-doc.org/doxygen/1.8.1/ruby_8c-source.html#l00425 >> >> It looks like the first argument may have to be the script name. >> >> E > > Actually, the source code indicates that the first argument should be > the ruby program name, i.e., "ruby". This is how it worked on OSX and > should be the same on win32. thanks for the idea, though. Hm, strange. I did just quickly read it, maybe it's simply confusingly expressed. You may well be right, it's just superfluous in that case :) 01103 void 01104 ruby_process_options(argc, argv) 01105 int argc; 01106 char **argv; 01107 { 01108 origargc = argc; origargv = argv; 01109 01110 ruby_script(argv[0]); // <== This here 01111 rb_argv0 = rb_progname; 01112 #if defined(USE_DLN_A_OUT) 01113 dln_argv0 = argv[0]; 01114 #endif 01115 proc_options(argc, argv); 01116 01117 if (do_check && ruby_nerrs == 0) { 01118 printf("Syntax OK\n"); 01119 exit(0); 01120 } 01121 if (do_print) { 01122 rb_parser_append_print(); 01123 } 01124 if (do_loop) { 01125 rb_parser_while_loop(do_line, do_split); 01126 } 01127 } 01128 ... 01002 void 01003 ruby_script(name) 01004 char *name; 01005 { 01006 if (name) { 01007 rb_progname = rb_tainted_str_new2(name); 01008 ruby_sourcefile = rb_source_filename(name); 01009 } 01010 }