summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog20
-rw-r--r--bignum.c15
-rw-r--r--ext/curses/curses.c10
-rw-r--r--gc.c4
-rw-r--r--intern.h1
-rw-r--r--numeric.c22
-rw-r--r--pack.c10
-rw-r--r--random.c2
-rw-r--r--re.c1
-rw-r--r--ruby.c12
-rw-r--r--ruby.h2
11 files changed, 74 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index a6546a3117..db461b4775 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+Fri May 8 12:26:37 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_unpack): should be unsigned int (was signed int).
+
+Thu May 7 16:34:10 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_pack): `V', `N' uses newly created NUM2UINT().
+
+ * ruby.h (NUM2UINT): new macro.
+
+ * bignum.c (big2uint): try to convert bignum into UINT.
+
+ * re.c (reg_match): needed to return false for match with nil.
+
+ * gc.c (obj_free): wrong condition to free string.
+
+Wed May 6 21:08:08 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ruby.c (ruby_process_options): modified for DJGPP.
+
Wed May 6 15:48:03 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* experimental release 1.1b9_17.
diff --git a/bignum.c b/bignum.c
index ac84ae410c..4d708965de 100644
--- a/bignum.c
+++ b/bignum.c
@@ -342,8 +342,8 @@ big_to_s(x)
return big2str(x, 10);
}
-INT
-big2int(x)
+UINT
+big2uint(x)
VALUE x;
{
UINT num;
@@ -351,13 +351,22 @@ big2int(x)
USHORT *ds;
if (len > sizeof(INT)/sizeof(USHORT))
- ArgError("bignum too big to convert into `int'");
+ ArgError("bignum too big to convert into `uint'");
ds = BDIGITS(x);
num = 0;
while (len--) {
num = BIGUP(num);
num += ds[len];
}
+ return num;
+}
+
+INT
+big2int(x)
+ VALUE x;
+{
+ UINT num = big2uint(x);
+
if ((INT)num < 0) {
ArgError("bignum too big to convert into `int'");
}
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index 4c29202277..ec7c6c6002 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -12,12 +12,18 @@
# include <ncurses/curses.h>
# else
# include <curses.h>
-# if defined(__NetBSD__) && !defined(_maxx)
+# if (defined(__bsdi__) || defined(__NetBSD__)) && !defined(_maxx)
# define _maxx maxx
# endif
-# if defined(__NetBSD__) && !defined(_maxy)
+# if (defined(__bsdi__) || defined(__NetBSD__)) && !defined(_maxy)
# define _maxy maxy
# endif
+# if (defined(__bsdi__) || defined(__NetBSD__)) && !defined(_begx)
+# define _begx begx
+# endif
+# if (defined(__bsdi__) || defined(__NetBSD__)) && !defined(_begy)
+# define _begy begy
+# endif
# endif
#endif
diff --git a/gc.c b/gc.c
index 1642b4bf8b..e208d96ab5 100644
--- a/gc.c
+++ b/gc.c
@@ -658,7 +658,7 @@ obj_free(obj)
break;
case T_STRING:
#define STR_NO_ORIG FL_USER3 /* copied from string.c */
- if (!RANY(obj)->as.string.orig && FL_TEST(obj, STR_NO_ORIG))
+ if (!RANY(obj)->as.string.orig || FL_TEST(obj, STR_NO_ORIG))
free(RANY(obj)->as.string.ptr);
break;
case T_ARRAY:
@@ -1022,7 +1022,7 @@ static VALUE
id2ref(obj, id)
VALUE obj, id;
{
- INT ptr = NUM2INT(id);
+ INT ptr = NUM2UINT(id);
if (FIXNUM_P(ptr)) return (VALUE)ptr;
if (ptr == TRUE) return TRUE;
diff --git a/intern.h b/intern.h
index ac02c72072..86f0f0cd03 100644
--- a/intern.h
+++ b/intern.h
@@ -41,6 +41,7 @@ VALUE int2inum _((INT));
VALUE str2inum _((UCHAR *, int));
VALUE big2str _((VALUE, int));
INT big2int _((VALUE));
+UINT big2uint _((VALUE));
VALUE big_to_i _((VALUE));
VALUE dbl2big _((double));
double big2dbl _((VALUE));
diff --git a/numeric.c b/numeric.c
index 72c1137e3a..f5e843e32c 100644
--- a/numeric.c
+++ b/numeric.c
@@ -649,6 +649,16 @@ num2int(val)
}
}
+UINT
+num2uint(val)
+ VALUE val;
+{
+ if (TYPE(val) == T_BIGNUM) {
+ return big2uint(val);
+ }
+ return (UINT)num2int(val);
+}
+
VALUE
num2fix(val)
VALUE val;
@@ -956,7 +966,7 @@ fix_rev(num)
unsigned long val = FIX2UINT(num);
val = ~val;
- return INT2FIX(val);
+ return int2inum(val);
}
static VALUE
@@ -968,7 +978,7 @@ fix_and(x, y)
if (TYPE(y) == T_BIGNUM) {
return big_and(y, x);
}
- val = NUM2INT(x) & NUM2INT(y);
+ val = FIX2INT(x) & NUM2INT(y);
return int2inum(val);
}
@@ -981,8 +991,8 @@ fix_or(x, y)
if (TYPE(y) == T_BIGNUM) {
return big_or(y, x);
}
- val = NUM2INT(x) | NUM2INT(y);
- return INT2FIX(val);
+ val = FIX2INT(x) | NUM2INT(y);
+ return int2inum(val);
}
static VALUE
@@ -994,8 +1004,8 @@ fix_xor(x, y)
if (TYPE(y) == T_BIGNUM) {
return big_xor(y, x);
}
- val = NUM2INT(x) ^ NUM2INT(y);
- return INT2FIX(val);
+ val = FIX2INT(x) ^ NUM2INT(y);
+ return int2inum(val);
}
static VALUE
diff --git a/pack.c b/pack.c
index 6cd644c331..8bfb771830 100644
--- a/pack.c
+++ b/pack.c
@@ -308,7 +308,7 @@ pack_pack(ary, fmt)
from = NEXTFROM;
if (NIL_P(from)) i = 0;
else {
- i = NUM2INT(from);
+ i = NUM2UINT(from);
}
str_cat(res, (UCHAR*)&i, sizeof(int));
}
@@ -322,7 +322,7 @@ pack_pack(ary, fmt)
from = NEXTFROM;
if (NIL_P(from)) l = 0;
else {
- l = NUM2INT(from);
+ l = NUM2UINT(from);
}
str_cat(res, (UCHAR*)&l, sizeof(long));
}
@@ -349,7 +349,7 @@ pack_pack(ary, fmt)
from = NEXTFROM;
if (NIL_P(from)) l = 0;
else {
- l = NUM2INT(from);
+ l = NUM2UINT(from);
}
l = htonl(l);
str_cat(res, (UCHAR*)&l, sizeof(long));
@@ -377,7 +377,7 @@ pack_pack(ary, fmt)
from = NEXTFROM;
if (NIL_P(from)) l = 0;
else {
- l = NUM2INT(from);
+ l = NUM2UINT(from);
}
l = htovl(l);
str_cat(res, (UCHAR*)&l, sizeof(long));
@@ -743,7 +743,7 @@ pack_unpack(str, fmt)
unsigned int tmp;
memcpy(&tmp, s, sizeof(int));
s += sizeof(int);
- ary_push(ary, int2inum(tmp));
+ ary_push(ary, uint2inum(tmp));
}
break;
diff --git a/random.c b/random.c
index 8d01a961b1..02fc47bc01 100644
--- a/random.c
+++ b/random.c
@@ -50,7 +50,7 @@ f_srand(argc, argv, obj)
seed = tv.tv_sec ^ tv.tv_usec;
}
else {
- seed = NUM2INT(seed);
+ seed = NUM2UINT(seed);
}
#ifdef HAVE_RANDOM
diff --git a/re.c b/re.c
index d4455c349b..642e9b86d0 100644
--- a/re.c
+++ b/re.c
@@ -725,6 +725,7 @@ reg_match(re, str)
{
int start;
+ if (NIL_P(str)) return FALSE;
str = str_to_str(str);
start = reg_search(re, str, 0, 0);
if (start < 0) {
diff --git a/ruby.c b/ruby.c
index 9e8dedd15c..ac5117f258 100644
--- a/ruby.c
+++ b/ruby.c
@@ -567,7 +567,7 @@ load_file(fname, script)
if (script) {
rb_define_global_const("DATA", f);
}
- else if (f != rb_stdin) {
+ if (f != rb_stdin) {
io_close(f);
}
}
@@ -783,7 +783,7 @@ ruby_process_options(argc, argv)
{
origargc = argc; origargv = argv;
ruby_script(argv[0]); /* for the time being */
- rb_argv0 = str_taint(str_new2(argv[0]));
+ rb_argv0 = rb_progname;
#if defined(USE_DLN_A_OUT)
dln_argv0 = argv[0];
#endif
@@ -801,12 +801,12 @@ ruby_process_options(argc, argv)
if (do_loop) {
yywhile_loop(do_line, do_split);
}
- if (e_tmpname) {
- unlink(e_tmpname);
- e_tmpname = NULL;
- }
if (e_fp) {
fclose(e_fp);
e_fp = NULL;
}
+ if (e_tmpname) {
+ unlink(e_tmpname);
+ e_tmpname = NULL;
+ }
}
diff --git a/ruby.h b/ruby.h
index f73af1b72c..65c5853ae2 100644
--- a/ruby.h
+++ b/ruby.h
@@ -172,6 +172,8 @@ void rb_secure _((int));
INT num2int _((VALUE));
#define NUM2INT(x) (FIXNUM_P(x)?FIX2INT(x):num2int((VALUE)x))
+UINT num2uint _((VALUE));
+#define NUM2UINT(x) num2uint((VALUE)x)
double num2dbl _((VALUE));
#define NUM2DBL(x) num2dbl((VALUE)(x))