зеркало из https://github.com/github/ruby.git
Mon Jan 15 16:00:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_unpack): should check associated pointer packed by pack("P"). restriction added. Sun Jan 14 21:49:28 2001 Koji Arai <JCA02266@nifty.ne.jp> * sprintf.c (rb_f_sprintf): simple typo. binary base should be 2, not '2'. * re.c (rb_reg_s_last_match): should explicitly return nth match. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
ac8a2a31c2
Коммит
971a4d94f0
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Mon Jan 15 16:00:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* pack.c (pack_unpack): should check associated pointer packed by
|
||||
pack("P"). restriction added.
|
||||
|
||||
Sun Jan 14 21:49:28 2001 Koji Arai <JCA02266@nifty.ne.jp>
|
||||
|
||||
* sprintf.c (rb_f_sprintf): simple typo. binary base should be 2,
|
||||
not '2'.
|
||||
|
||||
* re.c (rb_reg_s_last_match): should explicitly return nth match.
|
||||
|
||||
Sun Jan 14 18:21:30 2001 Usaku Nakamura <usa@osb.att.ne.jp>
|
||||
|
||||
* win32/config.status.in: add some field.
|
||||
|
@ -30,6 +42,12 @@ Thu Jan 11 10:45:04 2001 WATANABE Hirofumi <eban@ruby-lang.org>
|
|||
|
||||
* djgpp/config.hin (INLINE): removed.
|
||||
|
||||
Thu Jan 11 06:45:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* object.c (rb_mod_dup): should propagate FL_SINGLETON.
|
||||
|
||||
* object.c (inspect_obj): handles the case of no instance variable.
|
||||
|
||||
Wed Jan 10 16:15:08 2001 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||
|
||||
* ruby.h: NORETURN macro is changed for VC++ 6.0.
|
||||
|
|
1
eval.c
1
eval.c
|
@ -6300,6 +6300,7 @@ block_pass(self, node)
|
|||
}
|
||||
POP_TAG();
|
||||
POP_ITER();
|
||||
printf("state: %d(%d)\n", state, _block.tag->dst);
|
||||
if (_block.tag->dst == state) {
|
||||
if (orphan) {
|
||||
state &= TAG_MASK;
|
||||
|
|
2
hash.c
2
hash.c
|
@ -381,8 +381,8 @@ rb_hash_indexes(argc, argv, hash)
|
|||
indexes = rb_ary_new2(argc);
|
||||
for (i=0; i<argc; i++) {
|
||||
RARRAY(indexes)->ptr[i] = rb_hash_aref(hash, argv[i]);
|
||||
RARRAY(indexes)->len++;
|
||||
}
|
||||
RARRAY(indexes)->len = i;
|
||||
return indexes;
|
||||
}
|
||||
|
||||
|
|
1
intern.h
1
intern.h
|
@ -325,6 +325,7 @@ VALUE rb_str_upto _((VALUE, VALUE, int));
|
|||
VALUE rb_str_inspect _((VALUE));
|
||||
VALUE rb_str_split _((VALUE, const char*));
|
||||
void rb_str_associate _((VALUE, VALUE));
|
||||
VALUE rb_str_associated _((VALUE));
|
||||
void rb_str_setter _((VALUE, ID, VALUE*));
|
||||
/* struct.c */
|
||||
VALUE rb_struct_new __((VALUE, ...));
|
||||
|
|
2
io.c
2
io.c
|
@ -2283,7 +2283,7 @@ prep_stdio(f, mode, klass)
|
|||
return (VALUE)io;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
static void
|
||||
prep_path(io, path)
|
||||
VALUE io;
|
||||
char *path;
|
||||
|
|
|
@ -370,10 +370,9 @@ def create_makefile(target, srcdir = File.dirname($0))
|
|||
end
|
||||
$DLDFLAGS = CONFIG["DLDFLAGS"]
|
||||
|
||||
if $configure_args['--enable-shared'] or CONFIG['LIBRUBY'] != CONFIG['LIBRUBY_A']
|
||||
$libs = CONFIG["LIBRUBYARG"] + " " + $libs
|
||||
$LIBPATH |= ["$(topdir)", CONFIG["libdir"]]
|
||||
end
|
||||
$libs = CONFIG["LIBRUBYARG"] + " " + $libs
|
||||
$configure_args['--enable-shared'] or $LIBPATH |= ["$(topdir)"]
|
||||
$LIBPATH |= [CONFIG["libdir"]]
|
||||
|
||||
defflag = ''
|
||||
if RUBY_PLATFORM =~ /cygwin|mingw/
|
||||
|
|
|
@ -113,12 +113,6 @@ extern char *getenv();
|
|||
extern char *strchr();
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define inline __inline__
|
||||
#else
|
||||
#define inline /**/
|
||||
#endif
|
||||
|
||||
#define range(low, item, hi) max(low, min(item, hi))
|
||||
|
||||
#if !defined(OS2) && !defined(MSDOS) && defined(HAVE_TZNAME)
|
||||
|
|
|
@ -108,9 +108,7 @@
|
|||
#define __const
|
||||
#endif /* People who don't like const sys_error */
|
||||
|
||||
#if defined NT && !defined __MINGW32__
|
||||
typedef long size_t;
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
|
@ -1095,8 +1093,6 @@ vsnprintf(str, n, fmt, ap)
|
|||
static char sccsid[] = "@(#)snprintf.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(__STDC__)
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
|
|
42
object.c
42
object.c
|
@ -162,6 +162,7 @@ inspect_i(id, value, str)
|
|||
if (!rb_is_instance_id(id)) return ST_CONTINUE;
|
||||
if (RSTRING(str)->ptr[0] == '-') { /* first element */
|
||||
RSTRING(str)->ptr[0] = '#';
|
||||
rb_str_cat2(str, " ");
|
||||
}
|
||||
else {
|
||||
rb_str_cat2(str, ", ");
|
||||
|
@ -182,6 +183,7 @@ inspect_obj(obj, str)
|
|||
{
|
||||
st_foreach(ROBJECT(obj)->iv_tbl, inspect_i, str);
|
||||
rb_str_cat2(str, ">");
|
||||
RSTRING(str)->ptr[0] = '#';
|
||||
OBJ_INFECT(str, obj);
|
||||
|
||||
return str;
|
||||
|
@ -205,7 +207,7 @@ rb_obj_inspect(obj)
|
|||
return str;
|
||||
}
|
||||
str = rb_str_new(0, strlen(c)+6+16+1); /* 6:tags 16:addr 1:eos */
|
||||
sprintf(RSTRING(str)->ptr, "-<%s:0x%lx ", c, obj);
|
||||
sprintf(RSTRING(str)->ptr, "-<%s:0x%lx", c, obj);
|
||||
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
|
||||
return rb_protect_inspect(inspect_obj, obj, str);
|
||||
}
|
||||
|
@ -286,10 +288,12 @@ rb_obj_taint(obj)
|
|||
VALUE obj;
|
||||
{
|
||||
rb_secure(4);
|
||||
if (OBJ_FROZEN(obj)) {
|
||||
rb_error_frozen("object");
|
||||
if (OBJ_TAINTED(obj)) {
|
||||
if (OBJ_FROZEN(obj)) {
|
||||
rb_error_frozen("object");
|
||||
}
|
||||
OBJ_TAINT(obj);
|
||||
}
|
||||
OBJ_TAINT(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -298,10 +302,12 @@ rb_obj_untaint(obj)
|
|||
VALUE obj;
|
||||
{
|
||||
rb_secure(3);
|
||||
if (OBJ_FROZEN(obj)) {
|
||||
rb_error_frozen("object");
|
||||
if (!OBJ_TAINTED(obj)) {
|
||||
if (OBJ_FROZEN(obj)) {
|
||||
rb_error_frozen("object");
|
||||
}
|
||||
FL_UNSET(obj, FL_TAINT);
|
||||
}
|
||||
FL_UNSET(obj, FL_TAINT);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -309,10 +315,13 @@ VALUE
|
|||
rb_obj_freeze(obj)
|
||||
VALUE obj;
|
||||
{
|
||||
if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj))
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't freeze object");
|
||||
|
||||
OBJ_FREEZE(obj);
|
||||
if (OBJ_FROZEN(obj)) {
|
||||
if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj)) {
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't freeze object");
|
||||
}
|
||||
|
||||
OBJ_FREEZE(obj);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -538,11 +547,14 @@ rb_mod_clone(module)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
rb_mod_dup(module)
|
||||
VALUE module;
|
||||
rb_mod_dup(mod)
|
||||
VALUE mod;
|
||||
{
|
||||
VALUE dup = rb_mod_clone(module);
|
||||
OBJSETUP(dup, RBASIC(module)->klass, BUILTIN_TYPE(module));
|
||||
VALUE dup = rb_mod_clone(mod);
|
||||
OBJSETUP(dup, RBASIC(mod)->klass, BUILTIN_TYPE(mod));
|
||||
if (FL_TEST(mod, FL_SINGLETON)) {
|
||||
FL_SET(dup, FL_SINGLETON);
|
||||
}
|
||||
return dup;
|
||||
}
|
||||
|
||||
|
|
37
pack.c
37
pack.c
|
@ -857,11 +857,11 @@ pack_pack(ary, fmt)
|
|||
while (len-- > 0) {
|
||||
char *t;
|
||||
from = NEXTFROM;
|
||||
if (NIL_P(from)) t = "";
|
||||
else {
|
||||
t = STR2CSTR(from);
|
||||
rb_str_associate(res, from);
|
||||
if (NIL_P(from)) {
|
||||
from = rb_str_new(0, 0);
|
||||
}
|
||||
t = STR2CSTR(from);
|
||||
rb_str_associate(res, from);
|
||||
rb_str_cat(res, (char*)&t, sizeof(char*));
|
||||
}
|
||||
break;
|
||||
|
@ -1611,12 +1611,33 @@ pack_unpack(str, fmt)
|
|||
case 'P':
|
||||
if (sizeof(char *) <= send - s) {
|
||||
char *t;
|
||||
VALUE str = rb_str_new(0, 0);
|
||||
VALUE a, tmp;
|
||||
|
||||
if (!(a = rb_str_associated(str))) {
|
||||
rb_raise(rb_eArgError, "no associated pointer");
|
||||
}
|
||||
memcpy(&t, s, sizeof(char *));
|
||||
s += sizeof(char *);
|
||||
if (t)
|
||||
rb_str_cat(str, t, len);
|
||||
rb_ary_push(ary, str);
|
||||
|
||||
if (t) {
|
||||
VALUE *p, *pend;
|
||||
|
||||
p = RARRAY(a)->ptr;
|
||||
pend = p + RARRAY(a)->len;
|
||||
while (p < pend) {
|
||||
if (TYPE(*p) == T_STRING && RSTRING(*p)->ptr == t)
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
if (p == pend) {
|
||||
rb_raise(rb_eArgError, "non associated pointer");
|
||||
}
|
||||
tmp = rb_str_new(t, len);
|
||||
}
|
||||
else {
|
||||
tmp = rb_str_new(0, 0);
|
||||
}
|
||||
rb_ary_push(ary, tmp);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
2
prec.c
2
prec.c
|
@ -43,7 +43,7 @@ prec_prec_f(x)
|
|||
|
||||
static VALUE
|
||||
prec_induced_from(module, x)
|
||||
|
||||
VALUE module, x;
|
||||
{
|
||||
rb_raise(rb_eTypeError, "undefined conversion from %s into %s",
|
||||
rb_class2name(CLASS_OF(x)), rb_class2name(module));
|
||||
|
|
29
re.c
29
re.c
|
@ -726,19 +726,6 @@ last_match_getter()
|
|||
return rb_reg_last_match(rb_backref_get());
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_reg_s_last_match(argc, argv)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
{
|
||||
VALUE nth;
|
||||
|
||||
if (rb_scan_args(argc, argv, "01", &nth) == 1) {
|
||||
rb_reg_nth_match(NUM2INT(nth), rb_backref_get());
|
||||
}
|
||||
return rb_reg_last_match(rb_backref_get());
|
||||
}
|
||||
|
||||
static VALUE
|
||||
prematch_getter()
|
||||
{
|
||||
|
@ -1028,6 +1015,7 @@ rb_reg_initialize_m(argc, argv, self)
|
|||
p = rb_str2cstr(src, &len);
|
||||
rb_reg_initialize(self, p, len, flag);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -1331,6 +1319,19 @@ match_setter(val)
|
|||
rb_backref_set(val);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_reg_s_last_match(argc, argv)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
{
|
||||
VALUE nth;
|
||||
|
||||
if (rb_scan_args(argc, argv, "01", &nth) == 1) {
|
||||
return rb_reg_nth_match(NUM2INT(nth), rb_backref_get());
|
||||
}
|
||||
return match_getter();
|
||||
}
|
||||
|
||||
void
|
||||
Init_Regexp()
|
||||
{
|
||||
|
@ -1366,7 +1367,7 @@ Init_Regexp()
|
|||
rb_define_singleton_method(rb_cRegexp, "compile", rb_reg_s_new, -1);
|
||||
rb_define_singleton_method(rb_cRegexp, "quote", rb_reg_s_quote, -1);
|
||||
rb_define_singleton_method(rb_cRegexp, "escape", rb_reg_s_quote, -1);
|
||||
rb_define_singleton_method(rb_cRegexp, "last_match", rb_reg_s_last_match, 0);
|
||||
rb_define_singleton_method(rb_cRegexp, "last_match", rb_reg_s_last_match, -1);
|
||||
|
||||
rb_define_method(rb_cRegexp, "initialize", rb_reg_initialize_m, -1);
|
||||
rb_define_method(rb_cRegexp, "clone", rb_reg_clone, 0);
|
||||
|
|
|
@ -566,7 +566,7 @@ rb_f_sprintf(argc, argv)
|
|||
break;
|
||||
case 8:
|
||||
c = '7'; break;
|
||||
case '2':
|
||||
case 2:
|
||||
c = '1'; break;
|
||||
}
|
||||
s = &buf[pos];
|
||||
|
|
10
string.c
10
string.c
|
@ -174,6 +174,16 @@ rb_str_associate(str, add)
|
|||
rb_ary_push(RSTRING(str)->orig, add);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_str_associated(str)
|
||||
VALUE str;
|
||||
{
|
||||
if (!FL_TEST(str, STR_NO_ORIG)) {
|
||||
return Qfalse;
|
||||
}
|
||||
return RSTRING(str)->orig;
|
||||
}
|
||||
|
||||
static ID to_str;
|
||||
|
||||
VALUE
|
||||
|
|
Загрузка…
Ссылка в новой задаче