зеркало из https://github.com/github/ruby.git
* parse.y (parser_parse_string): mention "regexp" in a error
message. a patch from Mauricio Fernandez <mfp at acm.org> [ruby-core:07340] * eval.c (rb_f_autoload): check if ruby_cbase is nil (during instance_eval for objects cannot have singleton classes, e.g. fixnums and symbols). [ruby-dev:28178] * gc.c (rb_gc_call_finalizer_at_exit): turn on during_gc while invoking finalizers. * gc.c (rb_gc_finalize_deferred): ditto. * io.c (rb_write_error2): use fwrite(3) if rb_stderr is not updated or is already freed. [ruby-dev:28313] * eval.c (error_line): include the class name of a surrounding method in error position description. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
c37c5419d2
Коммит
7f72360259
36
ChangeLog
36
ChangeLog
|
@ -1,3 +1,9 @@
|
||||||
|
Mon Feb 13 13:49:48 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* parse.y (parser_parse_string): mention "regexp" in a error
|
||||||
|
message. a patch from Mauricio Fernandez <mfp at acm.org>
|
||||||
|
[ruby-core:07340]
|
||||||
|
|
||||||
Mon Feb 13 00:01:32 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
|
Mon Feb 13 00:01:32 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
|
||||||
|
|
||||||
* oniguruma.h: Version 4.0.1
|
* oniguruma.h: Version 4.0.1
|
||||||
|
@ -18,16 +24,46 @@ Sat Feb 11 21:57:29 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||||
|
|
||||||
* ext/win32ole/tests/testWIN32OLE.rb: ditto.
|
* ext/win32ole/tests/testWIN32OLE.rb: ditto.
|
||||||
|
|
||||||
|
Sat Feb 11 01:57:44 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_f_autoload): check if ruby_cbase is nil (during
|
||||||
|
instance_eval for objects cannot have singleton classes,
|
||||||
|
e.g. fixnums and symbols). [ruby-dev:28178]
|
||||||
|
|
||||||
|
Fri Feb 10 12:31:05 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_eval): should support NODE_ZSUPER in NODE_ITER.
|
||||||
|
[ruby-dev:28326]
|
||||||
|
|
||||||
|
* eval.c (ZSUPER_ARGS): support macro.
|
||||||
|
|
||||||
|
Wed Feb 8 10:26:06 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* gc.c (rb_gc_call_finalizer_at_exit): turn on during_gc while
|
||||||
|
invoking finalizers.
|
||||||
|
|
||||||
|
* gc.c (rb_gc_finalize_deferred): ditto.
|
||||||
|
|
||||||
Tue Feb 7 23:03:13 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
Tue Feb 7 23:03:13 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||||
|
|
||||||
* ext/zlib/zlib.c: should not access ruby objects in finalizer.
|
* ext/zlib/zlib.c: should not access ruby objects in finalizer.
|
||||||
[ruby-dev:28286]
|
[ruby-dev:28286]
|
||||||
|
|
||||||
|
Tue Feb 7 18:42:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (rb_write_error2): use fwrite(3) if rb_stderr is not
|
||||||
|
updated or is already freed. [ruby-dev:28313]
|
||||||
|
|
||||||
Mon Feb 6 16:02:51 2006 WATANABE Hirofumi <eban@ruby-lang.org>
|
Mon Feb 6 16:02:51 2006 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* file.c (rb_thread_flock): ERROR_NOT_LOCKED is not an error on Cygwin.
|
* file.c (rb_thread_flock): ERROR_NOT_LOCKED is not an error on Cygwin.
|
||||||
In such situation, flock() should return 0.
|
In such situation, flock() should return 0.
|
||||||
|
|
||||||
|
Mon Feb 6 14:36:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (error_line): include the class name of a surrounding
|
||||||
|
method in error position description.
|
||||||
|
|
||||||
Mon Feb 6 00:14:57 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Mon Feb 6 00:14:57 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* enum.c (enum_find_index): a new method Enumerable#find_index.
|
* enum.c (enum_find_index): a new method Enumerable#find_index.
|
||||||
|
|
13
error.c
13
error.c
|
@ -961,7 +961,13 @@ Init_Exception(void)
|
||||||
rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
|
rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
|
||||||
rb_eKeyError = rb_define_class("KeyError", rb_eIndexError);
|
rb_eKeyError = rb_define_class("KeyError", rb_eIndexError);
|
||||||
rb_eRangeError = rb_define_class("RangeError", rb_eStandardError);
|
rb_eRangeError = rb_define_class("RangeError", rb_eStandardError);
|
||||||
rb_eNameError = rb_define_class("NameError", rb_eException);
|
|
||||||
|
rb_eScriptError = rb_define_class("ScriptError", rb_eException);
|
||||||
|
rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError);
|
||||||
|
rb_eLoadError = rb_define_class("LoadError", rb_eScriptError);
|
||||||
|
rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError);
|
||||||
|
|
||||||
|
rb_eNameError = rb_define_class("NameError", rb_eScriptError);
|
||||||
rb_define_method(rb_eNameError, "initialize", name_err_initialize, -1);
|
rb_define_method(rb_eNameError, "initialize", name_err_initialize, -1);
|
||||||
rb_define_method(rb_eNameError, "name", name_err_name, 0);
|
rb_define_method(rb_eNameError, "name", name_err_name, 0);
|
||||||
rb_define_method(rb_eNameError, "to_s", name_err_to_s, 0);
|
rb_define_method(rb_eNameError, "to_s", name_err_to_s, 0);
|
||||||
|
@ -975,11 +981,6 @@ Init_Exception(void)
|
||||||
rb_define_method(rb_eNoMethodError, "initialize", nometh_err_initialize, -1);
|
rb_define_method(rb_eNoMethodError, "initialize", nometh_err_initialize, -1);
|
||||||
rb_define_method(rb_eNoMethodError, "args", nometh_err_args, 0);
|
rb_define_method(rb_eNoMethodError, "args", nometh_err_args, 0);
|
||||||
|
|
||||||
rb_eScriptError = rb_define_class("ScriptError", rb_eException);
|
|
||||||
rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError);
|
|
||||||
rb_eLoadError = rb_define_class("LoadError", rb_eScriptError);
|
|
||||||
rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError);
|
|
||||||
|
|
||||||
rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
|
rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
|
||||||
rb_eSecurityError = rb_define_class("SecurityError", rb_eStandardError);
|
rb_eSecurityError = rb_define_class("SecurityError", rb_eStandardError);
|
||||||
rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException);
|
rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException);
|
||||||
|
|
291
eval.c
291
eval.c
|
@ -248,14 +248,15 @@ static VALUE rb_mod_define_method(int, VALUE*, VALUE);
|
||||||
NORETURN(static void rb_raise_jump(VALUE));
|
NORETURN(static void rb_raise_jump(VALUE));
|
||||||
static VALUE rb_make_exception(int argc, VALUE *argv);
|
static VALUE rb_make_exception(int argc, VALUE *argv);
|
||||||
|
|
||||||
static int scope_vmode;
|
static int vis_mode;
|
||||||
#define SCOPE_PUBLIC 0
|
#define VIS_PUBLIC 0
|
||||||
#define SCOPE_PRIVATE 1
|
#define VIS_PRIVATE 1
|
||||||
#define SCOPE_PROTECTED 2
|
#define VIS_PROTECTED 2
|
||||||
#define SCOPE_MODFUNC 5
|
#define VIS_MODFUNC 5
|
||||||
#define SCOPE_MASK 7
|
#define VIS_MASK 7
|
||||||
#define SCOPE_SET(f) (scope_vmode=(f))
|
#define VIS_SET(f) (vis_mode=(f))
|
||||||
#define SCOPE_TEST(f) (scope_vmode&(f))
|
#define VIS_TEST(f) (vis_mode&(f))
|
||||||
|
#define VIS_MODE(f) (vis_mode)
|
||||||
|
|
||||||
NODE* ruby_current_node;
|
NODE* ruby_current_node;
|
||||||
int ruby_safe_level = 0;
|
int ruby_safe_level = 0;
|
||||||
|
@ -672,13 +673,13 @@ rb_attr(VALUE klass, ID id, int read, int write, int ex)
|
||||||
|
|
||||||
if (!ex) noex = NOEX_PUBLIC;
|
if (!ex) noex = NOEX_PUBLIC;
|
||||||
else {
|
else {
|
||||||
if (SCOPE_TEST(SCOPE_PRIVATE)) {
|
if (VIS_TEST(VIS_PRIVATE)) {
|
||||||
noex = NOEX_PRIVATE;
|
noex = NOEX_PRIVATE;
|
||||||
rb_warning((scope_vmode == SCOPE_MODFUNC) ?
|
rb_warning((VIS_MODE() == VIS_MODFUNC) ?
|
||||||
"attribute accessor as module_function" :
|
"attribute accessor as module_function" :
|
||||||
"private attribute?");
|
"private attribute?");
|
||||||
}
|
}
|
||||||
else if (SCOPE_TEST(SCOPE_PROTECTED)) {
|
else if (VIS_TEST(VIS_PROTECTED)) {
|
||||||
noex = NOEX_PROTECTED;
|
noex = NOEX_PROTECTED;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -729,6 +730,9 @@ static unsigned long frame_unique = 0;
|
||||||
_frame.block = (link)?ruby_frame->block:0;\
|
_frame.block = (link)?ruby_frame->block:0;\
|
||||||
_frame.flags = 0; \
|
_frame.flags = 0; \
|
||||||
_frame.uniq = frame_unique++; \
|
_frame.uniq = frame_unique++; \
|
||||||
|
_frame.callee = 0; \
|
||||||
|
_frame.this_func = 0; \
|
||||||
|
_frame.this_class = 0; \
|
||||||
ruby_frame = &_frame
|
ruby_frame = &_frame
|
||||||
|
|
||||||
#define POP_FRAME() \
|
#define POP_FRAME() \
|
||||||
|
@ -747,7 +751,7 @@ static unsigned long block_unique = 0;
|
||||||
_block.cref = ruby_cref; \
|
_block.cref = ruby_cref; \
|
||||||
_block.frame.node = ruby_current_node;\
|
_block.frame.node = ruby_current_node;\
|
||||||
_block.scope = ruby_scope; \
|
_block.scope = ruby_scope; \
|
||||||
_block.vmode = scope_vmode; \
|
_block.vmode = vis_mode; \
|
||||||
_block.flags = BLOCK_D_SCOPE; \
|
_block.flags = BLOCK_D_SCOPE; \
|
||||||
_block.dyna_vars = ruby_dyna_vars; \
|
_block.dyna_vars = ruby_dyna_vars; \
|
||||||
_block.wrapper = ruby_wrapper; \
|
_block.wrapper = ruby_wrapper; \
|
||||||
|
@ -776,6 +780,8 @@ struct RVarmap *ruby_dyna_vars;
|
||||||
|
|
||||||
#define DVAR_DONT_RECYCLE FL_USER2
|
#define DVAR_DONT_RECYCLE FL_USER2
|
||||||
|
|
||||||
|
#define DMETHOD_P() (ruby_frame->prev ? (ruby_frame->prev->flags & FRAME_DMETH) : 0)
|
||||||
|
|
||||||
static struct RVarmap*
|
static struct RVarmap*
|
||||||
new_dvar(ID id, VALUE value, struct RVarmap *prev)
|
new_dvar(ID id, VALUE value, struct RVarmap *prev)
|
||||||
{
|
{
|
||||||
|
@ -953,7 +959,7 @@ static NODE *top_cref;
|
||||||
#define POP_CREF() ruby_cref = ruby_cref->nd_next
|
#define POP_CREF() ruby_cref = ruby_cref->nd_next
|
||||||
|
|
||||||
#define PUSH_SCOPE() do { \
|
#define PUSH_SCOPE() do { \
|
||||||
volatile int _vmode = scope_vmode; \
|
volatile int _vmode = vis_mode; \
|
||||||
struct SCOPE * volatile _old; \
|
struct SCOPE * volatile _old; \
|
||||||
NEWOBJ(_scope, struct SCOPE); \
|
NEWOBJ(_scope, struct SCOPE); \
|
||||||
OBJSETUP(_scope, 0, T_SCOPE); \
|
OBJSETUP(_scope, 0, T_SCOPE); \
|
||||||
|
@ -962,7 +968,7 @@ static NODE *top_cref;
|
||||||
_scope->flags = 0; \
|
_scope->flags = 0; \
|
||||||
_old = ruby_scope; \
|
_old = ruby_scope; \
|
||||||
ruby_scope = _scope; \
|
ruby_scope = _scope; \
|
||||||
scope_vmode = SCOPE_PUBLIC
|
vis_mode = VIS_PUBLIC
|
||||||
|
|
||||||
typedef struct thread * rb_thread_t;
|
typedef struct thread * rb_thread_t;
|
||||||
static rb_thread_t curr_thread = 0;
|
static rb_thread_t curr_thread = 0;
|
||||||
|
@ -983,7 +989,7 @@ static void scope_dup(struct SCOPE *);
|
||||||
} \
|
} \
|
||||||
ruby_scope->flags |= SCOPE_NOSTACK; \
|
ruby_scope->flags |= SCOPE_NOSTACK; \
|
||||||
ruby_scope = _old; \
|
ruby_scope = _old; \
|
||||||
scope_vmode = _vmode; \
|
vis_mode = _vmode; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
struct ruby_env {
|
struct ruby_env {
|
||||||
|
@ -1083,25 +1089,58 @@ warn_printf(const char *fmt, ...)
|
||||||
rb_write_error(buf);
|
rb_write_error(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
error_line(struct FRAME *frame, NODE *node)
|
||||||
|
{
|
||||||
|
char *file;
|
||||||
|
int line;
|
||||||
|
|
||||||
|
if (node) {
|
||||||
|
file = node->nd_file;
|
||||||
|
line = nd_line(node);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
file = ruby_sourcefile;
|
||||||
|
line = ruby_sourceline;
|
||||||
|
}
|
||||||
|
ruby_set_current_source();
|
||||||
|
if (ruby_sourcefile) {
|
||||||
|
if (frame->callee) {
|
||||||
|
if (frame->flags & FRAME_FUNC) {
|
||||||
|
return rb_sprintf("%s:%d:in `%s'", file, line,
|
||||||
|
rb_id2name(frame->this_func));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
VALUE oklass = frame->this_class;
|
||||||
|
|
||||||
|
if (TYPE(oklass) == T_ICLASS) {
|
||||||
|
oklass = RBASIC(oklass)->klass;
|
||||||
|
}
|
||||||
|
else if (FL_TEST(oklass, FL_SINGLETON)) {
|
||||||
|
oklass = rb_iv_get(oklass, "__attached__");
|
||||||
|
}
|
||||||
|
return rb_sprintf("%s:%d:in `%s#%s'", file, line,
|
||||||
|
rb_class2name(oklass),
|
||||||
|
rb_id2name(frame->this_func));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!node && ruby_sourceline == 0) {
|
||||||
|
return rb_str_new2(ruby_sourcefile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return rb_sprintf("%s:%d", file, line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define warn_print(x) rb_write_error(x)
|
#define warn_print(x) rb_write_error(x)
|
||||||
#define warn_print2(x,l) rb_write_error2(x,l)
|
#define warn_print2(x,l) rb_write_error2(x,l)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
error_pos(void)
|
error_pos(void)
|
||||||
{
|
{
|
||||||
ruby_set_current_source();
|
VALUE pos = error_line(ruby_frame, 0);
|
||||||
if (ruby_sourcefile) {
|
warn_printf("%s", StringValueCStr(pos));
|
||||||
if (ruby_frame->callee) {
|
|
||||||
warn_printf("%s:%d:in `%s'", ruby_sourcefile, ruby_sourceline,
|
|
||||||
rb_id2name(ruby_frame->callee));
|
|
||||||
}
|
|
||||||
else if (ruby_sourceline == 0) {
|
|
||||||
warn_printf("%s", ruby_sourcefile);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
warn_printf("%s:%d", ruby_sourcefile, ruby_sourceline);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -1285,7 +1324,7 @@ ruby_init(void)
|
||||||
PUSH_SCOPE();
|
PUSH_SCOPE();
|
||||||
top_scope = ruby_scope;
|
top_scope = ruby_scope;
|
||||||
/* default visibility is private at toplevel */
|
/* default visibility is private at toplevel */
|
||||||
SCOPE_SET(SCOPE_PRIVATE);
|
VIS_SET(VIS_PRIVATE);
|
||||||
|
|
||||||
PUSH_TAG(PROT_NONE);
|
PUSH_TAG(PROT_NONE);
|
||||||
if ((state = EXEC_TAG()) == 0) {
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
|
@ -1495,7 +1534,7 @@ ruby_exec_internal(void)
|
||||||
|
|
||||||
PUSH_THREAD_TAG();
|
PUSH_THREAD_TAG();
|
||||||
/* default visibility is private at toplevel */
|
/* default visibility is private at toplevel */
|
||||||
SCOPE_SET(SCOPE_PRIVATE);
|
VIS_SET(VIS_PRIVATE);
|
||||||
if ((state = EXEC_TAG()) == 0) {
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
eval_node(ruby_top_self, ruby_eval_tree);
|
eval_node(ruby_top_self, ruby_eval_tree);
|
||||||
}
|
}
|
||||||
|
@ -1582,9 +1621,6 @@ rb_eval_string_wrap(const char *str, int *state)
|
||||||
ruby_top_self = rb_obj_clone(ruby_top_self);
|
ruby_top_self = rb_obj_clone(ruby_top_self);
|
||||||
rb_extend_object(ruby_top_self, ruby_wrapper);
|
rb_extend_object(ruby_top_self, ruby_wrapper);
|
||||||
PUSH_FRAME(Qfalse);
|
PUSH_FRAME(Qfalse);
|
||||||
ruby_frame->callee = 0;
|
|
||||||
ruby_frame->this_func = 0;
|
|
||||||
ruby_frame->this_class = 0;
|
|
||||||
ruby_frame->self = self;
|
ruby_frame->self = self;
|
||||||
PUSH_CREF(ruby_wrapper = rb_module_new());
|
PUSH_CREF(ruby_wrapper = rb_module_new());
|
||||||
PUSH_SCOPE();
|
PUSH_SCOPE();
|
||||||
|
@ -1712,9 +1748,6 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level)
|
||||||
saved_scope = ruby_scope;
|
saved_scope = ruby_scope;
|
||||||
ruby_scope = top_scope;
|
ruby_scope = top_scope;
|
||||||
PUSH_FRAME(Qfalse);
|
PUSH_FRAME(Qfalse);
|
||||||
ruby_frame->callee = 0;
|
|
||||||
ruby_frame->this_func = 0;
|
|
||||||
ruby_frame->this_class = 0;
|
|
||||||
ruby_frame->self = ruby_top_self;
|
ruby_frame->self = ruby_top_self;
|
||||||
PUSH_CREF(ruby_wrapper ? ruby_wrapper : rb_cObject);
|
PUSH_CREF(ruby_wrapper ? ruby_wrapper : rb_cObject);
|
||||||
|
|
||||||
|
@ -1743,49 +1776,47 @@ ruby_current_class_object()
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
ev_const_defined(NODE *cref, ID id, VALUE self)
|
ev_const_defined(ID id, VALUE self)
|
||||||
{
|
{
|
||||||
NODE *cbase = cref;
|
NODE *cbase = ruby_cref;
|
||||||
VALUE result;
|
VALUE result;
|
||||||
|
|
||||||
while (cbase && cbase->nd_next) {
|
while (cbase && cbase->nd_next) {
|
||||||
struct RClass *klass = RCLASS(cbase->nd_clss);
|
struct RClass *klass = RCLASS(cbase->nd_clss);
|
||||||
|
|
||||||
if (!NIL_P(klass)) {
|
if (NIL_P(klass)) return rb_const_defined(CLASS_OF(self), id);
|
||||||
if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) {
|
if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) {
|
||||||
if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) {
|
if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) {
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
}
|
|
||||||
return Qtrue;
|
|
||||||
}
|
}
|
||||||
|
return Qtrue;
|
||||||
}
|
}
|
||||||
cbase = cbase->nd_next;
|
cbase = cbase->nd_next;
|
||||||
}
|
}
|
||||||
return rb_const_defined(cref->nd_clss, id);
|
return rb_const_defined(ruby_cbase, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
ev_const_get(NODE *cref, ID id, VALUE self)
|
ev_const_get(ID id, VALUE self)
|
||||||
{
|
{
|
||||||
NODE *cbase = cref;
|
NODE *cbase = ruby_cref;
|
||||||
VALUE result;
|
VALUE result;
|
||||||
|
|
||||||
while (cbase && cbase->nd_next) {
|
while (cbase && cbase->nd_next) {
|
||||||
VALUE klass = cbase->nd_clss;
|
VALUE klass = cbase->nd_clss;
|
||||||
|
|
||||||
if (!NIL_P(klass)) {
|
if (NIL_P(klass)) return rb_const_get(CLASS_OF(self), id);
|
||||||
while (RCLASS(klass)->iv_tbl &&
|
while (RCLASS(klass)->iv_tbl &&
|
||||||
st_lookup(RCLASS(klass)->iv_tbl, id, &result)) {
|
st_lookup(RCLASS(klass)->iv_tbl, id, &result)) {
|
||||||
if (result == Qundef) {
|
if (result == Qundef) {
|
||||||
if (!RTEST(rb_autoload_load(klass, id))) break;
|
if (!RTEST(rb_autoload_load(klass, id))) break;
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
cbase = cbase->nd_next;
|
cbase = cbase->nd_next;
|
||||||
}
|
}
|
||||||
return rb_const_get(cref->nd_clss, id);
|
return rb_const_get(ruby_cbase, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -2071,7 +2102,8 @@ rb_mod_alias_method(VALUE mod, VALUE newname, VALUE oldname)
|
||||||
static NODE*
|
static NODE*
|
||||||
copy_node_scope(NODE *node, NODE *rval)
|
copy_node_scope(NODE *node, NODE *rval)
|
||||||
{
|
{
|
||||||
NODE *copy = NEW_NODE(NODE_SCOPE,0,rval,node->nd_next);
|
NODE *cref = NEW_NODE(NODE_CREF,rval->nd_clss,0,rval->nd_next);;
|
||||||
|
NODE *copy = NEW_NODE(NODE_SCOPE,0,cref,node->nd_next);
|
||||||
|
|
||||||
if (node->nd_tbl) {
|
if (node->nd_tbl) {
|
||||||
copy->nd_tbl = ALLOC_N(ID, node->nd_tbl[0]+1);
|
copy->nd_tbl = ALLOC_N(ID, node->nd_tbl[0]+1);
|
||||||
|
@ -2128,6 +2160,21 @@ copy_node_scope(NODE *node, NODE *rval)
|
||||||
|
|
||||||
#define SETUP_ARGS(anode) SETUP_ARGS0(anode, anode->nd_alen)
|
#define SETUP_ARGS(anode) SETUP_ARGS0(anode, anode->nd_alen)
|
||||||
|
|
||||||
|
#define ZSUPER_ARGS() do {\
|
||||||
|
argc = ruby_frame->argc;\
|
||||||
|
if (argc && DMETHOD_P()) {\
|
||||||
|
if (TYPE(RBASIC(ruby_scope)->klass) != T_ARRAY ||\
|
||||||
|
RARRAY(RBASIC(ruby_scope)->klass)->len != argc) {\
|
||||||
|
rb_raise(rb_eRuntimeError, \
|
||||||
|
"super: specify arguments explicitly");\
|
||||||
|
}\
|
||||||
|
argv = RARRAY(RBASIC(ruby_scope)->klass)->ptr;\
|
||||||
|
}\
|
||||||
|
else {\
|
||||||
|
argv = ruby_scope->local_vars + 2;\
|
||||||
|
}\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define MATCH_DATA *rb_svar(node->nd_cnt)
|
#define MATCH_DATA *rb_svar(node->nd_cnt)
|
||||||
|
|
||||||
static const char* is_defined(VALUE, NODE*, char*, int);
|
static const char* is_defined(VALUE, NODE*, char*, int);
|
||||||
|
@ -2268,7 +2315,7 @@ is_defined(VALUE self, NODE *node /* OK */, char *buf, int noeval)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_CONST:
|
case NODE_CONST:
|
||||||
if (ev_const_defined(ruby_cref, node->nd_vid, self)) {
|
if (ev_const_defined(node->nd_vid, self)) {
|
||||||
return "constant";
|
return "constant";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2949,6 +2996,8 @@ rb_eval(VALUE self, NODE *n)
|
||||||
case NODE_LAMBDA:
|
case NODE_LAMBDA:
|
||||||
PUSH_TAG(PROT_LOOP);
|
PUSH_TAG(PROT_LOOP);
|
||||||
PUSH_FRAME(Qtrue);
|
PUSH_FRAME(Qtrue);
|
||||||
|
ruby_frame->this_func = 0;
|
||||||
|
ruby_frame->this_class = 0;
|
||||||
PUSH_BLOCK(ruby_frame->block, node->nd_var, node->nd_body);
|
PUSH_BLOCK(ruby_frame->block, node->nd_var, node->nd_body);
|
||||||
state = EXEC_TAG();
|
state = EXEC_TAG();
|
||||||
result = proc_lambda();
|
result = proc_lambda();
|
||||||
|
@ -3283,6 +3332,7 @@ rb_eval(VALUE self, NODE *n)
|
||||||
case NODE_VCALL:
|
case NODE_VCALL:
|
||||||
scope = CALLING_VCALL; break;
|
scope = CALLING_VCALL; break;
|
||||||
case NODE_SUPER:
|
case NODE_SUPER:
|
||||||
|
case NODE_ZSUPER:
|
||||||
scope = CALLING_SUPER; break;
|
scope = CALLING_SUPER; break;
|
||||||
default:
|
default:
|
||||||
/* error! */
|
/* error! */
|
||||||
|
@ -3297,8 +3347,13 @@ rb_eval(VALUE self, NODE *n)
|
||||||
if (scope == CALLING_NORMAL) {
|
if (scope == CALLING_NORMAL) {
|
||||||
recv = rb_eval(self, node->nd_recv);
|
recv = rb_eval(self, node->nd_recv);
|
||||||
}
|
}
|
||||||
SETUP_ARGS(node->nd_args);
|
if (nd_type(node) == NODE_ZSUPER) {
|
||||||
ruby_current_node = node;
|
ZSUPER_ARGS();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SETUP_ARGS(node->nd_args);
|
||||||
|
ruby_current_node = node;
|
||||||
|
}
|
||||||
SET_CURRENT_SOURCE();
|
SET_CURRENT_SOURCE();
|
||||||
if (scope == CALLING_SUPER) {
|
if (scope == CALLING_SUPER) {
|
||||||
result = call_super(argc, argv, block);
|
result = call_super(argc, argv, block);
|
||||||
|
@ -3371,19 +3426,7 @@ rb_eval(VALUE self, NODE *n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nd_type(node) == NODE_ZSUPER) {
|
if (nd_type(node) == NODE_ZSUPER) {
|
||||||
argc = ruby_frame->argc;
|
ZSUPER_ARGS();
|
||||||
if (argc && ruby_frame->prev &&
|
|
||||||
(ruby_frame->prev->flags & FRAME_DMETH)) {
|
|
||||||
if (TYPE(RBASIC(ruby_scope)->klass) != T_ARRAY ||
|
|
||||||
RARRAY(RBASIC(ruby_scope)->klass)->len != argc) {
|
|
||||||
rb_raise(rb_eRuntimeError,
|
|
||||||
"super: specify arguments explicitly");
|
|
||||||
}
|
|
||||||
argv = RARRAY(RBASIC(ruby_scope)->klass)->ptr;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
argv = ruby_scope->local_vars + 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SETUP_ARGS(node->nd_args);
|
SETUP_ARGS(node->nd_args);
|
||||||
|
@ -3579,7 +3622,7 @@ rb_eval(VALUE self, NODE *n)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_CONST:
|
case NODE_CONST:
|
||||||
result = ev_const_get(ruby_cref, node->nd_vid, self);
|
result = ev_const_get(node->nd_vid, self);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_CVAR:
|
case NODE_CVAR:
|
||||||
|
@ -3779,7 +3822,7 @@ rb_eval(VALUE self, NODE *n)
|
||||||
int noex;
|
int noex;
|
||||||
|
|
||||||
if (NIL_P(ruby_cbase)) {
|
if (NIL_P(ruby_cbase)) {
|
||||||
rb_raise(rb_eTypeError, "no class/module to add method");
|
rb_raise(rb_eTypeError, "no class/module to define method");
|
||||||
}
|
}
|
||||||
if (ruby_cbase == rb_cObject && node->nd_mid == init) {
|
if (ruby_cbase == rb_cObject && node->nd_mid == init) {
|
||||||
rb_warn("redefining Object#initialize may cause infinite loop");
|
rb_warn("redefining Object#initialize may cause infinite loop");
|
||||||
|
@ -3796,10 +3839,10 @@ rb_eval(VALUE self, NODE *n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SCOPE_TEST(SCOPE_PRIVATE) || node->nd_mid == init) {
|
if (VIS_TEST(VIS_PRIVATE) || node->nd_mid == init) {
|
||||||
noex = NOEX_PRIVATE;
|
noex = NOEX_PRIVATE;
|
||||||
}
|
}
|
||||||
else if (SCOPE_TEST(SCOPE_PROTECTED)) {
|
else if (VIS_TEST(VIS_PROTECTED)) {
|
||||||
noex = NOEX_PROTECTED;
|
noex = NOEX_PROTECTED;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3811,7 +3854,7 @@ rb_eval(VALUE self, NODE *n)
|
||||||
|
|
||||||
defn = copy_node_scope(node->nd_defn, ruby_cref);
|
defn = copy_node_scope(node->nd_defn, ruby_cref);
|
||||||
rb_add_method(ruby_cbase, node->nd_mid, defn, noex);
|
rb_add_method(ruby_cbase, node->nd_mid, defn, noex);
|
||||||
if (scope_vmode == SCOPE_MODFUNC) {
|
if (VIS_MODE() == VIS_MODFUNC) {
|
||||||
rb_add_method(rb_singleton_class(ruby_cbase),
|
rb_add_method(rb_singleton_class(ruby_cbase),
|
||||||
node->nd_mid, defn, NOEX_PUBLIC);
|
node->nd_mid, defn, NOEX_PUBLIC);
|
||||||
}
|
}
|
||||||
|
@ -4038,6 +4081,7 @@ module_setup(VALUE module, NODE *n)
|
||||||
}
|
}
|
||||||
|
|
||||||
PUSH_CREF(module);
|
PUSH_CREF(module);
|
||||||
|
VIS_SET(VIS_PUBLIC);
|
||||||
PUSH_TAG(PROT_NONE);
|
PUSH_TAG(PROT_NONE);
|
||||||
if ((state = EXEC_TAG()) == 0) {
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
EXEC_EVENT_HOOK(RUBY_EVENT_CLASS, n, ruby_cbase,
|
EXEC_EVENT_HOOK(RUBY_EVENT_CLASS, n, ruby_cbase,
|
||||||
|
@ -4740,8 +4784,8 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags, int avalue)
|
||||||
ruby_wrapper = block->wrapper;
|
ruby_wrapper = block->wrapper;
|
||||||
old_scope = ruby_scope;
|
old_scope = ruby_scope;
|
||||||
ruby_scope = block->scope;
|
ruby_scope = block->scope;
|
||||||
old_vmode = scope_vmode;
|
old_vmode = vis_mode;
|
||||||
scope_vmode = (flags & YIELD_PUBLIC_DEF) ? SCOPE_PUBLIC : block->vmode;
|
vis_mode = (flags & YIELD_PUBLIC_DEF) ? VIS_PUBLIC : block->vmode;
|
||||||
if (block->flags & BLOCK_D_SCOPE) {
|
if (block->flags & BLOCK_D_SCOPE) {
|
||||||
/* put place holder for dynamic (in-block) local variables */
|
/* put place holder for dynamic (in-block) local variables */
|
||||||
ruby_dyna_vars = new_dvar(0, 0, block->dyna_vars);
|
ruby_dyna_vars = new_dvar(0, 0, block->dyna_vars);
|
||||||
|
@ -4926,7 +4970,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags, int avalue)
|
||||||
if (ruby_scope->flags & SCOPE_DONT_RECYCLE)
|
if (ruby_scope->flags & SCOPE_DONT_RECYCLE)
|
||||||
scope_dup(old_scope);
|
scope_dup(old_scope);
|
||||||
ruby_scope = old_scope;
|
ruby_scope = old_scope;
|
||||||
scope_vmode = old_vmode;
|
vis_mode = old_vmode;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
@ -5672,7 +5716,7 @@ formal_assign(VALUE recv, NODE *node, int argc, const VALUE *argv, VALUE *local_
|
||||||
ruby_frame->self = recv;\
|
ruby_frame->self = recv;\
|
||||||
ruby_frame->argc = argc;\
|
ruby_frame->argc = argc;\
|
||||||
ruby_frame->block = block;\
|
ruby_frame->block = block;\
|
||||||
ruby_frame->flags = (flags & NOEX_RECV) ? FRAME_FUNC : 0;\
|
ruby_frame->flags = ((flags & NOEX_RECV) ? FRAME_FUNC : 0) | 0;
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_call0(VALUE klass, VALUE recv, ID id, ID oid,
|
rb_call0(VALUE klass, VALUE recv, ID id, ID oid,
|
||||||
|
@ -5682,6 +5726,7 @@ rb_call0(VALUE klass, VALUE recv, ID id, ID oid,
|
||||||
{
|
{
|
||||||
NODE *b2; /* OK */
|
NODE *b2; /* OK */
|
||||||
volatile VALUE result = Qnil;
|
volatile VALUE result = Qnil;
|
||||||
|
int dmeth = DMETHOD_P();
|
||||||
static int tick;
|
static int tick;
|
||||||
volatile VALUE args;
|
volatile VALUE args;
|
||||||
volatile int safe = -1;
|
volatile int safe = -1;
|
||||||
|
@ -5839,7 +5884,7 @@ rb_call0(VALUE klass, VALUE recv, ID id, ID oid,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TAG_RETRY:
|
case TAG_RETRY:
|
||||||
if (rb_block_given_p()) JUMP_TAG(state);
|
if (block) JUMP_TAG(state);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
jump_tag_but_local_jump(state, result);
|
jump_tag_but_local_jump(state, result);
|
||||||
|
@ -6067,17 +6112,7 @@ backtrace(int lev)
|
||||||
frame = frame->prev;
|
frame = frame->prev;
|
||||||
}
|
}
|
||||||
if (lev < 0) {
|
if (lev < 0) {
|
||||||
ruby_set_current_source();
|
str = error_line(frame, 0);
|
||||||
if (frame->this_func) {
|
|
||||||
str = rb_sprintf("%s:%d:in `%s'", ruby_sourcefile, ruby_sourceline,
|
|
||||||
rb_id2name(frame->this_func));
|
|
||||||
}
|
|
||||||
else if (ruby_sourceline == 0) {
|
|
||||||
str = rb_str_new2(ruby_sourcefile);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
str = rb_sprintf("%s:%d", ruby_sourcefile, ruby_sourceline);
|
|
||||||
}
|
|
||||||
rb_ary_push(ary, str);
|
rb_ary_push(ary, str);
|
||||||
if (lev < -1) return ary;
|
if (lev < -1) return ary;
|
||||||
}
|
}
|
||||||
|
@ -6093,8 +6128,7 @@ backtrace(int lev)
|
||||||
for (; frame && (n = frame->node); frame = frame->prev) {
|
for (; frame && (n = frame->node); frame = frame->prev) {
|
||||||
if (frame->prev && frame->prev->this_func) {
|
if (frame->prev && frame->prev->this_func) {
|
||||||
if (frame->prev->node == n) continue;
|
if (frame->prev->node == n) continue;
|
||||||
str = rb_sprintf("%s:%d:in `%s'", n->nd_file, nd_line(n),
|
str = error_line(frame->prev, n);
|
||||||
rb_id2name(frame->prev->this_func));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
str = rb_sprintf("%s:%d", n->nd_file, nd_line(n));
|
str = rb_sprintf("%s:%d", n->nd_file, nd_line(n));
|
||||||
|
@ -6216,8 +6250,8 @@ eval(VALUE self, VALUE src, VALUE scope, const char *file, int line)
|
||||||
ruby_scope = data->scope;
|
ruby_scope = data->scope;
|
||||||
old_dyna_vars = ruby_dyna_vars;
|
old_dyna_vars = ruby_dyna_vars;
|
||||||
ruby_dyna_vars = data->dyna_vars;
|
ruby_dyna_vars = data->dyna_vars;
|
||||||
old_vmode = scope_vmode;
|
old_vmode = vis_mode;
|
||||||
scope_vmode = data->vmode;
|
vis_mode = data->vmode;
|
||||||
old_cref = (VALUE)ruby_cref;
|
old_cref = (VALUE)ruby_cref;
|
||||||
ruby_cref = data->cref;
|
ruby_cref = data->cref;
|
||||||
old_wrapper = ruby_wrapper;
|
old_wrapper = ruby_wrapper;
|
||||||
|
@ -6264,8 +6298,7 @@ eval(VALUE self, VALUE src, VALUE scope, const char *file, int line)
|
||||||
ruby_frame = frame.tmp;
|
ruby_frame = frame.tmp;
|
||||||
ruby_scope = old_scope;
|
ruby_scope = old_scope;
|
||||||
ruby_dyna_vars = old_dyna_vars;
|
ruby_dyna_vars = old_dyna_vars;
|
||||||
data->vmode = scope_vmode; /* write back visibility mode */
|
vis_mode = old_vmode;
|
||||||
scope_vmode = old_vmode;
|
|
||||||
if (dont_recycle) {
|
if (dont_recycle) {
|
||||||
struct tag *tag;
|
struct tag *tag;
|
||||||
struct RVarmap *vars;
|
struct RVarmap *vars;
|
||||||
|
@ -6381,15 +6414,15 @@ exec_under(VALUE (*func) (VALUE), VALUE under, VALUE args)
|
||||||
ruby_frame->this_class = f->this_class;
|
ruby_frame->this_class = f->this_class;
|
||||||
ruby_frame->argc = f->argc;
|
ruby_frame->argc = f->argc;
|
||||||
|
|
||||||
mode = scope_vmode;
|
mode = vis_mode;
|
||||||
SCOPE_SET(SCOPE_PUBLIC);
|
VIS_SET(VIS_PUBLIC);
|
||||||
PUSH_TAG(PROT_NONE);
|
PUSH_TAG(PROT_NONE);
|
||||||
if ((state = EXEC_TAG()) == 0) {
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
val = (*func)(args);
|
val = (*func)(args);
|
||||||
}
|
}
|
||||||
POP_TAG();
|
POP_TAG();
|
||||||
POP_CREF();
|
POP_CREF();
|
||||||
SCOPE_SET(mode);
|
VIS_SET(mode);
|
||||||
POP_FRAME();
|
POP_FRAME();
|
||||||
if (state) JUMP_TAG(state);
|
if (state) JUMP_TAG(state);
|
||||||
|
|
||||||
|
@ -6650,16 +6683,15 @@ rb_load(VALUE fname, int wrap)
|
||||||
self = rb_obj_clone(ruby_top_self);
|
self = rb_obj_clone(ruby_top_self);
|
||||||
rb_extend_object(self, ruby_wrapper);
|
rb_extend_object(self, ruby_wrapper);
|
||||||
PUSH_CREF(ruby_wrapper);
|
PUSH_CREF(ruby_wrapper);
|
||||||
|
/* default visibility is private at loading toplevel */
|
||||||
|
VIS_SET(VIS_PRIVATE);
|
||||||
}
|
}
|
||||||
PUSH_FRAME(Qfalse);
|
PUSH_FRAME(Qfalse);
|
||||||
ruby_frame->callee = 0;
|
|
||||||
ruby_frame->this_func = 0;
|
|
||||||
ruby_frame->this_class = 0;
|
|
||||||
ruby_frame->self = self;
|
ruby_frame->self = self;
|
||||||
PUSH_SCOPE();
|
PUSH_SCOPE();
|
||||||
/* default visibility is private at loading toplevel */
|
|
||||||
SCOPE_SET(SCOPE_PRIVATE);
|
|
||||||
PUSH_TAG(PROT_NONE);
|
PUSH_TAG(PROT_NONE);
|
||||||
|
/* default visibility is private at loading toplevel */
|
||||||
|
VIS_SET(VIS_PRIVATE);
|
||||||
state = EXEC_TAG();
|
state = EXEC_TAG();
|
||||||
callee = ruby_frame->callee;
|
callee = ruby_frame->callee;
|
||||||
this_func = ruby_frame->this_func;
|
this_func = ruby_frame->this_func;
|
||||||
|
@ -6981,15 +7013,18 @@ rb_require_safe(VALUE fname, int safe)
|
||||||
struct {
|
struct {
|
||||||
NODE *node;
|
NODE *node;
|
||||||
ID this_func, callee;
|
ID this_func, callee;
|
||||||
int vmode, safe;
|
int safe, vmode;
|
||||||
} volatile saved;
|
} volatile saved;
|
||||||
char *volatile ftptr = 0;
|
char *volatile ftptr = 0;
|
||||||
|
|
||||||
saved.vmode = scope_vmode;
|
|
||||||
saved.node = ruby_current_node;
|
saved.node = ruby_current_node;
|
||||||
saved.callee = ruby_frame->callee;
|
saved.callee = ruby_frame->callee;
|
||||||
saved.this_func = ruby_frame->this_func;
|
saved.this_func = ruby_frame->this_func;
|
||||||
saved.safe = ruby_safe_level;
|
saved.safe = ruby_safe_level;
|
||||||
|
saved.vmode = vis_mode;
|
||||||
|
PUSH_SCOPE();
|
||||||
|
PUSH_CREF(ruby_cbase);
|
||||||
|
VIS_SET(VIS_PUBLIC);
|
||||||
PUSH_TAG(PROT_NONE);
|
PUSH_TAG(PROT_NONE);
|
||||||
if ((state = EXEC_TAG()) == 0) {
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
VALUE path;
|
VALUE path;
|
||||||
|
@ -7024,7 +7059,7 @@ rb_require_safe(VALUE fname, int safe)
|
||||||
ruby_sourceline = 0;
|
ruby_sourceline = 0;
|
||||||
ruby_frame->callee = 0;
|
ruby_frame->callee = 0;
|
||||||
ruby_frame->this_func = 0;
|
ruby_frame->this_func = 0;
|
||||||
SCOPE_SET(SCOPE_PUBLIC);
|
VIS_SET(VIS_PUBLIC);
|
||||||
handle = (long)dln_load(RSTRING(path)->ptr);
|
handle = (long)dln_load(RSTRING(path)->ptr);
|
||||||
rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
|
rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
|
||||||
break;
|
break;
|
||||||
|
@ -7039,8 +7074,10 @@ rb_require_safe(VALUE fname, int safe)
|
||||||
ruby_set_current_source();
|
ruby_set_current_source();
|
||||||
ruby_frame->this_func = saved.this_func;
|
ruby_frame->this_func = saved.this_func;
|
||||||
ruby_frame->callee = saved.callee;
|
ruby_frame->callee = saved.callee;
|
||||||
SCOPE_SET(saved.vmode);
|
|
||||||
ruby_safe_level = saved.safe;
|
ruby_safe_level = saved.safe;
|
||||||
|
VIS_SET(saved.vmode);
|
||||||
|
POP_CREF();
|
||||||
|
POP_SCOPE();
|
||||||
if (ftptr) {
|
if (ftptr) {
|
||||||
if (st_delete(loading_tbl, (st_data_t *)&ftptr, 0)) { /* loading done */
|
if (st_delete(loading_tbl, (st_data_t *)&ftptr, 0)) { /* loading done */
|
||||||
free(ftptr);
|
free(ftptr);
|
||||||
|
@ -7098,7 +7135,7 @@ rb_mod_public(int argc, VALUE *argv, VALUE module)
|
||||||
{
|
{
|
||||||
secure_visibility(module);
|
secure_visibility(module);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
SCOPE_SET(SCOPE_PUBLIC);
|
VIS_SET(VIS_PUBLIC);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
set_method_visibility(module, argc, argv, NOEX_PUBLIC);
|
set_method_visibility(module, argc, argv, NOEX_PUBLIC);
|
||||||
|
@ -7121,7 +7158,7 @@ rb_mod_protected(int argc, VALUE *argv, VALUE module)
|
||||||
{
|
{
|
||||||
secure_visibility(module);
|
secure_visibility(module);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
SCOPE_SET(SCOPE_PROTECTED);
|
VIS_SET(VIS_PROTECTED);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
set_method_visibility(module, argc, argv, NOEX_PROTECTED);
|
set_method_visibility(module, argc, argv, NOEX_PROTECTED);
|
||||||
|
@ -7153,7 +7190,7 @@ rb_mod_private(int argc, VALUE *argv, VALUE module)
|
||||||
{
|
{
|
||||||
secure_visibility(module);
|
secure_visibility(module);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
SCOPE_SET(SCOPE_PRIVATE);
|
VIS_SET(VIS_PRIVATE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
set_method_visibility(module, argc, argv, NOEX_PRIVATE);
|
set_method_visibility(module, argc, argv, NOEX_PRIVATE);
|
||||||
|
@ -7269,7 +7306,7 @@ rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
|
||||||
|
|
||||||
secure_visibility(module);
|
secure_visibility(module);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
SCOPE_SET(SCOPE_MODFUNC);
|
VIS_SET(VIS_MODFUNC);
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7575,9 +7612,6 @@ call_end_proc(VALUE data)
|
||||||
PUSH_FRAME(Qfalse);
|
PUSH_FRAME(Qfalse);
|
||||||
ruby_frame->self = ruby_frame->prev->self;
|
ruby_frame->self = ruby_frame->prev->self;
|
||||||
ruby_frame->node = 0;
|
ruby_frame->node = 0;
|
||||||
ruby_frame->callee = 0;
|
|
||||||
ruby_frame->this_func = 0;
|
|
||||||
ruby_frame->this_class = 0;
|
|
||||||
proc_invoke(data, rb_ary_new2(0), Qundef, 0);
|
proc_invoke(data, rb_ary_new2(0), Qundef, 0);
|
||||||
POP_FRAME();
|
POP_FRAME();
|
||||||
}
|
}
|
||||||
|
@ -7830,6 +7864,11 @@ rb_mod_autoload_p(VALUE mod, VALUE sym)
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
|
rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
|
||||||
{
|
{
|
||||||
|
VALUE klass = ruby_cbase;
|
||||||
|
|
||||||
|
if (NIL_P(ruby_cbase)) {
|
||||||
|
rb_raise(rb_eTypeError, "no class/module for autoload target");
|
||||||
|
}
|
||||||
return rb_mod_autoload(ruby_cbase, sym, file);
|
return rb_mod_autoload(ruby_cbase, sym, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7848,6 +7887,9 @@ static VALUE
|
||||||
rb_f_autoload_p(VALUE obj, VALUE sym)
|
rb_f_autoload_p(VALUE obj, VALUE sym)
|
||||||
{
|
{
|
||||||
/* use ruby_cbase as same as rb_f_autoload. */
|
/* use ruby_cbase as same as rb_f_autoload. */
|
||||||
|
if (NIL_P(ruby_cbase)) {
|
||||||
|
return Qfalse;
|
||||||
|
}
|
||||||
return rb_mod_autoload_p(ruby_cbase, sym);
|
return rb_mod_autoload_p(ruby_cbase, sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8282,7 +8324,6 @@ proc_invoke(VALUE proc, VALUE args /* OK */, VALUE self, VALUE klass)
|
||||||
if (self != Qundef) _block.frame.self = self;
|
if (self != Qundef) _block.frame.self = self;
|
||||||
if (klass) _block.frame.this_class = klass;
|
if (klass) _block.frame.this_class = klass;
|
||||||
_block.frame.argc = RARRAY(tmp)->len;
|
_block.frame.argc = RARRAY(tmp)->len;
|
||||||
if (ruby_frame->flags & FRAME_DMETH)
|
|
||||||
if (_block.frame.argc && (ruby_frame->flags & FRAME_DMETH)) {
|
if (_block.frame.argc && (ruby_frame->flags & FRAME_DMETH)) {
|
||||||
NEWOBJ(scope, struct SCOPE);
|
NEWOBJ(scope, struct SCOPE);
|
||||||
OBJSETUP(scope, tmp, T_SCOPE);
|
OBJSETUP(scope, tmp, T_SCOPE);
|
||||||
|
@ -9385,10 +9426,10 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
|
||||||
rb_raise(rb_eTypeError, "wrong argument type (expected Proc/Method)");
|
rb_raise(rb_eTypeError, "wrong argument type (expected Proc/Method)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SCOPE_TEST(SCOPE_PRIVATE)) {
|
if (VIS_TEST(VIS_PRIVATE)) {
|
||||||
noex = NOEX_PRIVATE;
|
noex = NOEX_PRIVATE;
|
||||||
}
|
}
|
||||||
else if (SCOPE_TEST(SCOPE_PROTECTED)) {
|
else if (VIS_TEST(VIS_PROTECTED)) {
|
||||||
noex = NOEX_PROTECTED;
|
noex = NOEX_PROTECTED;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -9758,7 +9799,7 @@ struct thread {
|
||||||
NODE *cref;
|
NODE *cref;
|
||||||
struct ruby_env *anchor;
|
struct ruby_env *anchor;
|
||||||
|
|
||||||
int flags; /* misc. states (vmode/rb_trap_immediate/raised) */
|
int flags; /* misc. states (rb_trap_immediate/raised) */
|
||||||
|
|
||||||
NODE *node;
|
NODE *node;
|
||||||
|
|
||||||
|
@ -10175,7 +10216,7 @@ rb_thread_save_context(rb_thread_t th)
|
||||||
th->cref = ruby_cref;
|
th->cref = ruby_cref;
|
||||||
th->dyna_vars = ruby_dyna_vars;
|
th->dyna_vars = ruby_dyna_vars;
|
||||||
th->flags &= THREAD_FLAGS_MASK;
|
th->flags &= THREAD_FLAGS_MASK;
|
||||||
th->flags |= (rb_trap_immediate<<8) | scope_vmode;
|
th->flags |= (rb_trap_immediate<<8) | vis_mode;
|
||||||
th->tag = prot_tag;
|
th->tag = prot_tag;
|
||||||
th->tracing = tracing;
|
th->tracing = tracing;
|
||||||
th->errinfo = ruby_errinfo;
|
th->errinfo = ruby_errinfo;
|
||||||
|
@ -10251,8 +10292,8 @@ rb_thread_restore_context_0(rb_thread_t th, int exit, void *vp)
|
||||||
ruby_scope = th->scope;
|
ruby_scope = th->scope;
|
||||||
ruby_wrapper = th->wrapper;
|
ruby_wrapper = th->wrapper;
|
||||||
ruby_cref = th->cref;
|
ruby_cref = th->cref;
|
||||||
|
vis_mode = th->flags&VIS_MASK;
|
||||||
ruby_dyna_vars = th->dyna_vars;
|
ruby_dyna_vars = th->dyna_vars;
|
||||||
scope_vmode = th->flags&SCOPE_MASK;
|
|
||||||
prot_tag = th->tag;
|
prot_tag = th->tag;
|
||||||
tracing = th->tracing;
|
tracing = th->tracing;
|
||||||
ruby_errinfo = th->errinfo;
|
ruby_errinfo = th->errinfo;
|
||||||
|
|
106
ext/dbm/dbm.c
106
ext/dbm/dbm.c
|
@ -32,7 +32,7 @@ struct dbmdata {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
closed_dbm()
|
closed_dbm(void)
|
||||||
{
|
{
|
||||||
rb_raise(rb_eDBMError, "closed DBM file");
|
rb_raise(rb_eDBMError, "closed DBM file");
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,7 @@ closed_dbm()
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_dbm(dbmp)
|
free_dbm(struct dbmdata *dbmp)
|
||||||
struct dbmdata *dbmp;
|
|
||||||
{
|
{
|
||||||
if (dbmp) {
|
if (dbmp) {
|
||||||
if (dbmp->di_dbm) dbm_close(dbmp->di_dbm);
|
if (dbmp->di_dbm) dbm_close(dbmp->di_dbm);
|
||||||
|
@ -59,8 +58,7 @@ free_dbm(dbmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_close(obj)
|
fdbm_close(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
|
||||||
|
@ -72,8 +70,7 @@ fdbm_close(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_closed(obj)
|
fdbm_closed(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
|
||||||
|
@ -86,19 +83,14 @@ fdbm_closed(obj)
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE fdbm_alloc _((VALUE));
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_alloc(klass)
|
fdbm_alloc(VALUE klass)
|
||||||
VALUE klass;
|
|
||||||
{
|
{
|
||||||
return Data_Wrap_Struct(klass, 0, free_dbm, 0);
|
return Data_Wrap_Struct(klass, 0, free_dbm, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_initialize(argc, argv, obj)
|
fdbm_initialize(int argc, VALUE *argv, VALUE obj)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE file, vmode, vflags;
|
VALUE file, vmode, vflags;
|
||||||
DBM *dbm;
|
DBM *dbm;
|
||||||
|
@ -151,10 +143,7 @@ fdbm_initialize(argc, argv, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_s_open(argc, argv, klass)
|
fdbm_s_open(int argc, VALUE *argv, VALUE klass)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE klass;
|
|
||||||
{
|
{
|
||||||
VALUE obj = Data_Wrap_Struct(klass, 0, free_dbm, 0);
|
VALUE obj = Data_Wrap_Struct(klass, 0, free_dbm, 0);
|
||||||
|
|
||||||
|
@ -170,8 +159,7 @@ fdbm_s_open(argc, argv, klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_fetch(obj, keystr, ifnone)
|
fdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
|
||||||
VALUE obj, keystr, ifnone;
|
|
||||||
{
|
{
|
||||||
datum key, value;
|
datum key, value;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -192,17 +180,13 @@ fdbm_fetch(obj, keystr, ifnone)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_aref(obj, keystr)
|
fdbm_aref(VALUE obj, VALUE keystr)
|
||||||
VALUE obj, keystr;
|
|
||||||
{
|
{
|
||||||
return fdbm_fetch(obj, keystr, Qnil);
|
return fdbm_fetch(obj, keystr, Qnil);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_fetch_m(argc, argv, obj)
|
fdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE keystr, valstr, ifnone;
|
VALUE keystr, valstr, ifnone;
|
||||||
|
|
||||||
|
@ -215,8 +199,7 @@ fdbm_fetch_m(argc, argv, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_index(obj, valstr)
|
fdbm_index(VALUE obj, VALUE valstr)
|
||||||
VALUE obj, valstr;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -238,8 +221,7 @@ fdbm_index(obj, valstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_select(obj)
|
fdbm_select(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE new = rb_ary_new();
|
VALUE new = rb_ary_new();
|
||||||
datum key, val;
|
datum key, val;
|
||||||
|
@ -263,10 +245,7 @@ fdbm_select(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_values_at(argc, argv, obj)
|
fdbm_values_at(int argc, VALUE *argv, VALUE obj)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE new = rb_ary_new2(argc);
|
VALUE new = rb_ary_new2(argc);
|
||||||
int i;
|
int i;
|
||||||
|
@ -279,16 +258,14 @@ fdbm_values_at(argc, argv, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fdbm_modify(obj)
|
fdbm_modify(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
rb_secure(4);
|
rb_secure(4);
|
||||||
if (OBJ_FROZEN(obj)) rb_error_frozen("DBM");
|
if (OBJ_FROZEN(obj)) rb_error_frozen("DBM");
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_delete(obj, keystr)
|
fdbm_delete(VALUE obj, VALUE keystr)
|
||||||
VALUE obj, keystr;
|
|
||||||
{
|
{
|
||||||
datum key, value;
|
datum key, value;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -322,8 +299,7 @@ fdbm_delete(obj, keystr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_shift(obj)
|
fdbm_shift(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -345,8 +321,7 @@ fdbm_shift(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_delete_if(obj)
|
fdbm_delete_if(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -386,8 +361,7 @@ fdbm_delete_if(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_clear(obj)
|
fdbm_clear(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -407,8 +381,7 @@ fdbm_clear(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_invert(obj)
|
fdbm_invert(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -455,8 +428,7 @@ fdbm_replace(VALUE obj, VALUE other)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_store(obj, keystr, valstr)
|
fdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
|
||||||
VALUE obj, keystr, valstr;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -486,8 +458,7 @@ fdbm_store(obj, keystr, valstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_length(obj)
|
fdbm_length(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -506,8 +477,7 @@ fdbm_length(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_empty_p(obj)
|
fdbm_empty_p(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -530,8 +500,7 @@ fdbm_empty_p(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_each_value(obj)
|
fdbm_each_value(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -547,8 +516,7 @@ fdbm_each_value(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_each_key(obj)
|
fdbm_each_key(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -563,8 +531,7 @@ fdbm_each_key(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_each_pair(obj)
|
fdbm_each_pair(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
DBM *dbm;
|
DBM *dbm;
|
||||||
|
@ -585,8 +552,7 @@ fdbm_each_pair(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_keys(obj)
|
fdbm_keys(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -604,8 +570,7 @@ fdbm_keys(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_values(obj)
|
fdbm_values(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -623,8 +588,7 @@ fdbm_values(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_has_key(obj, keystr)
|
fdbm_has_key(VALUE obj, VALUE keystr)
|
||||||
VALUE obj, keystr;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -641,8 +605,7 @@ fdbm_has_key(obj, keystr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_has_value(obj, valstr)
|
fdbm_has_value(VALUE obj, VALUE valstr)
|
||||||
VALUE obj, valstr;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -663,8 +626,7 @@ fdbm_has_value(obj, valstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_to_a(obj)
|
fdbm_to_a(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -683,8 +645,7 @@ fdbm_to_a(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_to_hash(obj)
|
fdbm_to_hash(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -703,14 +664,13 @@ fdbm_to_hash(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_reject(obj)
|
fdbm_reject(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
return rb_hash_delete_if(fdbm_to_hash(obj));
|
return rb_hash_delete_if(fdbm_to_hash(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_dbm()
|
Init_dbm(void)
|
||||||
{
|
{
|
||||||
rb_cDBM = rb_define_class("DBM", rb_cObject);
|
rb_cDBM = rb_define_class("DBM", rb_cObject);
|
||||||
rb_eDBMError = rb_define_class("DBMError", rb_eStandardError);
|
rb_eDBMError = rb_define_class("DBMError", rb_eStandardError);
|
||||||
|
|
205
ext/gdbm/gdbm.c
205
ext/gdbm/gdbm.c
|
@ -21,8 +21,7 @@ static VALUE rb_cGDBM, rb_eGDBMError, rb_eGDBMFatalError;
|
||||||
#define MY_BLOCK_SIZE (2048)
|
#define MY_BLOCK_SIZE (2048)
|
||||||
#define MY_FATAL_FUNC rb_gdbm_fatal
|
#define MY_FATAL_FUNC rb_gdbm_fatal
|
||||||
static void
|
static void
|
||||||
rb_gdbm_fatal(msg)
|
rb_gdbm_fatal(char *msg)
|
||||||
char *msg;
|
|
||||||
{
|
{
|
||||||
rb_raise(rb_eGDBMFatalError, msg);
|
rb_raise(rb_eGDBMFatalError, msg);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +32,7 @@ struct dbmdata {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
closed_dbm()
|
closed_dbm(void)
|
||||||
{
|
{
|
||||||
rb_raise(rb_eRuntimeError, "closed GDBM file");
|
rb_raise(rb_eRuntimeError, "closed GDBM file");
|
||||||
}
|
}
|
||||||
|
@ -50,8 +49,7 @@ closed_dbm()
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_dbm(dbmp)
|
free_dbm(struct dbmdata *dbmp)
|
||||||
struct dbmdata *dbmp;
|
|
||||||
{
|
{
|
||||||
if (dbmp) {
|
if (dbmp) {
|
||||||
if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm);
|
if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm);
|
||||||
|
@ -60,8 +58,7 @@ free_dbm(dbmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_close(obj)
|
fgdbm_close(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
|
||||||
|
@ -73,8 +70,7 @@ fgdbm_close(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_closed(obj)
|
fgdbm_closed(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
|
||||||
|
@ -87,20 +83,14 @@ fgdbm_closed(obj)
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE fgdbm_s_alloc _((VALUE));
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_s_alloc(klass)
|
fgdbm_s_alloc(VALUE klass)
|
||||||
VALUE klass;
|
|
||||||
{
|
{
|
||||||
return Data_Wrap_Struct(klass, 0, free_dbm, 0);
|
return Data_Wrap_Struct(klass, 0, free_dbm, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_initialize(argc, argv, obj)
|
fgdbm_initialize(int argc, VALUE *argv, VALUE obj)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE file, vmode, vflags;
|
VALUE file, vmode, vflags;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -161,10 +151,7 @@ fgdbm_initialize(argc, argv, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_s_open(argc, argv, klass)
|
fgdbm_s_open(int argc, VALUE *argv, VALUE klass)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE klass;
|
|
||||||
{
|
{
|
||||||
VALUE obj = Data_Wrap_Struct(klass, 0, free_dbm, 0);
|
VALUE obj = Data_Wrap_Struct(klass, 0, free_dbm, 0);
|
||||||
|
|
||||||
|
@ -180,9 +167,7 @@ fgdbm_s_open(argc, argv, klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_gdbm_fetch(dbm, key)
|
rb_gdbm_fetch(GDBM_FILE dbm, datum key)
|
||||||
GDBM_FILE dbm;
|
|
||||||
datum key;
|
|
||||||
{
|
{
|
||||||
datum val;
|
datum val;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
|
@ -202,9 +187,7 @@ rb_gdbm_fetch(dbm, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_gdbm_fetch2(dbm, keystr)
|
rb_gdbm_fetch2(GDBM_FILE dbm, VALUE keystr)
|
||||||
GDBM_FILE dbm;
|
|
||||||
VALUE keystr;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
|
|
||||||
|
@ -216,8 +199,7 @@ rb_gdbm_fetch2(dbm, keystr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_gdbm_fetch3(obj, keystr)
|
rb_gdbm_fetch3(VALUE obj, VALUE keystr)
|
||||||
VALUE obj, keystr;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -227,8 +209,7 @@ rb_gdbm_fetch3(obj, keystr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_gdbm_firstkey(dbm)
|
rb_gdbm_firstkey(GDBM_FILE dbm)
|
||||||
GDBM_FILE dbm;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
|
@ -248,9 +229,7 @@ rb_gdbm_firstkey(dbm)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_gdbm_nextkey(dbm, keystr)
|
rb_gdbm_nextkey(GDBM_FILE dbm, VALUE keystr)
|
||||||
GDBM_FILE dbm;
|
|
||||||
VALUE keystr;
|
|
||||||
{
|
{
|
||||||
datum key, key2;
|
datum key, key2;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
|
@ -272,8 +251,7 @@ rb_gdbm_nextkey(dbm, keystr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_fetch(obj, keystr, ifnone)
|
fgdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
|
||||||
VALUE obj, keystr, ifnone;
|
|
||||||
{
|
{
|
||||||
VALUE valstr;
|
VALUE valstr;
|
||||||
|
|
||||||
|
@ -287,17 +265,13 @@ fgdbm_fetch(obj, keystr, ifnone)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_aref(obj, keystr)
|
fgdbm_aref(VALUE obj, VALUE keystr)
|
||||||
VALUE obj, keystr;
|
|
||||||
{
|
{
|
||||||
return rb_gdbm_fetch3(obj, keystr);
|
return rb_gdbm_fetch3(obj, keystr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_fetch_m(argc, argv, obj)
|
fgdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE keystr, valstr, ifnone;
|
VALUE keystr, valstr, ifnone;
|
||||||
|
|
||||||
|
@ -310,8 +284,7 @@ fgdbm_fetch_m(argc, argv, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_index(obj, valstr)
|
fgdbm_index(VALUE obj, VALUE valstr)
|
||||||
VALUE obj, valstr;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -334,8 +307,7 @@ fgdbm_index(obj, valstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_select(obj)
|
fgdbm_select(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE new = rb_ary_new();
|
VALUE new = rb_ary_new();
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -358,10 +330,7 @@ fgdbm_select(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_values_at(argc, argv, obj)
|
fgdbm_values_at(int argc, VALUE *argv, VALUE obj)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE new = rb_ary_new2(argc);
|
VALUE new = rb_ary_new2(argc);
|
||||||
int i;
|
int i;
|
||||||
|
@ -374,16 +343,14 @@ fgdbm_values_at(argc, argv, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rb_gdbm_modify(obj)
|
rb_gdbm_modify(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
rb_secure(4);
|
rb_secure(4);
|
||||||
if (OBJ_FROZEN(obj)) rb_error_frozen("GDBM");
|
if (OBJ_FROZEN(obj)) rb_error_frozen("GDBM");
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_gdbm_delete(obj, keystr)
|
rb_gdbm_delete(VALUE obj, VALUE keystr)
|
||||||
VALUE obj, keystr;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -410,8 +377,7 @@ rb_gdbm_delete(obj, keystr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_delete(obj, keystr)
|
fgdbm_delete(VALUE obj, VALUE keystr)
|
||||||
VALUE obj, keystr;
|
|
||||||
{
|
{
|
||||||
VALUE valstr;
|
VALUE valstr;
|
||||||
|
|
||||||
|
@ -421,8 +387,7 @@ fgdbm_delete(obj, keystr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_shift(obj)
|
fgdbm_shift(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -439,8 +404,7 @@ fgdbm_shift(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_delete_if(obj)
|
fgdbm_delete_if(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -472,8 +436,7 @@ fgdbm_delete_if(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_clear(obj)
|
fgdbm_clear(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, nextkey;
|
datum key, nextkey;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -510,8 +473,7 @@ fgdbm_clear(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_invert(obj)
|
fgdbm_invert(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -528,42 +490,8 @@ fgdbm_invert(obj)
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE each_pair _((VALUE));
|
|
||||||
|
|
||||||
static VALUE fgdbm_store _((VALUE,VALUE,VALUE));
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
update_i(pair, dbm)
|
fgdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
|
||||||
VALUE pair, dbm;
|
|
||||||
{
|
|
||||||
Check_Type(pair, T_ARRAY);
|
|
||||||
if (RARRAY(pair)->len < 2) {
|
|
||||||
rb_raise(rb_eArgError, "pair must be [key, value]");
|
|
||||||
}
|
|
||||||
fgdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
|
|
||||||
return Qnil;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
|
||||||
fgdbm_update(obj, other)
|
|
||||||
VALUE obj, other;
|
|
||||||
{
|
|
||||||
rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
|
||||||
fgdbm_replace(obj, other)
|
|
||||||
VALUE obj, other;
|
|
||||||
{
|
|
||||||
fgdbm_clear(obj);
|
|
||||||
rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
|
||||||
fgdbm_store(obj, keystr, valstr)
|
|
||||||
VALUE obj, keystr, valstr;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -590,8 +518,33 @@ fgdbm_store(obj, keystr, valstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_length(obj)
|
update_i(VALUE pair, VALUE dbm)
|
||||||
VALUE obj;
|
{
|
||||||
|
Check_Type(pair, T_ARRAY);
|
||||||
|
if (RARRAY(pair)->len < 2) {
|
||||||
|
rb_raise(rb_eArgError, "pair must be [key, value]");
|
||||||
|
}
|
||||||
|
fgdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
fgdbm_update(VALUE obj, VALUE other)
|
||||||
|
{
|
||||||
|
rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
fgdbm_replace(VALUE obj, VALUE other)
|
||||||
|
{
|
||||||
|
fgdbm_clear(obj);
|
||||||
|
rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
fgdbm_length(VALUE obj)
|
||||||
{
|
{
|
||||||
datum key, nextkey;
|
datum key, nextkey;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -612,8 +565,7 @@ fgdbm_length(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_empty_p(obj)
|
fgdbm_empty_p(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -636,8 +588,7 @@ fgdbm_empty_p(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_each_value(obj)
|
fgdbm_each_value(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -654,8 +605,7 @@ fgdbm_each_value(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_each_key(obj)
|
fgdbm_each_key(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -672,8 +622,7 @@ fgdbm_each_key(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_each_pair(obj)
|
fgdbm_each_pair(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -691,8 +640,7 @@ fgdbm_each_pair(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_keys(obj)
|
fgdbm_keys(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -710,8 +658,7 @@ fgdbm_keys(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_values(obj)
|
fgdbm_values(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, nextkey;
|
datum key, nextkey;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -731,8 +678,7 @@ fgdbm_values(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_has_key(obj, keystr)
|
fgdbm_has_key(VALUE obj, VALUE keystr)
|
||||||
VALUE obj, keystr;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -749,8 +695,7 @@ fgdbm_has_key(obj, keystr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_has_value(obj, valstr)
|
fgdbm_has_value(VALUE obj, VALUE valstr)
|
||||||
VALUE obj, valstr;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -774,8 +719,7 @@ fgdbm_has_value(obj, valstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_to_a(obj)
|
fgdbm_to_a(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -793,8 +737,7 @@ fgdbm_to_a(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_reorganize(obj)
|
fgdbm_reorganize(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -806,8 +749,7 @@ fgdbm_reorganize(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_sync(obj)
|
fgdbm_sync(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -819,8 +761,7 @@ fgdbm_sync(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_set_cachesize(obj, val)
|
fgdbm_set_cachesize(VALUE obj, VALUE val)
|
||||||
VALUE obj, val;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -835,8 +776,7 @@ fgdbm_set_cachesize(obj, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_set_fastmode(obj, val)
|
fgdbm_set_fastmode(VALUE obj, VALUE val)
|
||||||
VALUE obj, val;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -854,8 +794,7 @@ fgdbm_set_fastmode(obj, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_set_syncmode(obj, val)
|
fgdbm_set_syncmode(VALUE obj, VALUE val)
|
||||||
VALUE obj, val;
|
|
||||||
{
|
{
|
||||||
#if !defined(GDBM_SYNCMODE)
|
#if !defined(GDBM_SYNCMODE)
|
||||||
fgdbm_set_fastmode(obj, RTEST(val) ? Qfalse : Qtrue);
|
fgdbm_set_fastmode(obj, RTEST(val) ? Qfalse : Qtrue);
|
||||||
|
@ -878,8 +817,7 @@ fgdbm_set_syncmode(obj, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_to_hash(obj)
|
fgdbm_to_hash(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
GDBM_FILE dbm;
|
GDBM_FILE dbm;
|
||||||
|
@ -897,14 +835,13 @@ fgdbm_to_hash(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fgdbm_reject(obj)
|
fgdbm_reject(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
return rb_hash_delete_if(fgdbm_to_hash(obj));
|
return rb_hash_delete_if(fgdbm_to_hash(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_gdbm()
|
Init_gdbm(void)
|
||||||
{
|
{
|
||||||
rb_cGDBM = rb_define_class("GDBM", rb_cObject);
|
rb_cGDBM = rb_define_class("GDBM", rb_cObject);
|
||||||
rb_eGDBMError = rb_define_class("GDBMError", rb_eStandardError);
|
rb_eGDBMError = rb_define_class("GDBMError", rb_eStandardError);
|
||||||
|
|
|
@ -143,10 +143,7 @@ static long masks[] = {
|
||||||
datum nullitem = {NULL, 0};
|
datum nullitem = {NULL, 0};
|
||||||
|
|
||||||
DBM *
|
DBM *
|
||||||
sdbm_open(file, flags, mode)
|
sdbm_open(register char *file, register int flags, register int mode)
|
||||||
register char *file;
|
|
||||||
register int flags;
|
|
||||||
register int mode;
|
|
||||||
{
|
{
|
||||||
register DBM *db;
|
register DBM *db;
|
||||||
register char *dirname;
|
register char *dirname;
|
||||||
|
@ -175,11 +172,7 @@ register int mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBM *
|
DBM *
|
||||||
sdbm_prep(dirname, pagname, flags, mode)
|
sdbm_prep(char *dirname, char *pagname, int flags, int mode)
|
||||||
char *dirname;
|
|
||||||
char *pagname;
|
|
||||||
int flags;
|
|
||||||
int mode;
|
|
||||||
{
|
{
|
||||||
register DBM *db;
|
register DBM *db;
|
||||||
struct stat dstat;
|
struct stat dstat;
|
||||||
|
@ -235,8 +228,7 @@ int mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sdbm_close(db)
|
sdbm_close(register DBM *db)
|
||||||
register DBM *db;
|
|
||||||
{
|
{
|
||||||
if (db == NULL)
|
if (db == NULL)
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
@ -248,9 +240,7 @@ register DBM *db;
|
||||||
}
|
}
|
||||||
|
|
||||||
datum
|
datum
|
||||||
sdbm_fetch(db, key)
|
sdbm_fetch(register DBM *db, datum key)
|
||||||
register DBM *db;
|
|
||||||
datum key;
|
|
||||||
{
|
{
|
||||||
if (db == NULL || bad(key))
|
if (db == NULL || bad(key))
|
||||||
return errno = EINVAL, nullitem;
|
return errno = EINVAL, nullitem;
|
||||||
|
@ -262,9 +252,7 @@ datum key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sdbm_delete(db, key)
|
sdbm_delete(register DBM *db, datum key)
|
||||||
register DBM *db;
|
|
||||||
datum key;
|
|
||||||
{
|
{
|
||||||
if (db == NULL || bad(key))
|
if (db == NULL || bad(key))
|
||||||
return errno = EINVAL, -1;
|
return errno = EINVAL, -1;
|
||||||
|
@ -288,11 +276,7 @@ datum key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sdbm_store(db, key, val, flags)
|
sdbm_store(register DBM *db, datum key, datum val, int flags)
|
||||||
register DBM *db;
|
|
||||||
datum key;
|
|
||||||
datum val;
|
|
||||||
int flags;
|
|
||||||
{
|
{
|
||||||
int need;
|
int need;
|
||||||
register long hash;
|
register long hash;
|
||||||
|
@ -350,10 +334,7 @@ int flags;
|
||||||
* giving up.
|
* giving up.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
makroom(db, hash, need)
|
makroom(register DBM *db, long int hash, int need)
|
||||||
register DBM *db;
|
|
||||||
long hash;
|
|
||||||
int need;
|
|
||||||
{
|
{
|
||||||
long newp;
|
long newp;
|
||||||
char twin[PBLKSIZ];
|
char twin[PBLKSIZ];
|
||||||
|
@ -450,8 +431,7 @@ int need;
|
||||||
* deletions aren't taken into account. (ndbm bug)
|
* deletions aren't taken into account. (ndbm bug)
|
||||||
*/
|
*/
|
||||||
datum
|
datum
|
||||||
sdbm_firstkey(db)
|
sdbm_firstkey(register DBM *db)
|
||||||
register DBM *db;
|
|
||||||
{
|
{
|
||||||
if (db == NULL)
|
if (db == NULL)
|
||||||
return errno = EINVAL, nullitem;
|
return errno = EINVAL, nullitem;
|
||||||
|
@ -470,8 +450,7 @@ register DBM *db;
|
||||||
}
|
}
|
||||||
|
|
||||||
datum
|
datum
|
||||||
sdbm_nextkey(db)
|
sdbm_nextkey(register DBM *db)
|
||||||
register DBM *db;
|
|
||||||
{
|
{
|
||||||
if (db == NULL)
|
if (db == NULL)
|
||||||
return errno = EINVAL, nullitem;
|
return errno = EINVAL, nullitem;
|
||||||
|
@ -482,9 +461,7 @@ register DBM *db;
|
||||||
* all important binary trie traversal
|
* all important binary trie traversal
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
getpage(db, hash)
|
getpage(register DBM *db, register long int hash)
|
||||||
register DBM *db;
|
|
||||||
register long hash;
|
|
||||||
{
|
{
|
||||||
register int hbit;
|
register int hbit;
|
||||||
register long dbit;
|
register long dbit;
|
||||||
|
@ -526,9 +503,7 @@ register long hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
getdbit(db, dbit)
|
getdbit(register DBM *db, register long int dbit)
|
||||||
register DBM *db;
|
|
||||||
register long dbit;
|
|
||||||
{
|
{
|
||||||
register long c;
|
register long c;
|
||||||
register long dirb;
|
register long dirb;
|
||||||
|
@ -549,9 +524,7 @@ register long dbit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
setdbit(db, dbit)
|
setdbit(register DBM *db, register long int dbit)
|
||||||
register DBM *db;
|
|
||||||
register long dbit;
|
|
||||||
{
|
{
|
||||||
register long c;
|
register long c;
|
||||||
register long dirb;
|
register long dirb;
|
||||||
|
@ -585,8 +558,7 @@ register long dbit;
|
||||||
* the page, try the next page in sequence
|
* the page, try the next page in sequence
|
||||||
*/
|
*/
|
||||||
static datum
|
static datum
|
||||||
getnext(db)
|
getnext(register DBM *db)
|
||||||
register DBM *db;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
|
|
||||||
|
@ -661,9 +633,7 @@ static int seepair proto((char *, int, char *, int));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fitpair(pag, need)
|
fitpair(char *pag, int need)
|
||||||
char *pag;
|
|
||||||
int need;
|
|
||||||
{
|
{
|
||||||
register int n;
|
register int n;
|
||||||
register int off;
|
register int off;
|
||||||
|
@ -680,10 +650,7 @@ int need;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
putpair(pag, key, val)
|
putpair(char *pag, datum key, datum val)
|
||||||
char *pag;
|
|
||||||
datum key;
|
|
||||||
datum val;
|
|
||||||
{
|
{
|
||||||
register int n;
|
register int n;
|
||||||
register int off;
|
register int off;
|
||||||
|
@ -711,9 +678,7 @@ datum val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static datum
|
static datum
|
||||||
getpair(pag, key)
|
getpair(char *pag, datum key)
|
||||||
char *pag;
|
|
||||||
datum key;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
register int n;
|
register int n;
|
||||||
|
@ -733,9 +698,7 @@ datum key;
|
||||||
|
|
||||||
#ifdef SEEDUPS
|
#ifdef SEEDUPS
|
||||||
static int
|
static int
|
||||||
duppair(pag, key)
|
duppair(char *pag, datum key)
|
||||||
char *pag;
|
|
||||||
datum key;
|
|
||||||
{
|
{
|
||||||
register short *ino = (short *) pag;
|
register short *ino = (short *) pag;
|
||||||
return GET_SHORT(ino,0) > 0 &&
|
return GET_SHORT(ino,0) > 0 &&
|
||||||
|
@ -744,9 +707,7 @@ datum key;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static datum
|
static datum
|
||||||
getnkey(pag, num)
|
getnkey(char *pag, int num)
|
||||||
char *pag;
|
|
||||||
int num;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
register int off;
|
register int off;
|
||||||
|
@ -765,9 +726,7 @@ int num;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
delpair(pag, key)
|
delpair(char *pag, datum key)
|
||||||
char *pag;
|
|
||||||
datum key;
|
|
||||||
{
|
{
|
||||||
register int n;
|
register int n;
|
||||||
register int i;
|
register int i;
|
||||||
|
@ -837,11 +796,7 @@ datum key;
|
||||||
* return 0 if not found.
|
* return 0 if not found.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
seepair(pag, n, key, siz)
|
seepair(char *pag, register int n, register char *key, register int siz)
|
||||||
char *pag;
|
|
||||||
register int n;
|
|
||||||
register char *key;
|
|
||||||
register int siz;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
register int off = PBLKSIZ;
|
register int off = PBLKSIZ;
|
||||||
|
@ -857,10 +812,7 @@ register int siz;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
splpage(pag, new, sbit)
|
splpage(char *pag, char *new, long int sbit)
|
||||||
char *pag;
|
|
||||||
char *new;
|
|
||||||
long sbit;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
datum val;
|
datum val;
|
||||||
|
@ -901,8 +853,7 @@ long sbit;
|
||||||
* this could be made more rigorous.
|
* this could be made more rigorous.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
chkpage(pag)
|
chkpage(char *pag)
|
||||||
char *pag;
|
|
||||||
{
|
{
|
||||||
register int n;
|
register int n;
|
||||||
register int off;
|
register int off;
|
||||||
|
@ -942,9 +893,7 @@ char *pag;
|
||||||
* 65587 even better.
|
* 65587 even better.
|
||||||
*/
|
*/
|
||||||
long
|
long
|
||||||
sdbm_hash(str, len)
|
sdbm_hash(register char *str, register int len)
|
||||||
register char *str;
|
|
||||||
register int len;
|
|
||||||
{
|
{
|
||||||
register unsigned long n = 0;
|
register unsigned long n = 0;
|
||||||
|
|
||||||
|
|
161
ext/sdbm/init.c
161
ext/sdbm/init.c
|
@ -41,8 +41,7 @@ closed_sdbm()
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_sdbm(dbmp)
|
free_sdbm(struct dbmdata *dbmp)
|
||||||
struct dbmdata *dbmp;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (dbmp->di_dbm) sdbm_close(dbmp->di_dbm);
|
if (dbmp->di_dbm) sdbm_close(dbmp->di_dbm);
|
||||||
|
@ -50,8 +49,7 @@ free_sdbm(dbmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_close(obj)
|
fsdbm_close(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
|
||||||
|
@ -63,8 +61,7 @@ fsdbm_close(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_closed(obj)
|
fsdbm_closed(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
|
||||||
|
@ -77,19 +74,14 @@ fsdbm_closed(obj)
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE fsdbm_alloc _((VALUE));
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_alloc(klass)
|
fsdbm_alloc(VALUE klass)
|
||||||
VALUE klass;
|
|
||||||
{
|
{
|
||||||
return Data_Wrap_Struct(klass, 0, free_sdbm, 0);
|
return Data_Wrap_Struct(klass, 0, free_sdbm, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_initialize(argc, argv, obj)
|
fsdbm_initialize(int argc, VALUE *argv, VALUE obj)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE file, vmode;
|
VALUE file, vmode;
|
||||||
DBM *dbm;
|
DBM *dbm;
|
||||||
|
@ -129,10 +121,7 @@ fsdbm_initialize(argc, argv, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_s_open(argc, argv, klass)
|
fsdbm_s_open(int argc, VALUE *argv, VALUE klass)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE klass;
|
|
||||||
{
|
{
|
||||||
VALUE obj = Data_Wrap_Struct(klass, 0, free_sdbm, 0);
|
VALUE obj = Data_Wrap_Struct(klass, 0, free_sdbm, 0);
|
||||||
|
|
||||||
|
@ -148,8 +137,7 @@ fsdbm_s_open(argc, argv, klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_fetch(obj, keystr, ifnone)
|
fsdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
|
||||||
VALUE obj, keystr, ifnone;
|
|
||||||
{
|
{
|
||||||
datum key, value;
|
datum key, value;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -170,17 +158,13 @@ fsdbm_fetch(obj, keystr, ifnone)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_aref(obj, keystr)
|
fsdbm_aref(VALUE obj, VALUE keystr)
|
||||||
VALUE obj, keystr;
|
|
||||||
{
|
{
|
||||||
return fsdbm_fetch(obj, keystr, Qnil);
|
return fsdbm_fetch(obj, keystr, Qnil);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_fetch_m(argc, argv, obj)
|
fsdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE keystr, valstr, ifnone;
|
VALUE keystr, valstr, ifnone;
|
||||||
|
|
||||||
|
@ -193,8 +177,7 @@ fsdbm_fetch_m(argc, argv, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_index(obj, valstr)
|
fsdbm_index(VALUE obj, VALUE valstr)
|
||||||
VALUE obj, valstr;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -215,8 +198,7 @@ fsdbm_index(obj, valstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_select(obj)
|
fsdbm_select(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE new = rb_ary_new();
|
VALUE new = rb_ary_new();
|
||||||
datum key, val;
|
datum key, val;
|
||||||
|
@ -240,10 +222,7 @@ fsdbm_select(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_values_at(argc, argv, obj)
|
fsdbm_values_at(int argc, VALUE *argv, VALUE obj)
|
||||||
int argc;
|
|
||||||
VALUE *argv;
|
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE new = rb_ary_new2(argc);
|
VALUE new = rb_ary_new2(argc);
|
||||||
int i;
|
int i;
|
||||||
|
@ -256,16 +235,14 @@ fsdbm_values_at(argc, argv, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fdbm_modify(obj)
|
fdbm_modify(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
rb_secure(4);
|
rb_secure(4);
|
||||||
if (OBJ_FROZEN(obj)) rb_error_frozen("SDBM");
|
if (OBJ_FROZEN(obj)) rb_error_frozen("SDBM");
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_delete(obj, keystr)
|
fsdbm_delete(VALUE obj, VALUE keystr)
|
||||||
VALUE obj, keystr;
|
|
||||||
{
|
{
|
||||||
datum key, value;
|
datum key, value;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -300,8 +277,7 @@ fsdbm_delete(obj, keystr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_shift(obj)
|
fsdbm_shift(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -324,8 +300,7 @@ fsdbm_shift(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_delete_if(obj)
|
fsdbm_delete_if(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -364,8 +339,7 @@ fsdbm_delete_if(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_clear(obj)
|
fsdbm_clear(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -385,8 +359,7 @@ fsdbm_clear(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_invert(obj)
|
fsdbm_invert(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -404,42 +377,8 @@ fsdbm_invert(obj)
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE each_pair _((VALUE));
|
|
||||||
|
|
||||||
static VALUE fsdbm_store _((VALUE,VALUE,VALUE));
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
update_i(pair, dbm)
|
fsdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
|
||||||
VALUE pair, dbm;
|
|
||||||
{
|
|
||||||
Check_Type(pair, T_ARRAY);
|
|
||||||
if (RARRAY(pair)->len < 2) {
|
|
||||||
rb_raise(rb_eArgError, "pair must be [key, value]");
|
|
||||||
}
|
|
||||||
fsdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
|
|
||||||
return Qnil;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
|
||||||
fsdbm_update(obj, other)
|
|
||||||
VALUE obj, other;
|
|
||||||
{
|
|
||||||
rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
|
||||||
fsdbm_replace(obj, other)
|
|
||||||
VALUE obj, other;
|
|
||||||
{
|
|
||||||
fsdbm_clear(obj);
|
|
||||||
rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
|
||||||
fsdbm_store(obj, keystr, valstr)
|
|
||||||
VALUE obj, keystr, valstr;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -474,8 +413,33 @@ fsdbm_store(obj, keystr, valstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_length(obj)
|
update_i(VALUE pair, VALUE dbm)
|
||||||
VALUE obj;
|
{
|
||||||
|
Check_Type(pair, T_ARRAY);
|
||||||
|
if (RARRAY(pair)->len < 2) {
|
||||||
|
rb_raise(rb_eArgError, "pair must be [key, value]");
|
||||||
|
}
|
||||||
|
fsdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
fsdbm_update(VALUE obj, VALUE other)
|
||||||
|
{
|
||||||
|
rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
fsdbm_replace(VALUE obj, VALUE other)
|
||||||
|
{
|
||||||
|
fsdbm_clear(obj);
|
||||||
|
rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
fsdbm_length(VALUE obj)
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -494,8 +458,7 @@ fsdbm_length(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_empty_p(obj)
|
fsdbm_empty_p(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -518,8 +481,7 @@ fsdbm_empty_p(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_each_value(obj)
|
fsdbm_each_value(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -535,8 +497,7 @@ fsdbm_each_value(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_each_key(obj)
|
fsdbm_each_key(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -551,8 +512,7 @@ fsdbm_each_key(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_each_pair(obj)
|
fsdbm_each_pair(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
DBM *dbm;
|
DBM *dbm;
|
||||||
|
@ -572,8 +532,7 @@ fsdbm_each_pair(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_keys(obj)
|
fsdbm_keys(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key;
|
datum key;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -590,8 +549,7 @@ fsdbm_keys(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_values(obj)
|
fsdbm_values(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -609,8 +567,7 @@ fsdbm_values(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_has_key(obj, keystr)
|
fsdbm_has_key(VALUE obj, VALUE keystr)
|
||||||
VALUE obj, keystr;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -627,8 +584,7 @@ fsdbm_has_key(obj, keystr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_has_value(obj, valstr)
|
fsdbm_has_value(VALUE obj, VALUE valstr)
|
||||||
VALUE obj, valstr;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -649,8 +605,7 @@ fsdbm_has_value(obj, valstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_to_a(obj)
|
fsdbm_to_a(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -669,8 +624,7 @@ fsdbm_to_a(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_to_hash(obj)
|
fsdbm_to_hash(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
datum key, val;
|
datum key, val;
|
||||||
struct dbmdata *dbmp;
|
struct dbmdata *dbmp;
|
||||||
|
@ -689,8 +643,7 @@ fsdbm_to_hash(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fsdbm_reject(obj)
|
fsdbm_reject(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
return rb_hash_delete_if(fsdbm_to_hash(obj));
|
return rb_hash_delete_if(fsdbm_to_hash(obj));
|
||||||
}
|
}
|
||||||
|
|
114
ext/zlib/zlib.c
114
ext/zlib/zlib.c
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
/*--------- Prototypes --------*/
|
/*--------- Prototypes --------*/
|
||||||
|
|
||||||
static NORETURN(void raise_zlib_error _((int, const char *)));
|
static NORETURN(void raise_zlib_error _((int, const char*)));
|
||||||
static VALUE rb_zlib_version _((VALUE));
|
static VALUE rb_zlib_version _((VALUE));
|
||||||
static VALUE do_checksum _((int, VALUE*, uLong (*) _((uLong, const Bytef*, uInt))));
|
static VALUE do_checksum _((int, VALUE*, uLong (*) _((uLong, const Bytef*, uInt))));
|
||||||
static VALUE rb_zlib_adler32 _((int, VALUE*, VALUE));
|
static VALUE rb_zlib_adler32 _((int, VALUE*, VALUE));
|
||||||
|
@ -43,14 +43,14 @@ static void finalizer_warn _((const char*));
|
||||||
|
|
||||||
struct zstream;
|
struct zstream;
|
||||||
struct zstream_funcs;
|
struct zstream_funcs;
|
||||||
static void zstream_init _((struct zstream*, const struct zstream_funcs *));
|
static void zstream_init _((struct zstream*, const struct zstream_funcs*));
|
||||||
static void zstream_expand_buffer _((struct zstream*));
|
static void zstream_expand_buffer _((struct zstream*));
|
||||||
static void zstream_expand_buffer_into _((struct zstream*, int));
|
static void zstream_expand_buffer_into _((struct zstream*, int));
|
||||||
static void zstream_append_buffer _((struct zstream*, const char*, int));
|
static void zstream_append_buffer _((struct zstream*, const Bytef*, int));
|
||||||
static VALUE zstream_detach_buffer _((struct zstream*));
|
static VALUE zstream_detach_buffer _((struct zstream*));
|
||||||
static VALUE zstream_shift_buffer _((struct zstream*, int));
|
static VALUE zstream_shift_buffer _((struct zstream*, int));
|
||||||
static void zstream_buffer_ungetc _((struct zstream*, int));
|
static void zstream_buffer_ungetc _((struct zstream*, int));
|
||||||
static void zstream_append_input _((struct zstream*, const char*, unsigned int));
|
static void zstream_append_input _((struct zstream*, const Bytef*, unsigned int));
|
||||||
static void zstream_discard_input _((struct zstream*, unsigned int));
|
static void zstream_discard_input _((struct zstream*, unsigned int));
|
||||||
static void zstream_reset_input _((struct zstream*));
|
static void zstream_reset_input _((struct zstream*));
|
||||||
static void zstream_passthrough_input _((struct zstream*));
|
static void zstream_passthrough_input _((struct zstream*));
|
||||||
|
@ -272,7 +272,7 @@ static VALUE
|
||||||
do_checksum(argc, argv, func)
|
do_checksum(argc, argv, func)
|
||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
uLong (*func) _((uLong, const Bytef *, uInt));
|
uLong (*func) _((uLong, const Bytef*, uInt));
|
||||||
{
|
{
|
||||||
VALUE str, vsum;
|
VALUE str, vsum;
|
||||||
unsigned long sum;
|
unsigned long sum;
|
||||||
|
@ -294,7 +294,7 @@ do_checksum(argc, argv, func)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
StringValue(str);
|
StringValue(str);
|
||||||
sum = func(sum, RSTRING(str)->ptr, RSTRING(str)->len);
|
sum = func(sum, (Bytef*)RSTRING(str)->ptr, RSTRING(str)->len);
|
||||||
}
|
}
|
||||||
return rb_uint2inum(sum);
|
return rb_uint2inum(sum);
|
||||||
}
|
}
|
||||||
|
@ -447,7 +447,7 @@ zstream_expand_buffer(z)
|
||||||
rb_str_buf_new makes a zero-length string. */
|
rb_str_buf_new makes a zero-length string. */
|
||||||
z->buf = rb_str_new(0, ZSTREAM_INITIAL_BUFSIZE);
|
z->buf = rb_str_new(0, ZSTREAM_INITIAL_BUFSIZE);
|
||||||
z->buf_filled = 0;
|
z->buf_filled = 0;
|
||||||
z->stream.next_out = RSTRING(z->buf)->ptr;
|
z->stream.next_out = (Bytef*)RSTRING(z->buf)->ptr;
|
||||||
z->stream.avail_out = ZSTREAM_INITIAL_BUFSIZE;
|
z->stream.avail_out = ZSTREAM_INITIAL_BUFSIZE;
|
||||||
RBASIC(z->buf)->klass = 0;
|
RBASIC(z->buf)->klass = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -466,7 +466,7 @@ zstream_expand_buffer(z)
|
||||||
z->stream.avail_out = (inc < ZSTREAM_AVAIL_OUT_STEP_MAX) ?
|
z->stream.avail_out = (inc < ZSTREAM_AVAIL_OUT_STEP_MAX) ?
|
||||||
inc : ZSTREAM_AVAIL_OUT_STEP_MAX;
|
inc : ZSTREAM_AVAIL_OUT_STEP_MAX;
|
||||||
}
|
}
|
||||||
z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
|
z->stream.next_out = (Bytef*)RSTRING(z->buf)->ptr + z->buf_filled;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -479,13 +479,13 @@ zstream_expand_buffer_into(z, size)
|
||||||
rb_str_buf_new makes a zero-length string. */
|
rb_str_buf_new makes a zero-length string. */
|
||||||
z->buf = rb_str_new(0, size);
|
z->buf = rb_str_new(0, size);
|
||||||
z->buf_filled = 0;
|
z->buf_filled = 0;
|
||||||
z->stream.next_out = RSTRING(z->buf)->ptr;
|
z->stream.next_out = (Bytef*)RSTRING(z->buf)->ptr;
|
||||||
z->stream.avail_out = size;
|
z->stream.avail_out = size;
|
||||||
RBASIC(z->buf)->klass = 0;
|
RBASIC(z->buf)->klass = 0;
|
||||||
}
|
}
|
||||||
else if (z->stream.avail_out != size) {
|
else if (z->stream.avail_out != size) {
|
||||||
rb_str_resize(z->buf, z->buf_filled + size);
|
rb_str_resize(z->buf, z->buf_filled + size);
|
||||||
z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
|
z->stream.next_out = (Bytef*)RSTRING(z->buf)->ptr + z->buf_filled;
|
||||||
z->stream.avail_out = size;
|
z->stream.avail_out = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -493,14 +493,14 @@ zstream_expand_buffer_into(z, size)
|
||||||
static void
|
static void
|
||||||
zstream_append_buffer(z, src, len)
|
zstream_append_buffer(z, src, len)
|
||||||
struct zstream *z;
|
struct zstream *z;
|
||||||
const char *src;
|
const Bytef *src;
|
||||||
int len;
|
int len;
|
||||||
{
|
{
|
||||||
if (NIL_P(z->buf)) {
|
if (NIL_P(z->buf)) {
|
||||||
z->buf = rb_str_buf_new(len);
|
z->buf = rb_str_buf_new(len);
|
||||||
rb_str_buf_cat(z->buf, src, len);
|
rb_str_buf_cat(z->buf, (char*)src, len);
|
||||||
z->buf_filled = len;
|
z->buf_filled = len;
|
||||||
z->stream.next_out = RSTRING(z->buf)->ptr;
|
z->stream.next_out = (Bytef*)RSTRING(z->buf)->ptr;
|
||||||
z->stream.avail_out = 0;
|
z->stream.avail_out = 0;
|
||||||
RBASIC(z->buf)->klass = 0;
|
RBASIC(z->buf)->klass = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -520,11 +520,11 @@ zstream_append_buffer(z, src, len)
|
||||||
}
|
}
|
||||||
memcpy(RSTRING(z->buf)->ptr + z->buf_filled, src, len);
|
memcpy(RSTRING(z->buf)->ptr + z->buf_filled, src, len);
|
||||||
z->buf_filled += len;
|
z->buf_filled += len;
|
||||||
z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
|
z->stream.next_out = (Bytef*)RSTRING(z->buf)->ptr + z->buf_filled;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define zstream_append_buffer2(z,v) \
|
#define zstream_append_buffer2(z,v) \
|
||||||
zstream_append_buffer((z),RSTRING(v)->ptr,RSTRING(v)->len)
|
zstream_append_buffer((z),(Bytef*)RSTRING(v)->ptr,RSTRING(v)->len)
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
zstream_detach_buffer(z)
|
zstream_detach_buffer(z)
|
||||||
|
@ -564,7 +564,7 @@ zstream_shift_buffer(z, len)
|
||||||
z->buf_filled -= len;
|
z->buf_filled -= len;
|
||||||
memmove(RSTRING(z->buf)->ptr, RSTRING(z->buf)->ptr + len,
|
memmove(RSTRING(z->buf)->ptr, RSTRING(z->buf)->ptr + len,
|
||||||
z->buf_filled);
|
z->buf_filled);
|
||||||
z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
|
z->stream.next_out = (Bytef*)RSTRING(z->buf)->ptr + z->buf_filled;
|
||||||
z->stream.avail_out = RSTRING(z->buf)->len - z->buf_filled;
|
z->stream.avail_out = RSTRING(z->buf)->len - z->buf_filled;
|
||||||
if (z->stream.avail_out > ZSTREAM_AVAIL_OUT_STEP_MAX) {
|
if (z->stream.avail_out > ZSTREAM_AVAIL_OUT_STEP_MAX) {
|
||||||
z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
|
z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
|
||||||
|
@ -594,23 +594,23 @@ zstream_buffer_ungetc(z, c)
|
||||||
static void
|
static void
|
||||||
zstream_append_input(z, src, len)
|
zstream_append_input(z, src, len)
|
||||||
struct zstream *z;
|
struct zstream *z;
|
||||||
const char *src;
|
const Bytef *src;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
{
|
{
|
||||||
if (len <= 0) return;
|
if (len <= 0) return;
|
||||||
|
|
||||||
if (NIL_P(z->input)) {
|
if (NIL_P(z->input)) {
|
||||||
z->input = rb_str_buf_new(len);
|
z->input = rb_str_buf_new(len);
|
||||||
rb_str_buf_cat(z->input, src, len);
|
rb_str_buf_cat(z->input, (char*)src, len);
|
||||||
RBASIC(z->input)->klass = 0;
|
RBASIC(z->input)->klass = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_str_buf_cat(z->input, src, len);
|
rb_str_buf_cat(z->input, (char*)src, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define zstream_append_input2(z,v)\
|
#define zstream_append_input2(z,v)\
|
||||||
zstream_append_input((z), RSTRING(v)->ptr, RSTRING(v)->len)
|
zstream_append_input((z), (Bytef*)RSTRING(v)->ptr, RSTRING(v)->len)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zstream_discard_input(z, len)
|
zstream_discard_input(z, len)
|
||||||
|
@ -716,12 +716,12 @@ zstream_run(z, src, len, flush)
|
||||||
volatile VALUE guard;
|
volatile VALUE guard;
|
||||||
|
|
||||||
if (NIL_P(z->input) && len == 0) {
|
if (NIL_P(z->input) && len == 0) {
|
||||||
z->stream.next_in = "";
|
z->stream.next_in = (Bytef*)"";
|
||||||
z->stream.avail_in = 0;
|
z->stream.avail_in = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
zstream_append_input(z, src, len);
|
zstream_append_input(z, src, len);
|
||||||
z->stream.next_in = RSTRING(z->input)->ptr;
|
z->stream.next_in = (Bytef*)RSTRING(z->input)->ptr;
|
||||||
z->stream.avail_in = RSTRING(z->input)->len;
|
z->stream.avail_in = RSTRING(z->input)->len;
|
||||||
/* keep reference to `z->input' so as not to be garbage collected
|
/* keep reference to `z->input' so as not to be garbage collected
|
||||||
after zstream_reset_input() and prevent `z->stream.next_in'
|
after zstream_reset_input() and prevent `z->stream.next_in'
|
||||||
|
@ -780,7 +780,7 @@ zstream_sync(z, src, len)
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!NIL_P(z->input)) {
|
if (!NIL_P(z->input)) {
|
||||||
z->stream.next_in = RSTRING(z->input)->ptr;
|
z->stream.next_in = (Bytef*)RSTRING(z->input)->ptr;
|
||||||
z->stream.avail_in = RSTRING(z->input)->len;
|
z->stream.avail_in = RSTRING(z->input)->len;
|
||||||
err = inflateSync(&z->stream);
|
err = inflateSync(&z->stream);
|
||||||
if (err == Z_OK) {
|
if (err == Z_OK) {
|
||||||
|
@ -791,7 +791,7 @@ zstream_sync(z, src, len)
|
||||||
}
|
}
|
||||||
zstream_reset_input(z);
|
zstream_reset_input(z);
|
||||||
if (err != Z_DATA_ERROR) {
|
if (err != Z_DATA_ERROR) {
|
||||||
rest = rb_str_new(z->stream.next_in, z->stream.avail_in);
|
rest = rb_str_new((char*)z->stream.next_in, z->stream.avail_in);
|
||||||
raise_zlib_error(err, z->stream.msg);
|
raise_zlib_error(err, z->stream.msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -806,7 +806,7 @@ zstream_sync(z, src, len)
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
}
|
}
|
||||||
if (err != Z_DATA_ERROR) {
|
if (err != Z_DATA_ERROR) {
|
||||||
rest = rb_str_new(z->stream.next_in, z->stream.avail_in);
|
rest = rb_str_new((char*)z->stream.next_in, z->stream.avail_in);
|
||||||
raise_zlib_error(err, z->stream.msg);
|
raise_zlib_error(err, z->stream.msg);
|
||||||
}
|
}
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
|
@ -970,7 +970,7 @@ rb_zstream_finish(obj)
|
||||||
struct zstream *z = get_zstream(obj);
|
struct zstream *z = get_zstream(obj);
|
||||||
VALUE dst;
|
VALUE dst;
|
||||||
|
|
||||||
zstream_run(z, "", 0, Z_FINISH);
|
zstream_run(z, (Bytef*)"", 0, Z_FINISH);
|
||||||
dst = zstream_detach_buffer(z);
|
dst = zstream_detach_buffer(z);
|
||||||
|
|
||||||
OBJ_INFECT(dst, obj);
|
OBJ_INFECT(dst, obj);
|
||||||
|
@ -1200,10 +1200,10 @@ static VALUE
|
||||||
deflate_run(args)
|
deflate_run(args)
|
||||||
VALUE args;
|
VALUE args;
|
||||||
{
|
{
|
||||||
struct zstream *z = (struct zstream *)((VALUE *)args)[0];
|
struct zstream *z = (struct zstream*)((VALUE*)args)[0];
|
||||||
VALUE src = ((VALUE *)args)[1];
|
VALUE src = ((VALUE*)args)[1];
|
||||||
|
|
||||||
zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, Z_FINISH);
|
zstream_run(z, (Bytef*)RSTRING(src)->ptr, RSTRING(src)->len, Z_FINISH);
|
||||||
return zstream_detach_buffer(z);
|
return zstream_detach_buffer(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1263,12 +1263,12 @@ do_deflate(z, src, flush)
|
||||||
int flush;
|
int flush;
|
||||||
{
|
{
|
||||||
if (NIL_P(src)) {
|
if (NIL_P(src)) {
|
||||||
zstream_run(z, "", 0, Z_FINISH);
|
zstream_run(z, (Bytef*)"", 0, Z_FINISH);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StringValue(src);
|
StringValue(src);
|
||||||
if (flush != Z_NO_FLUSH || RSTRING(src)->len > 0) { /* prevent BUF_ERROR */
|
if (flush != Z_NO_FLUSH || RSTRING(src)->len > 0) { /* prevent BUF_ERROR */
|
||||||
zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, flush);
|
zstream_run(z, (Bytef*)RSTRING(src)->ptr, RSTRING(src)->len, flush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1342,7 +1342,7 @@ rb_deflate_flush(argc, argv, obj)
|
||||||
rb_scan_args(argc, argv, "01", &v_flush);
|
rb_scan_args(argc, argv, "01", &v_flush);
|
||||||
flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH);
|
flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH);
|
||||||
if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */
|
if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */
|
||||||
zstream_run(z, "", 0, flush);
|
zstream_run(z, (Bytef*)"", 0, flush);
|
||||||
}
|
}
|
||||||
dst = zstream_detach_buffer(z);
|
dst = zstream_detach_buffer(z);
|
||||||
|
|
||||||
|
@ -1403,7 +1403,7 @@ rb_deflate_set_dictionary(obj, dic)
|
||||||
OBJ_INFECT(obj, dic);
|
OBJ_INFECT(obj, dic);
|
||||||
StringValue(src);
|
StringValue(src);
|
||||||
err = deflateSetDictionary(&z->stream,
|
err = deflateSetDictionary(&z->stream,
|
||||||
RSTRING(src)->ptr, RSTRING(src)->len);
|
(Bytef*)RSTRING(src)->ptr, RSTRING(src)->len);
|
||||||
if (err != Z_OK) {
|
if (err != Z_OK) {
|
||||||
raise_zlib_error(err, z->stream.msg);
|
raise_zlib_error(err, z->stream.msg);
|
||||||
}
|
}
|
||||||
|
@ -1465,11 +1465,11 @@ static VALUE
|
||||||
inflate_run(args)
|
inflate_run(args)
|
||||||
VALUE args;
|
VALUE args;
|
||||||
{
|
{
|
||||||
struct zstream *z = (struct zstream *)((VALUE *)args)[0];
|
struct zstream *z = (struct zstream*)((VALUE*)args)[0];
|
||||||
VALUE src = ((VALUE *)args)[1];
|
VALUE src = ((VALUE*)args)[1];
|
||||||
|
|
||||||
zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, Z_SYNC_FLUSH);
|
zstream_run(z, (Bytef*)RSTRING(src)->ptr, RSTRING(src)->len, Z_SYNC_FLUSH);
|
||||||
zstream_run(z, "", 0, Z_FINISH); /* for checking errors */
|
zstream_run(z, (Bytef*)"", 0, Z_FINISH); /* for checking errors */
|
||||||
return zstream_detach_buffer(z);
|
return zstream_detach_buffer(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1520,12 +1520,12 @@ do_inflate(z, src)
|
||||||
VALUE src;
|
VALUE src;
|
||||||
{
|
{
|
||||||
if (NIL_P(src)) {
|
if (NIL_P(src)) {
|
||||||
zstream_run(z, "", 0, Z_FINISH);
|
zstream_run(z, (Bytef*)"", 0, Z_FINISH);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StringValue(src);
|
StringValue(src);
|
||||||
if (RSTRING(src)->len > 0) { /* prevent Z_BUF_ERROR */
|
if (RSTRING(src)->len > 0) { /* prevent Z_BUF_ERROR */
|
||||||
zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, Z_SYNC_FLUSH);
|
zstream_run(z, (Bytef*)RSTRING(src)->ptr, RSTRING(src)->len, Z_SYNC_FLUSH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1621,7 +1621,7 @@ rb_inflate_sync(obj, src)
|
||||||
|
|
||||||
OBJ_INFECT(obj, src);
|
OBJ_INFECT(obj, src);
|
||||||
StringValue(src);
|
StringValue(src);
|
||||||
return zstream_sync(z, RSTRING(src)->ptr, RSTRING(src)->len);
|
return zstream_sync(z, (Bytef*)RSTRING(src)->ptr, RSTRING(src)->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1665,7 +1665,7 @@ rb_inflate_set_dictionary(obj, dic)
|
||||||
OBJ_INFECT(obj, dic);
|
OBJ_INFECT(obj, dic);
|
||||||
StringValue(src);
|
StringValue(src);
|
||||||
err = inflateSetDictionary(&z->stream,
|
err = inflateSetDictionary(&z->stream,
|
||||||
RSTRING(src)->ptr, RSTRING(src)->len);
|
(Bytef*)RSTRING(src)->ptr, RSTRING(src)->len);
|
||||||
if (err != Z_OK) {
|
if (err != Z_OK) {
|
||||||
raise_zlib_error(err, z->stream.msg);
|
raise_zlib_error(err, z->stream.msg);
|
||||||
}
|
}
|
||||||
|
@ -1849,7 +1849,7 @@ static VALUE
|
||||||
gzfile_read_raw_partial(arg)
|
gzfile_read_raw_partial(arg)
|
||||||
VALUE arg;
|
VALUE arg;
|
||||||
{
|
{
|
||||||
struct gzfile *gz = (struct gzfile *)arg;
|
struct gzfile *gz = (struct gzfile*)arg;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
|
|
||||||
str = rb_funcall(gz->io, id_readpartial, 1, INT2FIX(GZFILE_READ_SIZE));
|
str = rb_funcall(gz->io, id_readpartial, 1, INT2FIX(GZFILE_READ_SIZE));
|
||||||
|
@ -1861,7 +1861,7 @@ static VALUE
|
||||||
gzfile_read_raw_rescue(arg)
|
gzfile_read_raw_rescue(arg)
|
||||||
VALUE arg;
|
VALUE arg;
|
||||||
{
|
{
|
||||||
struct gzfile *gz = (struct gzfile *)arg;
|
struct gzfile *gz = (struct gzfile*)arg;
|
||||||
VALUE str = Qnil;
|
VALUE str = Qnil;
|
||||||
if (rb_obj_is_kind_of(ruby_errinfo, rb_eNoMethodError)) {
|
if (rb_obj_is_kind_of(ruby_errinfo, rb_eNoMethodError)) {
|
||||||
str = rb_funcall(gz->io, id_read, 1, INT2FIX(GZFILE_READ_SIZE));
|
str = rb_funcall(gz->io, id_read, 1, INT2FIX(GZFILE_READ_SIZE));
|
||||||
|
@ -1955,7 +1955,7 @@ static void
|
||||||
gzfile_make_header(gz)
|
gzfile_make_header(gz)
|
||||||
struct gzfile *gz;
|
struct gzfile *gz;
|
||||||
{
|
{
|
||||||
unsigned char buf[10]; /* the size of gzip header */
|
Bytef buf[10]; /* the size of gzip header */
|
||||||
unsigned char flags = 0, extraflags = 0;
|
unsigned char flags = 0, extraflags = 0;
|
||||||
|
|
||||||
if (!NIL_P(gz->orig_name)) {
|
if (!NIL_P(gz->orig_name)) {
|
||||||
|
@ -1986,11 +1986,11 @@ gzfile_make_header(gz)
|
||||||
|
|
||||||
if (!NIL_P(gz->orig_name)) {
|
if (!NIL_P(gz->orig_name)) {
|
||||||
zstream_append_buffer2(&gz->z, gz->orig_name);
|
zstream_append_buffer2(&gz->z, gz->orig_name);
|
||||||
zstream_append_buffer(&gz->z, "\0", 1);
|
zstream_append_buffer(&gz->z, (Bytef*)"\0", 1);
|
||||||
}
|
}
|
||||||
if (!NIL_P(gz->comment)) {
|
if (!NIL_P(gz->comment)) {
|
||||||
zstream_append_buffer2(&gz->z, gz->comment);
|
zstream_append_buffer2(&gz->z, gz->comment);
|
||||||
zstream_append_buffer(&gz->z, "\0", 1);
|
zstream_append_buffer(&gz->z, (Bytef*)"\0", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gz->z.flags |= GZFILE_FLAG_HEADER_FINISHED;
|
gz->z.flags |= GZFILE_FLAG_HEADER_FINISHED;
|
||||||
|
@ -2000,7 +2000,7 @@ static void
|
||||||
gzfile_make_footer(gz)
|
gzfile_make_footer(gz)
|
||||||
struct gzfile *gz;
|
struct gzfile *gz;
|
||||||
{
|
{
|
||||||
unsigned char buf[8]; /* 8 is the size of gzip footer */
|
Bytef buf[8]; /* 8 is the size of gzip footer */
|
||||||
|
|
||||||
gzfile_set32(gz->crc, buf);
|
gzfile_set32(gz->crc, buf);
|
||||||
gzfile_set32(gz->z.stream.total_in, &buf[4]);
|
gzfile_set32(gz->z.stream.total_in, &buf[4]);
|
||||||
|
@ -2020,7 +2020,7 @@ gzfile_read_header(gz)
|
||||||
rb_raise(cGzError, "not in gzip format");
|
rb_raise(cGzError, "not in gzip format");
|
||||||
}
|
}
|
||||||
|
|
||||||
head = RSTRING(gz->z.input)->ptr;
|
head = (unsigned char*)RSTRING(gz->z.input)->ptr;
|
||||||
|
|
||||||
if (head[0] != GZ_MAGIC1 || head[1] != GZ_MAGIC2) {
|
if (head[0] != GZ_MAGIC1 || head[1] != GZ_MAGIC2) {
|
||||||
rb_raise(cGzError, "not in gzip format");
|
rb_raise(cGzError, "not in gzip format");
|
||||||
|
@ -2058,7 +2058,7 @@ gzfile_read_header(gz)
|
||||||
if (!gzfile_read_raw_ensure(gz, 2)) {
|
if (!gzfile_read_raw_ensure(gz, 2)) {
|
||||||
rb_raise(cGzError, "unexpected end of file");
|
rb_raise(cGzError, "unexpected end of file");
|
||||||
}
|
}
|
||||||
len = gzfile_get16(RSTRING(gz->z.input)->ptr);
|
len = gzfile_get16((Bytef*)RSTRING(gz->z.input)->ptr);
|
||||||
if (!gzfile_read_raw_ensure(gz, 2 + len)) {
|
if (!gzfile_read_raw_ensure(gz, 2 + len)) {
|
||||||
rb_raise(cGzError, "unexpected end of file");
|
rb_raise(cGzError, "unexpected end of file");
|
||||||
}
|
}
|
||||||
|
@ -2096,8 +2096,8 @@ gzfile_check_footer(gz)
|
||||||
rb_raise(cNoFooter, "footer is not found");
|
rb_raise(cNoFooter, "footer is not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
crc = gzfile_get32(RSTRING(gz->z.input)->ptr);
|
crc = gzfile_get32((Bytef*)RSTRING(gz->z.input)->ptr);
|
||||||
length = gzfile_get32(RSTRING(gz->z.input)->ptr + 4);
|
length = gzfile_get32((Bytef*)RSTRING(gz->z.input)->ptr + 4);
|
||||||
|
|
||||||
gz->z.stream.total_in += 8; /* to rewind correctly */
|
gz->z.stream.total_in += 8; /* to rewind correctly */
|
||||||
zstream_discard_input(&gz->z, 8);
|
zstream_discard_input(&gz->z, 8);
|
||||||
|
@ -2143,7 +2143,7 @@ gzfile_read_more(gz)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (RSTRING(str)->len > 0) { /* prevent Z_BUF_ERROR */
|
if (RSTRING(str)->len > 0) { /* prevent Z_BUF_ERROR */
|
||||||
zstream_run(&gz->z, RSTRING(str)->ptr, RSTRING(str)->len,
|
zstream_run(&gz->z, (Bytef*)RSTRING(str)->ptr, RSTRING(str)->len,
|
||||||
Z_SYNC_FLUSH);
|
Z_SYNC_FLUSH);
|
||||||
}
|
}
|
||||||
if (gz->z.buf_filled > 0) break;
|
if (gz->z.buf_filled > 0) break;
|
||||||
|
@ -2160,7 +2160,7 @@ gzfile_calc_crc(gz, str)
|
||||||
gz->ungetc -= RSTRING(str)->len;
|
gz->ungetc -= RSTRING(str)->len;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gz->crc = crc32(gz->crc, RSTRING(str)->ptr + gz->ungetc,
|
gz->crc = crc32(gz->crc, (Bytef*)RSTRING(str)->ptr + gz->ungetc,
|
||||||
RSTRING(str)->len - gz->ungetc);
|
RSTRING(str)->len - gz->ungetc);
|
||||||
gz->ungetc = 0;
|
gz->ungetc = 0;
|
||||||
}
|
}
|
||||||
|
@ -2285,7 +2285,7 @@ gzfile_writer_end(gz)
|
||||||
gzfile_make_header(gz);
|
gzfile_make_header(gz);
|
||||||
}
|
}
|
||||||
|
|
||||||
zstream_run(&gz->z, "", 0, Z_FINISH);
|
zstream_run(&gz->z, (Bytef*)"", 0, Z_FINISH);
|
||||||
gzfile_make_footer(gz);
|
gzfile_make_footer(gz);
|
||||||
gzfile_write_raw(gz);
|
gzfile_write_raw(gz);
|
||||||
zstream_end(&gz->z);
|
zstream_end(&gz->z);
|
||||||
|
@ -2812,7 +2812,7 @@ rb_gzwriter_flush(argc, argv, obj)
|
||||||
|
|
||||||
flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH);
|
flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH);
|
||||||
if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */
|
if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */
|
||||||
zstream_run(&gz->z, "", 0, flush);
|
zstream_run(&gz->z, (Bytef*)"", 0, flush);
|
||||||
}
|
}
|
||||||
|
|
||||||
gzfile_write_raw(gz);
|
gzfile_write_raw(gz);
|
||||||
|
@ -2834,7 +2834,7 @@ rb_gzwriter_write(obj, str)
|
||||||
if (TYPE(str) != T_STRING) {
|
if (TYPE(str) != T_STRING) {
|
||||||
str = rb_obj_as_string(str);
|
str = rb_obj_as_string(str);
|
||||||
}
|
}
|
||||||
gzfile_write(gz, RSTRING(str)->ptr, RSTRING(str)->len);
|
gzfile_write(gz, (Bytef*)RSTRING(str)->ptr, RSTRING(str)->len);
|
||||||
return INT2FIX(RSTRING(str)->len);
|
return INT2FIX(RSTRING(str)->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2848,7 +2848,7 @@ rb_gzwriter_putc(obj, ch)
|
||||||
struct gzfile *gz = get_gzfile(obj);
|
struct gzfile *gz = get_gzfile(obj);
|
||||||
char c = NUM2CHR(ch);
|
char c = NUM2CHR(ch);
|
||||||
|
|
||||||
gzfile_write(gz, &c, 1);
|
gzfile_write(gz, (Bytef*)&c, 1);
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
gc.c
7
gc.c
|
@ -772,7 +772,6 @@ gc_mark_children(VALUE ptr, int lev)
|
||||||
case NODE_IF: /* 1,2,3 */
|
case NODE_IF: /* 1,2,3 */
|
||||||
case NODE_FOR:
|
case NODE_FOR:
|
||||||
case NODE_ITER:
|
case NODE_ITER:
|
||||||
case NODE_CREF:
|
|
||||||
case NODE_WHEN:
|
case NODE_WHEN:
|
||||||
case NODE_MASGN:
|
case NODE_MASGN:
|
||||||
case NODE_RESCUE:
|
case NODE_RESCUE:
|
||||||
|
@ -792,6 +791,7 @@ gc_mark_children(VALUE ptr, int lev)
|
||||||
case NODE_CALL:
|
case NODE_CALL:
|
||||||
case NODE_DEFS:
|
case NODE_DEFS:
|
||||||
case NODE_OP_ASGN1:
|
case NODE_OP_ASGN1:
|
||||||
|
case NODE_CREF:
|
||||||
gc_mark((VALUE)obj->as.node.u1.node, lev);
|
gc_mark((VALUE)obj->as.node.u1.node, lev);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case NODE_SUPER: /* 3 */
|
case NODE_SUPER: /* 3 */
|
||||||
|
@ -1831,11 +1831,13 @@ rb_gc_finalize_deferred(void)
|
||||||
{
|
{
|
||||||
RVALUE *p = deferred_final_list;
|
RVALUE *p = deferred_final_list;
|
||||||
|
|
||||||
|
during_gc++;
|
||||||
deferred_final_list = 0;
|
deferred_final_list = 0;
|
||||||
if (p) {
|
if (p) {
|
||||||
finalize_list(p);
|
finalize_list(p);
|
||||||
}
|
}
|
||||||
free_unused_heaps();
|
free_unused_heaps();
|
||||||
|
during_gc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1844,6 +1846,8 @@ rb_gc_call_finalizer_at_exit(void)
|
||||||
RVALUE *p, *pend;
|
RVALUE *p, *pend;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* finalizers are part of garbage collection */
|
||||||
|
during_gc++;
|
||||||
/* run finalizers */
|
/* run finalizers */
|
||||||
if (need_call_final) {
|
if (need_call_final) {
|
||||||
p = deferred_final_list;
|
p = deferred_final_list;
|
||||||
|
@ -1884,6 +1888,7 @@ rb_gc_call_finalizer_at_exit(void)
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
during_gc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
7
io.c
7
io.c
|
@ -3798,7 +3798,12 @@ rb_obj_display(int argc, VALUE *argv, VALUE self)
|
||||||
void
|
void
|
||||||
rb_write_error2(const char *mesg, long len)
|
rb_write_error2(const char *mesg, long len)
|
||||||
{
|
{
|
||||||
rb_io_write(rb_stderr, rb_str_new(mesg, len));
|
if (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0) {
|
||||||
|
fwrite(mesg, sizeof(char), len, stderr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rb_io_write(rb_stderr, rb_str_new(mesg, len));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -206,7 +206,7 @@ module IRB
|
||||||
begin
|
begin
|
||||||
load rc_file
|
load rc_file
|
||||||
rescue LoadError, Errno::ENOENT
|
rescue LoadError, Errno::ENOENT
|
||||||
rescue
|
rescue # StandardError, ScriptError
|
||||||
print "load error: #{rc_file}\n"
|
print "load error: #{rc_file}\n"
|
||||||
print $!.class, ": ", $!, "\n"
|
print $!.class, ": ", $!, "\n"
|
||||||
for err in $@[0, $@.size - 2]
|
for err in $@[0, $@.size - 2]
|
||||||
|
@ -250,7 +250,7 @@ module IRB
|
||||||
for m in @CONF[:LOAD_MODULES]
|
for m in @CONF[:LOAD_MODULES]
|
||||||
begin
|
begin
|
||||||
require m
|
require m
|
||||||
rescue
|
rescue # StandardError, ScriptError
|
||||||
print $@[0], ":", $!.class, ": ", $!, "\n"
|
print $@[0], ":", $!.class, ": ", $!, "\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
2
node.h
2
node.h
|
@ -225,6 +225,7 @@ typedef struct RNode {
|
||||||
|
|
||||||
#define nd_modl u1.id
|
#define nd_modl u1.id
|
||||||
#define nd_clss u1.value
|
#define nd_clss u1.value
|
||||||
|
#define nd_vis u2.argc
|
||||||
|
|
||||||
#define nd_beg u1.node
|
#define nd_beg u1.node
|
||||||
#define nd_end u2.node
|
#define nd_end u2.node
|
||||||
|
@ -325,7 +326,6 @@ typedef struct RNode {
|
||||||
#define NEW_MODULE(n,b) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(b),0)
|
#define NEW_MODULE(n,b) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(b),0)
|
||||||
#define NEW_COLON2(c,i) NEW_NODE(NODE_COLON2,c,i,0)
|
#define NEW_COLON2(c,i) NEW_NODE(NODE_COLON2,c,i,0)
|
||||||
#define NEW_COLON3(i) NEW_NODE(NODE_COLON3,0,i,0)
|
#define NEW_COLON3(i) NEW_NODE(NODE_COLON3,0,i,0)
|
||||||
#define NEW_CREF(c) (NEW_NODE(NODE_CREF,0,0,c))
|
|
||||||
#define NEW_DOT2(b,e) NEW_NODE(NODE_DOT2,b,e,0)
|
#define NEW_DOT2(b,e) NEW_NODE(NODE_DOT2,b,e,0)
|
||||||
#define NEW_DOT3(b,e) NEW_NODE(NODE_DOT3,b,e,0)
|
#define NEW_DOT3(b,e) NEW_NODE(NODE_DOT3,b,e,0)
|
||||||
#define NEW_ATTRSET(a) NEW_NODE(NODE_ATTRSET,a,0,0)
|
#define NEW_ATTRSET(a) NEW_NODE(NODE_ATTRSET,a,0,0)
|
||||||
|
|
13
parse.y
13
parse.y
|
@ -5194,9 +5194,16 @@ parser_parse_string(struct parser_params *parser, NODE *quote)
|
||||||
}
|
}
|
||||||
pushback(c);
|
pushback(c);
|
||||||
if (tokadd_string(func, term, paren, "e->nd_nest) == -1) {
|
if (tokadd_string(func, term, paren, "e->nd_nest) == -1) {
|
||||||
ruby_sourceline = nd_line(quote);
|
if (func & STR_FUNC_REGEXP) {
|
||||||
rb_compile_error(PARSER_ARG "unterminated string meets end of file");
|
ruby_sourceline = nd_line(quote);
|
||||||
return tSTRING_END;
|
rb_compile_error(PARSER_ARG "unterminated regexp meets end of file");
|
||||||
|
return tREGEXP_END;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ruby_sourceline = nd_line(quote);
|
||||||
|
rb_compile_error(PARSER_ARG "unterminated string meets end of file");
|
||||||
|
return tSTRING_END;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tokfix();
|
tokfix();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче