1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ruby.h: use ifdef (or defined) for macro constants that may or

may not be defined to shut up gcc's -Wundef warnings.
  [ruby-core:08447]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2006-07-31 06:34:10 +00:00
parent dc136c12ee
commit 17c3d539f0
8 changed files with 34 additions and 13 deletions

View file

@ -3,6 +3,12 @@ Mon Jul 31 13:38:22 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httprequest.rb (WEBrick::HTTPReuqest#parse_uri): improve * lib/webrick/httprequest.rb (WEBrick::HTTPReuqest#parse_uri): improve
for the value of IPv6 address in the Host: header field. for the value of IPv6 address in the Host: header field.
Mon Jul 31 09:22:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ruby.h: use ifdef (or defined) for macro constants that may or
may not be defined to shut up gcc's -Wundef warnings.
[ruby-core:08447]
Sun Jul 30 23:26:22 2006 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Jul 30 23:26:22 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_call0): trace call/return of method defined from block. * eval.c (rb_call0): trace call/return of method defined from block.

2
eval.c
View file

@ -10296,7 +10296,7 @@ rb_thread_switch(n)
NORETURN(static void rb_thread_restore_context _((rb_thread_t,int))); NORETURN(static void rb_thread_restore_context _((rb_thread_t,int)));
# if _MSC_VER >= 1300 # if defined(_MSC_VER) && _MSC_VER >= 1300
__declspec(noinline) static void stack_extend(rb_thread_t, int); __declspec(noinline) static void stack_extend(rb_thread_t, int);
# endif # endif
static void static void

2
io.c
View file

@ -267,7 +267,7 @@ rb_io_check_readable(fptr)
if (!(fptr->mode & FMODE_READABLE)) { if (!(fptr->mode & FMODE_READABLE)) {
rb_raise(rb_eIOError, "not opened for reading"); rb_raise(rb_eIOError, "not opened for reading");
} }
#if NEED_IO_SEEK_BETWEEN_RW #ifdef NEED_IO_SEEK_BETWEEN_RW
if (((fptr->mode & FMODE_WBUF) || if (((fptr->mode & FMODE_WBUF) ||
(fptr->mode & (FMODE_SYNCWRITE|FMODE_RBUF)) == FMODE_SYNCWRITE) && (fptr->mode & (FMODE_SYNCWRITE|FMODE_RBUF)) == FMODE_SYNCWRITE) &&
!feof(fptr->f) && !feof(fptr->f) &&

View file

@ -12,6 +12,11 @@ class TruncatedDataError<IOError
end end
class IO class IO
# reads exactly n bytes from the IO stream.
# If the data read is nil, raises EOFError.
# If the data read is too short, raises TruncatedDataError.
# The method TruncatedDataError#data may be used to obtain
# the truncated message.
def readbytes(n) def readbytes(n)
str = read(n) str = read(n)
if str == nil if str == nil

View file

@ -1,4 +1,11 @@
# Weak Reference class that does not bother GCing.
require "delegate"
# Weak Reference class that does not bother GCing. This allows the
# referenced object to be garbage collected as if nothing else is
# referring to it. Because Weakref inherits from Delegator it passes
# method calls to the object from which it was constructed, so it
# is of the same Duck Type.
# #
# Usage: # Usage:
# foo = Object.new # foo = Object.new
@ -8,11 +15,9 @@
# p foo.to_s # should be same class # p foo.to_s # should be same class
# ObjectSpace.garbage_collect # ObjectSpace.garbage_collect
# p foo.to_s # should raise exception (recycled) # p foo.to_s # should raise exception (recycled)
require "delegate"
class WeakRef<Delegator class WeakRef<Delegator
# RefError is raised if an object cannot be referenced by a WeakRef.
class RefError<StandardError class RefError<StandardError
end end
@ -40,6 +45,7 @@ class WeakRef<Delegator
end end
} }
# Create a new WeakRef from +orig+.
def initialize(orig) def initialize(orig)
super super
@__id = orig.__id__ @__id = orig.__id__
@ -56,6 +62,9 @@ class WeakRef<Delegator
@@id_rev_map[self.__id__] = @__id @@id_rev_map[self.__id__] = @__id
end end
# Return the object this WeakRef references. Raise
# RefError if this is impossible. The object is that
# to which method calls are delegated (see Delegator).
def __getobj__ def __getobj__
unless @@id_rev_map[self.__id__] == @__id unless @@id_rev_map[self.__id__] == @__id
raise RefError, "Illegal Reference - probably recycled", caller(2) raise RefError, "Illegal Reference - probably recycled", caller(2)
@ -67,6 +76,7 @@ class WeakRef<Delegator
end end
end end
# Determine if this Weakref still refers to anything.
def weakref_alive? def weakref_alive?
@@id_rev_map[self.__id__] == @__id @@id_rev_map[self.__id__] == @__id
end end

