summaryrefslogtreecommitdiff
path: root/spec/ruby/library/net/ftp/help_spec.rb
AgeCommit message (Expand)Author
2021-05-27Guard ruby/spec with spec/mspec/tool/wrap_with_guard.rbHiroshi SHIBATA
2019-07-27Update to ruby/spec@875a09eBenoit Daloze
2018-03-04Update to ruby/spec@c1b568beregon
2017-09-20Move spec/rubyspec to spec/ruby for consistencyeregon
33df304142f0c8'>patch) tree4fb40e7eab065c70d5b2cdb44eb16bea01b12c15 parentb596fbbc375ea58aa2b869cb6025b2bb101f96b9 (diff)
* io.c (rb_io_mode_flags): both 'r+b' and 'rb+' should be allowed.
* io.c (rb_io_mode_modenum): ditto. * gc.c (rb_memerror): rename from mem_error, and exported. * gc.c (Init_GC): pre-allocate NoMemoryError instance. * object.c (convert_type): error message changed from "failed to convert" to "cannot convert", since it does not try to convert if an object does not respond to the converting method. * eval.c (block_pass): convert Method to Proc using rb_check_convert_type(). * object.c (rb_check_convert_type): always convert T_DATA * eval.c (rb_thread_cleanup): should not terminate main_thread by Fatal error. * regex.c (is_in_list): need to not exclude NUL and NEWLINE. * re.c (rb_reg_expr_str): wrong backslash escapement. * re.c (rb_reg_expr_str): do not escape embedded space characters. * marshal.c (w_object): T_DATA process patch from Joel VanderWerf <vjoel@PATH.Berkeley.EDU>. This is temporary hack; it remains undocumented, and it will be removed when marshaling is re-designed. * marshal.c (r_object): ditto. * numeric.c (num_step): Integer#step is moved to Numeric#step; Fixnum#step is merged into this method. * numeric.c (int_dotimes): Fixnum#times is merged. * numeric.c (int_upto): Fixnum#upto is merged. * numeric.c (int_downto): Fixnum#downto is merged. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat
-rw-r--r--ChangeLog55
-rw-r--r--array.c7
-rw-r--r--error.c48
-rw-r--r--eval.c62
-rw-r--r--file.c9
-rw-r--r--gc.c40
-rw-r--r--intern.h2
-rw-r--r--io.c61
-rw-r--r--lib/mkmf.rb2
-rw-r--r--marshal.c57
-rw-r--r--numeric.c217
-rw-r--r--object.c5
-rw-r--r--parse.y84
-rw-r--r--range.c2
-rw-r--r--re.c66
-rw-r--r--regex.c10
-rw-r--r--regex.h6
-rw-r--r--ruby.h15
-rw-r--r--rubysig.h43
-rw-r--r--signal.c92
-rw-r--r--string.c23
-rw-r--r--time.c4
-rw-r--r--variable.c5
-rw-r--r--version.h4
24 files changed, 485 insertions, 434 deletions
diff --git a/ChangeLog b/ChangeLog
index a79f4b4776..b162165f8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Apr 24 06:48:31 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * io.c (rb_io_mode_flags): both 'r+b' and 'rb+' should be allowed.
+
+ * io.c (rb_io_mode_modenum): ditto.
+
Wed Apr 24 01:16:14 2002 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_mark): must check if ptr is NULL
@@ -14,12 +20,61 @@ Wed Apr 24 00:37:12 2002 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/mkmf.rb (create_makefile): add `{$(srcdir)}' when including depend
file.
+Tue Apr 23 12:58:18 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_memerror): rename from mem_error, and exported.
+
+ * gc.c (Init_GC): pre-allocate NoMemoryError instance.
+
+ * object.c (convert_type): error message changed from "failed to
+ convert" to "cannot convert", since it does not try to convert
+ if an object does not respond to the converting method.
+
+Mon Apr 22 09:31:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (block_pass): convert Method to Proc using
+ rb_check_convert_type().
+
+ * object.c (rb_check_convert_type): always convert T_DATA
+
+ * eval.c (rb_thread_cleanup): should not terminate main_thread by
+ Fatal error.
+
+ * regex.c (is_in_list): need to not exclude NUL and NEWLINE.
+
+Sat Apr 20 00:19:13 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_expr_str): wrong backslash escapement.
+
+ * re.c (rb_reg_expr_str): do not escape embedded space
+ characters.
+
Fri Apr 19 22:03:40 2002 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/Makefile.sub: add -DNT to $CFLAGS instead of $CPPFLAGS.
* win32/setup.mak: ditto.
+Fri Apr 19 17:24:22 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_object): T_DATA process patch from Joel VanderWerf
+ <vjoel@PATH.Berkeley.EDU>. This is temporary hack; it remains
+ undocumented, and it will be removed when marshaling is
+ re-designed.
+
+ * marshal.c (r_object): ditto.
+
+Fri Apr 19 17:10:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (num_step): Integer#step is moved to Numeric#step;
+ Fixnum#step is merged into this method.
+
+ * numeric.c (int_dotimes): Fixnum#times is merged.
+
+ * numeric.c (int_upto): Fixnum#upto is merged.
+
+ * numeric.c (int_downto): Fixnum#downto is merged.
+
Fri Apr 19 16:22:55 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* ext/socket/extconf.rb: include <windows.h>, <winsock.h> on _WIN32.
diff --git a/array.c b/array.c
index ff5ded0e5c..59dfe31ce2 100644
--- a/array.c
+++ b/array.c
@@ -207,13 +207,6 @@ to_ary(ary)
return rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
}
-static VALUE
-to_ary_failed(failed)
- int *failed;
-{
- *failed = Qtrue;
-}
-
static VALUE rb_ary_replace _((VALUE, VALUE));
static VALUE
diff --git a/error.c b/error.c
index 936079a659..65f4ec3745 100644
--- a/error.c
+++ b/error.c
@@ -182,30 +182,30 @@ static struct types {
int type;
const char *name;
} builtin_types[] = {
- T_NIL, "nil",
- T_OBJECT, "Object",
- T_CLASS, "Class",
- T_ICLASS, "iClass", /* internal use: mixed-in module holder */
- T_MODULE, "Module",
- T_FLOAT, "Float",
- T_STRING, "String",
- T_REGEXP, "Regexp",
- T_ARRAY, "Array",
- T_FIXNUM, "Fixnum",
- T_HASH, "Hash",
- T_STRUCT, "Struct",
- T_BIGNUM, "Bignum",
- T_FILE, "File",
- T_TRUE, "true",
- T_FALSE, "false",
- T_SYMBOL, "Symbol", /* :symbol */
- T_DATA, "Data", /* internal use: wrapped C pointers */
- T_MATCH, "MatchData", /* data of $~ */
- T_VARMAP, "Varmap", /* internal use: dynamic variables */
- T_SCOPE, "Scope", /* internal use: variable scope */
- T_NODE, "Node", /* internal use: syntax tree node */
- T_UNDEF, "undef", /* internal use: #undef; should not happen */
- -1, 0,
+ {T_NIL, "nil"},
+ {T_OBJECT, "Object"},
+ {T_CLASS, "Class"},
+ {T_ICLASS, "iClass"}, /* internal use: mixed-in module holder */
+ {T_MODULE, "Module"},
+ {T_FLOAT, "Float"},
+ {T_STRING, "String"},
+ {T_REGEXP, "Regexp"},
+ {T_ARRAY, "Array"},
+ {T_FIXNUM, "Fixnum"},
+ {T_HASH, "Hash"},
+ {T_STRUCT, "Struct"},
+ {T_BIGNUM, "Bignum"},
+ {T_FILE, "File"},
+ {T_TRUE, "true"},
+ {T_FALSE, "false"},
+ {T_SYMBOL, "Symbol"}, /* :symbol */
+ {T_DATA, "Data"}, /* internal use: wrapped C pointers */
+ {T_MATCH, "MatchData"}, /* data of $~ */
+ {T_VARMAP, "Varmap"}, /* internal use: dynamic variables */
+ {T_SCOPE, "Scope"}, /* internal use: variable scope */
+ {T_NODE, "Node"}, /* internal use: syntax tree node */
+ {T_UNDEF, "undef"}, /* internal use: #undef; should not happen */
+ {-1, 0}
};
void
diff --git a/eval.c b/eval.c
index d3a3d76dcf..820ab40292 100644
--- a/eval.c
+++ b/eval.c
@@ -105,7 +105,6 @@ static void rb_f_END _((void));
static VALUE rb_f_block_given_p _((void));
static VALUE block_pass _((VALUE,NODE*));
static VALUE rb_cMethod;
-static VALUE method_proc _((VALUE));
static VALUE method_call _((int, VALUE*, VALUE));
static VALUE rb_cUnboundMethod;
static VALUE umethod_bind _((VALUE, VALUE));
@@ -117,7 +116,7 @@ static int scope_vmode;
#define SCOPE_PROTECTED 2
#define SCOPE_MODFUNC 5
#define SCOPE_MASK 7
-#define SCOPE_SET(f) do {scope_vmode=(f);} while(0)
+#define SCOPE_SET(f) scope_vmode=(f)
#define SCOPE_TEST(f) (scope_vmode&(f))
int ruby_safe_level = 0;
@@ -440,7 +439,7 @@ rb_method_boundp(klass, id, ex)
return Qfalse;
}
-static ID init, alloc, eqq, each, aref, aset, match, to_ary, missing;
+static ID init, alloc, eqq, each, aref, aset, match, missing;
static ID added, singleton_added;
static ID __id__, __send__;
@@ -507,7 +506,7 @@ struct SCOPE *ruby_scope;
static struct FRAME *top_frame;
static struct SCOPE *top_scope;
-#define PUSH_FRAME() { \
+#define PUSH_FRAME() do { \
struct FRAME _frame; \
_frame.prev = ruby_frame; \
_frame.tmp = 0; \
@@ -524,7 +523,7 @@ static struct SCOPE *top_scope;
ruby_sourcefile = _frame.file; \
ruby_sourceline = _frame.line; \
ruby_frame = _frame.prev; \
-}
+} while (0)
struct BLOCKTAG {
struct RBasic super;
@@ -565,7 +564,7 @@ new_blktag()
return blktag;
}
-#define PUSH_BLOCK(v,b) { \
+#define PUSH_BLOCK(v,b) do { \
struct BLOCK _block; \
_block.tag = new_blktag(); \
_block.var = v; \
@@ -590,10 +589,10 @@ new_blktag()
else if (!(_block.scope->flags & SCOPE_DONT_RECYCLE)) \
rb_gc_force_recycle((VALUE)_block.tag); \
ruby_block = _block.prev; \
-}
+} while (0)
struct RVarmap *ruby_dyna_vars;
-#define PUSH_VARS() { \
+#define PUSH_VARS() do { \
struct RVarmap * volatile _old; \
_old = ruby_dyna_vars; \
ruby_dyna_vars = 0
@@ -604,7 +603,7 @@ struct RVarmap *ruby_dyna_vars;
FL_SET(_old, DVAR_DONT_RECYCLE); \
}\
ruby_dyna_vars = _old; \
-}
+} while (0)
#define DVAR_DONT_RECYCLE FL_USER2
@@ -747,7 +746,7 @@ static struct iter *ruby_iter;
#define ITER_PRE 1
#define ITER_CUR 2
-#define PUSH_ITER(i) { \
+#define PUSH_ITER(i) do { \
struct iter _iter; \
_iter.prev = ruby_iter; \
_iter.iter = (i); \
@@ -755,7 +754,7 @@ static struct iter *ruby_iter;
#define POP_ITER() \
ruby_iter = _iter.prev; \
-}
+} while (0)
struct tag {
jmp_buf buf;
@@ -769,7 +768,7 @@ struct tag {
};
static struct tag *prot_tag;
-#define PUSH_TAG(ptag) { \
+#define PUSH_TAG(ptag) do { \
struct tag _tag; \
_tag.retval = Qnil; \
_tag.frame = ruby_frame; \
@@ -796,11 +795,11 @@ static struct tag *prot_tag;
if (_tag.prev) \
_tag.prev->retval = _tag.retval;\
prot_tag = _tag.prev; \
-}
+} while (0)
#define POP_TMPTAG() \
prot_tag = _tag.prev; \
-}
+} while (0)
#define TAG_RETURN 0x1
#define TAG_BREAK 0x2
@@ -815,18 +814,18 @@ static struct tag *prot_tag;
VALUE ruby_class;
static VALUE ruby_wrapper; /* security wrapper */
-#define PUSH_CLASS() { \
+#define PUSH_CLASS() do { \
VALUE _class = ruby_class
#define POP_CLASS() ruby_class = _class; \
-}
+} while (0)
static NODE *ruby_cref = 0;
static NODE *top_cref;
#define PUSH_CREF(c) ruby_cref = rb_node_newnode(NODE_CREF,(c),0,ruby_cref)
#define POP_CREF() ruby_cref = ruby_cref->nd_next
-#define PUSH_SCOPE() { \
+#define PUSH_SCOPE() do { \
volatile int _vmode = scope_vmode; \
struct SCOPE * volatile _old; \
NEWOBJ(_scope, struct SCOPE); \
@@ -858,7 +857,7 @@ static void scope_dup _((struct SCOPE *));
ruby_scope->flags |= SCOPE_NOSTACK; \
ruby_scope = _old; \
scope_vmode = _vmode; \
-}
+} while (0)
static VALUE rb_eval _((VALUE,NODE*));
static VALUE eval _((VALUE,VALUE,VALUE,char*,int));
@@ -1756,7 +1755,7 @@ copy_node_scope(node, rval)
}\
} while (0)
-#define BEGIN_CALLARGS {\
+#define BEGIN_CALLARGS do {\
struct BLOCK *tmp_block = ruby_block;\
if (ruby_iter->iter == ITER_PRE) {\
ruby_block = ruby_block->prev;\
@@ -1766,7 +1765,7 @@ copy_node_scope(node, rval)
#define END_CALLARGS \
ruby_block = tmp_block;\
POP_ITER();\
-}
+} while (0)
#define MATCH_DATA *rb_svar(node->nd_cnt)
@@ -2152,7 +2151,10 @@ rb_eval(self, n)
int state;
volatile VALUE result = Qnil;
-#define RETURN(v) { result = (v); goto finish; }
+#define RETURN(v) do { \
+ result = (v); \
+ goto finish; \
+} while (0)
again:
if (!node) RETURN(Qnil);
@@ -4929,7 +4931,7 @@ eval(self, src, scope, file, line)
char *file;
int line;
{
- struct BLOCK *data;
+ struct BLOCK *data = NULL;
volatile VALUE result = Qnil;
struct SCOPE * volatile old_scope;
struct BLOCK * volatile old_block;
@@ -5472,7 +5474,6 @@ rb_f_require(obj, fname)
{
VALUE feature, tmp;
char *ext, *ftptr; /* OK */
- volatile VALUE load;
int state;
volatile int safe = ruby_safe_level;
@@ -6019,7 +6020,6 @@ Init_eval()
aref = rb_intern("[]");
aset = rb_intern("[]=");
match = rb_intern("=~");
- to_ary = rb_intern("to_ary");
missing = rb_intern("method_missing");
added = rb_intern("method_added");
singleton_added = rb_intern("singleton_method_added");
@@ -6590,6 +6590,7 @@ block_pass(self, node)
NODE *node;
{
VALUE block = rb_eval(self, node->nd_body); /* OK */
+ VALUE b;
struct BLOCK * volatile old_block;
struct BLOCK _block;
struct BLOCK *data;
@@ -6604,13 +6605,12 @@ block_pass(self, node)
POP_ITER();
return result;
}
- if (rb_obj_is_kind_of(block, rb_cMethod)) {
- block = method_proc(block);
- }
- else if (!rb_obj_is_proc(block)) {
+ b = rb_check_convert_type(block, T_DATA, "Proc", "to_proc");
+ if (!rb_obj_is_proc(b)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc)",
rb_class2name(CLASS_OF(block)));
}
+ block = b;
if (rb_safe_level() >= 1 && OBJ_TAINTED(block)) {
if (rb_safe_level() > proc_get_safe_level(block)) {
@@ -8697,8 +8697,10 @@ rb_thread_cleanup()
rb_thread_ready(th);
th->gid = 0;
th->priority = 0;
- th->status = THREAD_TO_KILL;
- RDATA(th->thread)->dfree = NULL;
+ if (th != main_thread) {
+ th->status = THREAD_TO_KILL;
+ RDATA(th->thread)->dfree = NULL;
+ }
}
}
END_FOREACH(th);
diff --git a/file.c b/file.c
index 3a7f5e393f..064cc78259 100644
--- a/file.c
+++ b/file.c
@@ -1587,7 +1587,7 @@ rb_file_s_basename(argc, argv)
VALUE *argv;
{
VALUE fname, fext, basename;
- char *name, *p, *ext;
+ char *name, *p, *ext = NULL;
int f;
if (rb_scan_args(argc, argv, "11", &fname, &fext) == 2) {
@@ -1998,7 +1998,7 @@ static VALUE
rb_stat_clone(obj)
VALUE obj;
{
- struct stat st, *nst;
+ struct stat *nst;
VALUE clone;
@@ -2403,7 +2403,7 @@ rb_find_file_ext(filep, ext)
VALUE *filep;
const char * const *ext;
{
- char *path, *e, *found;
+ char *path, *found;
char *f = RSTRING(*filep)->ptr;
VALUE fname;
int i, j;
@@ -2454,10 +2454,9 @@ VALUE
rb_find_file(path)
VALUE path;
{
- VALUE tmp, fname;
+ VALUE tmp;
char *f = RSTRING(path)->ptr;
char *lpath;
- struct stat st;
if (f[0] == '~') {
path = rb_file_s_expand_path(1, &path);
diff --git a/gc.c b/gc.c
index e95f38e6b3..6cd0222f2f 100644
--- a/gc.c
+++ b/gc.c
@@ -66,22 +66,19 @@ static void run_final();
#endif
static unsigned long malloc_memories = 0;
+static VALUE nomem_error;
-static void
-mem_error(mesg)
- char *mesg;
+void
+rb_memerror()
{
static int recurse = 0;
- if (rb_safe_level() >= 4) {
- rb_raise(rb_eNoMemError, mesg);
+ if (recurse > 0 && rb_safe_level() < 4) {
+ fprintf(stderr, "[FATAL] failed to allocate memory\n");
+ exit(1);
}
- if (recurse == 0) {
- recurse++;
- rb_fatal(mesg);
- }
- fprintf(stderr, "[FATAL] failed to allocate memory\n");
- exit(1);
+ recurse++;
+ rb_exc_raise(nomem_error);
}
void *
@@ -104,10 +101,7 @@ ruby_xmalloc(size)
rb_gc();
RUBY_CRITICAL(mem = malloc(size));
if (!mem) {
- if (size >= 10 * 1024 * 1024) {
- mem_error("tried to allocate too big memory");
- }
- mem_error("failed to allocate memory");
+ rb_memerror();
}
}
@@ -144,10 +138,7 @@ ruby_xrealloc(ptr, size)
rb_gc();
RUBY_CRITICAL(mem = realloc(ptr, size));
if (!mem) {
- if (size >= 10 * 1024 * 1024) {
- rb_raise(rb_eNoMemError, "tried to re-allocate too big memory");
- }
- mem_error("failed to allocate memory(realloc)");
+ rb_memerror();
}
}
@@ -287,11 +278,11 @@ add_heap()
RUBY_CRITICAL(heaps = (heaps_used>0)?
(RVALUE**)realloc(heaps, heaps_length*sizeof(RVALUE*)):
(RVALUE**)malloc(heaps_length*sizeof(RVALUE*)));
- if (heaps == 0) mem_error("heaps: can't alloc memory");
+ if (heaps == 0) rb_memerror();
RUBY_CRITICAL(heaps_limits = (heaps_used>0)?
(int*)realloc(heaps_limits, heaps_length*sizeof(int)):
(int*)malloc(heaps_length*sizeof(int)));
- if (heaps_limits == 0) mem_error("heaps_limits: can't alloc memory");
+ if (heaps_limits == 0) rb_memerror();
}
for (;;) {
@@ -299,7 +290,7 @@ add_heap()
heaps_limits[heaps_used] = heap_slots;
if (p == 0) {
if (heap_slots == HEAP_MIN_SLOTS) {
- mem_error("add_heap: can't alloc memory");
+ rb_memerror();
}
heap_slots = HEAP_MIN_SLOTS;
continue;
@@ -396,8 +387,6 @@ int
ruby_stack_length(p)
VALUE **p;
{
- int ret;
-
SET_STACK_END;
if (p) *p = STACK_END;
return STACK_LENGTH;
@@ -1558,4 +1547,7 @@ Init_GC()
finalizers = rb_ary_new();
source_filenames = st_init_strtable();
+
+ nomem_error = rb_exc_new(rb_eNoMemError, "failed to allocate memory");
+ rb_global_variable(&nomem_error);
}
diff --git a/intern.h b/intern.h
index 2ca00ace4a..733f1c1029 100644
--- a/intern.h
+++ b/intern.h