diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-09-03 05:29:19 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-09-03 05:29:19 +0000 |
commit | 4365377d76020c5cacf03a35989f370d05f5780a (patch) | |
tree | 3351683d7f4a8991b411dee9dad61f856c42b5e0 /ruby.c | |
parent | 9f1e0829daa572708a0aeb3dddbd33d13cb15693 (diff) |
* io.c (rb_io_popen): accept integer flags as mode.
* file.c (rb_find_file_ext): extension table can be supplied from
outside. renamed.
* eval.c (rb_f_require): replace rb_find_file_noext by
rb_find_file_ext.
* eval.c (rb_provided): should also check feature without
extension.
* numeric.c (flo_to_s): do not rely on decimal point to be '.'
* parse.y (yylex): ternary ? can be followed by newline.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 74 |
1 files changed, 38 insertions, 36 deletions
@@ -6,7 +6,7 @@ $Date$ created at: Tue Aug 10 12:47:31 JST 1993 - Copyright (C) 1993-2000 Yukihiro Matsumoto + Copyright (C) 1993-2001 Yukihiro Matsumoto Copyright (C) 2000 Network Applied Communication Laboratory, Inc. Copyright (C) 2000 Information-technology Promotion Agency, Japan @@ -60,7 +60,7 @@ static VALUE do_split = Qfalse; static char *script; -static int origargc, origarglen; +static int origargc; static char **origargv; static void @@ -664,11 +664,6 @@ proc_options(argc, argv) } } - if (e_script) { - argc++, argv--; - argv[0] = script; - } - if (version) { ruby_show_version(); exit(0); @@ -687,7 +682,9 @@ proc_options(argc, argv) script = "-"; } else { - script = argv[0]; + if (!e_script) { + script = argv[0]; + } if (script[0] == '\0') { script = "-"; } @@ -879,24 +876,11 @@ set_arg0(val, id) { char *s; int i; - int len = origarglen; + static int len; if (origargv == 0) rb_raise(rb_eRuntimeError, "$0 not initialized"); s = rb_str2cstr(val, &i); -#ifndef __hpux - if (i >= len) { - memcpy(origargv[0], s, len); - origargv[0][len] = '\0'; - } - else { - memcpy(origargv[0], s, i); - s = origargv[0]+i; - *s++ = '\0'; - while (++i < len) - *s++ = ' '; - } - rb_progname = rb_tainted_str_new2(origargv[0]); -#else +#ifdef __hpux if (i >= PST_CLEN) { union pstun j; j.pst_command = s; @@ -909,8 +893,39 @@ set_arg0(val, id) j.pst_command = s; pstat(PSTAT_SETCMD, j, i, 0, 0); } +#elif defined(HAVE_SETPROCTITLE) + setproctitle("%.*s", i, s); rb_progname = rb_tainted_str_new(s, i); +#else + if (len == 0) { + char *s = origargv[0]; + int i; + + s += strlen(s); + /* See if all the arguments are contiguous in memory */ + for (i = 1; i < origargc; i++) { + if (origargv[i] == s + 1) + s += strlen(++s); /* this one is ok too */ + } + len = s - origargv[0]; + } + if (i >= len) { + i = len; + memcpy(origargv[0], s, i); + origargv[0][i] = '\0'; + } + else { + memcpy(origargv[0], s, i); + s = origargv[0]+i; + *s++ = '\0'; + while (++i < len) + *s++ = ' '; + for (i = 1; i < origargc; i++) + origargv[i] = 0; + } + rb_progname = rb_tainted_str_new2(origargv[0]); #endif + rb_progname = rb_tainted_str_new(s, i); } void @@ -1008,19 +1023,6 @@ ruby_process_options(argc, argv) char **argv; { origargc = argc; origargv = argv; -#ifndef __hpux - if (origarglen == 0) { - int i; - char *s = origargv[0]; - s += strlen(s); - /* See if all the arguments are contiguous in memory */ - for (i = 1; i < origargc; i++) { - if (origargv[i] == s + 1) - s += strlen(++s); /* this one is ok too */ - } - origarglen = s - origargv[0]; - } -#endif ruby_script(argv[0]); /* for the time being */ rb_argv0 = rb_progname; #if defined(USE_DLN_A_OUT) |