Skip to content

Commit

Permalink
* configure.in (ieeefp.h), numeric.c: needed for finite() on
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
nobu committed Dec 11, 2003
1 parent c5d4ee4 commit faab8f2
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 49 deletions.
44 changes: 44 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
Thu Dec 11 11:39:43 2003 Nobuyoshi Nakada <[email protected]>

* 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 <[email protected]>

* ext/stringio/stringio.c (strio_read): set EOF flag at short read.
Expand Down
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 7 additions & 14 deletions ext/bigdecimal/bigdecimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion ext/dl/sym.c
Original file line number Diff line number Diff line change
Expand Up @@ -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':
{
Expand Down
2 changes: 1 addition & 1 deletion ext/iconv/iconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
15 changes: 7 additions & 8 deletions ext/pty/pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions ext/socket/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
15 changes: 8 additions & 7 deletions ext/syck/rubyext.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 4 additions & 0 deletions numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include <float.h>
#endif

#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif

/* use IEEE 64bit values if not defined */
#ifndef FLT_RADIX
#define FLT_RADIX 2
Expand Down
4 changes: 2 additions & 2 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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 */
}
Expand Down
20 changes: 10 additions & 10 deletions ruby.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@ extern "C" {

/* need to include <ctype.h> 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
#ifndef NORETURN
# define NORETURN(x) x
#endif

#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
#if defined(HAVE_ALLOCA_H)
#include <alloca.h>
#endif

Expand Down

0 comments on commit faab8f2

Please sign in to comment.