mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
marshal/reg_clone
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3af58a0a57
commit
0d30af8fd2
5 changed files with 57 additions and 29 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Fri Jul 24 02:10:22 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* marshal.c (r_bytes2): allocated buffer size was too short.
|
||||||
|
|
||||||
|
* marshal.c (w_object): saves all options, not only casefold flag.
|
||||||
|
|
||||||
|
* re.c (reg_clone): now copies options properly.
|
||||||
|
|
||||||
|
* re.c (reg_get_kcode): code number was wrong.
|
||||||
|
|
||||||
Wed Jul 22 11:59:59 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
Wed Jul 22 11:59:59 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
* st.c (rehash): still had a GC problem. fixed.
|
* st.c (rehash): still had a GC problem. fixed.
|
||||||
|
|
1
intern.h
1
intern.h
|
@ -221,6 +221,7 @@ VALUE reg_match_last _((VALUE));
|
||||||
VALUE reg_new _((char*, int, int));
|
VALUE reg_new _((char*, int, int));
|
||||||
VALUE reg_match _((VALUE, VALUE));
|
VALUE reg_match _((VALUE, VALUE));
|
||||||
VALUE reg_match2 _((VALUE));
|
VALUE reg_match2 _((VALUE));
|
||||||
|
int reg_options _((VALUE));
|
||||||
char*rb_get_kcode _((void));
|
char*rb_get_kcode _((void));
|
||||||
void rb_set_kcode _((char*));
|
void rb_set_kcode _((char*));
|
||||||
/* ruby.c */
|
/* ruby.c */
|
||||||
|
|
39
marshal.c
39
marshal.c
|
@ -299,7 +299,7 @@ w_object(obj, arg, limit)
|
||||||
w_uclass(obj, cRegexp, arg);
|
w_uclass(obj, cRegexp, arg);
|
||||||
w_byte(TYPE_REGEXP, arg);
|
w_byte(TYPE_REGEXP, arg);
|
||||||
w_bytes(RREGEXP(obj)->str, RREGEXP(obj)->len, arg);
|
w_bytes(RREGEXP(obj)->str, RREGEXP(obj)->len, arg);
|
||||||
w_byte(FL_TEST(obj, FL_USER1), arg);
|
w_byte(reg_options(obj), arg);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case T_ARRAY:
|
case T_ARRAY:
|
||||||
|
@ -511,13 +511,20 @@ r_long(arg)
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long blen; /* hidden length register */
|
#define r_bytes2(s, len, arg) do { \
|
||||||
#define r_bytes(s, arg) \
|
(len) = r_long(arg); \
|
||||||
(blen = r_long(arg), r_bytes0(&s,ALLOCA_N(char,blen),blen,arg))
|
(s) = ALLOCA_N(char,(len)+1); \
|
||||||
|
r_bytes0((s),(len),(arg)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
static int
|
#define r_bytes(s, arg) do { \
|
||||||
r_bytes0(sp, s, len, arg)
|
int r_bytes_len; \
|
||||||
char **sp, *s;
|
r_bytes2((s), r_bytes_len, (arg)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
static void
|
||||||
|
r_bytes0(s, len, arg)
|
||||||
|
char *s;
|
||||||
int len;
|
int len;
|
||||||
struct load_arg *arg;
|
struct load_arg *arg;
|
||||||
{
|
{
|
||||||
|
@ -531,11 +538,7 @@ r_bytes0(sp, s, len, arg)
|
||||||
memcpy(s, arg->ptr, len);
|
memcpy(s, arg->ptr, len);
|
||||||
arg->ptr += len;
|
arg->ptr += len;
|
||||||
}
|
}
|
||||||
|
s[len] = '\0';
|
||||||
(s)[len] = '\0';
|
|
||||||
*sp = s;
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ID
|
static ID
|
||||||
|
@ -572,8 +575,9 @@ r_string(arg)
|
||||||
struct load_arg *arg;
|
struct load_arg *arg;
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int len = r_bytes(buf, arg);
|
int len;
|
||||||
|
|
||||||
|
r_bytes2(buf, len, arg);
|
||||||
return str_taint(str_new(buf, len));
|
return str_taint(str_new(buf, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,9 +676,12 @@ r_object(arg)
|
||||||
case TYPE_REGEXP:
|
case TYPE_REGEXP:
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int len = r_bytes(buf, arg);
|
int len;
|
||||||
int ci = r_byte(arg);
|
int options;
|
||||||
return r_regist(reg_new(buf, len, ci), arg);
|
|
||||||
|
r_bytes2(buf, len, arg);
|
||||||
|
options = r_byte(arg);
|
||||||
|
return r_regist(reg_new(buf, len, options), arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_ARRAY:
|
case TYPE_ARRAY:
|
||||||
|
|
34
re.c
34
re.c
|
@ -664,11 +664,11 @@ reg_new_1(klass, s, len, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
reg_new(s, len, flag)
|
reg_new(s, len, options)
|
||||||
char *s;
|
char *s;
|
||||||
int len, flag;
|
int len, options;
|
||||||
{
|
{
|
||||||
return reg_new_1(cRegexp, s, len, flag);
|
return reg_new_1(cRegexp, s, len, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ign_cache;
|
static int ign_cache;
|
||||||
|
@ -838,11 +838,11 @@ reg_get_kcode(re)
|
||||||
|
|
||||||
switch (RBASIC(re)->flags & KCODE_MASK) {
|
switch (RBASIC(re)->flags & KCODE_MASK) {
|
||||||
case KCODE_NONE:
|
case KCODE_NONE:
|
||||||
kcode |= 2; break;
|
|
||||||
case KCODE_EUC:
|
|
||||||
kcode |= 4; break;
|
kcode |= 4; break;
|
||||||
|
case KCODE_EUC:
|
||||||
|
kcode |= 8; break;
|
||||||
case KCODE_SJIS:
|
case KCODE_SJIS:
|
||||||
kcode |= 6; break;
|
kcode |= 12; break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -850,16 +850,26 @@ reg_get_kcode(re)
|
||||||
return kcode;
|
return kcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
reg_options(re)
|
||||||
|
VALUE re;
|
||||||
|
{
|
||||||
|
int options = 0;
|
||||||
|
|
||||||
|
if (FL_TEST(re, REG_IGNORECASE))
|
||||||
|
options |= RE_OPTION_IGNORECASE;
|
||||||
|
if (FL_TEST(re, KCODE_FIXED)) {
|
||||||
|
options |= reg_get_kcode(re);
|
||||||
|
}
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
reg_clone(re)
|
reg_clone(re)
|
||||||
VALUE re;
|
VALUE re;
|
||||||
{
|
{
|
||||||
int flag = FL_TEST(re, REG_IGNORECASE)?1:0;
|
return reg_new_1(CLASS_OF(re), RREGEXP(re)->str, RREGEXP(re)->len,
|
||||||
|
reg_options(re));
|
||||||
if (FL_TEST(re, KCODE_FIXED)) {
|
|
||||||
flag |= reg_get_kcode(re);
|
|
||||||
}
|
|
||||||
return reg_new_1(CLASS_OF(re), RREGEXP(re)->str, RREGEXP(re)->len, flag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
|
|
@ -337,7 +337,7 @@ f_sprintf(argc, argv)
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'u':
|
case 'u':
|
||||||
default:
|
default:
|
||||||
if (flags & FPLUS) sign = 1;
|
if (flags&(FPLUS|FSPACE)) sign = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (flags & FSHARP) {
|
if (flags & FSHARP) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue