summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-04-18 08:46:18 (GMT)
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-04-18 08:46:18 (GMT)
commite63a9901412d465cd90143d658fda8fa938d7f8c (patch)
tree12cf55d22b7b78304e8a692c44217e9531a31c02
parent8a7b08bb787c2d8d531e0b84974fb2a4bec30d87 (diff)
* re.c (rb_reg_expr_str): should treat backslash specially in
escaping. * io.c: complete off_t handling; missing argument for fptr_finalize(); polished rb_scan_args call. * dir.c: wrap multi-statment macro by do { } while (0) * eval.c, numeric,c, sprintf.c, util.c: ditto. * bignum.c (rb_big_eq): check `y == x' if y is neither Fixnum, Bignum, nor Float. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog21
-rw-r--r--array.c2
-rw-r--r--bignum.c7
-rw-r--r--class.c4
-rw-r--r--compar.c2
-rw-r--r--dir.c6
-rw-r--r--enum.c10
-rw-r--r--eval.c44
-rw-r--r--file.c8
-rw-r--r--inits.c2
-rw-r--r--intern.h24
-rw-r--r--io.c23
-rw-r--r--main.c2
-rw-r--r--marshal.c2
-rw-r--r--math.c21
-rw-r--r--prec.c2
-rw-r--r--random.c12
-rw-r--r--re.c8
-rw-r--r--ruby.h8
-rw-r--r--sprintf.c15
-rw-r--r--string.c8
-rw-r--r--time.c7
-rw-r--r--util.c6
23 files changed, 146 insertions, 98 deletions
diff --git a/ChangeLog b/ChangeLog
index 76a2713..5d9c00b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,10 +7,31 @@ Wed Apr 17 23:55:34 2002 Akinori MUSHA <knu@iDaemons.org>
* ext/Setup*, ext/bigfloat/*: Back out the import of BigFloat in
favor of its forthcoming successor, BigDecimal.
+Wed Apr 17 16:53:33 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_expr_str): should treat backslash specially in
+ escaping.
+
+Wed Apr 17 08:16:41 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+
+ * io.c: complete off_t handling; missing argument for
+ fptr_finalize(); polished rb_scan_args call.
+
+Wed Apr 17 00:01:59 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+
+ * dir.c: wrap multi-statment macro by do { } while (0)
+
+ * eval.c, numeric,c, sprintf.c, util.c: ditto.
+
Tue Apr 16 08:59:50 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* eval.c (assign): convert mrhs to mvalue.
+Mon Apr 15 18:12:57 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_eq): check `y == x' if y is neither Fixnum,
+ Bignum, nor Float.
+
Mon Apr 15 09:27:31 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_unpack): should treat 'U' in character unit, not in
diff --git a/array.c b/array.c
index 18f08ce..ff5ded0 100644
--- a/array.c
+++ b/array.c
@@ -173,7 +173,7 @@ rb_ary_new3(n, va_alist)
VALUE
rb_ary_new4(n, elts)
long n;
- VALUE *elts;
+ const VALUE *elts;
{
VALUE ary;
diff --git a/bignum.c b/bignum.c
index 873d359..b4e9148 100644
--- a/bignum.c
+++ b/bignum.c
@@ -861,9 +861,12 @@ rb_big_eq(x, y)
case T_BIGNUM:
break;
case T_FLOAT:
- return (rb_big2dbl(x) == RFLOAT(y)->value)?Qtrue:Qfalse;
+ if (rb_big2dbl(x) == RFLOAT(y)->value)
+ return Qtrue;
+ else
+ return Qfalse;
default:
- return Qfalse;
+ return rb_equal(y, x);
}
if (RBIGNUM(x)->sign != RBIGNUM(y)->sign) return Qfalse;
if (RBIGNUM(x)->len != RBIGNUM(y)->len) return Qfalse;
diff --git a/class.c b/class.c
index 45dcf41..4856535 100644
--- a/class.c
+++ b/class.c
@@ -772,11 +772,11 @@ rb_define_attr(klass, name, read, write)
int
#ifdef HAVE_STDARG_PROTOTYPES
-rb_scan_args(int argc, VALUE *argv, const char *fmt, ...)
+rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
#else
rb_scan_args(argc, argv, fmt, va_alist)
int argc;
- VALUE *argv;
+ const VALUE *argv;
const char *fmt;
va_dcl
#endif
diff --git a/compar.c b/compar.c
index 86494e2..371459f 100644
--- a/compar.c
+++ b/compar.c
@@ -6,7 +6,7 @@
$Date$
created at: Thu Aug 26 14:39:48 JST 1993
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/
diff --git a/dir.c b/dir.c
index 6814e4a..8ade547 100644
--- a/dir.c
+++ b/dir.c
@@ -6,7 +6,7 @@
$Date$
created at: Wed Jan 5 09:51:01 JST 1994
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
@@ -313,10 +313,10 @@ dir_closed()
rb_raise(rb_eIOError, "closed directory");
}
-#define GetDIR(obj, dirp) {\
+#define GetDIR(obj, dirp) do {\
Data_Get_Struct(obj, struct dir_data, dirp);\
if (dirp->dir == NULL) dir_closed();\
-}
+} while (0)
static VALUE
dir_path(dir)
diff --git a/enum.c b/enum.c
index 301dd95..4b5ec82 100644
--- a/enum.c
+++ b/enum.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Oct 1 15:15:19 JST 1993
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/
@@ -172,12 +172,12 @@ static VALUE
enum_collect(obj)
VALUE obj;
{
- VALUE tmp;
+ VALUE ary;
- tmp = rb_ary_new();
- rb_iterate(rb_each, obj, rb_block_given_p() ? collect_i : collect_all, tmp);
+ ary = rb_ary_new();
+ rb_iterate(rb_each, obj, rb_block_given_p() ? collect_i : collect_all, ary);
- return tmp;
+ return ary;
}
static VALUE
diff --git a/eval.c b/eval.c
index 4bee61c..484671d 100644
--- a/eval.c
+++ b/eval.c
@@ -518,12 +518,13 @@ static struct SCOPE *top_scope;
_frame.argc = 0; \
_frame.argv = 0; \
_frame.flags = FRAME_ALLOCA; \
- ruby_frame = &_frame; \
+ ruby_frame = &_frame
#define POP_FRAME() \
ruby_sourcefile = _frame.file; \
ruby_sourceline = _frame.line; \
- ruby_frame = _frame.prev; }
+ ruby_frame = _frame.prev; \
+}
struct BLOCKTAG {
struct RBasic super;
@@ -581,7 +582,7 @@ new_blktag()
_block.flags = BLOCK_D_SCOPE; \
_block.dyna_vars = ruby_dyna_vars; \
_block.wrapper = ruby_wrapper; \
- ruby_block = &_block;
+ ruby_block = &_block
#define POP_BLOCK() \
if (_block.tag->flags & (BLOCK_DYNAMIC)) \
@@ -595,7 +596,7 @@ struct RVarmap *ruby_dyna_vars;
#define PUSH_VARS() { \
struct RVarmap * volatile _old; \
_old = ruby_dyna_vars; \
- ruby_dyna_vars = 0;
+ ruby_dyna_vars = 0
#define POP_VARS() \
if (_old && (ruby_scope->flags & SCOPE_DONT_RECYCLE)) {\
@@ -750,7 +751,7 @@ static struct iter *ruby_iter;
struct iter _iter; \
_iter.prev = ruby_iter; \
_iter.iter = (i); \
- ruby_iter = &_iter; \
+ ruby_iter = &_iter
#define POP_ITER() \
ruby_iter = _iter.prev; \
@@ -777,7 +778,7 @@ static struct tag *prot_tag;
_tag.scope = ruby_scope; \
_tag.tag = ptag; \
_tag.dst = 0; \
- prot_tag = &_tag;
+ prot_tag = &_tag
#define PROT_NONE 0
#define PROT_FUNC -1
@@ -785,11 +786,11 @@ static struct tag *prot_tag;
#define EXEC_TAG() setjmp(prot_tag->buf)
-#define JUMP_TAG(st) { \
+#define JUMP_TAG(st) do { \
ruby_frame = prot_tag->frame; \
ruby_iter = prot_tag->iter; \
longjmp(prot_tag->buf,(st)); \
-}
+} while (0)
#define POP_TAG() \
if (_tag.prev) \
@@ -815,9 +816,10 @@ VALUE ruby_class;
static VALUE ruby_wrapper; /* security wrapper */
#define PUSH_CLASS() { \
- VALUE _class = ruby_class; \
+ VALUE _class = ruby_class
-#define POP_CLASS() ruby_class = _class; }
+#define POP_CLASS() ruby_class = _class; \
+}
static NODE *ruby_cref = 0;
static NODE *top_cref;
@@ -834,7 +836,7 @@ static NODE *top_cref;
_scope->flags = 0; \
_old = ruby_scope; \
ruby_scope = _scope; \
- scope_vmode = SCOPE_PUBLIC;
+ scope_vmode = SCOPE_PUBLIC
typedef struct thread * rb_thread_t;
static rb_thread_t curr_thread = 0;
@@ -863,7 +865,7 @@ static VALUE eval _((VALUE,VALUE,VALUE,char*,int));
static NODE *compile _((VALUE, char*, int));
static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int));
-static VALUE rb_call _((VALUE,VALUE,ID,int,VALUE*,int));
+static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int));
static VALUE module_setup _((VALUE,NODE*));
static VALUE massign _((VALUE,NODE*,VALUE,int));
@@ -1150,7 +1152,7 @@ ruby_options(argc, argv)
{
int state;
- PUSH_TAG(PROT_NONE)
+ PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
ruby_process_options(argc, argv);
}
@@ -1714,7 +1716,7 @@ copy_node_scope(node, rval)
# define TMP_ALLOC(n) ALLOCA_N(VALUE,n)
#endif
-#define SETUP_ARGS(anode) {\
+#define SETUP_ARGS(anode) do {\
NODE *n = anode;\
if (!n) {\
argc = 0;\
@@ -1752,14 +1754,14 @@ copy_node_scope(node, rval)
ruby_sourcefile = file;\
ruby_sourceline = line;\
}\
-}
+} while (0)
#define BEGIN_CALLARGS {\
struct BLOCK *tmp_block = ruby_block;\
if (ruby_iter->iter == ITER_PRE) {\
ruby_block = ruby_block->prev;\
}\
- PUSH_ITER(ITER_NOT);
+ PUSH_ITER(ITER_NOT)
#define END_CALLARGS \
ruby_block = tmp_block;\
@@ -4651,7 +4653,7 @@ rb_call(klass, recv, mid, argc, argv, scope)
VALUE klass, recv;
ID mid;
int argc; /* OK */
- VALUE *argv; /* OK */
+ const VALUE *argv; /* OK */
int scope;
{
NODE *body; /* OK */
@@ -4780,7 +4782,7 @@ rb_funcall2(recv, mid, argc, argv)
VALUE recv;
ID mid;
int argc;
- VALUE *argv;
+ const VALUE *argv;
{
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
}
@@ -4790,7 +4792,7 @@ rb_funcall3(recv, mid, argc, argv)
VALUE recv;
ID mid;
int argc;
- VALUE *argv;
+ const VALUE *argv;
{
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0);
}
@@ -4798,7 +4800,7 @@ rb_funcall3(recv, mid, argc, argv)
VALUE
rb_call_super(argc, argv)
int argc;
- VALUE *argv;
+ const VALUE *argv;
{
VALUE result;
@@ -8372,7 +8374,7 @@ rb_thread_abort_exc_set(thread, val)
th->priority = 0;\
th->gid = 1;\
th->locals = 0;\
-} while(0)
+} while (0)
static rb_thread_t
rb_thread_alloc(klass)
diff --git a/file.c b/file.c
index ca036ea..3a7f5e3 100644
--- a/file.c
+++ b/file.c
@@ -1678,7 +1678,7 @@ rb_file_s_truncate(klass, path, len)
SafeStringValue(path);
#ifdef HAVE_TRUNCATE
- if (truncate(RSTRING(path)->ptr, NUM2INT(len)) < 0)
+ if (truncate(RSTRING(path)->ptr, NUM2OFFT(len)) < 0)
rb_sys_fail(RSTRING(path)->ptr);
#else
# ifdef HAVE_CHSIZE
@@ -1694,7 +1694,7 @@ rb_file_s_truncate(klass, path, len)
rb_sys_fail(RSTRING(path)->ptr);
}
# endif
- if (chsize(tmpfd, NUM2INT(len)) < 0) {
+ if (chsize(tmpfd, NUM2OFFT(len)) < 0) {
close(tmpfd);
rb_sys_fail(RSTRING(path)->ptr);
}
@@ -1719,11 +1719,11 @@ rb_file_truncate(obj, len)
rb_raise(rb_eIOError, "not opened for writing");
}
#ifdef HAVE_TRUNCATE
- if (ftruncate(fileno(fptr->f), NUM2INT(len)) < 0)
+ if (ftruncate(fileno(fptr->f), NUM2OFFT(len)) < 0)
rb_sys_fail(fptr->path);
#else
# ifdef HAVE_CHSIZE
- if (chsize(fileno(fptr->f), NUM2INT(len)) < 0)
+ if (chsize(fileno(fptr->f), NUM2OFFT(len)) < 0)
rb_sys_fail(fptr->path);
# else
rb_notimplement();
diff --git a/inits.c b/inits.c
index d3fffb6..dd7af5a 100644
--- a/inits.c
+++ b/inits.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Dec 28 16:01:58 JST 1993
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/
diff --git a/intern.h b/intern.h
index 0eed0dd..2ca00ac 100644
--- a/intern.h
+++ b/intern.h
@@ -23,7 +23,7 @@ VALUE rb_assoc_new _((VALUE, VALUE));
VALUE rb_ary_new _((void));
VALUE rb_ary_new2 _((long));
VALUE rb_ary_new3 __((long,...));
-VALUE rb_ary_new4 _((long, VALUE *));
+VALUE rb_ary_new4 _((long, const VALUE *));
VALUE rb_ary_freeze _((VALUE));
VALUE rb_ary_aref _((int, VALUE*, VALUE));
void rb_ary_store _((VALUE, long, VALUE));
@@ -204,7 +204,7 @@ VALUE rb_find_file _((VALUE));
/* gc.c */
int ruby_stack_check _((void));
int ruby_stack_length _((VALUE**));
-char *rb_source_filename _((const char *));
+char *rb_source_filename _((const char*));
void rb_gc_mark_locations _((VALUE*, VALUE*));
void rb_mark_tbl _((struct st_table*));
void rb_mark_hash _((struct st_table*));
@@ -224,7 +224,7 @@ VALUE rb_hash_aref _((VALUE, VALUE));
VALUE rb_hash_aset _((VALUE, VALUE, VALUE));
VALUE rb_hash_delete_if _((VALUE));
VALUE rb_hash_delete _((VALUE,VALUE));
-int rb_path_check _((char *));
+int rb_path_check _((char*));
int rb_env_path_tainted _((void));
/* io.c */
EXTERN VALUE rb_fs;
@@ -278,7 +278,7 @@ VALUE rb_Integer _((VALUE));
VALUE rb_Float _((VALUE));
VALUE rb_String _((VALUE));
VALUE rb_Array _((VALUE));
-double rb_cstr_to_dbl _((const char *, int));
+double rb_cstr_to_dbl _((const char*, int));
double rb_str_to_dbl _((VALUE, int));
/* parse.y */
EXTERN int ruby_sourceline;
@@ -354,14 +354,14 @@ VALUE rb_str_new _((const char*, long));
VALUE rb_str_new2 _((const char*));
VALUE rb_str_new3 _((VALUE));
VALUE rb_str_new4 _((VALUE));
-VALUE rb_str_new5 _((VALUE, const char *, long));
+VALUE rb_str_new5 _((VALUE, const char*, long));
VALUE rb_tainted_str_new _((const char*, long));
VALUE rb_tainted_str_new2 _((const char*));
VALUE rb_str_buf_new _((long));
VALUE rb_str_buf_new2 _((const char*));
VALUE rb_str_buf_append _((VALUE, VALUE));
-VALUE rb_str_buf_cat _((VALUE, const char *, long));
-VALUE rb_str_buf_cat2 _((VALUE, const char *));
+VALUE rb_str_buf_cat _((VALUE, const char*, long));
+VALUE rb_str_buf_cat2 _((VALUE, const char*));
VALUE rb_obj_as_string _((VALUE));
VALUE rb_str_dup _((VALUE));
VALUE rb_str_dup_frozen _((VALUE));
@@ -415,8 +415,8 @@ void rb_free_generic_ivar _((VALUE));
VALUE rb_ivar_get _((VALUE, ID));
VALUE rb_ivar_set _((VALUE, ID, VALUE));
VALUE rb_ivar_defined _((VALUE, ID));
-VALUE rb_iv_set _((VALUE, const char *, VALUE));
-VALUE rb_iv_get _((VALUE, const char *));
+VALUE rb_iv_set _((VALUE, const char*, VALUE));
+VALUE rb_iv_get _((VALUE, const char*));
VALUE rb_obj_instance_variables _((VALUE));
VALUE rb_obj_remove_instance_variable _((VALUE, VALUE));
void *rb_mod_const_at _((VALUE, void*));
@@ -436,9 +436,9 @@ void rb_autoload_load _((ID));
VALUE rb_cvar_defined _((VALUE, ID));
void rb_cvar_set _((VALUE, ID, VALUE, int));
VALUE rb_cvar_get _((VALUE, ID));
-void rb_cv_set _((VALUE, const char *, VALUE));
-VALUE rb_cv_get _((VALUE, const char *));
-void rb_define_class_variable _((VALUE, const char *, VALUE));
+void rb_cv_set _((VALUE, const char*, VALUE));
+VALUE rb_cv_get _((VALUE, const char*));
+void rb_define_class_variable _((VALUE, const char*, VALUE));
VALUE rb_mod_class_variables _((VALUE));
VALUE rb_mod_remove_cvar _((VALUE, VALUE));
/* version.c */
diff --git a/io.c b/io.c
index bc67247..97f950a 100644
--- a/io.c
+++ b/io.c
@@ -364,7 +364,7 @@ rb_io_seek(io, offset, whence)
int whence;
{
OpenFile *fptr;
- long pos;
+ off_t pos;
GetOpenFile(io, fptr);
pos = fseeko(fptr->f, NUM2OFFT(offset), whence);
@@ -381,11 +381,11 @@ rb_io_seek_m(argc, argv, io)
VALUE io;
{
VALUE offset, ptrname;
- int whence;
+ int whence = SEEK_SET;
- rb_scan_args(argc, argv, "11", &offset, &ptrname);
- if (argc == 1) whence = SEEK_SET;
- else whence = NUM2INT(ptrname);
+ if (rb_scan_args(argc, argv, "11", &offset, &ptrname) == 2) {
+ whence = NUM2INT(ptrname);
+ }
return rb_io_seek(io, offset, whence);
}
@@ -395,14 +395,14 @@ rb_io_set_pos(io, offset)
VALUE io, offset;
{
OpenFile *fptr;
- long pos;
+ off_t pos;
GetOpenFile(io, fptr);
pos = fseeko(fptr->f, NUM2OFFT(offset), SEEK_SET);
if (pos != 0) rb_sys_fail(fptr->path);
clearerr(fptr->f);
- return INT2NUM(pos);
+ return OFFT2NUM(pos);
}
static VALUE
@@ -1161,6 +1161,7 @@ rb_io_isatty(io)
static void
fptr_finalize(fptr, fin)
OpenFile *fptr;
+ int fin;
{
int n1 = 0, n2 = 0, e = 0, f1, f2 = -1;
@@ -1318,13 +1319,13 @@ rb_io_sysseek(argc, argv, io)
VALUE io;
{
VALUE offset, ptrname;
- int whence;
+ int whence = SEEK_SET;
OpenFile *fptr;
off_t pos;
- rb_scan_args(argc, argv, "11", &offset, &ptrname);
- if (argc == 1) whence = SEEK_SET;
- else whence = NUM2INT(ptrname);
+ if (rb_scan_args(argc, argv, "11", &offset, &ptrname) == 2) {
+ whence = NUM2INT(ptrname);
+ }
GetOpenFile(io, fptr);
if ((fptr->mode & FMODE_READABLE) && READ_DATA_PENDING(fptr->f)) {
diff --git a/main.c b/main.c
index ef1b495..3c6ccf4 100644
--- a/main.c
+++ b/main.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Aug 19 13:19:58 JST 1994
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/
diff --git a/marshal.c b/marshal.c
index 0aefac1..b15af3b 100644
--- a/marshal.c
+++ b/marshal.c
@@ -6,7 +6,7 @@
$Date$
created at: Thu Apr 27 16:30:01 JST 1995
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/
diff --git a/math.c b/math.c
index d4a24d2..153c5b7 100644
--- a/math.c
+++ b/math.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Jan 25 14:12:56 JST 1994
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/
@@ -16,16 +16,17 @@
VALUE rb_mMath;
#define Need_Float(x) (x) = rb_Float(x)
-#define Need_Float2(x,y) {\
+#define Need_Float2(x,y) do {\
Need_Float(x);\
Need_Float(y);\
-}
+} while (0)
static VALUE
math_atan2(obj, y, x)
VALUE obj, x, y;
{
Need_Float2(y, x);
+
return rb_float_new(atan2(RFLOAT(y)->value, RFLOAT(x)->value));
}
@@ -85,6 +86,7 @@ math_atan(obj, x)
VALUE obj, x;
{
Need_Float(x);
+
return rb_float_new(atan(RFLOAT(x)->value));
}
@@ -102,6 +104,7 @@ math_cosh(obj, x)
VALUE obj, x;
{
Need_Float(x);
+
return rb_float_new(cosh(RFLOAT(x)->value));
}
@@ -119,6 +122,7 @@ math_sinh(obj, x)
VALUE obj, x;
{
Need_Float(x);
+
return rb_float_new(sinh(RFLOAT(x)->value));
}
@@ -136,6 +140,7 @@ math_tanh(obj, x)
VALUE obj, x;
{
Need_Float(x);
+
return rb_float_new(tanh(RFLOAT(x)->value));
}
@@ -144,6 +149,7 @@ math_acosh(obj, x)
VALUE obj, x;
{
Need_Float(x);
+
return rb_float_new(acosh(RFLOAT(x)->value));
}
@@ -152,6 +158,7 @@ math_asinh(obj, x)
VALUE obj, x;
{
Need_Float(x);
+
return rb_float_new(asinh(RFLOAT(x)->value));
}
@@ -160,6 +167,7 @@ math_atanh(obj, x)
VALUE obj, x;
{
Need_Float(x);
+
return rb_float_new(atanh(RFLOAT(x)->value));
}
@@ -168,6 +176,7 @@ math_exp(obj, x)
VALUE obj, x;
{
Need_Float(x);
+
return rb_float_new(exp(RFLOAT(x)->value));
}
@@ -181,6 +190,7 @@ math_log(obj, x)
VALUE obj, x;
{
Need_Float(x);
+
return rb_float_new(log(RFLOAT(x)->value));
}
@@ -189,6 +199,7 @@ math_log10(obj, x)
VALUE obj, x;
{
Need_Float(x);
+
return rb_float_new(log10(RFLOAT(x)->value));
}
@@ -210,8 +221,8 @@ math_frexp(obj, x)
int exp;
Need_Float(x);
+
d = frexp(RFLOAT(x)->value, &exp);
-
return rb_assoc_new(rb_float_new(d), INT2NUM(exp));
}
@@ -222,6 +233,7 @@ math_ldexp(obj, x, n)
double d;
Need_Float(x);
+
return rb_float_new(d = ldexp(RFLOAT(x)->value, NUM2INT(n)));
}
@@ -230,6 +242,7 @@ math_hypot(obj, x, y)
VALUE obj, x, y;
{
Need_Float2(x, y);
+
return rb_float_new(hypot(RFLOAT(x)->value, RFLOAT(y)->value));
}
diff --git a/prec.c b/prec.c
index 436b4d5..aad80d9 100644
--- a/prec.c
+++ b/prec.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Jan 26 02:40:41 2000
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/
diff --git a/random.c b/random.c
index ba568cd..e383016 100644
--- a/random.c
+++ b/random.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Dec 24 16:39:21 JST 1993
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/
@@ -77,7 +77,7 @@ void srand48 _((long));
#endif /* not HAVE_DRAND48 */
static int first = 1;
-#ifdef HAVE_RANDOM
+#ifdef HAVE_INITSTATE
static char state[256];
#endif
@@ -88,7 +88,7 @@ rand_init(seed)
int old;
static unsigned int saved_seed;
-#if defined HAVE_INITSTATE
+#ifdef HAVE_INITSTATE
if (first == 1) {
initstate(1, state, sizeof state);
}
@@ -111,11 +111,11 @@ rb_f_srand(argc, argv, obj)
VALUE *argv;
VALUE obj;
{
- VALUE a;
+ VALUE sd;
unsigned int seed, old;
rb_secure(4);
- if (rb_scan_args(argc, argv, "01", &a) == 0) {
+ if (rb_scan_args(argc, argv, "01", &sd) == 0) {
static int n = 0;
struct timeval tv;
@@ -123,7 +123,7 @@ rb_f_srand(argc, argv, obj)
seed = tv.tv_sec ^ tv.tv_usec ^ getpid() ^ n++;
}
else {
- seed = NUM2UINT(a);
+ seed = NUM2UINT(sd);
}
old = rand_init(seed);
diff --git a/re.c b/re.c
index 41364a1..2488ccb 100644
--- a/re.c
+++ b/re.c
@@ -238,7 +238,13 @@ rb_reg_expr_str(str, s, len)
else {
p = s;
while (p<pend) {
- if (*p == '/') {
+ if (*p == '\\') {
+ rb_str_buf_cat(str, p++, 1);
+ if (p<pend) {
+ rb_str_buf_cat(str, p, 1);
+ }
+ }
+ else if (*p == '/') {
char c = '\\';
rb_str_buf_cat(str, &c, 1);
rb_str_buf_cat(str, p, 1);
diff --git a/ruby.h b/ruby.h
index 7bdc827..9408964 100644
--- a/ruby.h
+++ b/ruby.h
@@ -497,10 +497,10 @@ VALUE rb_eval_string _((const char*));
VALUE rb_eval_string_protect _((const char*, int*));
VALUE rb_eval_string_wrap _((const char*, int*));
VALUE rb_funcall __((VALUE, ID, int, ...));
-VALUE rb_funcall2 _((VALUE, ID, int, VALUE*));
-VALUE rb_funcall3 _((VALUE, ID, int, VALUE*));
-int rb_scan_args __((int, VALUE*, const char*, ...));
-VALUE rb_call_super _((int, VALUE*));
+VALUE rb_funcall2 _((VALUE, ID, int, const VALUE*));
+VALUE rb_funcall3 _((VALUE, ID, int, const VALUE*));
+int rb_scan_args __((int, const VALUE*, const char*, ...));
+VALUE rb_call_super _((int, const VALUE*));
VALUE rb_gv_set _((const char*, VALUE));
VALUE rb_gv_get _((const char*));
diff --git a/sprintf.c b/sprintf.c
index e9742f3..5f0aeba 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Oct 15 10:39:26 JST 1993
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
@@ -62,23 +62,22 @@ remove_sign_bits(str, base)
#define FWIDTH 32
#define FPREC 64
-#define CHECK(l) {\
+#define CHECK(l) \
while (blen + (l) >= bsiz) {\
REALLOC_N(buf, char, bsiz*2);\
bsiz*=2;\
- }\
-}
+ }
-#define PUSH(s, l) { \
+#define PUSH(s, l) do { \
CHECK(l);\
memcpy(&buf[blen], s, l);\
blen += (l);\
-}
+} while (0)
#define GETARG() \
((nextarg >= argc) ? (rb_raise(rb_eArgError, "too few argument."), 0) : argv[nextarg++])
-#define GETASTER(val) { \
+#define GETASTER(val) do { \
t = p++; \
n = 0; \
for (; p < end && ISDIGIT(*p); p++) { \
@@ -98,7 +97,7 @@ remove_sign_bits(str, base)
p = t; \
} \
val = NUM2INT(tmp); \
-}
+} while (0)
VALUE
rb_f_sprintf(argc, argv)
diff --git a/string.c b/string.c
index 72a1783..4eb2bb9 100644
--- a/string.c
+++ b/string.c
@@ -58,6 +58,10 @@ str_new(klass, ptr, len)
{
VALUE str = rb_obj_alloc(klass);
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative string size (or size too big)");
+ }
+
RSTRING(str)->len = len;
RSTRING(str)->aux.capa = len;
RSTRING(str)->ptr = ALLOC_N(char,len+1);
@@ -460,8 +464,8 @@ void
rb_str_modify(str)
VALUE str;
{
- if (str_independent(str)) return;
- str_make_independent(str);
+ if (!str_independent(str))
+ str_make_independent(str);
}
VALUE
diff --git a/time.c b/time.c
index 4ac38bc..9bfaba1 100644
--- a/time.c
+++ b/time.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Dec 28 14:31:59 JST 1993
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/
@@ -40,9 +40,8 @@ struct time_object {
int tm_got;
};
-#define GetTimeval(obj, tobj) {\
- Data_Get_Struct(obj, struct time_object, tobj);\
-}
+#define GetTimeval(obj, tobj) \
+ Data_Get_Struct(obj, struct time_object, tobj)
static VALUE
time_s_alloc(klass)
diff --git a/util.c b/util.c
index feb7004..d43ee63 100644
--- a/util.c
+++ b/util.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Mar 10 17:22:34 JST 1995
- Copyright (C) 1993-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/
@@ -464,8 +464,8 @@ static void mmrot3_(a, b, c, mmarg)
/*****************************************************/
typedef struct { char *LL, *RR; } stack_node; /* Stack structure for L,l,R,r */
-#define PUSH(ll,rr) {top->LL = (ll); top->RR = (rr); ++top;} /* Push L,l,R,r */
-#define POP(ll,rr) {--top; ll = top->LL; rr = top->RR;} /* Pop L,l,R,r */
+#define PUSH(ll,rr) do { top->LL = (ll); top->RR = (rr); ++top; } while (0) /* Push L,l,R,r */
+#define POP(ll,rr) do { --top; ll = top->LL; rr = top->RR; } while (0) /* Pop L,l,R,r */
#define med3(a,b,c) ((*cmp)(a,b)<0 ? \
((*cmp)(b,c)<0 ? b : ((*cmp)(a,c)<0 ? c : a)) : \