Skip to content

Commit

Permalink
* eval.c (backtrace): should ignore line 0 frame.
Browse files Browse the repository at this point in the history
* sprintf.c (rb_f_sprintf): preceding ".." for negative
  hexadecimal numbers should not appear if prec (e.g. %.4) is
  specified.

* compar.c (cmp_eq,cmp_gt,cmp_ge,cmp_lt,cmp_le): "<=>" might
  return nil.  check using rb_cmpint().

* error.c (init_syserr): remove sys_nerr dependency.

* regex.c (re_match): avoid dereferencing if size == 0.


git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_6@3112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Dec 2, 2002
1 parent fcee965 commit 1dd1f3e
Show file tree
Hide file tree
Showing 13 changed files with 335 additions and 189 deletions.
21 changes: 21 additions & 0 deletions ChangeLog
@@ -1,3 +1,7 @@
Tue Dec 3 01:48:06 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (backtrace): should ignore line 0 frame.

Sun Dec 1 22:43:29 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>

* win32/win32.c (win32_stat): empty path is invalid, and return
Expand Down Expand Up @@ -37,10 +41,27 @@ Fri Nov 22 19:30:17 2002 Akinori MUSHA <knu@iDaemons.org>

* instruby.rb: Install batch files on Windows. [Submitted by usa]

Fri Nov 22 22:55:01 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* sprintf.c (rb_f_sprintf): preceding ".." for negative
hexadecimal numbers should not appear if prec (e.g. %.4) is
specified.

Thu Nov 21 20:56:35 2002 Minero Aoki <aamine@loveruby.net>

* lib/net/http.rb: should not overwrite Host: header.

Wed Nov 20 02:07:12 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* compar.c (cmp_eq,cmp_gt,cmp_ge,cmp_lt,cmp_le): "<=>" might
return nil. check using rb_cmpint().

* error.c (init_syserr): remove sys_nerr dependency.

Tue Nov 19 22:37:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* regex.c (re_match): avoid dereferencing if size == 0.

Tue Nov 19 05:16:23 2002 Akinori MUSHA <knu@iDaemons.org>

* instruby.rb: Do not install various working files under bin/.
Expand Down
1 change: 0 additions & 1 deletion MANIFEST
Expand Up @@ -222,7 +222,6 @@ missing/strchr.c
missing/strerror.c
missing/strftime.c
missing/strstr.c
missing/strtod.c
missing/strtol.c
missing/strtoul.c
missing/vsnprintf.c
Expand Down
29 changes: 12 additions & 17 deletions compar.c
Expand Up @@ -21,9 +21,9 @@ cmp_eq(a)
VALUE *a;
{
VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
int t = NUM2INT(c);

if (t == 0) return Qtrue;
if (NIL_P(c)) return Qfalse;
if (rb_cmpint(c) == 0) return Qtrue;
return Qfalse;
}

Expand Down Expand Up @@ -51,9 +51,9 @@ cmp_gt(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
int t = NUM2INT(c);

if (t > 0) return Qtrue;
if (NIL_P(c)) return Qfalse;
if (rb_cmpint(c) > 0) return Qtrue;
return Qfalse;
}

Expand All @@ -62,9 +62,9 @@ cmp_ge(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
int t = NUM2INT(c);

if (t >= 0) return Qtrue;
if (NIL_P(c)) return Qfalse;
if (rb_cmpint(c) >= 0) return Qtrue;
return Qfalse;
}

Expand All @@ -73,9 +73,9 @@ cmp_lt(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
int t = NUM2INT(c);

if (t < 0) return Qtrue;
if (NIL_P(c)) return Qfalse;
if (rb_cmpint(c) < 0) return Qtrue;
return Qfalse;
}

Expand All @@ -84,23 +84,18 @@ cmp_le(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
int t = NUM2INT(c);

if (t <= 0) return Qtrue;
if (NIL_P(c)) return Qfalse;
if (rb_cmpint(c) <= 0) return Qtrue;
return Qfalse;
}

static VALUE
cmp_between(x, min, max)
VALUE x, min, max;
{
VALUE c = rb_funcall(x, cmp, 1, min);
long t = NUM2LONG(c);
if (t < 0) return Qfalse;

c = rb_funcall(x, cmp, 1, max);
t = NUM2LONG(c);
if (t > 0) return Qfalse;
if (cmp_lt(x, min)) return Qfalse;
if (cmp_gt(x, max)) return Qfalse;
return Qtrue;
}

Expand Down
30 changes: 0 additions & 30 deletions configure.in
Expand Up @@ -402,36 +402,6 @@ fi
AC_FUNC_GETPGRP
AC_FUNC_SETPGRP