8
ruby.h
View file

@ -102,7 +102,7 @@ typedef unsigned long ID;
# endif # endif
#endif #endif
#if HAVE_LONG_LONG #ifdef HAVE_LONG_LONG
# ifndef LLONG_MAX # ifndef LLONG_MAX
# ifdef LONG_LONG_MAX # ifdef LONG_LONG_MAX
# define LLONG_MAX LONG_LONG_MAX # define LLONG_MAX LONG_LONG_MAX
@ -144,7 +144,7 @@ VALUE rb_uint2inum _((unsigned long));
#define ULONG2NUM(v) UINT2NUM(v) #define ULONG2NUM(v) UINT2NUM(v)
#define rb_uint_new(v) rb_uint2inum(v) #define rb_uint_new(v) rb_uint2inum(v)
#if HAVE_LONG_LONG #ifdef HAVE_LONG_LONG
VALUE rb_ll2inum _((LONG_LONG)); VALUE rb_ll2inum _((LONG_LONG));
#define LL2NUM(v) rb_ll2inum(v) #define LL2NUM(v) rb_ll2inum(v)
VALUE rb_ull2inum _((unsigned LONG_LONG)); VALUE rb_ull2inum _((unsigned LONG_LONG));
@ -265,14 +265,14 @@ unsigned long rb_fix2uint _((VALUE));
#define FIX2UINT(x) ((unsigned int)FIX2ULONG(x)) #define FIX2UINT(x) ((unsigned int)FIX2ULONG(x))
#endif #endif
#if HAVE_LONG_LONG #ifdef HAVE_LONG_LONG
LONG_LONG rb_num2ll _((VALUE)); LONG_LONG rb_num2ll _((VALUE));
unsigned LONG_LONG rb_num2ull _((VALUE)); unsigned LONG_LONG rb_num2ull _((VALUE));
# define NUM2LL(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2ll((VALUE)x)) # define NUM2LL(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2ll((VALUE)x))
# define NUM2ULL(x) rb_num2ull((VALUE)x) # define NUM2ULL(x) rb_num2ull((VALUE)x)
#endif #endif
#if HAVE_LONG_LONG && SIZEOF_OFF_T > SIZEOF_LONG #if defined(HAVE_LONG_LONG) && SIZEOF_OFF_T > SIZEOF_LONG
# define NUM2OFFT(x) ((off_t)NUM2LL(x)) # define NUM2OFFT(x) ((off_t)NUM2LL(x))
#else #else
# define NUM2OFFT(x) NUM2LONG(x) # define NUM2OFFT(x) NUM2LONG(x)

2
st.c
View file

@ -537,7 +537,7 @@ strhash(string)
h &= ~g; h &= ~g;
} }
return h; return h;
#elif HASH_PERL #elif defined(HASH_PERL)
register int val = 0; register int val = 0;
while ((c = *string++) != '\0') { while ((c = *string++) != '\0') {

View file

@ -856,7 +856,7 @@ rb_str_hash(str)
register char *p = RSTRING(str)->ptr; register char *p = RSTRING(str)->ptr;
register int key = 0; register int key = 0;
#ifdef HASH_ELFHASH #if defined(HASH_ELFHASH)
register unsigned int g; register unsigned int g;
while (len--) { while (len--) {
@ -865,7 +865,7 @@ rb_str_hash(str)
key ^= g >> 24; key ^= g >> 24;
key &= ~g; key &= ~g;
} }
#elif HASH_PERL #elif defined(HASH_PERL)
while (len--) { while (len--) {
key += *p++; key += *p++;
key += (key << 10); key += (key << 10);