diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-09-03 05:37:42 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-09-03 05:37:42 +0000 |
commit | 0f35b58a2fbae58a20979de77a3a642c42f41899 (patch) | |
tree | cab4099dba0fde8650c94226a1f9ce94549561c9 | |
parent | c9d1be6327640aa5bc01f8c6c8846e4e3fb31337 (diff) | |
download | bundler-0f35b58a2fbae58a20979de77a3a642c42f41899.tar.gz |
* ruby.c (proc_options): should not alter origargv[].
* ruby.c (set_arg0): long strings for $0 dumped core.
* ruby.c (set_arg0): use setprogtitle() if it's available.
* 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 '.'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 31 | ||||
-rw-r--r-- | ToDo | 1 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | eval.c | 26 | ||||
-rw-r--r-- | file.c | 11 | ||||
-rw-r--r-- | io.c | 14 | ||||
-rw-r--r-- | numeric.c | 37 | ||||
-rw-r--r-- | pack.c | 66 | ||||
-rw-r--r-- | regex.c | 2 | ||||
-rw-r--r-- | ruby.c | 79 | ||||
-rw-r--r-- | sprintf.c | 19 | ||||
-rw-r--r-- | version.h | 4 |
12 files changed, 134 insertions, 158 deletions
@@ -3,6 +3,12 @@ Mon Sep 3 14:11:17 2001 Akinori MUSHA <knu@iDaemons.org> * error.c: unbreak the build on *BSD with gcc 3.0.1 by removing the conflicting declaration of sys_nerr for *BSD. +Sat Sep 1 18:50:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * ruby.c (proc_options): should not alter origargv[]. + + * ruby.c (set_arg0): long strings for $0 dumped core. + Sat Sep 1 09:50:54 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> * ruby.c (set_arg0): prevent SEGV when val is longer than the @@ -11,6 +17,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 14:05:28 2001 Brian F. Feldman <green@FreeBSD.org> + + * ruby.c (set_arg0): use setprogtitle() if it's available. + +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. @@ -87,6 +87,7 @@ Standard Libraries * move NameError under StandardError. * library to load per-user profile seeking .ruby_profile or ruby.ini file. * warning framework +* marshal should not depend on sprintf/strtod (works bad for locale). Extension Libraries diff --git a/configure.in b/configure.in index 2fd670dfe3..f895e435bf 100644 --- a/configure.in +++ b/configure.in @@ -295,7 +295,7 @@ AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\ isinf isnan finite hypot) AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd chroot\ truncate chsize times utimes fcntl lockf lstat symlink readlink\ - setitimer setruid seteuid setreuid setresuid \ + setitimer setruid seteuid setreuid setresuid setproctitle\ setrgid setegid setregid setresgid pause lchown lchmod\ getpgrp setpgrp getpgid setpgid getgroups getpriority getrlimit\ dlopen sigprocmask sigaction _setjmp setsid telldir seekdir fchmod) @@ -5393,6 +5393,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; @@ -5400,8 +5408,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); @@ -5444,14 +5452,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); @@ -5481,7 +5489,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; @@ -2284,22 +2284,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); @@ -1339,7 +1339,7 @@ rb_io_binmode_flags(mode) return flags; } -int +static int rb_io_mode_binmode(mode) const char *mode; { @@ -1378,10 +1378,9 @@ rb_io_mode_binmode(mode) } static char* -rb_io_modestr(flags) +rb_io_binmode_mode(flags, mode) int flags; { - static char mode[4]; char *p = mode; switch (flags & (O_RDONLY|O_WRONLY|O_RDWR)) { @@ -1517,11 +1516,12 @@ rb_file_sysopen_internal(io, fname, flags, mode) OpenFile *fptr; int fd; char *m; + char mbuf[4]; MakeOpenFile(io, fptr); fd = rb_sysopen(fname, flags, mode); - m = rb_io_modestr(flags); + m = rb_io_binmode_mode(flags, mbuf); fptr->mode = rb_io_binmode_flags(flags); fptr->f = rb_fdopen(fd, m); fptr->path = strdup(fname); @@ -1760,10 +1760,14 @@ rb_io_popen(str, argc, argv, klass) { char *mode; VALUE pname, pmode, port; + char mbuf[4]; if (rb_scan_args(argc, argv, "11", &pname, &pmode) == 1) { mode = "r"; } + else if (FIXNUM_P(pmode)) { + mode = rb_io_binmode_mode(FIX2INT(pmode), mbuf); + } else { mode = StringValuePtr(pmode); } @@ -1817,7 +1821,7 @@ rb_open_file(argc, argv, io) if (FIXNUM_P(vmode) || !NIL_P(perm)) { flags = FIXNUM_P(vmode) ? NUM2INT(vmode) : rb_io_mode_binmode(StringValuePtr(vmode)); fmode = NIL_P(perm) ? 0666 : NUM2INT(perm); - + file = rb_file_sysopen_internal(io, path, flags, fmode); } else { @@ -214,30 +214,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); } @@ -656,16 +656,7 @@ pack_pack(ary, fmt) float f; from = NEXTFROM; - switch (TYPE(from)) { - case T_FLOAT: - f = RFLOAT(from)->value; - break; - case T_STRING: - f = strtod(RSTRING(from)->ptr, 0); - default: - f = (float)NUM2INT(from); - break; - } + f = RFLOAT(rb_Float(from))->value; rb_str_buf_cat(res, (char*)&f, sizeof(float)); } break; @@ -676,16 +667,7 @@ pack_pack(ary, fmt) FLOAT_CONVWITH(ftmp); from = NEXTFROM; - switch (TYPE(from)) { - case T_FLOAT: - f = RFLOAT(from)->value; - break; - case T_STRING: - f = strtod(RSTRING(from)->ptr, 0); - default: - f = (float)NUM2INT(from); - break; - } + f = RFLOAT(rb_Float(from))->value; f = HTOVF(f,ftmp); rb_str_buf_cat(res, (char*)&f, sizeof(float)); } @@ -697,16 +679,7 @@ pack_pack(ary, fmt) DOUBLE_CONVWITH(dtmp); from = NEXTFROM; - switch (TYPE(from)) { - case T_FLOAT: - d = RFLOAT(from)->value; - break; - case T_STRING: - d = strtod(RSTRING(from)->ptr, 0); - default: - d = (double)NUM2INT(from); - break; - } + d = RFLOAT(rb_Float(from))->value; d = HTOVD(d,dtmp); rb_str_buf_cat(res, (char*)&d, sizeof(double)); } @@ -718,16 +691,7 @@ pack_pack(ary, fmt) double d; from = NEXTFROM; - switch (TYPE(from)) { - case T_FLOAT: - d = RFLOAT(from)->value; - break; - case T_STRING: - d = strtod(RSTRING(from)->ptr, 0); - default: - d = (double)NUM2INT(from); - break; - } + d = RFLOAT(rb_Float(from))->value; rb_str_buf_cat(res, (char*)&d, sizeof(double)); } break; @@ -738,16 +702,7 @@ pack_pack(ary, fmt) FLOAT_CONVWITH(ftmp); from = NEXTFROM; - switch (TYPE(from)) { - case T_FLOAT: - f = RFLOAT(from)->value; - break; - case T_STRING: - f = strtod(RSTRING(from)->ptr, 0); - default: - f = (float)NUM2INT(from); - break; - } + f = RFLOAT(rb_Float(from))->value; f = HTONF(f,ftmp); rb_str_buf_cat(res, (char*)&f, sizeof(float)); } @@ -759,16 +714,7 @@ pack_pack(ary, fmt) DOUBLE_CONVWITH(dtmp); from = NEXTFROM; - switch (TYPE(from)) { - case T_FLOAT: - d = RFLOAT(from)->value; - break; - case T_STRING: - d = strtod(RSTRING(from)->ptr, 0); - default: - d = (double)NUM2INT(from); - break; - } + d = RFLOAT(rb_Float(from))->value; d = HTOND(d,dtmp); rb_str_buf_cat(res, (char*)&d, sizeof(double)); } @@ -4177,7 +4177,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; } @@ -60,7 +60,7 @@ static VALUE do_split = Qfalse; static char *script; -static int origargc, origarglen; +static int origargc; static char **origargv; static void @@ -667,11 +667,6 @@ proc_options(argc, argv) } } - if (e_script) { - argc++, argv--; - argv[0] = script; - } - if (version) { ruby_show_version(); exit(0); @@ -690,7 +685,9 @@ proc_options(argc, argv) script = "-"; } else { - script = argv[0]; + if (!e_script) { + script = argv[0]; + } if (script[0] == '\0') { script = "-"; } @@ -882,26 +879,13 @@ set_arg0(val, id) { char *s; int i; - int len = origarglen; + static int len; if (origargv == 0) rb_raise(rb_eRuntimeError, "$0 not initialized"); StringValue(val); s = RSTRING(val)->ptr; i = RSTRING(val)->len; -#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; @@ -916,7 +900,44 @@ set_arg0(val, id) pstat(PSTAT_SETCMD, j, i, 0, 0); } rb_progname = rb_tainted_str_new(s, i); +#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++; + s += strlen(s); /* this one is ok too */ + } + else { + break; + } + } + 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; + } #endif + rb_progname = rb_tainted_str_new2(origargv[0]); } void @@ -1014,19 +1035,7 @@ 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) @@ -589,24 +589,7 @@ rb_f_sprintf(argc, argv) int i, need = 6; char fbuf[32]; - switch (TYPE(val)) { - case T_FIXNUM: - fval = (double)FIX2LONG(val); - break; - case T_FLOAT: - fval = RFLOAT(val)->value; - break; - case T_BIGNUM: - fval = rb_big2dbl(val); - break; - case T_STRING: - fval = strtod(RSTRING(val)->ptr, 0); - break; - default: - fval = NUM2DBL(val); - break; - } - + fval = RFLOAT(rb_Float(val))->value; fmt_setup(fbuf, *p, flags, width, prec); need = 0; if (*p != 'e' && *p != 'E') { @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.7.1" -#define RUBY_RELEASE_DATE "2001-09-01" +#define RUBY_RELEASE_DATE "2001-09-03" #define RUBY_VERSION_CODE 171 -#define RUBY_RELEASE_CODE 20010901 +#define RUBY_RELEASE_CODE 20010903 |