summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorYukihiro Matsumoto <matz@ruby-lang.org>1995-01-10 00:58:20 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2019-08-17 22:09:31 +0900
commit5d828b25d4ae30a000c054a724ac248dadbb97b3 (patch)
tree080fc6e3b41b9c59cf5def77ae619a82e7e252db /string.c
parentbd0c733b77b561f4d12daccebf06a7c71917000b (diff)
version 0.64v0_64
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.64.tar.gz Tue Jan 10 00:58:20 1995 Yukihiro Matsumoto (matz@dyna) * eval.c: レシーバと引数は常にiterではない. * cons.c(aref,aset): negative offset対応. Mon Jan 9 14:40:39 1995 Yukihiro Matsumoto (matz@ix-02) * parse.y: foo{..}の形式において,fooをローカル変数やクラス名では なく,引数なしの関数型メソッド呼び出しとみなすようにした. * list.c -> cons.c: 名称変更(クラス名も). * list.c: a::b::c::nilをリスト(a b c)とみなすlisp形式から,a::b::c をリスト(a b c)とみなすruby形式に変更.[], []=, eachもそれに会わ せた仕様とする. * list.c: consペアとしての機能を強調.仕様変更. Sat Jan 7 01:26:26 1995 Yukihiro Matsumoto (matz@dyna) * eval.c: 自己代入の不具合修正. * eval.c(masign): 多重代入が配列もリストもとれるようにした. * list.c: assocを2要素の配列からList(CONSペア)に変更した. Fri Jan 6 13:42:12 1995 Yukihiro Matsumoto (matz@ix-02) * parse.y: a[b]+=cやa.b+=cなどの自己代入形式で,aやbを2度評価しな くなった. * eval.c: iterator設定のバグフィックス. * list.c: Listクラスを新設. Thu Jan 5 13:55:00 1995 Yukihiro Matsumoto (matz@ix-02) * parse.y: SCOPEのメモリリークをなくした. * eval.c: built-inメソッドへの引数の引き渡し方を変更して,配列の生 成数を減らした. * re.c: match-dataを毎回生成することをやめた.`$~'をアクセスした時 にon-demandで生成する. * string.c etc: 不必要なmemmoveをmemcpyに置換. * parse.y: =~, !~は副作用があるのでコンパイル時に展開できない. Tue Jan 3 02:04:36 1995 Yukihiro Matsumoto (matz@dyna) * eval.c: rest引数のbug fix. * eval.c,gc.c: scopeをオブジェクトにした. * eval.c: envとscopeの扱いを変更した. Wed Dec 28 09:46:57 1994 Yukihiro Matsumoto (matz@ix-02) * parse.y: evalでローカル変数が追加された場合に対応した. * parse.y: 演算子を含むaliasのbug fix. Tue Dec 27 16:45:20 1994 Yukihiro Matsumoto (matz@ix-02) * parse.y: def A Bをalias A Bに変更. * eval.c: alias関係のbug修正.nodeをオブジェクト化した時にenbugし たようだ. * signal.c: システムコールの再定義を止めた. * io.c(select): write/exceptのフラグ設定にバグ. * Makefile.in: static link用オプションをMake変数として独立させた.
Diffstat (limited to 'string.c')
-rw-r--r--string.c75
1 files changed, 41 insertions, 34 deletions
diff --git a/string.c b/string.c
index d1dc737..3861f71 100644
--- a/string.c
+++ b/string.c
@@ -3,7 +3,7 @@
string.c -
$Author: matz $
- $Date: 1994/12/09 09:40:28 $
+ $Date: 1995/01/10 10:43:01 $
created at: Mon Aug 9 17:12:58 JST 1993
Copyright (C) 1994 Yukihiro Matsumoto
@@ -105,7 +105,7 @@ Sstr_new(class, str)
str2->len = str->len;
str2->ptr = ALLOC_N(char, str->len+1);
if (str2->ptr) {
- memmove(str2->ptr, str->ptr, str->len);
+ memcpy(str2->ptr, str->ptr, str->len);
}
str2->ptr[str->len] = '\0';
str2->orig = Qnil;
@@ -147,7 +147,7 @@ Fstr_times(str, times)
str2 = (struct RString*)str_new(0, str->len*times);
for (i=0; i<times; i++) {
- memmove(str2->ptr+(i*str->len), str->ptr, str->len);
+ memcpy(str2->ptr+(i*str->len), str->ptr, str->len);
}
str2->ptr[str2->len] = '\0';
@@ -269,7 +269,7 @@ str_cat(str, ptr, len)
if (len > 0) {
REALLOC_N(str->ptr, char, str->len + len + 1);
if (ptr)
- memmove(str->ptr + str->len, ptr, len);
+ memcpy(str->ptr + str->len, ptr, len);
str->len += len;
str->ptr[str->len] = '\0'; /* sentinel */
}
@@ -435,15 +435,16 @@ str_index(str, sub, offset)
}
static VALUE
-Fstr_index(str, args)
+Fstr_index(argc, argv, str)
+ int argc;
+ VALUE *argv;
struct RString *str;
- VALUE args;
{
struct RString *sub;
VALUE initpos;
int pos;
- if (rb_scan_args(args, "11", &sub, &initpos) == 2) {
+ if (rb_scan_args(argc, argv, "11", &sub, &initpos) == 2) {
pos = NUM2INT(initpos);
}
else {
@@ -468,16 +469,17 @@ Fstr_index(str, args)
}
static VALUE
-Fstr_rindex(str, args)
+Fstr_rindex(argc, argv, str)
+ int argc;
+ VALUE *argv;
struct RString *str;
- VALUE args;
{
struct RString *sub;
VALUE initpos;
int pos, len;
char *s, *sbeg, *t;
- if (rb_scan_args(args, "11", &sub, &initpos) == 2) {
+ if (rb_scan_args(argc, argv, "11", &sub, &initpos) == 2) {
pos = NUM2INT(initpos);
if (pos >= str->len) pos = str->len;
}
@@ -543,7 +545,7 @@ Fstr_next(orig)
if (s < sbeg && c != -1) {
str2 = (struct RString*)str_new(0, str->len+1);
str2->ptr[0] = c;
- memmove(str2->ptr+1, str->ptr, str->len);
+ memcpy(str2->ptr+1, str->ptr, str->len);
str = str2;
}
@@ -617,13 +619,14 @@ Fstr_aref_internal(str, indx)
}
static VALUE
-Fstr_aref(str, args)
+Fstr_aref(argc, argv, str)
+ int argc;
+ VALUE *argv;
struct RString *str;
- VALUE args;
{
VALUE arg1, arg2;
- if (rb_scan_args(args, "11", &arg1, &arg2) == 2) {
+ if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
return str_substr(str, NUM2INT(arg1), NUM2INT(arg2));
}
return Fstr_aref_internal(str, arg1);
@@ -640,7 +643,7 @@ str_replace(str, beg, len, val)
}
memmove(str->ptr+beg+val->len, str->ptr+beg+len, str->len-(beg+len));
- memmove(str->ptr+beg, val->ptr, val->len);
+ memcpy(str->ptr+beg, val->ptr, val->len);
str->len += val->len - len;
str->ptr[str->len] = '\0';
}
@@ -752,15 +755,16 @@ Fstr_aset_internal(str, indx, val)
}
static VALUE
-Fstr_aset(str, args)
+Fstr_aset(argc, argv, str)
+ int argc;
+ VALUE *argv;
struct RString *str;
- VALUE args;
{
VALUE arg1, arg2, arg3;
str_modify(str);
- if (rb_scan_args(args, "21", &arg1, &arg2, &arg3) == 3) {
+ if (rb_scan_args(argc, argv, "21", &arg1, &arg2, &arg3) == 3) {
int beg, len;
Check_Type(arg3, T_STRING);
@@ -1222,13 +1226,14 @@ tr_squeeze(str1, str2)
}
static VALUE
-Fstr_squeeze(str1, args)
+Fstr_squeeze(argc, argv, str1)
+ int argc;
+ VALUE *argv;
VALUE str1;
- VALUE *args;
{
VALUE str2;
- rb_scan_args(args, "01", &str2);
+ rb_scan_args(argc, argv, "01", &str2);
if (str2) {
Check_Type(str2, T_STRING);
}
@@ -1247,9 +1252,10 @@ Fstr_tr_s(str, src, repl)
}
static VALUE
-Fstr_split(str, args)
+Fstr_split(argc, argv, str)
+ int argc;
+ VALUE *argv;
struct RString *str;
- VALUE args;
{
extern VALUE FS;
struct RRegexp *spat;
@@ -1258,7 +1264,7 @@ Fstr_split(str, args)
int beg, end, lim, i;
VALUE result, tmp;
- rb_scan_args(args, "02", &spat, &limit);
+ rb_scan_args(argc, argv, "02", &spat, &limit);
if (limit) {
lim = NUM2INT(limit);
i = 1;
@@ -1523,15 +1529,16 @@ Fstr_intern(str)
}
static VALUE
-Fstr_sum(str, args)
+Fstr_sum(argc, argv, str)
+ int argc;
+ VALUE *argv;
struct RString *str;
- VALUE args;
{
VALUE vbits;
int bits;
char *p, *pend;
- rb_scan_args(args, "01", &vbits);
+ rb_scan_args(argc, argv, "01", &vbits);
if (vbits == Qnil) bits = 16;
else bits = NUM2INT(vbits);
@@ -1640,16 +1647,16 @@ Init_String()
rb_define_method(C_String, "+", Fstr_plus, 1);
rb_define_method(C_String, "*", Fstr_times, 1);
rb_define_method(C_String, "..", Fstr_dot2, 1);
- rb_define_method(C_String, "[]", Fstr_aref, -2);
- rb_define_method(C_String, "[]=", Fstr_aset, -2);
+ rb_define_method(C_String, "[]", Fstr_aref, -1);
+ rb_define_method(C_String, "[]=", Fstr_aset, -1);
rb_define_method(C_String, "length", Fstr_length, 0);
rb_define_alias(C_String, "size", "length");
rb_define_method(C_String, "=~", Fstr_match, 1);
rb_define_method(C_String, "~", Fstr_match2, 0);
rb_define_method(C_String, "next", Fstr_next, 0);
rb_define_method(C_String, "upto", Fstr_next, 1);
- rb_define_method(C_String, "index", Fstr_index, -2);
- rb_define_method(C_String, "rindex", Fstr_rindex, -2);
+ rb_define_method(C_String, "index", Fstr_index, -1);
+ rb_define_method(C_String, "rindex", Fstr_rindex, -1);
rb_define_method(C_String, "to_i", Fstr_to_i, 0);
rb_define_method(C_String, "to_f", Fstr_to_f, 0);
@@ -1666,7 +1673,7 @@ Init_String()
rb_define_method(C_String, "hex", Fstr_hex, 0);
rb_define_method(C_String, "oct", Fstr_oct, 0);
- rb_define_method(C_String, "split", Fstr_split, -2);
+ rb_define_method(C_String, "split", Fstr_split, -1);
rb_define_method(C_String, "reverse", Fstr_reverse, 0);
rb_define_method(C_String, "concat", Fstr_concat, 1);
rb_define_method(C_String, "crypt", Fstr_crypt, 1);
@@ -1684,12 +1691,12 @@ Init_String()
rb_define_method(C_String, "tr", Fstr_tr, 2);
rb_define_method(C_String, "tr_s", Fstr_tr_s, 2);
rb_define_method(C_String, "delete", Fstr_delete, 1);
- rb_define_method(C_String, "squeeze", Fstr_squeeze, -2);
+ rb_define_method(C_String, "squeeze", Fstr_squeeze, -1);
rb_define_method(C_String, "each", Fstr_each, 0);
rb_define_method(C_String, "each_byte", Fstr_each_byte, 0);
- rb_define_method(C_String, "sum", Fstr_sum, -2);
+ rb_define_method(C_String, "sum", Fstr_sum, -1);
rb_define_private_method(C_Kernel, "sub", Fsub, 2);
rb_define_private_method(C_Kernel, "gsub", Fgsub, 2);