AC_CACHE_CHECK(for working strtod, rb_cv_func_strtod,
[AC_TRY_RUN([
double strtod ();
int
main()
{
{
/* Some versions of Linux strtod mis-parse strings with leading '+'. */
char *string = " +69";
char *term;
double value;
value = strtod(string, &term);
if (value != 69 || term != (string + 4))
exit(1);
}

{
/* Under Solaris 2.4, strtod returns the wrong value for the
terminating character under some conditions. */
char *string = "NaN";
char *term;
strtod(string, &term);
if (term != string && *(term - 1) == 0)
exit(1);
}
exit(0);
}
], rb_cv_func_strtod=yes, rb_cv_func_strtod=no, rb_cv_func_strtod=no)])
test $rb_cv_func_strtod = no && LIBOBJS="$LIBOBJS strtod.o"

AC_C_BIGENDIAN
AC_C_CONST
AC_C_CHAR_UNSIGNED
Expand Down
150 changes: 25 additions & 125 deletions error.c
Expand Up @@ -13,6 +13,7 @@
#include "ruby.h"
#include "env.h"
#include "version.h"
#include "st.h"

#include <stdio.h>
#ifdef HAVE_STDARG_PROTOTYPES
Expand Down Expand Up @@ -412,101 +413,34 @@ exc_set_backtrace(exc, bt)
return rb_iv_set(exc, "bt", check_backtrace(bt));
}

#ifdef __BEOS__
typedef struct {
VALUE *list;
int n;
} syserr_list_entry;

typedef struct {
int ix;
int n;
} syserr_index_entry;

static VALUE syserr_error;
static VALUE syserr_list_b_general[16+1];
static VALUE syserr_list_b_os0[2+1];
static VALUE syserr_list_b_os1[5+1];
static VALUE syserr_list_b_os2[2+1];
static VALUE syserr_list_b_os3[3+1];
static VALUE syserr_list_b_os4[1+1];
static VALUE syserr_list_b_app[15+1];
static VALUE syserr_list_b_interface[0+1];
static VALUE syserr_list_b_media[8+1];
static VALUE syserr_list_b_midi[0+1];
static VALUE syserr_list_b_storage[15+1];
static VALUE syserr_list_b_posix[38+1];
static VALUE syserr_list_b_mail[8+1];
static VALUE syserr_list_b_print[1+1];
static VALUE syserr_list_b_device[14+1];

# define SYSERR_LIST_B(n) {(n), sizeof(n)/sizeof(VALUE)}
static const syserr_list_entry syserr_list[] = {
SYSERR_LIST_B(syserr_list_b_general),
SYSERR_LIST_B(syserr_list_b_os0),
SYSERR_LIST_B(syserr_list_b_os1),
SYSERR_LIST_B(syserr_list_b_os2),
SYSERR_LIST_B(syserr_list_b_os3),
SYSERR_LIST_B(syserr_list_b_os4),
SYSERR_LIST_B(syserr_list_b_app),
SYSERR_LIST_B(syserr_list_b_interface),
SYSERR_LIST_B(syserr_list_b_media),
SYSERR_LIST_B(syserr_list_b_midi),
SYSERR_LIST_B(syserr_list_b_storage),
SYSERR_LIST_B(syserr_list_b_posix),
SYSERR_LIST_B(syserr_list_b_mail),
SYSERR_LIST_B(syserr_list_b_print),
SYSERR_LIST_B(syserr_list_b_device),
};
# undef SYSERR_LIST_B
static st_table *syserr_tbl;

static const syserr_index_entry syserr_index[]= {
{0, 1}, {1, 5}, {6, 1}, {7, 1}, {8, 1}, {9, 1}, {10, 1}, {11, 1},
{12, 1}, {13, 1}, {14, 1}, {0, 0},
};
#else
static VALUE *syserr_list;
#endif
static VALUE
set_syserr(n, name)
int n;
const char *name;
{
VALUE error;

#if !defined(NT) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(sys_nerr)
# if !defined(__APPLE__) || (__APPLE_CC__ < 1151)
extern int sys_nerr;
# endif
#endif
if (!st_lookup(syserr_tbl, n, &error)) {
error = rb_define_class_under(rb_mErrno, name, rb_eSystemCallError);;
rb_define_const(error, "Errno", INT2NUM(n));
st_add_direct(syserr_tbl, n, error);
}
return error;
}

static VALUE
set_syserr(i, name)
int i;
const char *name;
get_syserr(int n)
{
#ifdef __BEOS__
VALUE *list;
int ix, offset;
#endif
VALUE error = rb_define_class_under(rb_mErrno, name, rb_eSystemCallError);
rb_define_const(error, "Errno", INT2NUM(i));
#ifdef __BEOS__
if (i == B_ERROR) {
syserr_error = error;
rb_global_variable(&syserr_error);
return error;
}
i -= B_GENERAL_ERROR_BASE;
ix = (i >> 12) & 0xf;
offset = (i >> 8) & 0xf;
if (offset < syserr_index[ix].n) {
ix = syserr_index[ix].ix;
if ((i & 0xff) < syserr_list[ix + offset].n) {
list = syserr_list[ix + offset].list;
list[i & 0xff] = error;
rb_global_variable(&list[i & 0xff]);
}
}
#else
if (i <= sys_nerr) {
syserr_list[i] = error;
VALUE error;

if (!st_lookup(syserr_tbl, n, &error)) {
char name[6];

sprintf(name, "E%03d", n);
error = set_syserr(n, name);
}
#endif
return error;
}

Expand Down Expand Up @@ -672,26 +606,7 @@ rb_sys_fail(mesg)
}

errno = 0;
#ifdef __BEOS__
ee = get_syserr(n);
if (!ee) {
char name[6];

sprintf(name, "E%03d", n);
ee = set_syserr(n, name);
}
#else
if (n > sys_nerr || !syserr_list[n]) {
char name[6];

sprintf(name, "E%03d", n);
ee = set_syserr(n, name);
}
else {
ee = syserr_list[n];
}
#endif
ee = rb_exc_new2(ee, buf);
ee = rb_exc_new2(get_syserr(n), buf);
rb_iv_set(ee, "errno", INT2NUM(n));
rb_exc_raise(ee);
}
Expand All @@ -713,26 +628,11 @@ rb_error_frozen(what)
static void
init_syserr()
{
#ifdef __BEOS__
int i, ix, offset;
#endif
syserr_tbl = st_init_numtable();
rb_eSystemCallError = rb_define_class("SystemCallError", rb_eStandardError);
rb_define_method(rb_eSystemCallError, "errno", syserr_errno, 0);

rb_mErrno = rb_define_module("Errno");
#ifdef __BEOS__
for (i = 0; syserr_index[i].n != 0; i++) {
ix = syserr_index[i].ix;
for (offset = 0; offset < syserr_index[i].n; offset++) {
MEMZERO(syserr_list[ix + offset].list, VALUE, syserr_list[ix + offset].n);
}
}
set_syserr(B_ERROR, "ERROR");
#else
syserr_list = ALLOC_N(VALUE, sys_nerr+1);
MEMZERO(syserr_list, VALUE, sys_nerr+1);
#endif

#ifdef EPERM
set_syserr(EPERM, "EPERM");
#endif
Expand Down
2 changes: 1 addition & 1 deletion eval.c
Expand Up @@ -4787,7 +4787,7 @@ backtrace(lev)
}
}
}
while (frame && frame->file) {
while (frame && frame->file && frame->line) {
if (frame->prev && frame->prev->last_func) {
snprintf(buf, BUFSIZ, "%s:%d:in `%s'",
frame->file, frame->line,
Expand Down
2 changes: 1 addition & 1 deletion gc.c
Expand Up @@ -922,7 +922,7 @@ obj_free(obj)
break;
#ifdef C_ALLOCA
case NODE_ALLOCA:
RUBY_CRITICAL(free(RANY(obj)->as.node.u1.value));
RUBY_CRITICAL(free(RANY(obj)->as.node.u1.node));
break;
#endif
}
Expand Down
1 change: 1 addition & 0 deletions numeric.c
Expand Up @@ -1559,6 +1559,7 @@ Init_Numeric()

rb_define_method(rb_cNumeric, "+@", num_uplus, 0);
rb_define_method(rb_cNumeric, "-@", num_uminus, 0);
rb_define_method(rb_cNumeric, "==", num_equal, 1);
rb_define_method(rb_cNumeric, "===", num_equal, 1);
rb_define_method(rb_cNumeric, "eql?", num_eql, 1);
rb_define_method(rb_cNumeric, "divmod", num_divmod, 1);
Expand Down
8 changes: 1 addition & 7 deletions parse.y
Expand Up @@ -2928,10 +2928,6 @@ arg_ambiguous()
rb_warning("ambiguous first argument; make sure");
}

#if !defined(strtod) && !defined(HAVE_STDLIB_H)
double strtod ();
#endif

static int
yylex()
{
Expand Down Expand Up @@ -4111,9 +4107,7 @@ str_extend(list, term, paren)
c = nextc();
}
}
else {
tokadd(c);
}
tokadd(c);
break;
}
/* out of brace */
Expand Down

0 comments on commit 1dd1f3e

Please sign in to comment.