summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--array.c1
-rw-r--r--bignum.c1
-rw-r--r--class.c1
-rw-r--r--eval.c4
-rw-r--r--ext/extmk.rb.in2
-rw-r--r--gc.c22
-rw-r--r--hash.c10
-rw-r--r--intern.h3
-rw-r--r--io.c7
-rw-r--r--marshal.c11
-rw-r--r--math.c1
-rw-r--r--numeric.c2
-rw-r--r--pack.c1
-rw-r--r--parse.y2
-rw-r--r--process.c3
-rw-r--r--random.c2
-rw-r--r--re.c47
-rw-r--r--ruby.c3
-rw-r--r--signal.c8
-rw-r--r--string.c10
-rw-r--r--struct.c2
-rw-r--r--time.c2
-rw-r--r--variable.c3
23 files changed, 55 insertions, 93 deletions
diff --git a/array.c b/array.c
index 81b422a..202facd 100644
--- a/array.c
+++ b/array.c
@@ -1182,7 +1182,6 @@ ary_uniq_bang(ary)
{
VALUE *p, *q, *t, *end;
VALUE v;
- int i;
ary_modify(ary);
p = RARRAY(ary)->ptr;
diff --git a/bignum.c b/bignum.c
index fbf5543..4667db8 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1289,6 +1289,7 @@ Init_Bignum()
rb_define_method(cBignum, "/", big_div, 1);
rb_define_method(cBignum, "%", big_mod, 1);
rb_define_method(cBignum, "divmod", big_divmod, 1);
+ rb_define_method(cBignum, "remainder", big_remainder, 1);
rb_define_method(cBignum, "**", big_pow, 1);
rb_define_method(cBignum, "&", big_and, 1);
rb_define_method(cBignum, "|", big_or, 1);
diff --git a/class.c b/class.c
index 28d11de..6b1ccd2 100644
--- a/class.c
+++ b/class.c
@@ -13,6 +13,7 @@
#include "ruby.h"
#include "node.h"
#include "st.h"
+#include <ctype.h>
#ifdef USE_CWGUSI
#include <stdio.h>
diff --git a/eval.c b/eval.c
index 73d0853..a8a5813 100644
--- a/eval.c
+++ b/eval.c
@@ -619,6 +619,7 @@ VALUE the_class;
the_scope->flag |= SCOPE_NOSTACK;\
}\
the_scope = _old;\
+ scope_vmode = _vmode;\
}
static VALUE rb_eval _((VALUE,NODE*));
@@ -5110,10 +5111,9 @@ obj_method(obj, vid)
{
VALUE method;
VALUE klass = CLASS_OF(obj);
- ID mid, id;
+ ID id;
NODE *body;
int noex;
- enum node_type type;
struct METHOD *data;
id = rb_to_id(vid);
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index fabfc44..77f42d7 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -404,7 +404,7 @@ for setup in ["@setup@", "#{$topdir}/ext/@setup@"]
if File.file? setup
f = open(setup)
while f.gets()
- $_.chop!
+ $_.chomp!
sub!(/#.*$/, '')
next if /^\s*$/
if /^option +nodynamic/
diff --git a/gc.c b/gc.c
index 8984dbb..6579b44 100644
--- a/gc.c
+++ b/gc.c
@@ -668,11 +668,12 @@ obj_free(obj)
if (RANY(obj)->as.array.ptr) free(RANY(obj)->as.array.ptr);
break;
case T_HASH:
- st_free_table(RANY(obj)->as.hash.tbl);
+ if (RANY(obj)->as.hash.tbl)
+ st_free_table(RANY(obj)->as.hash.tbl);
break;
case T_REGEXP:
- reg_free(RANY(obj)->as.regexp.ptr);
- free(RANY(obj)->as.regexp.str);
+ if (RANY(obj)->as.regexp.ptr) reg_free(RANY(obj)->as.regexp.ptr);
+ if (RANY(obj)->as.regexp.str) free(RANY(obj)->as.regexp.str);
break;
case T_DATA:
if (DATA_PTR(obj)) {
@@ -688,12 +689,16 @@ obj_free(obj)
}
break;
case T_MATCH:
- re_free_registers(RANY(obj)->as.match.regs);
- free(RANY(obj)->as.match.regs);
+ if (RANY(obj)->as.match.regs)
+ re_free_registers(RANY(obj)->as.match.regs);
+ if (RANY(obj)->as.match.regs)
+ free(RANY(obj)->as.match.regs);
break;
case T_FILE:
- io_fptr_finalize(RANY(obj)->as.file.fptr);
- free(RANY(obj)->as.file.fptr);
+ if (RANY(obj)->as.file.fptr) {
+ io_fptr_finalize(RANY(obj)->as.file.fptr);
+ free(RANY(obj)->as.file.fptr);
+ }
break;
case T_ICLASS:
/* iClass shares table with the module */
@@ -723,7 +728,8 @@ obj_free(obj)
break;
case T_STRUCT:
- free(RANY(obj)->as.rstruct.ptr);
+ if (RANY(obj)->as.rstruct.ptr)
+ free(RANY(obj)->as.rstruct.ptr);
break;
default:
diff --git a/hash.c b/hash.c
index 4a97c62..bf77840 100644
--- a/hash.c
+++ b/hash.c
@@ -164,6 +164,7 @@ hash_foreach_ensure(hash)
FL_UNSET(hash, HASH_DELETED);
}
}
+ return 0;
}
static int
@@ -193,13 +194,14 @@ hash_s_new(argc, argv, klass)
NEWOBJ(hash, struct RHash);
OBJSETUP(hash, klass, T_HASH);
+ hash->iter_lev = 0;
+ hash->status = 0;
+ hash->tbl = 0; /* avoid GC crashing */
+
rb_scan_args(argc, argv, "01", &sz);
if (NIL_P(sz)) size = 0;
else size = NUM2INT(sz);
- hash->iter_lev = 0;
- hash->status = 0;
- hash->tbl = 0; /* avoid GC crashing */
hash->tbl = st_init_table_with_size(&objhash, size);
obj_call_init((VALUE)hash);
@@ -916,8 +918,6 @@ f_setenv(obj, name, value)
setenv(RSTRING(name)->ptr, RSTRING(value)->ptr, 1);
if (strcmp(RSTRING(name)->ptr, "PATH") == 0) {
- char *p, pend;
-
if (str_tainted(value)) {
/* already tainted, no check */
path_tainted = 1;
diff --git a/intern.h b/intern.h
index ad28255..4096338 100644
--- a/intern.h
+++ b/intern.h
@@ -132,6 +132,8 @@ void thread_sleep_forever _((void));
VALUE thread_create _((VALUE (*)(), void*));
void thread_interrupt _((void));
void thread_trap_eval _((VALUE, int));
+int thread_select();
+void thread_wait_for();
/* file.c */
VALUE file_open _((char*, char*));
int eaccess _((char*, int));
@@ -255,6 +257,7 @@ VALUE str_taint _((VALUE));
VALUE str_tainted _((VALUE));
VALUE str_resize _((VALUE, int));
VALUE str_cat _((VALUE, char*, unsigned int));
+VALUE str_concat _((VALUE, VALUE));
int str_hash _((VALUE));
int str_cmp _((VALUE, VALUE));
VALUE str_upto _((VALUE, VALUE));
diff --git a/io.c b/io.c
index 0dda83f..fe4b87b 100644
--- a/io.c
+++ b/io.c
@@ -357,7 +357,6 @@ read_all(port)
{
OpenFile *fptr;
VALUE str = Qnil;
- char *buf;
struct stat st;
int siz = BUFSIZ;
int bytes = 0;
@@ -1578,7 +1577,6 @@ obj_display(argc, argv, self)
VALUE self;
{
VALUE out;
- VALUE str;
rb_scan_args(argc, argv, "01", &out);
if (NIL_P(out)) {
@@ -1611,7 +1609,7 @@ io_stdio_set(val, id, var)
ID id;
VALUE *var;
{
- OpenFile *fptr, *fptr2;
+ OpenFile *fptr;
int fd;
if (TYPE(val) != T_FILE) {
@@ -2094,7 +2092,8 @@ io_ctl(io, req, arg, io_p)
#if !defined(MSDOS) && !defined(__human68k__)
int cmd = NUM2INT(req);
OpenFile *fptr;
- int len, fd;
+ int len = 0;
+ int fd;
long narg = 0;
int retval;
diff --git a/marshal.c b/marshal.c
index 49cdaa5..b2c5add 100644
--- a/marshal.c
+++ b/marshal.c
@@ -208,7 +208,6 @@ w_object(obj, arg, limit)
struct dump_arg *arg;
int limit;
{
- int n;
struct dump_call_arg c_arg;
if (limit == 0) {
@@ -281,7 +280,6 @@ w_object(obj, arg, limit)
return;
case T_BIGNUM:
- write_bignum:
w_byte(TYPE_BIGNUM, arg);
{
char sign = RBIGNUM(obj)->sign?'+':'-';
@@ -386,6 +384,7 @@ dump(arg)
struct dump_call_arg *arg;
{
w_object(arg->obj, arg->arg, arg->limit);
+ return 0;
}
static VALUE
@@ -394,6 +393,7 @@ dump_ensure(arg)
{
st_free_table(arg->symbol);
st_free_table(arg->data);
+ return 0;
}
static VALUE
@@ -506,7 +506,7 @@ r_long(arg)
x |= (long)r_byte(arg) << (8*i);
}
}
- else if (c < 0) {
+ else {
c = -c;
if (c > sizeof(long)) long_toobig((int)c);
x = -1;
@@ -550,7 +550,6 @@ r_symbol(arg)
{
char *buf;
ID id;
- char type;
if (r_byte(arg) == TYPE_SYMLINK) {
int num = r_long(arg);
@@ -747,7 +746,6 @@ r_object(arg)
case TYPE_USERDEF:
{
VALUE klass;
- int len;
klass = rb_path2class(r_unique(arg));
if (rb_respond_to(klass, s_load)) {
@@ -805,6 +803,7 @@ load_ensure(arg)
{
st_free_table(arg->symbol);
st_free_table(arg->data);
+ return 0;
}
static VALUE
@@ -813,7 +812,6 @@ marshal_load(argc, argv)
VALUE *argv;
{
VALUE port, proc;
- FILE *fp;
int major;
VALUE v;
OpenFile *fptr;
@@ -855,6 +853,7 @@ marshal_load(argc, argv)
return v;
}
+void
Init_marshal()
{
VALUE mMarshal = rb_define_module("Marshal");
diff --git a/math.c b/math.c
index f03a009..2eaf2d4 100644
--- a/math.c
+++ b/math.c
@@ -108,7 +108,6 @@ math_ldexp(obj, x, n)
VALUE obj, x, n;
{
double d;
- int exp;
Need_Float(x);
return float_new(d = ldexp(RFLOAT(x)->value, NUM2INT(n)));
diff --git a/numeric.c b/numeric.c
index 75ff41d..104e069 100644
--- a/numeric.c
+++ b/numeric.c
@@ -82,8 +82,6 @@ VALUE
num_coerce_bin(x, y)
VALUE x, y;
{
- VALUE ary;
-
do_coerce(&x, &y);
return rb_funcall(x, rb_frame_last_func(), 1, y);
}
diff --git a/pack.c b/pack.c
index 38a1caa..393b6e0 100644
--- a/pack.c
+++ b/pack.c
@@ -896,7 +896,6 @@ pack_unpack(str, fmt)
{
VALUE str = str_new(0, (send - s)*3/4);
char *ptr = RSTRING(str)->ptr;
- int total = 0;
int a,b,c,d;
static int first = 1;
static int b64_xtable[256];
diff --git a/parse.y b/parse.y
index c8a5490..3b45a94 100644
--- a/parse.y
+++ b/parse.y
@@ -2280,6 +2280,8 @@ retry:
case EXPR_DOT:
sourceline++;
goto retry;
+ default:
+ break;
}
newline_seen++;
lex_state = EXPR_BEG;
diff --git a/process.c b/process.c
index 5dbaac5..5e8d51c 100644
--- a/process.c
+++ b/process.c
@@ -694,8 +694,7 @@ f_system(argc, argv)
return state == 0 ? TRUE : FALSE ;
#else
- VALUE prog = 0;
- int i;
+ volatile VALUE prog = 0;
int pid;
fflush(stdin); /* is it really needed? */
diff --git a/random.c b/random.c
index c819e10..6adfc59 100644
--- a/random.c
+++ b/random.c
@@ -144,8 +144,6 @@ f_rand(obj, vmax)
void
Init_Random()
{
- extern VALUE mKernel;
-
rb_define_global_function("srand", f_srand, -1);
rb_define_global_function("rand", f_rand, 1);
}
diff --git a/re.c b/re.c
index 888c412..b192080 100644
--- a/re.c
+++ b/re.c
@@ -338,6 +338,7 @@ match_alloc()
OBJSETUP(match, cMatch, T_MATCH);
match->str = 0;
+ match->regs = 0;
match->regs = ALLOC(struct re_registers);
MEMZERO(match->regs, struct re_registers, 1);
@@ -348,12 +349,11 @@ static VALUE
match_clone(orig)
VALUE orig;
{
- struct re_registers *rr;
-
NEWOBJ(match, struct RMatch);
OBJSETUP(match, cMatch, T_MATCH);
match->str = RMATCH(orig)->str;
+ match->regs = 0;
match->regs = ALLOC(struct re_registers);
match->regs->allocated = 0;
@@ -369,7 +369,6 @@ void
reg_prepare_re(reg)
VALUE reg;
{
- int result;
int casefold = RTEST(ignorecase);
int need_recompile = 0;
@@ -416,11 +415,9 @@ reg_search(reg, str, start, reverse)
int start, reverse;
{
int result;
- int casefold = RTEST(ignorecase);
VALUE match = 0;
struct re_registers *regs = 0;
int range;
- int need_recompile = 0;
if (start > RSTRING(str)->len) return -1;
@@ -634,6 +631,9 @@ reg_new_1(klass, s, len, flag)
NEWOBJ(re, struct RRegexp);
OBJSETUP(re, klass, T_REGEXP);
+ re->ptr = 0;
+ re->str = 0;
+
if (flag & 0x1) {
FL_SET(re, REG_IGNORECASE);
}
@@ -873,7 +873,6 @@ reg_regsub(str, src, regs)
struct re_registers *regs;
{
VALUE val = 0;
- VALUE tmp;
char *p, *s, *e, c;
int no;
@@ -942,41 +941,6 @@ reg_regsub(str, src, regs)
return val;
}
-#define IS_KCODE_FIXED(re) (FL_TEST((re), KCODE_FIXED)?1:0)
-
-static int
-reg_prepare_operation(re1, re2)
- VALUE re1, re2;
-{
- int flag = 0;
-
- Check_Type(re2, T_REGEXP);
- flag = IS_KCODE_FIXED(re1)+IS_KCODE_FIXED(re2)*2;
- switch (IS_KCODE_FIXED(re1)+IS_KCODE_FIXED(re2)*2) {
- case 3: /* both have fixed kcode (must match) */
- if (((RBASIC(re1)->flags^RBASIC(re2)->flags)&KCODE_MASK) != 0) {
- Raise(eRegxpError, "kanji code mismatch");
- }
- /* fall through */
- case 2: /* re2 has fixed kcode */
- flag = reg_get_kcode(re2);
- break;
- case 1: /* re1 has fixed kcode */
- flag = reg_get_kcode(re1);
- break;
- case 0: /* neither has fixed kcode */
- flag = 0;
- break;
- }
-
- if (FL_TEST(re1, REG_IGNORECASE) ^ FL_TEST(re2, REG_IGNORECASE)) {
- Raise(eRegxpError, "casefold mismatch");
- }
- if (FL_TEST(re1, REG_IGNORECASE)) flag |= 0x1;
-
- return flag;
-}
-
char*
rb_get_kcode()
{
@@ -1090,6 +1054,7 @@ Init_Regexp()
rb_global_variable(&matchcache);
cMatch = rb_define_class("MatchingData", cData);
+ rb_define_method(cMatch, "clone", match_clone, 0);
rb_define_method(cMatch, "to_a", match_to_a, 0);
rb_define_method(cMatch, "[]", match_aref, -1);
rb_define_method(cMatch, "to_s", match_to_s, 0);
diff --git a/ruby.c b/ruby.c
index 6263156..e675b3b 100644
--- a/ruby.c
+++ b/ruby.c
@@ -26,9 +26,10 @@
#ifdef __MWERKS__
#include "node.h"
+#endif
+
void show_version();
void show_copyright();
-#endif
#ifdef USE_CWGUSI
#include "macruby_missing.h"
diff --git a/signal.c b/signal.c
index ac444bb..4755f59 100644
--- a/signal.c
+++ b/signal.c
@@ -187,6 +187,7 @@ f_kill(argc, argv)
#ifdef USE_CWGUSI
rb_notimplement();
#else
+ int negative = 0;
int sig;
int i;
char *s;
@@ -205,9 +206,7 @@ f_kill(argc, argv)
break;
case T_STRING:
- {
- int negative = 0;
-
+ {
s = RSTRING(argv[0])->ptr;
if (s[0] == '-') {
negative++;
@@ -499,6 +498,7 @@ trap_ensure(arg)
sigsetmask(arg->mask);
#endif
trap_last_mask = arg->mask;
+ return 0;
}
#endif
@@ -553,8 +553,6 @@ void
Init_signal()
{
#ifndef MACOS_UNUSE_SIGNAL
- extern VALUE mKernel;
-
rb_define_global_function("trap", f_trap, -1);
#ifdef POSIX_SIGNAL
posix_signal(SIGINT, sighandle);
diff --git a/string.c b/string.c
index f0c05de..dd53432 100644
--- a/string.c
+++ b/string.c
@@ -287,8 +287,6 @@ str_substr(str, start, len)
VALUE str;
int start, len;
{
- struct RString *str2;
-
if (start < 0) {
start = RSTRING(str)->len + start;
}
@@ -976,7 +974,7 @@ str_sub_iter_s(str, pat, once)
int once;
{
VALUE val, result;
- int beg, offset, n, null;
+ int beg, offset, n;
struct re_registers *regs;
if (!iterator_p()) {
@@ -1698,10 +1696,10 @@ str_swapcase(str)
typedef unsigned char *USTR;
-static struct tr {
+struct tr {
int gen, now, max;
char *p, *pend;
-} trsrc, trrepl;
+};
static int
trnext(t)
@@ -1813,7 +1811,7 @@ tr_trans(str, src, repl, sflag)
*t++ = c;
}
}
- if (RSTRING(str)->len = (t - RSTRING(str)->ptr)) {
+ if (RSTRING(str)->len > (t - RSTRING(str)->ptr)) {
RSTRING(str)->len = (t - RSTRING(str)->ptr);
modify = 1;
*t = '\0';
diff --git a/struct.c b/struct.c
index fd7a5ab..1bd964f 100644
--- a/struct.c
+++ b/struct.c
@@ -358,7 +358,6 @@ struct_aref_id(s, id)
{
VALUE member;
int i, len;
- VALUE *p;
member = rb_iv_get(CLASS_OF(s), "__member__");
if (NIL_P(member)) {
@@ -400,7 +399,6 @@ struct_aset_id(s, id, val)
{
VALUE member;
int i, len;
- VALUE *p;
member = rb_iv_get(CLASS_OF(s), "__member__");
if (NIL_P(member)) {
diff --git a/time.c b/time.c
index 19ee715..6bd0443 100644
--- a/time.c
+++ b/time.c
@@ -688,7 +688,6 @@ time_to_a(time)
VALUE time;
{
struct time_object *tobj;
- VALUE ary;
GetTimeval(time, tobj);
if (tobj->tm_got == 0) {
@@ -750,7 +749,6 @@ time_strftime(time, format)
}
if (strlen(RSTRING(format)->ptr) < RSTRING(format)->len) {
/* Ruby string may contain \0's. */
- int l;
char *p = RSTRING(format)->ptr, *pe = p + RSTRING(format)->len;
str = str_new(0, 0);
diff --git a/variable.c b/variable.c
index 845d55a..c4f2d0d 100644
--- a/variable.c
+++ b/variable.c
@@ -553,10 +553,11 @@ f_untrace_var(argc, argv)
if (!st_lookup(global_tbl, id, &entry)) {
NameError("undefined global variable %s", rb_id2name(id));
}
+
+ trace = entry->trace;
if (NIL_P(cmd)) {
VALUE ary = ary_new();
- trace = entry->trace;
while (trace) {
struct trace_var *next = trace->next;
ary_push(ary, (VALUE)trace->data);