Skip to content

Commit

Permalink
forgot some checkins.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed May 6, 2001
1 parent 94df732 commit 1d3d27b
Show file tree
Hide file tree
Showing 36 changed files with 2,190 additions and 296 deletions.
1 change: 1 addition & 0 deletions ToDo
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Language Spec.
* to_i returns nil if str contains no digit.
* raise exception by `` error
* jar like combined library package.
* "@foo ||= 44" should not warn you.

Hacking Interpreter

Expand Down
65 changes: 34 additions & 31 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,21 @@ rb_ary_indexes(argc, argv, ary)
}

static void
rb_ary_update(ary, beg, len, rpl, rlen)
rb_ary_update(ary, beg, len, rpl)
VALUE ary;
long beg, len;
VALUE *rpl;
long rlen;
VALUE rpl;
{
long rlen;

if (NIL_P(rpl)) {
rpl = rb_ary_new2(0);
}
else if (TYPE(rpl) != T_ARRAY) {
rpl = rb_ary_new3(1, rpl);
}
rlen = RARRAY(rpl)->len;

if (len < 0) rb_raise(rb_eIndexError, "negative length %d", len);
if (beg < 0) {
beg += RARRAY(ary)->len;
Expand All @@ -567,7 +576,7 @@ rb_ary_update(ary, beg, len, rpl, rlen)
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
}
rb_mem_clear(RARRAY(ary)->ptr+RARRAY(ary)->len, beg-RARRAY(ary)->len);
MEMCPY(RARRAY(ary)->ptr+beg, rpl, VALUE, rlen);
MEMCPY(RARRAY(ary)->ptr+beg, RARRAY(rpl)->ptr, VALUE, rlen);
RARRAY(ary)->len = len;
}
else {
Expand All @@ -579,7 +588,7 @@ rb_ary_update(ary, beg, len, rpl, rlen)

alen = RARRAY(ary)->len + rlen - len;
if (alen >= RARRAY(ary)->capa) {
RARRAY(ary)->capa=alen;
RARRAY(ary)->capa = alen;
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
}

Expand All @@ -588,24 +597,8 @@ rb_ary_update(ary, beg, len, rpl, rlen)
VALUE, RARRAY(ary)->len-(beg+len));
RARRAY(ary)->len = alen;
}
MEMMOVE(RARRAY(ary)->ptr+beg, rpl, VALUE, rlen);
}
}

static void
rb_ary_replace(ary, beg, len, rpl)
VALUE ary, rpl;
long beg, len;
{
long rlen;

if (NIL_P(rpl)) {
rpl = rb_ary_new2(0);
}
else if (TYPE(rpl) != T_ARRAY) {
rpl = rb_ary_new3(1, rpl);
MEMMOVE(RARRAY(ary)->ptr+beg, RARRAY(rpl)->ptr, VALUE, rlen);
}
rb_ary_update(ary, beg, len, RARRAY(rpl)->ptr, RARRAY(rpl)->len);
}

static VALUE
Expand All @@ -617,7 +610,7 @@ rb_ary_aset(argc, argv, ary)
long offset, beg, len;

if (argc == 3) {
rb_ary_replace(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
rb_ary_update(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
return argv[2];
}
if (argc != 2) {
Expand All @@ -629,7 +622,7 @@ rb_ary_aset(argc, argv, ary)
}
else if (rb_range_beg_len(argv[0], &beg, &len, RARRAY(ary)->len, 1)) {
/* check if idx is Range */
rb_ary_replace(ary, beg, len, argv[1]);
rb_ary_update(ary, beg, len, argv[1]);
return argv[1];
}
if (TYPE(argv[0]) == T_BIGNUM) {
Expand All @@ -648,10 +641,20 @@ rb_ary_insert(argc, argv, ary)
VALUE *argv;
VALUE ary;
{
long pos;

if (argc < 2) {
rb_raise(rb_eArgError, "wrong # of arguments(at least 2)");
}
rb_ary_update(ary, NUM2LONG(argv[0]), 0, argv+1, argc-1);
pos = NUM2LONG(argv[0]);
if (pos == -1) {
pos = RSTRING(ary)->len;
}
else if (pos < 0) {
pos++;
}

rb_ary_update(ary, pos, 0, rb_ary_new4(argc-1, argv+1));
return ary;
}

Expand Down Expand Up @@ -1146,7 +1149,7 @@ rb_ary_slice_bang(argc, argv, ary)
pos = RARRAY(ary)->len + pos;
}
arg2 = rb_ary_subseq(ary, pos, len);
rb_ary_replace(ary, pos, len, Qnil); /* Qnil/rb_ary_new2(0) */
rb_ary_update(ary, pos, len, Qnil); /* Qnil/rb_ary_new2(0) */
return arg2;
}

Expand Down Expand Up @@ -1199,11 +1202,11 @@ rb_ary_delete_if(ary)
}

