summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--array.c12
-rw-r--r--error.c14
-rw-r--r--eval.c6
-rw-r--r--io.c2
-rw-r--r--ruby.c39
6 files changed, 53 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 68d37ca..ed3db7f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
Fri Oct 15 01:32:31 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * io.c (rb_io_ctl) :need to use NUM2ULONG, not NUM2INT.
+
* ext/Win32API/Win32API.c (Win32API_Call): need to use NUM2ULONG,
not NUM2INT.
@@ -20,6 +22,12 @@ Thu Oct 14 02:00:10 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (string): compile time string concatenation.
+Wed Oct 13 02:17:05 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * array.c (rb_ary_plus): remove recursion.
+
+ * array.c (rb_ary_sort_bang): detect modify attempt.
+
Wed Oct 13 02:17:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (block_pass): should copy block to prevent modifications.
diff --git a/array.c b/array.c
index a34545d..b3c5fd4 100644
--- a/array.c
+++ b/array.c
@@ -914,9 +914,9 @@ VALUE
rb_ary_sort_bang(ary)
VALUE ary;
{
+ rb_ary_modify(ary);
if (RARRAY(ary)->len <= 1) return ary;
- rb_ary_modify(ary);
FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */
rb_ensure(sort_internal, ary, sort_unlock, ary);
return ary;
@@ -926,8 +926,9 @@ VALUE
rb_ary_sort(ary)
VALUE ary;
{
+ ary = rb_ary_dup(ary);
if (RARRAY(ary)->len == 0) return ary;
- return rb_ary_sort_bang(rb_ary_dup(ary));
+ return rb_ary_sort_bang(ary);
}
VALUE
@@ -966,11 +967,11 @@ rb_ary_delete_at(ary, at)
long i, pos = NUM2LONG(at), len = RARRAY(ary)->len;
VALUE del = Qnil;
+ rb_ary_modify(ary);
if (pos >= len) return Qnil;
if (pos < 0) pos += len;
if (pos < 0) return Qnil;
- rb_ary_modify(ary);
del = RARRAY(ary)->ptr[pos];
for (i = pos + 1; i < len; i++, pos++) {
RARRAY(ary)->ptr[pos] = RARRAY(ary)->ptr[i];
@@ -1090,7 +1091,7 @@ rb_ary_plus(x, y)
VALUE z;
if (TYPE(y) != T_ARRAY) {
- return rb_ary_plus(x, rb_Array(y));
+ y = rb_Array(y);
}
z = rb_ary_new2(RARRAY(x)->len + RARRAY(y)->len);
@@ -1106,8 +1107,9 @@ rb_ary_concat(x, y)
{
VALUE *p, *pend;
+ rb_ary_modify(x);
if (TYPE(y) != T_ARRAY) {
- return rb_ary_concat(x, rb_Array(y));
+ y = rb_Array(y);
}
p = RARRAY(y)->ptr;
diff --git a/error.c b/error.c
index 6a48210..393603f 100644
--- a/error.c
+++ b/error.c
@@ -34,14 +34,20 @@ err_snprintf(buf, len, fmt, args)
int len;
va_list args;
{
+ int n;
+
if (!ruby_sourcefile) {
vsnprintf(buf, len, fmt, args);
+ return;
+ }
+ else if (ruby_sourceline == 0) {
+ n = snprintf(buf, len, "%s: ", ruby_sourcefile);
}
else {
- int n = snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline);
- if (len > n) {
- vsnprintf((char*)buf+n, len-n, fmt, args);
- }
+ n = snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline);
+ }
+ if (len > n) {
+ vsnprintf((char*)buf+n, len-n, fmt, args);
}
}
diff --git a/eval.c b/eval.c
index 588d668..7a85801 100644
--- a/eval.c
+++ b/eval.c
@@ -793,6 +793,9 @@ error_pos()
fprintf(stderr, "%s:%d:in `%s'", ruby_sourcefile, ruby_sourceline,
rb_id2name(ruby_frame->last_func));
}
+ else if (ruby_sourceline == 0) {
+ fprintf(stderr, "%s", ruby_sourcefile);
+ }
else {
fprintf(stderr, "%s:%d", ruby_sourcefile, ruby_sourceline);
}
@@ -4149,6 +4152,9 @@ backtrace(lev)
ruby_sourcefile, ruby_sourceline,
rb_id2name(frame->last_func));
}
+ else if (ruby_sourceline == 0) {
+ snprintf(buf, BUFSIZ, "%s", ruby_sourcefile);
+ }
else {
snprintf(buf, BUFSIZ, "%s:%d", ruby_sourcefile, ruby_sourceline);
}
diff --git a/io.c b/io.c
index 1dba2ea..ae5634e 100644
--- a/io.c
+++ b/io.c
@@ -2627,7 +2627,7 @@ rb_io_ctl(io, req, arg, io_p)
int io_p;
{
#if !defined(MSDOS) && !defined(__human68k__)
- int cmd = NUM2INT(req);
+ int cmd = NUM2ULONG(req);
OpenFile *fptr;
int len = 0;
int fd;
diff --git a/ruby.c b/ruby.c
index 488c963..bb3741d 100644
--- a/ruby.c
+++ b/ruby.c
@@ -44,20 +44,17 @@ char *strstr _((const char*,const char*));
char *getenv();
#endif
-static int version, copyright;
-
VALUE ruby_debug = Qfalse;
VALUE ruby_verbose = Qfalse;
-static int sflag = Qfalse;
+static int sflag = 0;
+static int xflag = 0;
+extern int yydebug;
char *ruby_inplace_mode = Qfalse;
# ifndef strdup
char *strdup();
# endif
-extern int yydebug;
-static int xflag = Qfalse;
-
static void load_stdin _((void));
static void load_file _((char *, int));
static void forbid_setid _((const char *));
@@ -242,6 +239,7 @@ void
require_libraries()
{
extern NODE *ruby_eval_tree;
+ char *orig_sourcefile = ruby_sourcefile;
NODE *save;
struct req_list *list = req_list_head.next;
struct req_list *tmp;
@@ -256,6 +254,7 @@ require_libraries()
list = tmp;
}
ruby_eval_tree = save;
+ ruby_sourcefile = orig_sourcefile;
}
extern void Init_ext _((void));
@@ -302,6 +301,10 @@ proc_options(argc, argv)
int do_search;
char *s;
+ int version = 0;
+ int copyright = 0;
+ int verbose = 0;
+
if (argc == 0) return;
version = Qfalse;
@@ -328,7 +331,7 @@ proc_options(argc, argv)
case 'd':
ruby_debug = Qtrue;
- ruby_verbose |= 1;
+ ruby_verbose = Qtrue;
s++;
goto reswitch;
@@ -339,9 +342,9 @@ proc_options(argc, argv)
case 'v':
ruby_show_version();
- ruby_verbose = 2;
+ verbose = 1;
case 'w':
- ruby_verbose |= 1;
+ ruby_verbose = Qtrue;
s++;
goto reswitch;
@@ -352,7 +355,7 @@ proc_options(argc, argv)
case 's':
forbid_setid("-s");
- sflag = Qtrue;
+ sflag = 1;
s++;
goto reswitch;
@@ -490,8 +493,10 @@ proc_options(argc, argv)
ruby_debug = 1;
else if (strcmp("version", s) == 0)
version = 1;
- else if (strcmp("verbose", s) == 0)
- ruby_verbose = 2;
+ else if (strcmp("verbose", s) == 0) {
+ verbose = 1;
+ ruby_verbose = Qtrue;
+ }
else if (strcmp("yydebug", s) == 0)
yydebug = 1;
else if (strcmp("help", s) == 0) {
@@ -536,11 +541,8 @@ proc_options(argc, argv)
ruby_show_copyright();
}
- if (ruby_verbose) ruby_verbose = Qtrue;
- if (ruby_debug) ruby_debug = Qtrue;
-
if (!e_script && argc == 0) { /* no more args */
- if (ruby_verbose == 3) exit(0);
+ if (verbose) exit(0);
script = "-";
}
else {
@@ -572,6 +574,7 @@ proc_options(argc, argv)
Init_ext(); /* should be called here for some reason :-( */
require_libraries();
+ ruby_sourcefile = argv0;
if (e_script) {
rb_compile_string(script, e_script, 1);
}
@@ -583,8 +586,8 @@ proc_options(argc, argv)
}
process_sflag();
- sflag = Qfalse;
- xflag = Qfalse;
+ sflag = 0;
+ xflag = 0;
}
extern int ruby__end__seen;