* 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2003-12-11 02:39:59 +00:00
Родитель c5d4ee4a39
Коммит faab8f264d
12 изменённых файлов: 90 добавлений и 49 удалений

Просмотреть файл

@ -1,3 +1,47 @@
Thu Dec 11 11:39:43 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 <nobu@ruby-lang.org> Wed Dec 10 19:28:56 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_read): set EOF flag at short read. * ext/stringio/stringio.c (strio_read): set EOF flag at short read.

Просмотреть файл

@ -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\ 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\ 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 \ 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. dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_UID_T AC_TYPE_UID_T

Просмотреть файл

@ -103,7 +103,7 @@ GetVpValue(VALUE v, int must)
} }
break; break;
case T_FIXNUM: case T_FIXNUM:
sprintf(szD, "%d", FIX2INT(v)); sprintf(szD, "%ld", FIX2LONG(v));
return VpCreateRbObject(VpBaseFig() * 2 + 1, szD); return VpCreateRbObject(VpBaseFig() * 2 + 1, szD);
#ifdef ENABLE_NUMERIC_STRING #ifdef ENABLE_NUMERIC_STRING
@ -146,9 +146,8 @@ BigDecimal_prec(VALUE self)
VALUE obj; VALUE obj;
GUARD_OBJ(p,GetVpValue(self,1)); GUARD_OBJ(p,GetVpValue(self,1));
obj = rb_ary_new(); obj = rb_assoc_new(INT2NUM(p->Prec*VpBaseFig()),
obj = rb_ary_push(obj,INT2NUM(p->Prec*VpBaseFig())); INT2NUM(p->MaxPrec*VpBaseFig()));
obj = rb_ary_push(obj,INT2NUM(p->MaxPrec*VpBaseFig()));
return obj; return obj;
} }
@ -427,14 +426,10 @@ BigDecimal_coerce(VALUE self, VALUE other)
VALUE obj; VALUE obj;
Real *b; Real *b;
if(TYPE(other) == T_FLOAT) { if(TYPE(other) == T_FLOAT) {
obj = rb_ary_new(); obj = rb_assoc_new(other, BigDecimal_to_f(self));
obj = rb_ary_push(obj,other);
obj = rb_ary_push(obj,BigDecimal_to_f(self));
} else { } else {
GUARD_OBJ(b,GetVpValue(other,1)); GUARD_OBJ(b,GetVpValue(other,1));
obj = rb_ary_new(); obj = rb_assoc_new(b->obj, self);
obj = rb_ary_push(obj, b->obj);
obj = rb_ary_push(obj, self);
} }
return obj; return obj;
} }
@ -780,9 +775,7 @@ BigDecimal_divmod(VALUE self, VALUE r)
obj = BigDecimal_DoDivmod(self,r,&div,&mod); obj = BigDecimal_DoDivmod(self,r,&div,&mod);
if(obj!=(VALUE)0) return obj; if(obj!=(VALUE)0) return obj;
SAVE(div);SAVE(mod); SAVE(div);SAVE(mod);
obj = rb_ary_new(); obj = rb_assoc_new(ToValue(div), ToValue(mod));
rb_ary_push(obj, ToValue(div));
rb_ary_push(obj, ToValue(mod));
return obj; return obj;
} }
@ -1124,7 +1117,7 @@ BigDecimal_split(VALUE self)
if(psz1[0]=='N') s=0; /* NaN */ if(psz1[0]=='N') s=0; /* NaN */
e = VpExponent10(vp); e = VpExponent10(vp);
obj1 = rb_str_new2(psz1); obj1 = rb_str_new2(psz1);
obj = rb_ary_new(); obj = rb_ary_new2(4);
rb_ary_push(obj, INT2FIX(s)); rb_ary_push(obj, INT2FIX(s));
rb_ary_push(obj, obj1); rb_ary_push(obj, obj1);
rb_ary_push(obj, INT2FIX(10)); rb_ary_push(obj, INT2FIX(10));

Просмотреть файл

