summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-13 05:58:11 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-13 05:58:11 +0000
commitad592443af373c3bbe61b41df106734856ad3072 (patch)
tree7b22e50d3e273c1777d0e0984f4bfca92978131c
parent9fd5fe739c55bfed9aa22728c1cefcb2e19d1720 (diff)
no INT,UINT
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--bignum.c91
-rw-r--r--configure.in1
-rw-r--r--error.c2
-rw-r--r--eval.c4
-rw-r--r--ext/socket/socket.c2
-rw-r--r--file.c2
-rw-r--r--gc.c6
-rw-r--r--intern.h108
-rw-r--r--io.c2
-rw-r--r--marshal.c18
-rw-r--r--node.h8
-rw-r--r--numeric.c96
-rw-r--r--pack.c46
-rw-r--r--random.c2
-rw-r--r--ruby.c2
-rw-r--r--ruby.h78
-rw-r--r--sample/test.rb1
-rw-r--r--string.c109
19 files changed, 311 insertions, 273 deletions
diff --git a/ChangeLog b/ChangeLog
index 2790f7df86..4d4e952d8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed May 13 14:56:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.h: xxx2INT, xxx2UINT checks values as int, not long.
+
+ * ruby.h: remove typedef's. INT, UINT, UCHAR, USHORT.
+
Tue May 12 17:38:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* experimental release 1.1b9_18.
diff --git a/bignum.c b/bignum.c
index 4d708965de..bd14002850 100644
--- a/bignum.c
+++ b/bignum.c
@@ -14,19 +14,20 @@
extern VALUE cInteger;
VALUE cBignum;
+typedef unsigned short USHORT;
#define BDIGITS(x) RBIGNUM(x)->digits
-#define BITSPERDIG (sizeof(USHORT)*CHAR_BIT)
+#define BITSPERDIG (sizeof(short)*CHAR_BIT)
#define BIGRAD (1L << BITSPERDIG)
-#define DIGSPERINT ((UINT)(sizeof(INT)/sizeof(USHORT)))
-#define BIGUP(x) ((UINT)(x) << BITSPERDIG)
+#define DIGSPERINT ((unsigned int)(sizeof(long)/sizeof(short)))
+#define BIGUP(x) ((unsigned int)(x) << BITSPERDIG)
#define BIGDN(x) ((x) >> BITSPERDIG)
#define BIGLO(x) ((x) & (BIGRAD-1))
static VALUE
bignew_1(klass, len, sign)
VALUE klass;
- UINT len;
+ unsigned int len;
char sign;
{
NEWOBJ(big, struct RBignum);
@@ -54,7 +55,7 @@ void
big_2comp(x) /* get 2's complement */
VALUE x;
{
- UINT i = RBIGNUM(x)->len;
+ unsigned int i = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(x);
long num;
@@ -79,7 +80,7 @@ static VALUE
bignorm(x)
VALUE x;
{
- UINT len = RBIGNUM(x)->len;
+ unsigned int len = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(x);
while (len-- && !ds[len]) ;
@@ -109,9 +110,9 @@ big_norm(x)
VALUE
uint2big(n)
- UINT n;
+ unsigned long n;
{
- UINT i = 0;
+ unsigned int i = 0;
USHORT *digits;
VALUE big;
@@ -131,9 +132,9 @@ uint2big(n)
VALUE
int2big(n)
- INT n;
+ long n;
{
- INT neg = 0;
+ long neg = 0;
VALUE big;
if (n < 0) {
@@ -149,7 +150,7 @@ int2big(n)
VALUE
uint2inum(n)
- UINT n;
+ unsigned long n;
{
if (POSFIXABLE(n)) return INT2FIX(n);
return uint2big(n);
@@ -157,7 +158,7 @@ uint2inum(n)
VALUE
int2inum(n)
- INT n;
+ long n;
{
if (FIXABLE(n)) return INT2FIX(n);
return int2big(n);
@@ -165,12 +166,12 @@ int2inum(n)
VALUE
str2inum(str, base)
- UCHAR *str;
+ char *str;
int base;
{
char sign = 1, c;
unsigned long num;
- UINT len, blen = 1, i;
+ unsigned int len, blen = 1, i;
VALUE z;
USHORT *zds;
@@ -208,12 +209,12 @@ str2inum(str, base)
}
if (len <= (sizeof(VALUE)*CHAR_BIT)) {
- UINT val = strtoul((char*)str, 0, base);
+ unsigned int val = strtoul((char*)str, 0, base);
if (POSFIXABLE(val)) {
if (sign) return INT2FIX(val);
else {
- INT result = -(INT)val;
+ long result = -(long)val;
return INT2FIX(result);
}
}
@@ -273,9 +274,9 @@ big2str(x, base)
{
VALUE t;
USHORT *ds;
- UINT i, j, hbase;
+ unsigned int i, j, hbase;
VALUE ss;
- UCHAR *s, c;
+ char *s, c;
if (FIXNUM_P(x)) {
return fix2str(x, base);
@@ -342,15 +343,15 @@ big_to_s(x)
return big2str(x, 10);
}
-UINT
-big2uint(x)
+unsigned long
+big2ulong(x)
VALUE x;
{
- UINT num;
- UINT len = RBIGNUM(x)->len;
+ unsigned int num;
+ unsigned int len = RBIGNUM(x)->len;
USHORT *ds;
- if (len > sizeof(INT)/sizeof(USHORT))
+ if (len > sizeof(long)/sizeof(short))
ArgError("bignum too big to convert into `uint'");
ds = BDIGITS(x);
num = 0;
@@ -361,13 +362,13 @@ big2uint(x)
return num;
}
-INT
-big2int(x)
+long
+big2long(x)
VALUE x;
{
- UINT num = big2uint(x);
+ unsigned long num = big2ulong(x);
- if ((INT)num < 0) {
+ if ((long)num < 0) {
ArgError("bignum too big to convert into `int'");
}
if (!RBIGNUM(x)->sign) return -num;
@@ -385,7 +386,7 @@ VALUE
dbl2big(d)
double d;
{
- UINT i = 0;
+ unsigned int i = 0;
long c;
USHORT *digits;
VALUE z;
@@ -412,7 +413,7 @@ big2dbl(x)
VALUE x;
{
double d = 0.0;
- UINT i = RBIGNUM(x)->len;
+ unsigned int i = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(x);
while (i--) {
@@ -485,7 +486,7 @@ big_neg(x)
VALUE x;
{
VALUE z = big_clone(x);
- UINT i = RBIGNUM(x)->len;
+ unsigned int i = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(z);
if (!RBIGNUM(x)->sign) big_2comp(z);
@@ -503,7 +504,7 @@ bigsub(x, y)
VALUE z = 0;
USHORT *zds;
long num;
- UINT i;
+ unsigned int i;
i = RBIGNUM(x)->len;
/* if x is larger than y, swap */
@@ -551,7 +552,7 @@ bigadd(x, y, sign)
{
VALUE z;
long num;
- UINT i, len;
+ unsigned int i, len;
if (RBIGNUM(x)->sign == (RBIGNUM(y)->sign ^ sign)) {
if (RBIGNUM(y)->sign == sign) return bigsub(y, x);
@@ -630,7 +631,7 @@ VALUE
big_mul(x, y)
VALUE x, y;
{
- UINT i = 0, j;
+ unsigned int i = 0, j;
unsigned long n = 0;
VALUE z;
USHORT *zds;
@@ -679,7 +680,7 @@ bigdivmod(x, y, div, mod, modulo)
VALUE *div, *mod;
int modulo;
{
- UINT nx = RBIGNUM(x)->len, ny = RBIGNUM(y)->len, i, j;
+ unsigned int nx = RBIGNUM(x)->len, ny = RBIGNUM(y)->len, i, j;
VALUE yy, z;
USHORT *xds, *yds, *zds, *tds;
unsigned long t2;
@@ -944,7 +945,7 @@ big_and(x, y)
{
VALUE z;
USHORT *ds1, *ds2, *zds;
- UINT i, l1, l2;
+ unsigned int i, l1, l2;
char sign;
if (FIXNUM_P(y)) {
@@ -995,7 +996,7 @@ big_or(x, y)
{
VALUE z;
USHORT *ds1, *ds2, *zds;
- UINT i, l1, l2;
+ unsigned int i, l1, l2;
char sign;
if (FIXNUM_P(y)) {
@@ -1047,7 +1048,7 @@ big_xor(x, y)
{
VALUE z;
USHORT *ds1, *ds2, *zds;
- UINT i, l1, l2;
+ unsigned int i, l1, l2;
char sign;
if (FIXNUM_P(y)) {
@@ -1103,11 +1104,11 @@ big_lshift(x, y)
{
USHORT *xds, *zds;
int shift = NUM2INT(y);
- UINT s1 = shift/BITSPERDIG;
- UINT s2 = shift%BITSPERDIG;
+ unsigned int s1 = shift/BITSPERDIG;
+ unsigned int s2 = shift%BITSPERDIG;
VALUE z;
unsigned long num = 0;
- UINT len, i;
+ unsigned int len, i;
if (shift < 0) return big_rshift(x, INT2FIX(-shift));
xds = BDIGITS(x);
@@ -1132,12 +1133,12 @@ big_rshift(x, y)
{
USHORT *xds, *zds;
int shift = NUM2INT(y);
- UINT s1 = shift/BITSPERDIG;
- UINT s2 = shift%BITSPERDIG;
+ unsigned int s1 = shift/BITSPERDIG;
+ unsigned int s2 = shift%BITSPERDIG;
VALUE z;
unsigned long num = 0;
- UINT i = RBIGNUM(x)->len;
- UINT j;
+ unsigned int i = RBIGNUM(x)->len;
+ unsigned int j;
if (shift < 0) return big_lshift(x, INT2FIX(-shift));
if (s1 > RBIGNUM(x)->len) {
@@ -1164,7 +1165,7 @@ big_aref(x, y)
{
USHORT *xds;
int shift = NUM2INT(y);
- UINT s1, s2;
+ unsigned int s1, s2;
if (shift < 0) return INT2FIX(0);
s1 = shift/BITSPERDIG;
diff --git a/configure.in b/configure.in
index 6dc56e2b49..e674d7935e 100644
--- a/configure.in
+++ b/configure.in
@@ -98,7 +98,6 @@ AC_STRUCT_ST_BLOCKS
LIBOBJS="$save_LIBOBJS"
AC_STRUCT_ST_RDEV
-AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(void*)
diff --git a/error.c b/error.c
index 48f100a2d9..cb6e8c8071 100644
--- a/error.c
+++ b/error.c
@@ -232,7 +232,7 @@ VALUE
exc_new(etype, ptr, len)
VALUE etype;
char *ptr;
- UINT len;
+ unsigned len;
{
VALUE exc = obj_alloc(etype);
diff --git a/eval.c b/eval.c
index 49364df54b..f4cd910e3d 100644
--- a/eval.c
+++ b/eval.c
@@ -758,7 +758,7 @@ error_print()
putc('\n', stderr);
}
else {
- UCHAR *tail = 0;
+ char *tail = 0;
int len = RSTRING(einfo)->len;
if (RSTRING(epath)->ptr[0] == '#') epath = 0;
@@ -2791,7 +2791,7 @@ rb_yield_0(val, self)
struct SCOPE *old_scope;
struct FRAME frame;
int state;
- static USHORT serial = 1;
+ static unsigned serial = 1;
if (!iterator_p()) {
Raise(eLocalJumpError, "yield called out of iterator");
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 481b9ffa2a..4d7cb0f35c 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1386,7 +1386,7 @@ static VALUE mConst;
static void
sock_define_const(name, value)
char *name;
- INT value;
+ int value;
{
rb_define_const(cSocket, name, INT2FIX(value));
rb_define_const(mConst, name, INT2FIX(value));
diff --git a/file.c b/file.c
index 2a635b46fd..845ca13c54 100644
--- a/file.c
+++ b/file.c
@@ -1247,7 +1247,7 @@ static VALUE
file_s_dirname(obj, fname)
VALUE obj, fname;
{
- UCHAR *name, *p;
+ char *name, *p;
name = STR2CSTR(fname);
p = strrchr(name, '/');
diff --git a/gc.c b/gc.c
index e208d96ab5..044d6675b8 100644
--- a/gc.c
+++ b/gc.c
@@ -170,7 +170,7 @@ rb_global_variable(var)
typedef struct RVALUE {
union {
struct {
- UINT flag; /* always 0 for freed obj */
+ unsigned long flag; /* always 0 for freed obj */
struct RVALUE *next;
} free;
struct RBasic basic;
@@ -985,7 +985,7 @@ run_final(obj)
if (!FL_TEST(obj, FL_FINALIZE)) return;
- obj = INT2NUM((int)obj); /* make obj into id */
+ obj = INT2NUM((long)obj); /* make obj into id */
for (i=0; i<RARRAY(finalizers)->len; i++) {
rb_eval_cmd(RARRAY(finalizers)->ptr[i], ary_new3(1,obj));
}
@@ -1022,7 +1022,7 @@ static VALUE
id2ref(obj, id)
VALUE obj, id;
{
- INT ptr = NUM2UINT(id);
+ unsigned long ptr = NUM2UINT(id);
if (FIXNUM_P(ptr)) return (VALUE)ptr;
if (ptr == TRUE) return TRUE;
diff --git a/intern.h b/intern.h
index 86f0f0cd03..9c13b7b584 100644
--- a/intern.h
+++ b/intern.h
@@ -3,12 +3,12 @@
*/
/* array.c */
-void memclear _((register VALUE *, register int));
+void memclear _((register VALUE*, register int));
VALUE assoc_new _((VALUE, VALUE));
VALUE ary_new _((void));
VALUE ary_new2 _((int));
VALUE ary_new3();
-VALUE ary_new4 _((int, VALUE *));
+VALUE ary_new4 _((int, VALUE*));
VALUE ary_freeze _((VALUE));
void ary_store _((VALUE, int, VALUE));
VALUE ary_push _((VALUE, VALUE));
@@ -34,14 +34,16 @@ VALUE ary_includes _((VALUE, VALUE));
VALUE big_clone _((VALUE));
void big_2comp _((VALUE));
VALUE big_norm _((VALUE));
-VALUE uint2big _((UINT));
-VALUE int2big _((INT));
-VALUE uint2inum _((UINT));
-VALUE int2inum _((INT));
-VALUE str2inum _((UCHAR *, int));
+VALUE uint2big _((unsigned long));
+VALUE int2big _((long));
+VALUE uint2inum _((unsigned long));
+VALUE int2inum _((long));
+VALUE str2inum _((char*, int));
VALUE big2str _((VALUE, int));
-INT big2int _((VALUE));
-UINT big2uint _((VALUE));
+long big2long _((VALUE));
+#define big2int(x) big2long(x)
+unsigned long big2ulong _((VALUE));
+#define big2uint(x) big2ulong(x)
VALUE big_to_i _((VALUE));
VALUE dbl2big _((double));
double big2dbl _((VALUE));
@@ -65,21 +67,21 @@ VALUE module_new _((void));
VALUE rb_define_module_id _((ID));
VALUE mod_included_modules _((VALUE));
VALUE mod_ancestors _((VALUE));
-VALUE class_instance_methods _((int, VALUE *, VALUE));
-VALUE class_private_instance_methods _((int, VALUE *, VALUE));
+VALUE class_instance_methods _((int, VALUE*, VALUE));
+VALUE class_private_instance_methods _((int, VALUE*, VALUE));
VALUE obj_singleton_methods _((VALUE));
void rb_define_method_id _((VALUE, ID, VALUE (*)(), int));
-void rb_undef_method _((VALUE, char *));
-void rb_define_protected_method _((VALUE, char *, VALUE (*)(), int));
-void rb_define_private_method _((VALUE, char *, VALUE (*)(), int));
+void rb_undef_method _((VALUE, char*));
+void rb_define_protected_method _((VALUE, char*, VALUE (*)(), int));
+void rb_define_private_method _((VALUE, char*, VALUE (*)(), int));
void rb_define_singleton_method _((VALUE,char*,VALUE(*)(),int));
void rb_define_private_method _((VALUE,char*,VALUE(*)(),int));
VALUE rb_singleton_class _((VALUE));
/* enum.c */
VALUE enum_length _((VALUE));
/* error.c */
-VALUE exc_new _((VALUE, char *, UINT));
-VALUE exc_new2 _((VALUE, char *));
+VALUE exc_new _((VALUE, char*, unsigned int));
+VALUE exc_new2 _((VALUE, char*));
VALUE exc_new3 _((VALUE, VALUE));
#ifdef __GNUC__
volatile voidfn TypeError;
@@ -95,9 +97,9 @@ void IndexError();
void LoadError();
#endif
/* eval.c */
-void rb_remove_method _((VALUE, char *));
-void rb_disable_super _((VALUE, char *));
-void rb_enable_super _((VALUE, char *));
+void rb_remove_method _((VALUE, char*));
+void rb_disable_super _((VALUE, char*));
+void rb_enable_super _((VALUE, char*));
void rb_clear_cache _((void));
void rb_alias _((VALUE, ID, ID));
void rb_attr _((VALUE,ID,int,int,int));
@@ -106,7 +108,7 @@ VALUE dyna_var_defined _((ID));
VALUE dyna_var_ref _((ID));
VALUE dyna_var_asgn _((ID, VALUE));
void ruby_init _((void));
-void ruby_options _((int, char **));
+void ruby_options _((int, char**));
void ruby_run _((void));
void rb_eval_cmd _((VALUE, VALUE));
void rb_trap_eval _((VALUE, int));
@@ -117,14 +119,14 @@ void rb_interrupt _((void));
int iterator_p _((void));
VALUE rb_yield_0 _((VALUE, volatile VALUE));
VALUE rb_apply _((VALUE, ID, VALUE));
-VALUE rb_funcall2 _((VALUE, ID, int, VALUE *));
+VALUE rb_funcall2 _((VALUE, ID, int, VALUE*));
void rb_backtrace _((void));
ID rb_frame_last_func _((void));
VALUE f_load _((VALUE, VALUE));
-void rb_provide _((char *));
+void rb_provide _((char*));
VALUE f_require _((VALUE, VALUE));
void obj_call_init _((VALUE));
-VALUE class_new_instance _((int, VALUE *, VALUE));
+VALUE class_new_instance _((int, VALUE*, VALUE));
VALUE f_lambda _((void));
void rb_set_end_proc _((void (*)(),VALUE));
void gc_mark_threads _((void));
@@ -134,16 +136,16 @@ void thread_fd_writable _((int));
int thread_alone _((void));
void thread_sleep _((int));
void thread_sleep_forever _((void));
-VALUE thread_create _((VALUE (*)(), void *));
+VALUE thread_create _((VALUE (*)(), void*));
void thread_interrupt _((void));
void thread_trap_eval _((VALUE, int));
/* file.c */
-VALUE file_open _((char *, char *));
-int eaccess _((char *, int));
+VALUE file_open _((char*, char*));
+int eaccess _((char*, int));
VALUE file_s_expand_path _((VALUE, VALUE));
/* gc.c */
-void rb_global_variable _((VALUE *));
-void gc_mark_locations _((VALUE *, VALUE *));
+void rb_global_variable _((VALUE*));
+void gc_mark_locations _((VALUE*, VALUE*));
void gc_mark_maybe();
void gc_mark();
void gc_force_recycle();
@@ -165,10 +167,10 @@ VALUE io_getc _((VALUE));
VALUE io_ungetc _((VALUE, VALUE));
VALUE io_close _((VALUE));
VALUE io_binmode _((VALUE));
-int io_mode_flags _((char *));
+int io_mode_flags _((char*));
VALUE io_reopen _((VALUE, VALUE));
VALUE f_gets _((void));
-void rb_str_setter _((VALUE, ID, VALUE *));
+void rb_str_setter _((VALUE, ID, VALUE*));
/* numeric.c */
void num_zerodiv _((void));
VALUE num_coerce_bin _((VALUE, VALUE));
@@ -208,11 +210,11 @@ void backref_set _((VALUE));
VALUE lastline_get _((void));
void lastline_set _((VALUE));
/* process.c */
-int rb_proc_exec _((char *));
+int rb_proc_exec _((char*));
void rb_syswait _((int));
/* range.c */
VALUE range_new _((VALUE, VALUE));
-VALUE range_beg_end _((VALUE, int *, int *));
+VALUE range_beg_end _((VALUE, int*, int*));
/* re.c */
VALUE reg_nth_defined _((int, VALUE));
VALUE reg_nth_match _((int, VALUE));
@@ -220,30 +222,30 @@ VALUE reg_last_match _((VALUE));
VALUE reg_match_pre _((VALUE));
VALUE reg_match_post _((VALUE));
VALUE reg_match_last _((VALUE));
-VALUE reg_new _((char *, int, int));
+VALUE reg_new _((char*, int, int));
VALUE reg_match _((VALUE, VALUE));
VALUE reg_match2 _((VALUE));
char*rb_get_kcode _((void));
-void rb_set_kcode _((char *));
+void rb_set_kcode _((char*));
/* ruby.c */
-void rb_load_file _((char *));
-void ruby_script _((char *));
+void rb_load_file _((char*));
+void ruby_script _((char*));
void ruby_prog_init _((void));
-void ruby_set_argv _((int, char **));
-void ruby_process_options _((int, char **));
+void ruby_set_argv _((int, char**));
+void ruby_process_options _((int, char**));
void ruby_require_modules _((void));
void ruby_load_script _((void));
/* signal.c */
-VALUE f_kill _((int, VALUE *));
+VALUE f_kill _((int, VALUE*));
void gc_mark_trap_list _((void));
void posix_signal _((int, void (*)()));
void rb_trap_exit _((void));
void rb_trap_exec _((void));
/* sprintf.c */
-VALUE f_sprintf _((int, VALUE *));
+VALUE f_sprintf _((int, VALUE*));
/* string.c */
-VALUE str_new _((UCHAR *, UINT));
-VALUE str_new2 _((UCHAR *));
+VALUE str_new _((char*, unsigned int));
+VALUE str_new2 _((char*));
VALUE str_new3 _((VALUE));
VALUE str_new4 _((VALUE));
VALUE obj_as_string _((VALUE));
@@ -258,12 +260,12 @@ VALUE str_dup_frozen _((VALUE));
VALUE str_taint _((VALUE));
VALUE str_tainted _((VALUE));
VALUE str_resize _((VALUE, int));
-VALUE str_cat _((VALUE, UCHAR *, UINT));
+VALUE str_cat _((VALUE, char*, unsigned int));
int str_hash _((VALUE));
int str_cmp _((VALUE, VALUE));
VALUE str_upto _((VALUE, VALUE));
VALUE str_inspect _((VALUE));
-VALUE str_split _((VALUE, char *));
+VALUE str_split _((VALUE, char*));
/* struct.c */
VALUE struct_new();
VALUE struct_define();
@@ -274,21 +276,21 @@ VALUE struct_getmember _((VALUE, ID));
/* time.c */
VALUE time_new _((int, int));
/* util.c */
-void add_suffix _((VALUE, char *));
-unsigned long scan_oct _((char *, int, int *));
-unsigned long scan_hex _((char *, int, int *));
+void add_suffix _((VALUE, char*));
+unsigned long scan_oct _((char*, int, int*));
+unsigned long scan_hex _((char*, int, int*));
/* variable.c */
VALUE mod_name _((VALUE));
VALUE rb_class_path _((VALUE));
-void rb_set_class_path _((VALUE, VALUE, char *));
-VALUE rb_path2class _((char *));
+void rb_set_class_path _((VALUE, VALUE, char*));
+VALUE rb_path2class _((char*));
void rb_name_class _((VALUE, ID));
-void rb_autoload _((char *, char *));
+void rb_autoload _((char*, char*));
VALUE f_autoload _((VALUE, VALUE, VALUE));
void gc_mark_global_tbl _((void));
-VALUE f_trace_var _((int, VALUE *));
-VALUE f_untrace_var _((int, VALUE *));
-VALUE rb_gvar_set2 _((char *, VALUE));
+VALUE f_trace_var _((int, VALUE*));
+VALUE f_untrace_var _((int, VALUE*));
+VALUE rb_gvar_set2 _((char*, VALUE));
VALUE f_global_variables _((void));
void rb_alias_variable _((ID, ID));
VALUE rb_ivar_get _((VALUE, ID));
diff --git a/io.c b/io.c
index 0f8529fb26..e8fc2573dc 100644
--- a/io.c
+++ b/io.c
@@ -159,7 +159,7 @@ io_write(io, str)
#ifdef __human68k__
{
- register UCHAR *ptr = RSTRING(str)->ptr;
+ register char *ptr = RSTRING(str)->ptr;
n = (int)RSTRING(str)->len;
while (--n >= 0)
if (fputc(*ptr++, f) == EOF)
diff --git a/marshal.c b/marshal.c
index 1aadcfb4e0..0e417f7bf8 100644
--- a/marshal.c
+++ b/marshal.c
@@ -69,7 +69,7 @@ w_byte(c, arg)
struct dump_arg *arg;
{
if (arg->fp) putc(c, arg->fp);
- else str_cat(arg->str, (UCHAR*)&c, 1);
+ else str_cat(arg->str, &c, 1);
}
static void
@@ -94,7 +94,7 @@ w_short(x, arg)
{
int i;
- for (i=0; i<sizeof(USHORT); i++) {
+ for (i=0; i<sizeof(short); i++) {
w_byte((x >> (i*8)) & 0xff, arg);
}
}
@@ -286,7 +286,7 @@ w_object(obj, arg, limit)
{
char sign = RBIGNUM(obj)->sign?'+':'-';
int len = RBIGNUM(obj)->len;
- USHORT *d = RBIGNUM(obj)->digits;
+ unsigned short *d = RBIGNUM(obj)->digits;
w_byte(sign, arg);
w_long(len, arg);
@@ -452,7 +452,7 @@ marshal_dump(argc, argv)
struct load_arg {
FILE *fp;
- UCHAR *ptr, *end;
+ char *ptr, *end;
st_table *symbol;
st_table *data;
VALUE proc;
@@ -467,15 +467,15 @@ r_byte(arg)
return EOF;
}
-static USHORT
+static unsigned short
r_short(arg)
struct load_arg *arg;
{
- USHORT x;
+ unsigned short x;
int i;
x = 0;
- for (i=0; i<sizeof(USHORT); i++) {
+ for (i=0; i<sizeof(short); i++) {
x |= r_byte(arg)<<(i*8);
}
@@ -656,13 +656,13 @@ r_object(arg)
case TYPE_BIGNUM:
{
int len;
- USHORT *digits;
+ unsigned short *digits;
NEWOBJ(big, struct RBignum);
OBJSETUP(big, cBignum, T_BIGNUM);
big->sign = (r_byte(arg) == '+');
big->len = len = r_long(arg);
- big->digits = digits = ALLOC_N(USHORT, len);
+ big->digits = digits = ALLOC_N(unsigned short, len);
while (len--) {
*digits++ = r_short(arg);
}
diff --git a/node.h b/node.h
index 04549d734c..c92fe3c0cf 100644
--- a/node.h
+++ b/node.h
@@ -110,7 +110,7 @@ enum node_type {
};
typedef struct RNode {
- UINT flags;
+ unsigned long flags;
char *nd_file;
union {
struct RNode *node;
@@ -122,15 +122,15 @@ typedef struct RNode {
union {
struct RNode *node;
ID id;
- INT argc;
+ int argc;
VALUE value;
} u2;
union {
struct RNode *node;
ID id;
- INT state;
+ int state;
struct global_entry *entry;
- INT cnt;
+ int cnt;
VALUE value;
} u3;
} NODE;
diff --git a/numeric.c b/numeric.c
index f5e843e32c..1bf00927b7 100644
--- a/numeric.c
+++ b/numeric.c
@@ -134,7 +134,7 @@ num_chr(num)
VALUE num;
{
char c;
- INT i = NUM2INT(num);
+ long i = NUM2LONG(num);
if (i < 0 || 0xff < i)
Fail("%d out of char range", i);
@@ -276,7 +276,7 @@ static VALUE
flo_div(x, y)
VALUE x, y;
{
- INT f_y;
+ long f_y;
double d;
switch (TYPE(y)) {
@@ -563,7 +563,7 @@ flo_to_i(num)
VALUE num;
{
double f = RFLOAT(num)->value;
- INT val;
+ long val;
if (!FIXABLE(f)) {
return dbl2big(f);
@@ -612,8 +612,8 @@ fail_to_integer(val)
rb_class2name(CLASS_OF(val)));
}
-INT
-num2int(val)
+long
+num2long(val)
VALUE val;
{
if (NIL_P(val)) {
@@ -625,16 +625,16 @@ num2int(val)
return FIX2INT(val);
case T_FLOAT:
- if (RFLOAT(val)->value <= (double)INT_MAX
- && RFLOAT(val)->value >= (double)INT_MIN) {
- return (int)(RFLOAT(val)->value);
+ if (RFLOAT(val)->value <= (double)LONG_MAX
+ && RFLOAT(val)->value >= (double)LONG_MIN) {
+ return (long)(RFLOAT(val)->value);
}
else {
TypeError("float %g out of rang of integer", RFLOAT(val)->value);
}
case T_BIGNUM:
- return big2int(val);
+ return big2long(val);
case T_STRING:
TypeError("no implicit conversion from string");
@@ -645,29 +645,55 @@ num2int(val)
if (!obj_is_kind_of(val, cInteger)) {
TypeError("`to_i' need to return integer");
}
- return NUM2INT(val);
+ return NUM2LONG(val);
}
}
-UINT
-num2uint(val)
+unsigned long
+num2ulong(val)
VALUE val;
{
if (TYPE(val) == T_BIGNUM) {
- return big2uint(val);
+ return big2ulong(val);
+ }
+ return (unsigned long)num2long(val);
+}
+
+#if SIZEOF_INT < SIZEOF_LONG
+int
+num2int(val)
+ VALUE val;
+{
+ long num = num2int(val);
+
+ if (num < INT_MIN || INT_MAX < num) {
+ ArgError("integer %d too big to convert to `int'.", num);
+ }
+ return (int)num;
+}
+
+int
+fix2int(val)
+ VALUE val;
+{
+ long num = FIXNUM_P(val)?FIX2LONG(val):num2long(val);
+
+ if (num < INT_MIN || INT_MAX < num) {
+ ArgError("integer %d too big to convert to `int'.", num);
}
- return (UINT)num2int(val);
+ return (int)num;
}
+#endif
VALUE
num2fix(val)
VALUE val;
{
- INT v;
+ long v;
if (FIXNUM_P(val)) return val;
- v = num2int(val);
+ v = num2long(val);
if (!FIXABLE(v))
Fail("integer %d out of range of fixnum", v);
return INT2FIX(v);
@@ -725,7 +751,7 @@ fix_plus(x, y)
switch (TYPE(y)) {
case T_FIXNUM:
{
- INT a, b, c;
+ long a, b, c;
VALUE r;
a = FIX2INT(x);
@@ -752,7 +778,7 @@ fix_minus(x, y)
switch (TYPE(y)) {
case T_FIXNUM:
{
- INT a, b, c;
+ long a, b, c;
VALUE r;
a = FIX2INT(x);
@@ -779,7 +805,7 @@ fix_mul(x, y)
switch (TYPE(y)) {
case T_FIXNUM:
{
- INT a, b, c;
+ long a, b, c;
VALUE r;
a = FIX2INT(x);
@@ -805,7 +831,7 @@ static VALUE
fix_div(x, y)
VALUE x, y;
{
- INT i;
+ long i;
if (TYPE(y) == T_FIXNUM) {
i = FIX2INT(y);
@@ -820,7 +846,7 @@ static VALUE
fix_modulo(x, y, modulo)
VALUE x, y;
{
- INT i;
+ long i;
if (TYPE(y) == T_FIXNUM) {
i = FIX2INT(y);
@@ -855,7 +881,7 @@ fix_pow(x, y)
VALUE x, y;
{
if (FIXNUM_P(y)) {
- INT a, b;
+ long a, b;
b = FIX2INT(y);
if (b == 0) return INT2FIX(1);
@@ -888,7 +914,7 @@ fix_cmp(x, y)
VALUE x, y;
{
if (FIXNUM_P(y)) {
- INT a = FIX2INT(x), b = FIX2INT(y);
+ long a = FIX2INT(x), b = FIX2INT(y);
if (a == b) return INT2FIX(0);
if (a > b) return INT2FIX(1);
@@ -904,7 +930,7 @@ fix_gt(x, y)
VALUE x, y;
{
if (FIXNUM_P(y)) {
- INT a = FIX2INT(x), b = FIX2INT(y);
+ long a = FIX2INT(x), b = FIX2INT(y);
if (a > b) return TRUE;
return FALSE;
@@ -919,7 +945,7 @@ fix_ge(x, y)
VALUE x, y;
{
if (FIXNUM_P(y)) {
- INT a = FIX2INT(x), b = FIX2INT(y);
+ long a = FIX2INT(x), b = FIX2INT(y);
if (a >= b) return TRUE;
return FALSE;
@@ -934,7 +960,7 @@ fix_lt(x, y)
VALUE x, y;
{
if (FIXNUM_P(y)) {
- INT a = FIX2INT(x), b = FIX2INT(y);
+ long a = FIX2INT(x), b = FIX2INT(y);
if (a < b) return TRUE;
return FALSE;
@@ -949,7 +975,7 @@ fix_le(x, y)
VALUE x, y;
{
if (FIXNUM_P(y)) {
- INT a = FIX2INT(x), b = FIX2INT(y);
+ long a = FIX2INT(x), b = FIX2INT(y);
if (a <= b) return TRUE;
return FALSE;
@@ -1031,7 +1057,7 @@ fix_rshift(x, y)
long i, val;
i = NUM2INT(y);
- if (i < sizeof(INT) * 8) {
+ if (i < sizeof(long) * 8) {
val = RSHIFT(FIX2INT(x), i);
return INT2FIX(val);
}
@@ -1082,7 +1108,7 @@ static VALUE
fix_abs(fix)
VALUE fix;
{
- INT i = FIX2INT(fix);
+ long i = FIX2INT(fix);
if (i < 0) i = -i;
@@ -1102,7 +1128,7 @@ static VALUE
fix_succ(fix)
VALUE fix;
{
- INT i = FIX2INT(fix) + 1;
+ long i = FIX2INT(fix) + 1;
return int2inum(i);
}
@@ -1111,7 +1137,7 @@ static VALUE
fix_size(fix)
VALUE fix;
{
- return INT2FIX(sizeof(INT));
+ return INT2FIX(sizeof(long));
}
VALUE
@@ -1185,7 +1211,7 @@ VALUE
fix_upto(from, to)
VALUE from, to;
{
- INT i, end;
+ long i, end;
if (!FIXNUM_P(to)) return num_upto(from, to);
end = FIX2INT(to);
@@ -1200,7 +1226,7 @@ static VALUE
fix_downto(from, to)
VALUE from, to;
{
- INT i, end;
+ long i, end;
if (!FIXNUM_P(to)) return num_downto(from, to);
end = FIX2INT(to);
@@ -1215,7 +1241,7 @@ static VALUE
fix_step(from, to, step)
VALUE from, to, step;
{
- INT i, end, diff;
+ long i, end, diff;
if (!FIXNUM_P(to) || !FIXNUM_P(step))
return num_step(from, to, step);
@@ -1243,7 +1269,7 @@ static VALUE
fix_dotimes(num)
VALUE num;
{
- INT i, end;
+ long i, end;
end = FIX2INT(num);
for (i=0; i<end; i++) {
diff --git a/pack.c b/pack.c
index 8bfb771830..6fba4fffdb 100644
--- a/pack.c
+++ b/pack.c
@@ -101,11 +101,11 @@ pack_pack(ary, fmt)
{
static char *nul10 = "\0\0\0\0\0\0\0\0\0\0";
static char *spc10 = " ";
- UCHAR *p, *pend;
+ char *p, *pend;
VALUE res, from;
char type;
int items, len, idx;
- UCHAR *ptr;
+ char *ptr;
int plen;
Check_Type(fmt, T_STRING);
@@ -296,7 +296,7 @@ pack_pack(ary, fmt)
else {
s = NUM2INT(from);
}
- str_cat(res, (UCHAR*)&s, sizeof(short));
+ str_cat(res, (char*)&s, sizeof(short));
}
break;
@@ -310,7 +310,7 @@ pack_pack(ary, fmt)
else {
i = NUM2UINT(from);
}
- str_cat(res, (UCHAR*)&i, sizeof(int));
+ str_cat(res, (char*)&i, sizeof(int));
}
break;
@@ -324,7 +324,7 @@ pack_pack(ary, fmt)
else {
l = NUM2UINT(from);
}
- str_cat(res, (UCHAR*)&l, sizeof(long));
+ str_cat(res, (char*)&l, sizeof(long));
}
break;
@@ -338,7 +338,7 @@ pack_pack(ary, fmt)
s = NUM2INT(from);
}
s = htons(s);
- str_cat(res, (UCHAR*)&s, sizeof(short));
+ str_cat(res, (char*)&s, sizeof(short));
}
break;
@@ -352,7 +352,7 @@ pack_pack(ary, fmt)
l = NUM2UINT(from);
}
l = htonl(l);
- str_cat(res, (UCHAR*)&l, sizeof(long));
+ str_cat(res, (char*)&l, sizeof(long));
}
break;
@@ -366,7 +366,7 @@ pack_pack(ary, fmt)
s = NUM2INT(from);
}
s = htovs(s);
- str_cat(res, (UCHAR*)&s, sizeof(short));
+ str_cat(res, (char*)&s, sizeof(short));
}
break;
@@ -380,7 +380,7 @@ pack_pack(ary, fmt)
l = NUM2UINT(from);
}
l = htovl(l);
- str_cat(res, (UCHAR*)&l, sizeof(long));
+ str_cat(res, (char*)&l, sizeof(long));
}
break;
@@ -400,7 +400,7 @@ pack_pack(ary, fmt)
f = (float)NUM2INT(from);
break;
}
- str_cat(res, (UCHAR*)&f, sizeof(float));
+ str_cat(res, (char*)&f, sizeof(float));
}
break;
@@ -420,7 +420,7 @@ pack_pack(ary, fmt)
d = (double)NUM2INT(from);
break;
}
- str_cat(res, (UCHAR*)&d, sizeof(double));
+ str_cat(res, (char*)&d, sizeof(double));
}
break;
@@ -507,12 +507,12 @@ static char b64_table[] =
static void
encodes(str, s, len, type)
VALUE str;
- UCHAR *s;
+ char *s;
int len;
int type;
{
char hunk[4];
- UCHAR *p, *pend;
+ char *p, *pend;
char *trans = type == 'u' ? uu_table : b64_table;
int padding;
@@ -550,8 +550,8 @@ pack_unpack(str, fmt)
VALUE str, fmt;
{
static char *hexdigits = "0123456789abcdef0123456789ABCDEFx";
- UCHAR *s, *send;
- UCHAR *p, *pend;
+ char *s, *send;
+ char *p, *pend;
VALUE ary;
char type;
int len;
@@ -586,7 +586,7 @@ pack_unpack(str, fmt)
if (len > send - s) len = send - s;
{
int end = len;
- UCHAR *t = s + len - 1;
+ char *t = s + len - 1;
while (t >= s) {
if (*t != ' ' && *t != '\0') break;
@@ -607,7 +607,7 @@ pack_unpack(str, fmt)
case 'b':
{
VALUE bitstr;
- UCHAR *t;
+ char *t;
int bits, i;
if (p[-1] == '*' || len > (send - s) * 8)
@@ -626,7 +626,7 @@ pack_unpack(str, fmt)
case 'B':
{
VALUE bitstr;
- UCHAR *t;
+ char *t;
int bits, i;
if (p[-1] == '*' || len > (send - s) * 8)
@@ -645,7 +645,7 @@ pack_unpack(str, fmt)
case 'h':
{
VALUE bitstr;
- UCHAR *t;
+ char *t;
int bits, i;
if (p[-1] == '*' || len > (send - s) * 2)
@@ -666,7 +666,7 @@ pack_unpack(str, fmt)
case 'H':
{
VALUE bitstr;
- UCHAR *t;
+ char *t;
int bits, i;
if (p[-1] == '*' || len > (send - s) * 2)
@@ -698,7 +698,7 @@ pack_unpack(str, fmt)
if (len > send - s)
len = send - s;
while (len-- > 0) {
- UCHAR c = *s++;
+ unsigned char c = *s++;
ary_push(ary, INT2FIX(c));
}
break;
@@ -844,7 +844,7 @@ pack_unpack(str, fmt)
case 'u':
{
VALUE str = str_new(0, (send - s)*3/4);
- UCHAR *ptr = RSTRING(str)->ptr;
+ char *ptr = RSTRING(str)->ptr;
int total = 0;
while (s < send && *s > ' ' && *s < 'a') {
@@ -898,7 +898,7 @@ pack_unpack(str, fmt)
case 'm':
{
VALUE str = str_new(0, (send - s)*3/4);
- UCHAR *ptr = RSTRING(str)->ptr;
+ char *ptr = RSTRING(str)->ptr;
int total = 0;
int a,b,c,d;
static int first = 1;
diff --git a/random.c b/random.c
index 02fc47bc01..21e93f3b51 100644
--- a/random.c
+++ b/random.c
@@ -87,7 +87,7 @@ f_rand(obj, vmax)
return big_rand(vmax);
case T_FLOAT:
- if (RFLOAT(vmax)->value > INT_MAX || RFLOAT(vmax)->value < INT_MIN)
+ if (RFLOAT(vmax)->value > LONG_MAX || RFLOAT(vmax)->value < LONG_MIN)
return big_rand(dbl2big(RFLOAT(vmax)->value));
break;
}
diff --git a/ruby.c b/ruby.c
index ac5117f258..8495d6b17d 100644
--- a/ruby.c
+++ b/ruby.c
@@ -542,7 +542,7 @@ load_file(fname, script)
RSTRING(line)->ptr[RSTRING(line)->len-2] = '\0';
if (p = strstr(p, " -")) {
int argc; char *argv[2]; char **argvp = argv;
- UCHAR *s = ++p;
+ char *s = ++p;
argc = 2; argv[0] = 0;
while (*p == '-') {
diff --git a/ruby.h b/ruby.h
index 65c5853ae2..9696030715 100644
--- a/ruby.h
+++ b/ruby.h
@@ -51,22 +51,16 @@
#pragma alloca
#endif
-#if SIZEOF_INT == SIZEOF_VOIDP
-typedef int INT;
-typedef unsigned int UINT;
-# define PTR_SIZED_MAX INT_MAX
-#elif SIZEOF_LONG == SIZEOF_VOIDP
+#if SIZEOF_LONG != SIZEOF_VOIDP
+---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
+# endif
+/* INT, UINT, UCHAR are obsolete macro, do not use them. */
typedef long INT;
typedef unsigned long UINT;
-# define PTR_SIZED_MAX LONG_MAX
-#else
----->> ruby requires sizeof(void*) == sizeof(int/long) to be compiled. <<----
-#endif
-typedef UINT VALUE;
-typedef unsigned int ID;
-
typedef unsigned char UCHAR;
-typedef unsigned short USHORT;
+
+typedef unsigned long VALUE;
+typedef unsigned int ID;
#ifdef __STDC__
# include <limits.h>
@@ -82,23 +76,17 @@ typedef unsigned short USHORT;
# ifndef LONG_MIN
# define LONG_MIN (-LONG_MAX-1)
# endif
-# ifndef INT_MAX
- /* assuming 32bit(2's compliment) int */
-# define INT_MAX 2147483647
-# define INT_MIN (-INT_MAX-1)
-# endif
# ifndef CHAR_BIT
# define CHAR_BIT 8
# endif
#endif
-#define PTR_SIZED_MIN (-PTR_SIZED_MAX-1)
-#define FIXNUM_MAX (PTR_SIZED_MAX>>1)
-#define FIXNUM_MIN RSHIFT((INT)PTR_SIZED_MIN,1)
+#define FIXNUM_MAX (LONG_MAX>>1)
+#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
#define FIXNUM_FLAG 0x01
-#define INT2FIX(i) (VALUE)(((INT)(i))<<1 | FIXNUM_FLAG)
-VALUE int2inum _((INT));
+#define INT2FIX(i) (VALUE)(((long)(i))<<1 | FIXNUM_FLAG)
+VALUE int2inum _((long));
#define INT2NUM(v) int2inum(v)
#if (-1==(((-1)<<1)&FIXNUM_FLAG)>>1)
@@ -106,9 +94,8 @@ VALUE int2inum _((INT));
#else
# define RSHIFT(x,y) (((x)<0) ? ~((~(x))>>y) : (x)>>y)
#endif
-#define FIX2INT(x) RSHIFT((INT)x,1)
-
-#define FIX2UINT(f) (((UINT)(f))>>1)
+#define FIX2LONG(x) RSHIFT((long)x,1)
+#define FIX2ULONG(x) (((unsigned long)(x))>>1)
#define FIXNUM_P(f) (((long)(f))&FIXNUM_FLAG)
#define POSFIXABLE(f) ((f) <= FIXNUM_MAX)
#define NEGFIXABLE(f) ((f) >= FIXNUM_MIN)
@@ -170,10 +157,23 @@ void rb_check_safe_str _((VALUE));
#define Check_SafeStr(v) rb_check_safe_str((VALUE)(v))
void rb_secure _((int));
-INT num2int _((VALUE));
+long num2long _((VALUE));
+unsigned long num2ulong _((VALUE));
+#define NUM2LONG(x) (FIXNUM_P(x)?FIX2INT(x):num2long((VALUE)x))
+#define NUM2ULONG(x) num2ulong((VALUE)x)
+#if SIZEOF_INT < SIZEOF_LONG
+int num2int _((VALUE));
#define NUM2INT(x) (FIXNUM_P(x)?FIX2INT(x):num2int((VALUE)x))
-UINT num2uint _((VALUE));
-#define NUM2UINT(x) num2uint((VALUE)x)
+int fix2int _((VALUE));
+#define FIX2INT(x) fix2int((VALUE)x)
+#define NUM2UINT(x) ((unsigned int)NUM2ULONG(x))
+#define FIX2UINT(x) ((unsigned int)FIX2ULONG(x))
+#else
+#define NUM2INT(x) NUM2LONG(x)
+#define NUM2UINT(x) NUM2ULONG(x)
+#define FIX2INT(x) FIX2LONG(x)
+#define FIX2UINT(x) FIX2ULONG(x)
+#endif
double num2dbl _((VALUE));
#define NUM2DBL(x) num2dbl((VALUE)(x))
@@ -197,7 +197,7 @@ VALUE rb_newobj _((void));
}
struct RBasic {
- UINT flags;
+ unsigned long flags;
VALUE klass;
};
@@ -220,29 +220,29 @@ struct RFloat {
struct RString {
struct RBasic basic;
- UINT len;
- UCHAR *ptr;
+ unsigned int len;
+ char *ptr;
VALUE orig;
};
struct RArray {
struct RBasic basic;
- UINT len, capa;
+ unsigned int len, capa;
VALUE *ptr;
};
struct RRegexp {
struct RBasic basic;
struct re_pattern_buffer *ptr;
- UINT len;
- UCHAR *str;
+ unsigned int len;
+ char *str;
};
struct RHash {
struct RBasic basic;
struct st_table *tbl;
int iter_lev;
- UINT status;
+ long status;
};
struct RFile {
@@ -279,15 +279,15 @@ VALUE data_object_alloc _((VALUE,void*,void (*)(),void (*)()));
struct RStruct {
struct RBasic basic;
- UINT len;
+ unsigned int len;
VALUE *ptr;
};
struct RBignum {
struct RBasic basic;
char sign;
- UINT len;
- USHORT *digits;
+ unsigned int len;
+ unsigned short *digits;
};
#define R_CAST(st) (struct st*)
diff --git a/sample/test.rb b/sample/test.rb
index 912f84e2d4..6b6150ab29 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -850,6 +850,7 @@ $x = ary.pack($format)
ary2 = $x.unpack($format)
ok(ary.length == ary2.length)
+p [ary.join(':'), ary2.join(':')]
ok(ary.join(':') == ary2.join(':'))
ok($x =~ /def/)
diff --git a/string.c b/string.c
index f355f8e597..15be9d0b2d 100644
--- a/string.c
+++ b/string.c
@@ -36,8 +36,8 @@ extern VALUE RS;
VALUE
str_new(ptr, len)
- UCHAR *ptr;
- UINT len;
+ char *ptr;
+ unsigned len;
{
NEWOBJ(str, struct RString);
OBJSETUP(str, cString, T_STRING);
@@ -58,7 +58,7 @@ str_new(ptr, len)
VALUE
str_new2(ptr)
- UCHAR *ptr;
+ char *ptr;
{
return str_new(ptr, strlen(ptr));
}
@@ -345,7 +345,7 @@ void
str_modify(str)
VALUE str;
{
- UCHAR *ptr;
+ char *ptr;
if (rb_safe_level() >= 5) {
extern VALUE eSecurityError;
@@ -431,8 +431,8 @@ str_resize(str, len)
VALUE
str_cat(str, ptr, len)
VALUE str;
- UCHAR *ptr;
- UINT len;
+ char *ptr;
+ unsigned len;
{
if (len > 0) {
str_modify(str);
@@ -459,7 +459,7 @@ str_hash(str)
VALUE str;
{
register int len = RSTRING(str)->len;
- register UCHAR *p = RSTRING(str)->ptr;
+ register char *p = RSTRING(str)->ptr;
register int key = 0;
if (RTEST(ignorecase)) {
@@ -491,7 +491,7 @@ int
str_cmp(str1, str2)
VALUE str1, str2;
{
- UINT len;
+ unsigned int len;
int retval;
if (RTEST(ignorecase)) {
@@ -571,7 +571,7 @@ str_index(str, sub, offset)
VALUE str, sub;
int offset;
{
- UCHAR *s, *e, *p;
+ char *s, *e, *p;
int len;
if (RSTRING(str)->len - offset < RSTRING(sub)->len) return -1;
@@ -643,7 +643,7 @@ str_rindex(argc, argv, str)
VALUE sub;
VALUE initpos;
int pos, len;
- UCHAR *s, *sbeg, *t;
+ char *s, *sbeg, *t;
if (rb_scan_args(argc, argv, "11", &sub, &initpos) == 2) {
pos = NUM2INT(initpos);
@@ -690,9 +690,9 @@ str_rindex(argc, argv, str)
return Qnil;
}
-static UCHAR
+static char
succ_char(s)
- UCHAR *s;
+ char *s;
{
char c = *s;
@@ -720,7 +720,7 @@ str_succ(orig)
VALUE orig;
{
VALUE str, str2;
- UCHAR *sbeg, *s;
+ char *sbeg, *s;
char c = -1;
str = str_new(RSTRING(orig)->ptr, RSTRING(orig)->len);
@@ -1296,7 +1296,7 @@ static VALUE
str_reverse_bang(str)
VALUE str;
{
- UCHAR *s, *e, *p, *q;
+ char *s, *e, *p, *q;
s = RSTRING(str)->ptr;
e = s + RSTRING(str)->len - 1;
@@ -1315,7 +1315,7 @@ str_reverse(str)
VALUE str;
{
VALUE obj;
- UCHAR *s, *e, *p;
+ char *s, *e, *p;
if (RSTRING(str)->len <= 1) return str;
@@ -1387,9 +1387,9 @@ str_inspect(str)
VALUE str;
{
#define STRMAX 80
- UCHAR buf[STRMAX];
- UCHAR *p, *pend;
- UCHAR *b;
+ char buf[STRMAX];
+ char *p, *pend;
+ char *b;
p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len;
b = buf;
@@ -1404,7 +1404,7 @@ str_inspect(str)
}
while (p < pend) {
- UCHAR c = *p++;
+ char c = *p++;
if (ismbchar(c) && p < pend) {
CHECK(2);
*b++ = c;
@@ -1479,14 +1479,14 @@ str_dump(str)
VALUE str;
{
int len;
- UCHAR *p, *pend;
- UCHAR *q, *qend;
+ char *p, *pend;
+ char *q, *qend;
VALUE result;
len = 2; /* "" */
p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len;
while (p < pend) {
- UCHAR c = *p++;
+ char c = *p++;
switch (c) {
case '"': case '\'':
case '\n': case '\r':
@@ -1512,7 +1512,7 @@ str_dump(str)
*q++ = '"';
while (p < pend) {
- UCHAR c = *p++;
+ char c = *p++;
if (c == '"' || c == '\\') {
*q++ = '\\';
@@ -1564,7 +1564,7 @@ static VALUE
str_upcase_bang(str)
VALUE str;
{
- UCHAR *s, *send;
+ char *s, *send;
int modify = 0;
str_modify(str);
@@ -1598,7 +1598,8 @@ static VALUE
str_downcase_bang(str)
VALUE str;
{
- UCHAR *s, *send, modify = 0;
+ char *s, *send;
+ int modify = 0;
str_modify(str);
s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
@@ -1631,7 +1632,8 @@ static VALUE
str_capitalize_bang(str)
VALUE str;
{
- UCHAR *s, *send, modify = 0;
+ char *s, *send;
+ int modify = 0;
str_modify(str);
s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
@@ -1666,7 +1668,8 @@ static VALUE
str_swapcase_bang(str)
VALUE str;
{
- UCHAR *s, *send, modify = 0;
+ char *s, *send;
+ int modify = 0;
str_modify(str);
s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
@@ -1699,11 +1702,11 @@ str_swapcase(str)
return val;
}
-typedef UCHAR *USTR;
+typedef unsigned char *USTR;
static struct tr {
int gen, now, max;
- UCHAR *p, *pend;
+ char *p, *pend;
} trsrc, trrepl;
static int
@@ -1746,9 +1749,9 @@ tr_trans(str, src, repl, sflag)
{
struct tr trsrc, trrepl;
int cflag = 0;
- UCHAR trans[256];
+ char trans[256];
int i, c, c0, modify = 0;
- UCHAR *s, *send;
+ char *s, *send;
str_modify(str);
src = str_to_str(src);
@@ -1803,7 +1806,7 @@ tr_trans(str, src, repl, sflag)
s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
c0 = -1;
if (sflag) {
- UCHAR *t = s;
+ char *t = s;
while (s < send) {
c = trans[*s++ & 0xff] & 0xff;
@@ -1857,7 +1860,7 @@ str_tr(str, src, repl)
static void
tr_setup_table(str, table)
VALUE str;
- UCHAR table[256];
+ char table[256];
{
struct tr tr;
int i, cflag = 0;
@@ -1882,8 +1885,8 @@ static VALUE
str_delete_bang(str1, str2)
VALUE str1, str2;
{
- UCHAR *s, *send, *t;
- UCHAR squeez[256];
+ char *s, *send, *t;
+ char squeez[256];
int modify = 0;
str2 = str_to_str(str2);
@@ -1921,8 +1924,8 @@ static VALUE
tr_squeeze(str1, str2)
VALUE str1, str2;
{
- UCHAR squeez[256];
- UCHAR *s, *send, *t;
+ char squeez[256];
+ char *s, *send, *t;
char c, save, modify = 0;
if (!NIL_P(str2)) {
@@ -2047,9 +2050,9 @@ str_split_method(argc, argv, str)
result = ary_new();
beg = 0;
if (char_sep != 0) {
- UCHAR *ptr = RSTRING(str)->ptr;
+ char *ptr = RSTRING(str)->ptr;
int len = RSTRING(str)->len;
- UCHAR *eptr = ptr + len;
+ char *eptr = ptr + len;
if (char_sep == ' ') { /* AWK emulation */
int skip = 1;
@@ -2163,8 +2166,8 @@ str_each_line(argc, argv, str)
VALUE rs;
int newline;
int rslen;
- UCHAR *p = RSTRING(str)->ptr, *pend = p + RSTRING(str)->len, *s;
- UCHAR *ptr = p;
+ char *p = RSTRING(str)->ptr, *pend = p + RSTRING(str)->len, *s;
+ char *ptr = p;
int len = RSTRING(str)->len;
VALUE line;
@@ -2281,7 +2284,7 @@ str_chomp_bang(argc, argv, str)
VALUE rs;
int newline;
int rslen;
- UCHAR *p = RSTRING(str)->ptr;
+ char *p = RSTRING(str)->ptr;
int len = RSTRING(str)->len;
if (rb_scan_args(argc, argv, "01", &rs) == 0) {
@@ -2351,7 +2354,7 @@ static VALUE
str_strip_bang(str)
VALUE str;
{
- UCHAR *s, *t, *e;
+ char *s, *t, *e;
str_modify(str);
s = RSTRING(str)->ptr;
@@ -2366,7 +2369,7 @@ str_strip_bang(str)
RSTRING(str)->len = t-s;
if (s > RSTRING(str)->ptr) {
- UCHAR *p = RSTRING(str)->ptr;
+ char *p = RSTRING(str)->ptr;
RSTRING(str)->ptr = ALLOC_N(char, RSTRING(str)->len+1);
memcpy(RSTRING(str)->ptr, s, RSTRING(str)->len);
@@ -2512,14 +2515,14 @@ str_sum(argc, argv, str)
{
VALUE vbits;
int bits;
- UCHAR *p, *pend;
+ char *p, *pend;
rb_scan_args(argc, argv, "01", &vbits);
if (NIL_P(vbits)) bits = 16;
else bits = NUM2INT(vbits);
p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len;
- if (bits > sizeof(UINT)*CHAR_BIT) {
+ if (bits > sizeof(long)*CHAR_BIT) {
VALUE res = INT2FIX(0);
VALUE mod;
@@ -2527,21 +2530,21 @@ str_sum(argc, argv, str)
mod = rb_funcall(mod, '-', 1, INT2FIX(1));
while (p < pend) {
- res = rb_funcall(res, '+', 1, INT2FIX((UINT)*p));
+ res = rb_funcall(res, '+', 1, INT2FIX((unsigned int)*p));
p++;
}
res = rb_funcall(res, '&', 1, mod);
return res;
}
else {
- UINT res = 0;
- UINT mod = (1<<bits)-1;
+ unsigned int res = 0;
+ unsigned int mod = (1<<bits)-1;
if (mod == 0) {
mod = -1;
}
while (p < pend) {
- res += (UINT)*p;
+ res += (unsigned int)*p;
p++;
}
res &= mod;
@@ -2556,7 +2559,7 @@ str_ljust(str, w)
{
int width = NUM2INT(w);
VALUE res;
- UCHAR *p, *pend;
+ char *p, *pend;
if (width < 0 || RSTRING(str)->len >= width) return str;
res = str_new(0, width);
@@ -2575,7 +2578,7 @@ str_rjust(str, w)
{
int width = NUM2INT(w);
VALUE res;
- UCHAR *p, *pend;
+ char *p, *pend;
if (width < 0 || RSTRING(str)->len >= width) return str;
res = str_new(0, width);
@@ -2594,7 +2597,7 @@ str_center(str, w)
{
int width = NUM2INT(w);
VALUE res;
- UCHAR *p, *pend;
+ char *p, *pend;
int n;
if (width < 0 || RSTRING(str)->len >= width) return str;