Skip to content

Commit

Permalink
* io.c (rb_io_popen): accept integer flags as mode.
Browse files Browse the repository at this point in the history
* 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_6@1720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Sep 3, 2001
1 parent 559e0ff commit 02e8f66
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 75 deletions.
25 changes: 25 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 17 additions & 9 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -5311,15 +5311,23 @@ 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;
{
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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down
11 changes: 2 additions & 9 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
36 changes: 19 additions & 17 deletions numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -2994,7 +2994,7 @@ yylex()
return '?';
}
c = nextc();
if (c == -1 || c == 10) {
if (c == -1) {
rb_compile_error("incomplete character syntax");
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
74 changes: 38 additions & 36 deletions ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -60,7 +60,7 @@ static VALUE do_split = Qfalse;

static char *script;

static int origargc, origarglen;
static int origargc;
static char **origargv;

static void
Expand Down Expand Up @@ -664,11 +664,6 @@ proc_options(argc, argv)
}
}

if (e_script) {
argc++, argv--;
argv[0] = script;
}

if (version) {
ruby_show_version();
exit(0);
Expand All @@ -687,7 +682,9 @@ proc_options(argc, argv)
script = "-";
}
else {
script = argv[0];
if (!e_script) {
script = argv[0];
}
if (script[0] == '\0') {
script = "-";
}
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 02e8f66

Please sign in to comment.