* io.c (rb_f_backquote): need not to check nil result.

[ruby-core:02078]

* io.c (rb_io_getline): should return nil on eof, even when nil rs is
  specified. [ruby-core:02077]

* pack.c (pack_pack): add sign check for 'i', and 'l'.
  [ruby-dev:22427]

* bignum.c (rb_quad_pack): add range check for 'quad int'.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-12-26 15:34:33 +00:00
Родитель ab0c37d0cf
Коммит b9a79bc020
6 изменённых файлов: 41 добавлений и 20 удалений

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

@ -1,3 +1,11 @@
Fri Dec 26 23:02:09 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_f_backquote): need not to check nil result.
[ruby-core:02078]
* io.c (rb_io_getline): should return nil on eof, even when nil rs is
specified. [ruby-core:02077]
Fri Dec 26 18:33:54 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in: check if getcontext and setcontext are available.
@ -12,6 +20,13 @@ Fri Dec 26 14:05:13 2003 Minero Aoki <aamine@loveruby.net>
* test/ruby/test_pack.rb: new test test_pack_N.
Fri Dec 26 12:53:26 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_pack): add sign check for 'i', and 'l'.
[ruby-dev:22427]
* bignum.c (rb_quad_pack): add range check for 'quad int'.
Fri Dec 26 10:58:58 2003 NAKAMURA Usaku <usa@ruby-lang.org>
* MANIFEST: add vms/config.h and remove vms/config.h_in.

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

