summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--bignum.c26
-rw-r--r--gc.c2
-rw-r--r--lib/net/http.rb9
-rw-r--r--object.c19
-rw-r--r--parse.y11
6 files changed, 60 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 7684c87..6c3dc18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,11 +17,28 @@ Wed Oct 16 13:36:29 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* variable.c (rb_alias_variable): ditto.
+Wed Oct 16 01:03:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_str_to_dbl): RString ptr might be NULL.
+
+ * object.c (rb_cstr_to_dbl): p pointer might be NULL.
+
+ * bignum.c (rb_str_to_inum): RString ptr might be NULL.
+
+ * bignum.c (rb_cstr_to_inum): str pointer might be NULL.
+
Sat Oct 12 23:44:11 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* win32/win32.c (rb_w32_putc): wrong condition to fill or flush on
bccwin32. [ruby-win32:408]
+Fri Oct 11 15:58:06 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (arg): rescue modifier is now an operator with
+ precedence right below assignments. i.e. "a = b rescue c" now
+ parsed as "a = (b rescue c)", not as "(a = b) rescue c". [new]
+ [experimental]
+
Fri Oct 11 06:05:30 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* win32/win32.c (rb_w32_fclose, rb_w32_close): use closesocket()
diff --git a/bignum.c b/bignum.c
index 3cf4544..0d23189 100644
--- a/bignum.c
+++ b/bignum.c
@@ -319,6 +319,10 @@ rb_cstr_to_inum(str, base, badcheck)
VALUE z;
BDIGIT *zds;
+ if (!str) {
+ if (badcheck) goto bad;
+ return INT2FIX(0);
+ }
if (badcheck) {
while (ISSPACE(*str)) str++;
}
@@ -501,16 +505,18 @@ rb_str_to_inum(str, base, badcheck)
StringValue(str);
s = RSTRING(str)->ptr;
- len = RSTRING(str)->len;
- if (s[len]) { /* no sentinel somehow */
- char *p = ALLOCA_N(char, len+1);
-
- MEMCPY(p, s, char, len);
- p[len] = '\0';
- s = p;
- }
- if (badcheck && len != strlen(s)) {
- rb_raise(rb_eArgError, "string for Integer contains null byte");
+ if (s) {
+ len = RSTRING(str)->len;
+ if (s[len]) { /* no sentinel somehow */
+ char *p = ALLOCA_N(char, len+1);
+
+ MEMCPY(p, s, char, len);
+ p[len] = '\0';
+ s = p;
+ }
+ if (badcheck && len != strlen(s)) {
+ rb_raise(rb_eArgError, "string for Integer contains null byte");
+ }
}
return rb_cstr_to_inum(s, base, badcheck);
}
diff --git a/gc.c b/gc.c
index a7486aa..0ef7970 100644
--- a/gc.c
+++ b/gc.c
@@ -991,7 +991,7 @@ gc_sweep()
}
}
}
- for (i = j = 0; j < heaps_used; i++) {
+ for (i = j = 1; j < heaps_used; i++) {
if (heaps_limits[i] == 0) {
free(heaps[i]);
heaps_used--;
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 0a1a714..6a906ad 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -476,6 +476,11 @@ All arguments named KEY is case-insensitive.
: self[ key ] = val
sets the header field corresponding to the case-insensitive key.
+: fetch( key [,default] )
+
+ returns the header field corresponding to the case-insensitive key.
+ returns the default value if there's no header field named key.
+
: key?( key )
true if key exists.
KEY is case insensitive.
@@ -923,6 +928,10 @@ module Net
@header.delete key.downcase
end
+ def fetch(*args)
+ @header.fetch(*args)
+ end
+
def key?( key )
@header.key? key.downcase
end
diff --git a/object.c b/object.c
index 72805e9..f505854 100644
--- a/object.c
+++ b/object.c
@@ -1031,6 +1031,7 @@ rb_cstr_to_dbl(p, badcheck)
char *end;
double d;
+ if (!p) return 0.0;
q = p;
if (badcheck) {
while (ISSPACE(*p)) p++;
@@ -1093,15 +1094,17 @@ rb_str_to_dbl(str, badcheck)
StringValue(str);
s = RSTRING(str)->ptr;
len = RSTRING(str)->len;
- if (s[len]) { /* no sentinel somehow */
- char *p = ALLOCA_N(char, len+1);
+ if (s) {
+ if (s[len]) { /* no sentinel somehow */
+ char *p = ALLOCA_N(char, len+1);
- MEMCPY(p, s, char, len);
- p[len] = '\0';
- s = p;
- }
- if (badcheck && len != strlen(s)) {
- rb_raise(rb_eArgError, "string for Float contains null byte");
+ MEMCPY(p, s, char, len);
+ p[len] = '\0';
+ s = p;
+ }
+ if (badcheck && len != strlen(s)) {
+ rb_raise(rb_eArgError, "string for Float contains null byte");
+ }
}
return rb_cstr_to_dbl(s, badcheck);
}
diff --git a/parse.y b/parse.y
index 56332e3..b9ca1fa 100644
--- a/parse.y
+++ b/parse.y
@@ -282,11 +282,12 @@ static void top_local_setup();
* precedence table
*/
-%left kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD kRESCUE_MOD
+%left kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
%left kOR kAND
%right kNOT
%nonassoc kDEFINED
%right '=' tOP_ASGN
+%left kRESCUE_MOD
%right '?' ':'
%nonassoc tDOT2 tDOT3
%left tOROP
@@ -423,10 +424,6 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
$$ = NEW_UNTIL(cond($3), $1, 1);
}
}
- | stmt kRESCUE_MOD stmt
- {
- $$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0);
- }
| klBEGIN
{
if (in_def || in_single) {
@@ -1039,6 +1036,10 @@ arg : lhs '=' arg
{
$$ = logop(NODE_OR, $1, $3);
}
+ | arg kRESCUE_MOD arg
+ {
+ $$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0);
+ }
| kDEFINED opt_nl {in_defined = 1;} arg
{
in_defined = 0;