Skip to content

Commit

Permalink
* re.c (rb_reg_match): should clear $~ if operand is nil.
Browse files Browse the repository at this point in the history
* re.c (rb_reg_match2): ditto.

* configure: merge Jonathan Baker's large file support patch
  [ruby-talk:35316], with read_all patch in [ruby-talk:35470].

* eval.c (rb_f_abort): optional message argument that be printed
  on termination. [new]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Mar 14, 2002
1 parent 4f0870f commit 997b69c
Show file tree
Hide file tree
Showing 14 changed files with 955 additions and 24 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Thu Mar 14 00:29:12 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* re.c (rb_reg_match): should clear $~ if operand is nil.

* re.c (rb_reg_match2): ditto.

Thu Mar 14 12:32:59 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>

* ext/stringio/stringio.c: fixed frozen string bug. ungetc no
Expand Down Expand Up @@ -25,6 +31,16 @@ Wed Mar 13 18:36:55 2002 Akinori MUSHA <knu@iDaemons.org>
* lib/getopts.rb: single_options can be nil[*], and is not not
optional. ([*]Pointed out by gotoken)

Wed Mar 13 17:23:46 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* configure: merge Jonathan Baker's large file support patch
[ruby-talk:35316], with read_all patch in [ruby-talk:35470].

Wed Mar 13 04:06:48 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (rb_f_abort): optional message argument that be printed
on termination.

Tue Mar 12 17:12:06 2002 Tanaka Akira <akr@m17n.org>

* lib/resolv.rb: don't complete domains for absolute FQNs.
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ lib/English.rb
lib/Env.rb
lib/README
lib/base64.rb
lib/benchmark.rb
lib/cgi.rb
lib/cgi/session.rb
lib/cgi-lib.rb
Expand Down
112 changes: 112 additions & 0 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ typedef long BDIGIT_DBL_SIGNED;
#define BITSPERDIG (sizeof(BDIGIT)*CHAR_BIT)
#define BIGRAD ((BDIGIT_DBL)1 << BITSPERDIG)
#define DIGSPERLONG ((unsigned int)(sizeof(long)/sizeof(BDIGIT)))
#if HAVE_LONG_LONG
# define DIGSPERLL ((unsigned int)(sizeof(long long)/sizeof(BDIGIT)))
#endif
#define BIGUP(x) ((BDIGIT_DBL)(x) << BITSPERDIG)
#define BIGDN(x) RSHIFT(x,BITSPERDIG)
#define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1)))
Expand Down Expand Up @@ -507,6 +510,67 @@ rb_str_to_inum(str, base, badcheck)
return rb_cstr_to_inum(s, base, badcheck);
}

#if HAVE_LONG_LONG

VALUE
rb_ull2big(n)
unsigned long long n;
{
BDIGIT_DBL num = n;
long i = 0;
BDIGIT *digits;
VALUE big;

i = 0;
big = bignew(DIGSPERLL, 1);
digits = BDIGITS(big);
while (i < DIGSPERLL) {
digits[i++] = BIGLO(num);
num = BIGDN(num);
}

i = DIGSPERLL;
while (i-- && !digits[i]) ;
RBIGNUM(big)->len = i+1;
return big;
}

VALUE
rb_ll2big(n)
long long n;
{
long neg = 0;
VALUE big;

if (n < 0) {
n = -n;
neg = 1;
}
big = rb_ull2big(n);
if (neg) {
RBIGNUM(big)->sign = 0;
}
return big;
}

VALUE
rb_ull2inum(n)
unsigned long long n;
{
if (POSFIXABLE(n)) return INT2FIX(n);
return rb_ull2big(n);
}

VALUE
rb_ll2inum(n)
long long n;
{
if (FIXABLE(n)) return INT2FIX(n);
return rb_ll2big(n);
}

#endif /* HAVE_LONG_LONG */

VALUE
rb_cstr2inum(str, base)
const char *str;
Expand Down Expand Up @@ -650,6 +714,54 @@ rb_big2long(x)
return num;
}

#if HAVE_LONG_LONG

static unsigned long long
big2ull(x, type)
VALUE x;
char *type;
{
long len = RBIGNUM(x)->len;
BDIGIT_DBL num;
BDIGIT *ds;

if (len > sizeof(long long)/sizeof(BDIGIT))
rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
ds = BDIGITS(x);
num = 0;
while (len--) {
num = BIGUP(num);
num += ds[len];
}
return num;
}

unsigned long long
rb_big2ull(x)
VALUE x;
{
unsigned long long num = big2ull(x, "unsigned long long");

if (!RBIGNUM(x)->sign) return -num;
return num;
}