@ -362,7 +362,7 @@ __declspec(noinline)
static int static int
rb_dlsym_guardcall(char type, ANY_TYPE *ret, long *stack, void *func) 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){ switch(type){
case '0': case '0':
{ {

Просмотреть файл

@ -426,7 +426,7 @@ iconv_convert
} }
else { else {
/* Some iconv() have a bug, return *outlen out of range */ /* 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; error = rb_eIconvOutOfRange;
} }

Просмотреть файл

@ -38,7 +38,7 @@
#define DEVICELEN 16 #define DEVICELEN 16
#if !defined(HAVE_OPENPTY) #if !defined(HAVE_OPENPTY)
#ifdef __hpux #if defined(__hpux)
static static
char *MasterDevice = "/dev/ptym/pty%s", char *MasterDevice = "/dev/ptym/pty%s",
*SlaveDevice = "/dev/pty/tty%s", *SlaveDevice = "/dev/pty/tty%s",
@ -61,8 +61,7 @@ char *MasterDevice = "/dev/ptym/pty%s",
"w8","w9","wa","wb","wc","wd","we","wf", "w8","w9","wa","wb","wc","wd","we","wf",
0, 0,
}; };
#else /* NOT HPUX */ #elif defined(_IBMESA) /* AIX/ESA */
#ifdef _IBMESA /* AIX/ESA */
static static
char *MasterDevice = "/dev/ptyp%s", char *MasterDevice = "/dev/ptyp%s",
*SlaveDevice = "/dev/ttyp%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", "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", "f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff",
}; };
#else #elif !defined(HAVE_PTSNAME)
static static
char *MasterDevice = "/dev/pty%s", char *MasterDevice = "/dev/pty%s",
*SlaveDevice = "/dev/tty%s", *SlaveDevice = "/dev/tty%s",
@ -99,8 +98,7 @@ char *MasterDevice = "/dev/pty%s",
"s8","s9","sa","sb","sc","sd","se","sf", "s8","s9","sa","sb","sc","sd","se","sf",
0, 0,
}; };
#endif /* _IBMESA */ #endif
#endif /* HPUX */
#endif /* !defined(HAVE_OPENPTY) */ #endif /* !defined(HAVE_OPENPTY) */
static char SlaveName[DEVICELEN]; static char SlaveName[DEVICELEN];
@ -342,9 +340,7 @@ static void
getDevice(master,slave) getDevice(master,slave)
int *master,*slave; int *master,*slave;
{ {
char **p;
int i,j; int i,j;
char MasterName[DEVICELEN];
#ifdef HAVE_PTSNAME #ifdef HAVE_PTSNAME
char *pn; char *pn;
@ -381,6 +377,9 @@ getDevice(master,slave)
} }
rb_raise(rb_eRuntimeError, "Cannot get Master/Slave device"); rb_raise(rb_eRuntimeError, "Cannot get Master/Slave device");
#else #else
char **p;
char MasterName[DEVICELEN];
for (p = deviceNo; *p != NULL; p++) { for (p = deviceNo; *p != NULL; p++) {
sprintf(MasterName,MasterDevice,*p); sprintf(MasterName,MasterDevice,*p);
if ((i = open(MasterName,O_RDWR,0)) >= 0) { if ((i = open(MasterName,O_RDWR,0)) >= 0) {

Просмотреть файл

@ -596,7 +596,7 @@ port_str(port, pbuf, len)
return 0; return 0;
} }
else if (FIXNUM_P(port)) { else if (FIXNUM_P(port)) {
snprintf(pbuf, len, "%d", FIX2INT(port)); snprintf(pbuf, len, "%ld", FIX2LONG(port));
return pbuf; return pbuf;
} }
else { else {
@ -893,7 +893,7 @@ init_inetsock_internal(arg)
{ {
int type = arg->type; int type = arg->type;
struct addrinfo *res; struct addrinfo *res;
int fd, status; int fd, status = 0;
char *syscall; char *syscall;
arg->remote.res = sock_addrinfo(arg->remote.host, arg->remote.serv, SOCK_STREAM, arg->remote.res = sock_addrinfo(arg->remote.host, arg->remote.serv, SOCK_STREAM,
@ -2106,7 +2106,7 @@ sock_s_getaddrinfo(argc, argv)
pptr = NULL; pptr = NULL;
} }
else if (FIXNUM_P(port)) { else if (FIXNUM_P(port)) {
snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port)); snprintf(pbuf, sizeof(pbuf), "%ld", FIX2LONG(port));
pptr = pbuf; pptr = pbuf;
} }
else { else {
@ -2225,7 +2225,7 @@ sock_s_getnameinfo(argc, argv)
pptr = NULL; pptr = NULL;
} }
else if (FIXNUM_P(port)) { else if (FIXNUM_P(port)) {
snprintf(pbuf, sizeof(pbuf), "%d", NUM2INT(port)); snprintf(pbuf, sizeof(pbuf), "%ld", NUM2LONG(port));
pptr = pbuf; pptr = pbuf;
} }
else { else {

Просмотреть файл

@ -72,6 +72,7 @@ SYMID rb_syck_load_handler _((SyckParser *, SyckNode *));
void rb_syck_err_handler _((SyckParser *, char *)); void rb_syck_err_handler _((SyckParser *, char *));
SyckNode * rb_syck_bad_anchor_handler _((SyckParser *, char *)); SyckNode * rb_syck_bad_anchor_handler _((SyckParser *, char *));
void rb_syck_output_handler _((SyckEmitter *, char *, long)); void rb_syck_output_handler _((SyckEmitter *, char *, long));
int syck_parser_assign_io _((SyckParser *, VALUE));
struct parser_xtra { struct parser_xtra {
VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */ VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */
@ -204,27 +205,27 @@ rb_syck_mktime(str)
/* Month*/ /* Month*/
ptr += 4; ptr += 4;
while ( !isdigit( *ptr ) ) ptr++; while ( !ISDIGIT( *ptr ) ) ptr++;
mon = INT2FIX(strtol(ptr, NULL, 10)); mon = INT2FIX(strtol(ptr, NULL, 10));
/* Day*/ /* Day*/
ptr += 2; ptr += 2;
while ( !isdigit( *ptr ) ) ptr++; while ( !ISDIGIT( *ptr ) ) ptr++;
day = INT2FIX(strtol(ptr, NULL, 10)); day = INT2FIX(strtol(ptr, NULL, 10));
/* Hour*/ /* Hour*/
ptr += 2; ptr += 2;
while ( !isdigit( *ptr ) ) ptr++; while ( !ISDIGIT( *ptr ) ) ptr++;
hour = INT2FIX(strtol(ptr, NULL, 10)); hour = INT2FIX(strtol(ptr, NULL, 10));
/* Minute */ /* Minute */
ptr += 2; ptr += 2;
while ( !isdigit( *ptr ) ) ptr++; while ( !ISDIGIT( *ptr ) ) ptr++;
min = INT2FIX(strtol(ptr, NULL, 10)); min = INT2FIX(strtol(ptr, NULL, 10));
/* Second */ /* Second */
ptr += 2; ptr += 2;
while ( !isdigit( *ptr ) ) ptr++; while ( !ISDIGIT( *ptr ) ) ptr++;
sec = INT2FIX(strtol(ptr, NULL, 10)); sec = INT2FIX(strtol(ptr, NULL, 10));
/* Millisecond */ /* Millisecond */
@ -485,12 +486,12 @@ yaml_org_handler( n, ref )
/* Month*/ /* Month*/
ptr += 4; ptr += 4;
while ( !isdigit( *ptr ) ) ptr++; while ( !ISDIGIT( *ptr ) ) ptr++;
mon = INT2FIX(strtol(ptr, NULL, 10)); mon = INT2FIX(strtol(ptr, NULL, 10));
/* Day*/ /* Day*/
ptr += 2; ptr += 2;
while ( !isdigit( *ptr ) ) ptr++; while ( !ISDIGIT( *ptr ) ) ptr++;
day = INT2FIX(strtol(ptr, NULL, 10)); day = INT2FIX(strtol(ptr, NULL, 10));
obj = rb_funcall( cDate, s_new, 3, year, mon, day ); obj = rb_funcall( cDate, s_new, 3, year, mon, day );

2
file.c
Просмотреть файл

@ -326,7 +326,7 @@ rb_stat_inspect(self)
if (i == 2) { /* mode */ if (i == 2) { /* mode */
char buf[32]; char buf[32];
sprintf(buf, "0%o", NUM2INT(v)); sprintf(buf, "0%lo", NUM2ULONG(v));
rb_str_buf_cat2(str, buf); rb_str_buf_cat2(str, buf);
} }
else if (i == 0 || i == 6) { /* dev/rdev */ else if (i == 0 || i == 6) { /* dev/rdev */

Просмотреть файл

@ -23,6 +23,10 @@
#include <float.h> #include <float.h>
#endif #endif
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
/* use IEEE 64bit values if not defined */ /* use IEEE 64bit values if not defined */
#ifndef FLT_RADIX #ifndef FLT_RADIX
#define FLT_RADIX 2 #define FLT_RADIX 2

Просмотреть файл

@ -5443,7 +5443,7 @@ static NODE*
arg_prepend(node1, node2) arg_prepend(node1, node2)
NODE *node1, *node2; NODE *node1, *node2;
{ {
switch (nodetype(node2)) { switch (nd_type(node2)) {
case NODE_ARRAY: case NODE_ARRAY:
return list_concat(NEW_LIST(node1), node2); return list_concat(NEW_LIST(node1), node2);
@ -5455,7 +5455,7 @@ arg_prepend(node1, node2)
return node2; return node2;
default: 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 */ return 0; /* not reached */
} }

20
ruby.h
Просмотреть файл

@ -36,16 +36,16 @@ extern "C" {
/* need to include <ctype.h> to use these macros */ /* need to include <ctype.h> to use these macros */
#ifndef ISPRINT #ifndef ISPRINT
#define ISASCII(c) isascii((unsigned char)(c)) #define ISASCII(c) isascii((int)(unsigned char)(c))
#undef ISPRINT #undef ISPRINT
#define ISPRINT(c) (ISASCII(c) && isprint((unsigned char)(c))) #define ISPRINT(c) (ISASCII(c) && isprint((int)(unsigned char)(c)))
#define ISSPACE(c) (ISASCII(c) && isspace((unsigned char)(c))) #define ISSPACE(c) (ISASCII(c) && isspace((int)(unsigned char)(c)))
#define ISUPPER(c) (ISASCII(c) && isupper((unsigned char)(c))) #define ISUPPER(c) (ISASCII(c) && isupper((int)(unsigned char)(c)))
#define ISLOWER(c) (ISASCII(c) && islower((unsigned char)(c))) #define ISLOWER(c) (ISASCII(c) && islower((int)(unsigned char)(c)))
#define ISALNUM(c) (ISASCII(c) && isalnum((unsigned char)(c))) #define ISALNUM(c) (ISASCII(c) && isalnum((int)(unsigned char)(c)))
#define ISALPHA(c) (ISASCII(c) && isalpha((unsigned char)(c))) #define ISALPHA(c) (ISASCII(c) && isalpha((int)(unsigned char)(c)))
#define ISDIGIT(c) (ISASCII(c) && isdigit((unsigned char)(c))) #define ISDIGIT(c) (ISASCII(c) && isdigit((int)(unsigned char)(c)))
#define ISXDIGIT(c) (ISASCII(c) && isxdigit((unsigned char)(c))) #define ISXDIGIT(c) (ISASCII(c) && isxdigit((int)(unsigned char)(c)))
#endif #endif
#define NORETURN_STYLE_NEW 1 #define NORETURN_STYLE_NEW 1
@ -53,7 +53,7 @@ extern "C" {
# define NORETURN(x) x # define NORETURN(x) x
#endif #endif
#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__) #if defined(HAVE_ALLOCA_H)
#include <alloca.h> #include <alloca.h>
#endif #endif