diff --git a/ChangeLog b/ChangeLog index b8400de8db..fe7a9211f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,47 @@ +Thu Dec 11 11:39:43 2003 Nobuyoshi Nakada + + * configure.in (ieeefp.h), numeric.c: needed for finite() on + Solaris. [ruby-core:01921] + + * file.c (rb_stat_inspect): adjust format specifier. + + * parse.c (arg_prepend): nodetype() is for debug use. + + * ruby.h (ISASCII, etc): cast to int to get rid of warning. + + * ruby.h (alloca.h): include even in GCC. [ruby-core:01925] + + * ext/bigdecimal/bigdecimal.c (GetVpValue): adjust format + specifier. + + * ext/bigdecimal/bigdecimal.c (BigDecimal_prec, BigDecimal_coerce, + BigDecimal_divmod): use rb_assoc_new() to suppress memory usage. + + * ext/bigdecimal/bigdecimal.c (BigDecimal_split): ditto. + + * ext/dl/sym.c (rb_dlsym_guardcall): guard itself should be + volatile. + + * ext/iconv/iconv.c (iconv_convert): ensure actual parameter with + format specifier. + + * ext/pty/pty.c (MasterDevice, SlaveDevice, deviceNo): do not + define unless used. + + * ext/pty/pty.c (getDevice): get rid of warning. + + * ext/socket/socket.c (port_str, sock_s_getaddrinfo, + sock_s_getnameinfo): FIX2INT() now returns long. + + * ext/socket/socket.c (init_inetsock_internal): uninitialized + variable. + + * ext/syck/rubyext.c (syck_parser_assign_io): add prototype. + + * ext/syck/rubyext.c (rb_syck_mktime, yaml_org_handler): use + ISDIGIT() instead of isdigit() to avoid warnings and for + platforms which don't support non-ascii charater. + Wed Dec 10 19:28:56 2003 Nobuyoshi Nakada * ext/stringio/stringio.c (strio_read): set EOF flag at short read. diff --git a/configure.in b/configure.in index 74f9b4b348..13b5c487c1 100644 --- a/configure.in +++ b/configure.in @@ -364,7 +364,7 @@ AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\ fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\ syscall.h pwd.h grp.h a.out.h utime.h memory.h direct.h sys/resource.h \ - sys/mkdev.h sys/utime.h netinet/in_systm.h float.h pthread.h) + sys/mkdev.h sys/utime.h netinet/in_systm.h float.h ieeefp.h pthread.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_UID_T diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index ae5f7a0895..6a9940d335 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -103,7 +103,7 @@ GetVpValue(VALUE v, int must) } break; case T_FIXNUM: - sprintf(szD, "%d", FIX2INT(v)); + sprintf(szD, "%ld", FIX2LONG(v)); return VpCreateRbObject(VpBaseFig() * 2 + 1, szD); #ifdef ENABLE_NUMERIC_STRING @@ -146,9 +146,8 @@ BigDecimal_prec(VALUE self) VALUE obj; GUARD_OBJ(p,GetVpValue(self,1)); - obj = rb_ary_new(); - obj = rb_ary_push(obj,INT2NUM(p->Prec*VpBaseFig())); - obj = rb_ary_push(obj,INT2NUM(p->MaxPrec*VpBaseFig())); + obj = rb_assoc_new(INT2NUM(p->Prec*VpBaseFig()), + INT2NUM(p->MaxPrec*VpBaseFig())); return obj; } @@ -427,14 +426,10 @@ BigDecimal_coerce(VALUE self, VALUE other) VALUE obj; Real *b; if(TYPE(other) == T_FLOAT) { - obj = rb_ary_new(); - obj = rb_ary_push(obj,other); - obj = rb_ary_push(obj,BigDecimal_to_f(self)); + obj = rb_assoc_new(other, BigDecimal_to_f(self)); } else { GUARD_OBJ(b,GetVpValue(other,1)); - obj = rb_ary_new(); - obj = rb_ary_push(obj, b->obj); - obj = rb_ary_push(obj, self); + obj = rb_assoc_new(b->obj, self); } return obj; } @@ -780,9 +775,7 @@ BigDecimal_divmod(VALUE self, VALUE r) obj = BigDecimal_DoDivmod(self,r,&div,&mod); if(obj!=(VALUE)0) return obj; SAVE(div);SAVE(mod); - obj = rb_ary_new(); - rb_ary_push(obj, ToValue(div)); - rb_ary_push(obj, ToValue(mod)); + obj = rb_assoc_new(ToValue(div), ToValue(mod)); return obj; } @@ -1124,7 +1117,7 @@ BigDecimal_split(VALUE self) if(psz1[0]=='N') s=0; /* NaN */ e = VpExponent10(vp); obj1 = rb_str_new2(psz1); - obj = rb_ary_new(); + obj = rb_ary_new2(4); rb_ary_push(obj, INT2FIX(s)); rb_ary_push(obj, obj1); rb_ary_push(obj, INT2FIX(10)); diff --git a/ext/dl/sym.c b/ext/dl/sym.c index 8044e6a4bb..a4dfbffce4 100644 --- a/ext/dl/sym.c +++ b/ext/dl/sym.c @@ -362,7 +362,7 @@ __declspec(noinline) static int rb_dlsym_guardcall(char type, ANY_TYPE *ret, long *stack, void *func) { - volatile char *guard = ALLOCA_N(char, 1); /* guard stack pointer */ + char *volatile guard = ALLOCA_N(char, 1); /* guard stack pointer */ switch(type){ case '0': { diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 5327797856..1ef2a51b1b 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -426,7 +426,7 @@ iconv_convert } else { /* Some iconv() have a bug, return *outlen out of range */ - sprintf(errmsg, "bug?(output length = %ld)", sizeof(buffer) - outlen); + sprintf(errmsg, "bug?(output length = %ld)", (long)(sizeof(buffer) - outlen)); error = rb_eIconvOutOfRange; } diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 0858f97441..cfd7e4854e 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -38,7 +38,7 @@ #define DEVICELEN 16 #if !defined(HAVE_OPENPTY) -#ifdef __hpux +#if defined(__hpux) static char *MasterDevice = "/dev/ptym/pty%s", *SlaveDevice = "/dev/pty/tty%s", @@ -61,8 +61,7 @@ char *MasterDevice = "/dev/ptym/pty%s", "w8","w9","wa","wb","wc","wd","we","wf", 0, }; -#else /* NOT HPUX */ -#ifdef _IBMESA /* AIX/ESA */ +#elif defined(_IBMESA) /* AIX/ESA */ static char *MasterDevice = "/dev/ptyp%s", *SlaveDevice = "/dev/ttyp%s", @@ -84,7 +83,7 @@ char *MasterDevice = "/dev/ptyp%s", "e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef", "f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff", }; -#else +#elif !defined(HAVE_PTSNAME) static char *MasterDevice = "/dev/pty%s", *SlaveDevice = "/dev/tty%s", @@ -99,8 +98,7 @@ char *MasterDevice = "/dev/pty%s", "s8","s9","sa","sb","sc","sd","se","sf", 0, }; -#endif /* _IBMESA */ -#endif /* HPUX */ +#endif #endif /* !defined(HAVE_OPENPTY) */ static char SlaveName[DEVICELEN]; @@ -342,9 +340,7 @@ static void getDevice(master,slave) int *master,*slave; { - char **p; int i,j; - char MasterName[DEVICELEN]; #ifdef HAVE_PTSNAME char *pn; @@ -381,6 +377,9 @@ getDevice(master,slave) } rb_raise(rb_eRuntimeError, "Cannot get Master/Slave device"); #else + char **p; + char MasterName[DEVICELEN]; + for (p = deviceNo; *p != NULL; p++) { sprintf(MasterName,MasterDevice,*p); if ((i = open(MasterName,O_RDWR,0)) >= 0) { diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 5cebe593bc..e842603067 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -596,7 +596,7 @@ port_str(port, pbuf, len) return 0; } else if (FIXNUM_P(port)) { - snprintf(pbuf, len, "%d", FIX2INT(port)); + snprintf(pbuf, len, "%ld", FIX2LONG(port)); return pbuf; } else { @@ -893,7 +893,7 @@ init_inetsock_internal(arg) { int type = arg->type; struct addrinfo *res; - int fd, status; + int fd, status = 0; char *syscall; arg->remote.res = sock_addrinfo(arg->remote.host, arg->remote.serv, SOCK_STREAM, @@ -2106,7 +2106,7 @@ sock_s_getaddrinfo(argc, argv) pptr = NULL; } else if (FIXNUM_P(port)) { - snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port)); + snprintf(pbuf, sizeof(pbuf), "%ld", FIX2LONG(port)); pptr = pbuf; } else { @@ -2225,7 +2225,7 @@ sock_s_getnameinfo(argc, argv) pptr = NULL; } else if (FIXNUM_P(port)) { - snprintf(pbuf, sizeof(pbuf), "%d", NUM2INT(port)); + snprintf(pbuf, sizeof(pbuf), "%ld", NUM2LONG(port)); pptr = pbuf; } else { diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c index 589033507d..3722babc39 100644 --- a/ext/syck/rubyext.c +++ b/ext/syck/rubyext.c @@ -72,6 +72,7 @@ SYMID rb_syck_load_handler _((SyckParser *, SyckNode *)); void rb_syck_err_handler _((SyckParser *, char *)); SyckNode * rb_syck_bad_anchor_handler _((SyckParser *, char *)); void rb_syck_output_handler _((SyckEmitter *, char *, long)); +int syck_parser_assign_io _((SyckParser *, VALUE)); struct parser_xtra { VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */ @@ -204,27 +205,27 @@ rb_syck_mktime(str) /* Month*/ ptr += 4; - while ( !isdigit( *ptr ) ) ptr++; + while ( !ISDIGIT( *ptr ) ) ptr++; mon = INT2FIX(strtol(ptr, NULL, 10)); /* Day*/ ptr += 2; - while ( !isdigit( *ptr ) ) ptr++; + while ( !ISDIGIT( *ptr ) ) ptr++; day = INT2FIX(strtol(ptr, NULL, 10)); /* Hour*/ ptr += 2; - while ( !isdigit( *ptr ) ) ptr++; + while ( !ISDIGIT( *ptr ) ) ptr++; hour = INT2FIX(strtol(ptr, NULL, 10)); /* Minute */ ptr += 2; - while ( !isdigit( *ptr ) ) ptr++; + while ( !ISDIGIT( *ptr ) ) ptr++; min = INT2FIX(strtol(ptr, NULL, 10)); /* Second */ ptr += 2; - while ( !isdigit( *ptr ) ) ptr++; + while ( !ISDIGIT( *ptr ) ) ptr++; sec = INT2FIX(strtol(ptr, NULL, 10)); /* Millisecond */ @@ -485,12 +486,12 @@ yaml_org_handler( n, ref ) /* Month*/ ptr += 4; - while ( !isdigit( *ptr ) ) ptr++; + while ( !ISDIGIT( *ptr ) ) ptr++; mon = INT2FIX(strtol(ptr, NULL, 10)); /* Day*/ ptr += 2; - while ( !isdigit( *ptr ) ) ptr++; + while ( !ISDIGIT( *ptr ) ) ptr++; day = INT2FIX(strtol(ptr, NULL, 10)); obj = rb_funcall( cDate, s_new, 3, year, mon, day ); diff --git a/file.c b/file.c index 18e2735d5e..cfa52e76bd 100644 --- a/file.c +++ b/file.c @@ -326,7 +326,7 @@ rb_stat_inspect(self) if (i == 2) { /* mode */ char buf[32]; - sprintf(buf, "0%o", NUM2INT(v)); + sprintf(buf, "0%lo", NUM2ULONG(v)); rb_str_buf_cat2(str, buf); } else if (i == 0 || i == 6) { /* dev/rdev */ diff --git a/numeric.c b/numeric.c index e533dfd0a2..341d0b8a3d 100644 --- a/numeric.c +++ b/numeric.c @@ -23,6 +23,10 @@ #include #endif +#ifdef HAVE_IEEEFP_H +#include +#endif + /* use IEEE 64bit values if not defined */ #ifndef FLT_RADIX #define FLT_RADIX 2 diff --git a/parse.y b/parse.y index a8f70b92ed..783689aa10 100644 --- a/parse.y +++ b/parse.y @@ -5443,7 +5443,7 @@ static NODE* arg_prepend(node1, node2) NODE *node1, *node2; { - switch (nodetype(node2)) { + switch (nd_type(node2)) { case NODE_ARRAY: return list_concat(NEW_LIST(node1), node2); @@ -5455,7 +5455,7 @@ arg_prepend(node1, node2) return node2; default: - rb_bug("unknown nodetype(%d) for arg_prepend", nodetype(node2)); + rb_bug("unknown nodetype(%d) for arg_prepend", nd_type(node2)); } return 0; /* not reached */ } diff --git a/ruby.h b/ruby.h index d90eaffe60..d258fa111f 100644 --- a/ruby.h +++ b/ruby.h @@ -36,16 +36,16 @@ extern "C" { /* need to include to use these macros */ #ifndef ISPRINT -#define ISASCII(c) isascii((unsigned char)(c)) +#define ISASCII(c) isascii((int)(unsigned char)(c)) #undef ISPRINT -#define ISPRINT(c) (ISASCII(c) && isprint((unsigned char)(c))) -#define ISSPACE(c) (ISASCII(c) && isspace((unsigned char)(c))) -#define ISUPPER(c) (ISASCII(c) && isupper((unsigned char)(c))) -#define ISLOWER(c) (ISASCII(c) && islower((unsigned char)(c))) -#define ISALNUM(c) (ISASCII(c) && isalnum((unsigned char)(c))) -#define ISALPHA(c) (ISASCII(c) && isalpha((unsigned char)(c))) -#define ISDIGIT(c) (ISASCII(c) && isdigit((unsigned char)(c))) -#define ISXDIGIT(c) (ISASCII(c) && isxdigit((unsigned char)(c))) +#define ISPRINT(c) (ISASCII(c) && isprint((int)(unsigned char)(c))) +#define ISSPACE(c) (ISASCII(c) && isspace((int)(unsigned char)(c))) +#define ISUPPER(c) (ISASCII(c) && isupper((int)(unsigned char)(c))) +#define ISLOWER(c) (ISASCII(c) && islower((int)(unsigned char)(c))) +#define ISALNUM(c) (ISASCII(c) && isalnum((int)(unsigned char)(c))) +#define ISALPHA(c) (ISASCII(c) && isalpha((int)(unsigned char)(c))) +#define ISDIGIT(c) (ISASCII(c) && isdigit((int)(unsigned char)(c))) +#define ISXDIGIT(c) (ISASCII(c) && isxdigit((int)(unsigned char)(c))) #endif #define NORETURN_STYLE_NEW 1 @@ -53,7 +53,7 @@ extern "C" { # define NORETURN(x) x #endif -#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__) +#if defined(HAVE_ALLOCA_H) #include #endif