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 | |
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
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | eval.c | 26 | ||||
-rw-r--r-- | file.c | 11 | ||||
-rw-r--r-- | io.c | 3 | ||||
-rw-r--r-- | numeric.c | 36 | ||||
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | regex.c | 2 | ||||
-rw-r--r-- | ruby.c | 74 | ||||
-rw-r--r-- | version.h | 4 |
9 files changed, 108 insertions, 75 deletions
@@ -11,6 +11,31 @@ Sat Sep 1 09:50:54 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> * ruby.c (ruby_process_options): initialize total length of original arguments at first. +Sat Sep 1 03:49:11 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * io.c (rb_io_popen): accept integer flags as mode. + +Fri Aug 31 19:46:05 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> + + * 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. + +Fri Aug 31 19:26:55 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> + + * eval.c (rb_provided): should also check feature without + extension. + +Fri Aug 31 13:06:33 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * numeric.c (flo_to_s): do not rely on decimal point to be '.' + +Wed Aug 29 02:18:53 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * parse.y (yylex): ternary ? can be followed by newline. + Mon Aug 27 07:32:23 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> * dir.c (rb_glob_helper): merge from 1.7: traversed files twice @@ -5311,6 +5311,14 @@ rb_feature_p(feature, wait) return Qtrue; } +static const char *const loadable_ext[] = { + ".rb", DLEXT, +#ifdef DLEXT2 + DLEXT2, +#endif + 0 +}; + int rb_provided(feature) const char *feature; @@ -5318,8 +5326,8 @@ rb_provided(feature) VALUE f = rb_str_new2(feature); if (strrchr(feature, '.') == 0) { - if (rb_find_file_noext(&f) == 0) { - return Qfalse; + if (rb_find_file_ext(&f, loadable_ext) == 0) { + return rb_feature_p(feature, Qfalse); } } return rb_feature_p(RSTRING(f)->ptr, Qfalse); @@ -5362,14 +5370,14 @@ rb_f_require(obj, fname) } else if (strcmp(".so", ext) == 0 || strcmp(".o", ext) == 0) { fname = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr); - feature = tmp = rb_str_dup(fname); - rb_str_cat2(tmp, DLEXT); - tmp = rb_find_file(tmp); - if (tmp) { - fname = tmp; +#ifdef DLEXT2 + tmp = fname; + if (rb_find_file_ext(&tmp, loadable_ext+1)) { + feature = tmp; + fname = rb_find_file(tmp); goto load_dyna; } -#ifdef DLEXT2 +#else feature = tmp = rb_str_dup(fname); rb_str_cat2(tmp, DLEXT); tmp = rb_find_file(tmp); @@ -5399,7 +5407,7 @@ rb_f_require(obj, fname) #endif } tmp = fname; - switch (rb_find_file_noext(&tmp)) { + switch (rb_find_file_ext(&tmp, loadable_ext)) { case 0: break; @@ -2154,22 +2154,15 @@ file_load_ok(file) extern VALUE rb_load_path; int -rb_find_file_noext(filep) +rb_find_file_ext(filep, ext) VALUE *filep; + char **ext; { char *path, *e, *found; char *f = RSTRING(*filep)->ptr; VALUE fname; int i, j; - static char *ext[] = { - ".rb", DLEXT, -#ifdef DLEXT2 - DLEXT2, -#endif - 0 - }; - if (f[0] == '~') { fname = *filep; fname = rb_file_s_expand_path(1, &fname); @@ -1680,6 +1680,9 @@ rb_io_popen(str, argc, argv, klass) if (rb_scan_args(argc, argv, "11", &pname, &pmode) == 1) { mode = "r"; } + else if (FIXNUM_P(pmode)) { + mode = rb_io_flags_mode(NUM2INT(pmode)); + } else { mode = STR2CSTR(pmode); } @@ -208,29 +208,31 @@ flo_to_s(flt) VALUE flt; { char buf[24]; - char *s; + char *fmt = "%.10g"; double value = RFLOAT(flt)->value; + double d1, d2; if (isinf(value)) return rb_str_new2(value < 0 ? "-Infinity" : "Infinity"); else if(isnan(value)) return rb_str_new2("NaN"); - else - sprintf(buf, "%-.10g", value); - if (s = strchr(buf, ' ')) *s = '\0'; - s = buf; if (s[0] == '-') s++; - if (strchr(s, '.') == 0) { - int len = strlen(buf); - char *ind = strchr(buf, 'e'); - - if (ind) { - memmove(ind+2, ind, len-(ind-buf)+1); - ind[0] = '.'; - ind[1] = '0'; - } else { - strcat(buf, ".0"); - } - } + + if (value < 1.0e-3) { + d1 = value; + while (d1 < 1.0) d1 *= 10.0; + d1 = modf(d1, &d2); + if (d1 == 0) fmt = "%.1e"; + } + else if (value >= 1.0e10) { + d1 = value; + while (d1 > 10.0) d1 /= 10.0; + d1 = modf(d1, &d2); + if (d1 == 0) fmt = "%.1e"; + } + else if ((d1 = modf(value, &d2)) == 0) { + fmt = "%.1f"; + } + sprintf(buf, fmt, value); return rb_str_new2(buf); } @@ -2994,7 +2994,7 @@ yylex() return '?'; } c = nextc(); - if (c == -1 || c == 10) { + if (c == -1) { rb_compile_error("incomplete character syntax"); return 0; } @@ -4176,7 +4176,7 @@ re_match(bufp, string_arg, size, pos, regs) if (IS_A_LETTER(d)) break; else goto fail; } - if (AT_STRINGS_BEG(d)) { + if (AT_STRINGS_END(d)) { if (PREV_IS_A_LETTER(d)) break; else goto fail; } @@ -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) @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.6.4" -#define RUBY_RELEASE_DATE "2001-09-01" +#define RUBY_RELEASE_DATE "2001-09-03" #define RUBY_VERSION_CODE 164 -#define RUBY_RELEASE_CODE 20010901 +#define RUBY_RELEASE_CODE 20010903 |