long long
rb_big2ll(x)
VALUE x;
{
unsigned long long num = big2ull(x, "long long");

if ((long long)num < 0 && (RBIGNUM(x)->sign
|| (long long)num != LLONG_MIN)) {
rb_raise(rb_eRangeError, "bignum too big to convert into `long long'");
}
if (!RBIGNUM(x)->sign) return -(long long)num;
return num;
}

#endif /* HAVE_LONG_LONG */

static VALUE
dbl2big(d)
double d;
Expand Down
9 changes: 9 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(ruby.h)

AC_PREREQ(2.50)

rb_version=`grep RUBY_VERSION $srcdir/version.h`
MAJOR=`expr "$rb_version" : '#define RUBY_VERSION "\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*"'`
MINOR=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*"'`
Expand Down Expand Up @@ -124,11 +126,16 @@ AC_MINIX
AC_EXEEXT
AC_OBJEXT

dnl check for large file stuff
AC_SYS_LARGEFILE

AC_CHECK_TYPES([long long, off_t])
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(long long, 0)
AC_CHECK_SIZEOF(__int64, 0)
AC_CHECK_SIZEOF(off_t, 0)
AC_CHECK_SIZEOF(void*, 4)
AC_CHECK_SIZEOF(float, 4)
AC_CHECK_SIZEOF(double, 8)
Expand Down Expand Up @@ -292,6 +299,8 @@ AC_TYPE_GETGROUPS
AC_TYPE_SIGNAL
AC_FUNC_ALLOCA
AC_FUNC_MEMCMP
AC_FUNC_FSEEKO
AC_CHECK_FUNCS(ftello)
AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
strchr strstr strtoul crypt flock vsnprintf\
isinf isnan finite hypot)
Expand Down
3 changes: 1 addition & 2 deletions defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ void *xrealloc _((void*,long));
void xfree _((void*));

#if SIZEOF_LONG_LONG > 0
# define HAVE_LONG_LONG
# define LONG_LONG long long
#elif SIZEOF___INT64 > 0
# define HAVE_LONG_LONG
# define HAVE_LONG_LONG 1
# define LONG_LONG __int64
# undef SIZEOF_LONG_LONG
# define SIZEOF_LONG_LONG SIZEOF___INT64
Expand Down
17 changes: 14 additions & 3 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -3491,10 +3491,21 @@ rb_abort()
}

static VALUE
rb_f_abort()
rb_f_abort(argc, argv)
int argc;
VALUE *argv;
{
rb_secure(4);
rb_abort();
if (argc == 0) {
rb_abort();
}
else {
VALUE mesg;

rb_scan_args(argc, argv, "01", &mesg);
rb_io_puts(argc, argv, rb_stderr);
exit(1);
}
return Qnil; /* not reached */
}

Expand Down Expand Up @@ -6056,7 +6067,7 @@ Init_eval()
rb_define_global_function("caller", rb_f_caller, -1);

rb_define_global_function("exit", rb_f_exit, -1);
rb_define_global_function("abort", rb_f_abort, 0);
rb_define_global_function("abort", rb_f_abort, -1);

rb_define_global_function("at_exit", rb_f_at_exit, 0);

Expand Down
4 changes: 2 additions & 2 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ static VALUE
rb_stat_size(self)
VALUE self;
{
return LONG2NUM(get_stat(self)->st_size);
return OFFT2NUM(get_stat(self)->st_size);
}

static VALUE
Expand Down Expand Up @@ -730,7 +730,7 @@ test_s(obj, fname)

if (rb_stat(fname, &st) < 0) return Qnil;
if (st.st_size == 0) return Qnil;
return rb_int2inum(st.st_size);
return OFFT2NUM(st.st_size);
}

static VALUE
Expand Down
6 changes: 6 additions & 0 deletions intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ long rb_big2long _((VALUE));
#define rb_big2int(x) rb_big2long(x)
unsigned long rb_big2ulong _((VALUE));
#define rb_big2uint(x) rb_big2ulong(x)
#if HAVE_LONG_LONG
VALUE rb_ll2inum _((long long));
VALUE rb_ull2inum _((unsigned long long));
long long rb_big2ll _((VALUE));
unsigned long long rb_big2ull _((VALUE));
#endif /* HAVE_LONG_LONG */
void rb_quad_pack _((char*,VALUE));
VALUE rb_quad_unpack _((const char*,int));
VALUE rb_dbl2big _((double));
Expand Down
Loading

0 comments on commit 997b69c

Please sign in to comment.