summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-31 06:34:10 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-31 06:34:10 +0000
commit17c3d539f008c3ad4179e520511b6a64fb4ba969 (patch)
tree6a277eed8c128f9212b0ef8316750e697701059d
parentdc136c12ee4d704de7621408ab0a5d9108284b45 (diff)
* 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
-rw-r--r--ChangeLog6
-rw-r--r--eval.c2
-rw-r--r--io.c2
-rw-r--r--lib/readbytes.rb5
-rw-r--r--lib/weakref.rb18
-rw-r--r--ruby.h8
-rw-r--r--st.c2
-rw-r--r--string.c4
8 files changed, 34 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index a110268..2ca4d6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
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>
* eval.c (rb_call0): trace call/return of method defined from block.
diff --git a/eval.c b/eval.c
index 60d2b46..d00891a 100644
--- a/eval.c
+++ b/eval.c
@@ -10296,7 +10296,7 @@ rb_thread_switch(n)
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);
# endif
static void
diff --git a/io.c b/io.c
index 1d34632..d454d33 100644
--- a/io.c
+++ b/io.c
@@ -267,7 +267,7 @@ rb_io_check_readable(fptr)
if (!(fptr->mode & FMODE_READABLE)) {
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) ||
(fptr->mode & (FMODE_SYNCWRITE|FMODE_RBUF)) == FMODE_SYNCWRITE) &&
!feof(fptr->f) &&
diff --git a/lib/readbytes.rb b/lib/readbytes.rb
index d6a3b10..08b92da 100644
--- a/lib/readbytes.rb
+++ b/lib/readbytes.rb
@@ -12,6 +12,11 @@ class TruncatedDataError<IOError
end
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)
str = read(n)
if str == nil
diff --git a/lib/weakref.rb b/lib/weakref.rb
index 49b907b..142286e 100644
--- a/lib/weakref.rb
+++ b/lib/weakref.rb
@@ -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:
# foo = Object.new
@@ -8,11 +15,9 @@
# p foo.to_s # should be same class
# ObjectSpace.garbage_collect
# p foo.to_s # should raise exception (recycled)
-
-require "delegate"
-
class WeakRef<Delegator
+ # RefError is raised if an object cannot be referenced by a WeakRef.
class RefError<StandardError
end
@@ -40,6 +45,7 @@ class WeakRef<Delegator
end
}
+ # Create a new WeakRef from +orig+.
def initialize(orig)
super
@__id = orig.__id__
@@ -56,6 +62,9 @@ class WeakRef<Delegator
@@id_rev_map[self.__id__] = @__id
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__
unless @@id_rev_map[self.__id__] == @__id
raise RefError, "Illegal Reference - probably recycled", caller(2)
@@ -67,6 +76,7 @@ class WeakRef<Delegator
end
end
+ # Determine if this Weakref still refers to anything.
def weakref_alive?
@@id_rev_map[self.__id__] == @__id
end
diff --git a/ruby.h b/ruby.h
index cd47f79..d8048f8 100644
--- a/ruby.h
+++ b/ruby.h
@@ -102,7 +102,7 @@ typedef unsigned long ID;
# endif
#endif
-#if HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG
# ifndef LLONG_MAX
# ifdef LONG_LONG_MAX
# define LLONG_MAX LONG_LONG_MAX
@@ -144,7 +144,7 @@ VALUE rb_uint2inum _((unsigned long));
#define ULONG2NUM(v) UINT2NUM(v)
#define rb_uint_new(v) rb_uint2inum(v)
-#if HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG
VALUE rb_ll2inum _((LONG_LONG));
#define LL2NUM(v) rb_ll2inum(v)
VALUE rb_ull2inum _((unsigned LONG_LONG));
@@ -265,14 +265,14 @@ unsigned long rb_fix2uint _((VALUE));
#define FIX2UINT(x) ((unsigned int)FIX2ULONG(x))
#endif
-#if HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG
LONG_LONG rb_num2ll _((VALUE));
unsigned LONG_LONG rb_num2ull _((VALUE));
# define NUM2LL(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2ll((VALUE)x))
# define NUM2ULL(x) rb_num2ull((VALUE)x)
#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))
#else
# define NUM2OFFT(x) NUM2LONG(x)
diff --git a/st.c b/st.c
index ced1f91..c16c310 100644
--- a/st.c
+++ b/st.c
@@ -537,7 +537,7 @@ strhash(string)
h &= ~g;
}
return h;
-#elif HASH_PERL
+#elif defined(HASH_PERL)
register int val = 0;
while ((c = *string++) != '\0') {
diff --git a/string.c b/string.c
index fb8be9d..83ac1e4 100644
--- a/string.c
+++ b/string.c
@@ -856,7 +856,7 @@ rb_str_hash(str)
register char *p = RSTRING(str)->ptr;
register int key = 0;
-#ifdef HASH_ELFHASH
+#if defined(HASH_ELFHASH)
register unsigned int g;
while (len--) {
@@ -865,7 +865,7 @@ rb_str_hash(str)
key ^= g >> 24;
key &= ~g;
}
-#elif HASH_PERL
+#elif defined(HASH_PERL)
while (len--) {
key += *p++;
key += (key << 10);