@ -203,6 +203,8 @@ rb_quad_pack(buf, val)
long len = RBIGNUM(val)->len;
BDIGIT *ds;
if (len > SIZEOF_LONG_LONG/SIZEOF_BDIGITS)
rb_raise(rb_eRangeError, "bignum too big to convert into `quad int'");
ds = BDIGITS(val);
q = 0;
while (len--) {
@ -272,7 +274,9 @@ rb_quad_pack(buf, val)
val = rb_int2big(FIX2LONG(val));
}
len = RBIGNUM(val)->len * SIZEOF_BDIGITS;
if (len > QUAD_SIZE) len = QUAD_SIZE;
if (len > QUAD_SIZE) {
rb_raise(rb_eRangeError, "bignum too big to convert into `quad int'");
}
memcpy(buf, (char*)BDIGITS(val), len);
if (!RBIGNUM(val)->sign) {
len = QUAD_SIZE;
@ -759,10 +763,10 @@ long
rb_big2long(x)
VALUE x;
{
unsigned long num = big2ulong(x, "int");
unsigned long num = big2ulong(x, "long");
if ((long)num < 0 && (RBIGNUM(x)->sign || (long)num != LONG_MIN)) {
rb_raise(rb_eRangeError, "bignum too big to convert into `int'");
rb_raise(rb_eRangeError, "bignum too big to convert into `long'");
}
if (!RBIGNUM(x)->sign) return -(long)num;
return num;

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

@ -709,7 +709,10 @@ if test "$enable_pthread" = "yes"; then
fi
AC_CHECK_FUNC(nanosleep)
if test "$ac_cv_func_nanosleep" = "no"; then
AC_CHECK_LIB(rt, nanosleep, AC_DEFINE(HAVE_NANOSLEEP))
AC_CHECK_LIB(rt, nanosleep)
if test "$ac_cv_lib_rt_nanosleep" = "yes"; then
AC_DEFINE(HAVE_NANOSLEEP)
fi
fi
fi
if test $ac_cv_header_ucontext_h = yes; then

3
io.c
Просмотреть файл

@ -1027,6 +1027,7 @@ rb_io_getline(rs, fptr)
rb_io_check_readable(fptr);
if (NIL_P(rs)) {
if (feof(fptr->f)) return Qnil;
str = read_all(fptr, 0, Qnil);
}
else if (rs == rb_default_rs) {
@ -3223,10 +3224,8 @@ rb_f_backquote(obj, str)
GetOpenFile(port, fptr);
result = read_all(fptr, remain_size(fptr), Qnil);
rb_io_close(port);
if (NIL_P(result)) return rb_str_new(0,0);
return result;
}

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

@ -217,7 +217,6 @@ def link_command(ldflags, opt="", libpath=$LIBPATH)
'CFLAGS' => "#$CFLAGS",
'ARCH_FLAG' => "#$ARCH_FLAG",
'LDFLAGS' => "#$LDFLAGS #{ldflags}",
'DLDFLAGS' => "#$DLDFLAGS",
'LIBPATH' => libpathflag(libpath),
'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
'LIBS' => "#$LIBRUBYARG_STATIC #{opt} #$LIBS")
@ -1013,7 +1012,7 @@ COMPILE_C = config_string('COMPILE_C') || '$(CC) $(CFLAGS) $(CPPFLAGS) -c $<'
COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<'
TRY_LINK = config_string('TRY_LINK') ||
"$(CC) #{OUTFLAG}conftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) " \
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(DLDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
LINK_SO = config_string('LINK_SO') ||
if CONFIG["DLEXT"] == $OBJEXT
"ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)\n"

25
pack.c
Просмотреть файл

@ -377,15 +377,15 @@ num2u32(x)
#endif
#if SIZEOF_LONG == SIZE32 || SIZEOF_INT == SIZE32
# define EXTEND32(x) ((I32)(x))
# define EXTEND32(x)
#else
/* invariant in modulo 1<<31 */
# define EXTEND32(x) (I32)(((1<<31)-1-(x))^~(~0<<31))
# define EXTEND32(x) do {if (!natint) {(x) = (I32)(((1<<31)-1-(x))^~(~0<<31))}} while(0)
#endif
#if SIZEOF_SHORT == SIZE16
# define EXTEND16(x) (short)(x)
# define EXTEND16(x)
#else
# define EXTEND16(x) (short)(((1<<15)-1-(x))^~(~0<<15))
# define EXTEND16(x) do { if (!natint) {(x) = (short)(((1<<15)-1-(x))^~(~0<<15))}} while(0)
#endif
#ifdef HAVE_LONG_LONG
@ -725,9 +725,12 @@ pack_pack(ary, fmt)
from = NEXTFROM;
if (NIL_P(from)) i = 0;
else {
else if (type == 'i') {
i = NATINT_I32(from);
}
else {
i = NATINT_U32(from);
}
rb_str_buf_cat(res, OFF32(&i), NATINT_LEN(int,4));
}
break;
@ -739,6 +742,9 @@ pack_pack(ary, fmt)
from = NEXTFROM;
if (NIL_P(from)) l = 0;
else if (type == 'l') {
l = NATINT_I32(from);
}
else {
l = NATINT_U32(from);
}
@ -1558,9 +1564,7 @@ pack_unpack(str, fmt)
while (len-- > 0) {
short tmp = 0;
memcpy(OFF16(&tmp), s, NATINT_LEN(short,2));
#if SIZEOF_SHORT != SIZE16
if (!natint) tmp = EXTEND16(tmp);
#endif
EXTEND16(tmp);
s += NATINT_LEN(short,2);
rb_ary_push(ary, INT2FIX(tmp));
}
@ -1605,15 +1609,12 @@ pack_unpack(str, fmt)
while (len-- > 0) {
long tmp = 0;
memcpy(OFF32(&tmp), s, NATINT_LEN(long,4));
#if SIZEOF_LONG != SIZE32
if (!natint) tmp = EXTEND32(tmp);
#endif
EXTEND32(tmp);
s += NATINT_LEN(long,4);
rb_ary_push(ary, LONG2NUM(tmp));
}
PACK_ITEM_ADJUST();
break;
case 'L':
PACK_LENGTH_ADJUST(unsigned long,4);
while (len-- > 0) {