static VALUE
rb_ary_replace_m(ary, ary2)
rb_ary_replace(ary, ary2)
VALUE ary, ary2;
{
ary2 = to_ary(ary2);
rb_ary_replace(ary, 0, RARRAY(ary)->len, ary2);
rb_ary_update(ary, 0, RARRAY(ary)->len, ary2);
return ary;
}

Expand Down Expand Up @@ -1292,7 +1295,7 @@ rb_ary_concat(x, y)

y = to_ary(y);
if (RARRAY(y)->len > 0) {
rb_ary_replace(x, RARRAY(x)->len, 0, y);
rb_ary_update(x, RARRAY(x)->len, 0, y);
}
return x;
}
Expand Down Expand Up @@ -1626,7 +1629,7 @@ flatten(ary, idx, ary2, memo)
rb_raise(rb_eArgError, "tried to flatten recursive array");
}
rb_ary_push(memo, id);
rb_ary_replace(ary, idx, 1, ary2);
rb_ary_update(ary, idx, 1, ary2);
while (i < lim) {
if (TYPE(RARRAY(ary)->ptr[i]) == T_ARRAY) {
n = flatten(ary, i, RARRAY(ary)->ptr[i], memo);
Expand Down Expand Up @@ -1730,7 +1733,7 @@ Init_Array()
rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at_m, 1);
rb_define_method(rb_cArray, "delete_if", rb_ary_delete_if, 0);
rb_define_method(rb_cArray, "reject!", rb_ary_reject_bang, 0);
rb_define_method(rb_cArray, "replace", rb_ary_replace_m, 1);
rb_define_method(rb_cArray, "replace", rb_ary_replace, 1);
rb_define_method(rb_cArray, "clear", rb_ary_clear, 0);
rb_define_method(rb_cArray, "fill", rb_ary_fill, -1);
rb_define_method(rb_cArray, "include?", rb_ary_includes, 1);
Expand Down
2 changes: 1 addition & 1 deletion bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ VALUE rb_cBignum;
#if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
typedef unsigned int BDIGIT;
typedef unsigned LONG_LONG BDIGIT_DBL;
typedef long long BDIGIT_DBL_SIGNED;
typedef LONG_LONG BDIGIT_DBL_SIGNED;
#elif SIZEOF_ING*2 <= SIZEOF_LONG
typedef unsigned int BDIGIT;
typedef unsigned long BDIGIT_DBL;
Expand Down
6 changes: 4 additions & 2 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ glob_helper(path, flag, func, arg)
void
rb_glob(path, func, arg)
char *path;
void (*func)();
void (*func) _((const char*, VALUE));
VALUE arg;
{
glob_helper(path, FNM_PERIOD, func, arg);
Expand All @@ -765,9 +765,11 @@ rb_globi(path, func, arg)
glob_helper(path, FNM_PERIOD|FNM_NOCASE, func, arg);
}

static void push_pattern _((const char *path, VALUE ary));

static void
push_pattern(path, ary)
char *path;
const char *path;
VALUE ary;
{
VALUE str = rb_tainted_str_new2(path);
Expand Down
10 changes: 6 additions & 4 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -3929,7 +3929,7 @@ rb_rescue(b_proc, data1, r_proc, data2)

VALUE
rb_protect(proc, data, state)
VALUE (*proc)();
VALUE (*proc) _((VALUE));
VALUE data;
int *state;
{
Expand Down Expand Up @@ -5731,7 +5731,7 @@ static struct end_proc_data *end_procs, *ephemeral_end_procs;

void
rb_set_end_proc(func, data)
void (*func)();
void (*func) _((VALUE));
VALUE data;
{
struct end_proc_data *link = ALLOC(struct end_proc_data);
Expand Down Expand Up @@ -5762,6 +5762,8 @@ rb_mark_end_proc()
}
}

static void call_end_proc _((VALUE data));

static void
call_end_proc(data)
VALUE data;
Expand Down Expand Up @@ -5804,7 +5806,7 @@ rb_exec_end_proc()

link = end_procs;
while (link) {
rb_protect((VALUE(*)())link->func, link->data, &status);
rb_protect((VALUE(*)_((VALUE)))link->func, link->data, &status);
if (status) {
error_handle(status);
}
Expand All @@ -5813,7 +5815,7 @@ rb_exec_end_proc()
while (ephemeral_end_procs) {
link = ephemeral_end_procs;
ephemeral_end_procs = link->next;
rb_protect((VALUE(*)())link->func, link->data, &status);
rb_protect((VALUE(*)_((VALUE)))link->func, link->data, &status);
if (status) {
error_handle(status);
}
Expand Down
Loading

0 comments on commit 1d3d27b

Please sign in to comment.