summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-01-21 09:01:23 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-01-21 09:01:23 +0000
commita2f60e923e2f9f7628e0ec75b9092af1a3e18b3d (patch)
treef0d2d04be7ee2391624500b844cdea22026c81ce
parent2cff4c0126a7e003653a183119ebdf7633246a9e (diff)
* lib/net/imap.rb (envelope): allow NIL.
* lib/net/imap.rb (body): ditto. * lib/net/imap.rb (number): ditto. * lib/net/imap.rb (ensure_nz_number): show a detailed error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--lib/net/imap.rb84
2 files changed, 60 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 31a008d28f5..56ee3f899a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Jan 21 17:57:56 2004 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb (envelope): allow NIL.
+ * lib/net/imap.rb (body): ditto.
+ * lib/net/imap.rb (number): ditto.
+ * lib/net/imap.rb (ensure_nz_number): show a detailed error
+ message.
+
Wed Jan 21 16:44:15 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (merge_libs): squeeze successive same libraries.
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 086717b97e4..6ca03c703f8 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -1361,7 +1361,9 @@ module Net # :nodoc:
def ensure_nz_number(num)
if num < -1 || num == 0 || num >= 4294967296
- raise DataFormatError, num.inspect
+ msg = "nz_number must be non-zero unsigned 32-bit integer: " +
+ num.inspect
+ raise DataFormatError, msg
end
end
end
@@ -2006,30 +2008,37 @@ module Net # :nodoc:
def envelope
@lex_state = EXPR_DATA
- match(T_LPAR)
- date = nstring
- match(T_SPACE)
- subject = nstring
- match(T_SPACE)
- from = address_list
- match(T_SPACE)
- sender = address_list
- match(T_SPACE)
- reply_to = address_list
- match(T_SPACE)
- to = address_list
- match(T_SPACE)
- cc = address_list
- match(T_SPACE)
- bcc = address_list
- match(T_SPACE)
- in_reply_to = nstring
- match(T_SPACE)
- message_id = nstring
- match(T_RPAR)
- @lex_state = EXPR_BEG
- return Envelope.new(date, subject, from, sender, reply_to,
- to, cc, bcc, in_reply_to, message_id)
+ token = lookahead
+ if token.symbol == T_NIL
+ shift_token
+ result = nil
+ else
+ match(T_LPAR)
+ date = nstring
+ match(T_SPACE)
+ subject = nstring
+ match(T_SPACE)
+ from = address_list
+ match(T_SPACE)
+ sender = address_list
+ match(T_SPACE)
+ reply_to = address_list
+ match(T_SPACE)
+ to = address_list
+ match(T_SPACE)
+ cc = address_list
+ match(T_SPACE)
+ bcc = address_list
+ match(T_SPACE)
+ in_reply_to = nstring
+ match(T_SPACE)
+ message_id = nstring
+ match(T_RPAR)
+ result = Envelope.new(date, subject, from, sender, reply_to,
+ to, cc, bcc, in_reply_to, message_id)
+ end
+ @lex_state = EXPR_BEG
+ return result
end
def flags_data
@@ -2082,14 +2091,20 @@ module Net # :nodoc:
def body
@lex_state = EXPR_DATA
- match(T_LPAR)
token = lookahead
- if token.symbol == T_LPAR
- result = body_type_mpart
- else
- result = body_type_1part
- end
- match(T_RPAR)
+ if token.symbol == T_NIL
+ shift_token
+ result = nil
+ else
+ match(T_LPAR)
+ token = lookahead
+ if token.symbol == T_LPAR
+ result = body_type_mpart
+ else
+ result = body_type_1part
+ end
+ match(T_RPAR)
+ end
@lex_state = EXPR_BEG
return result
end
@@ -2855,6 +2870,11 @@ module Net # :nodoc:
end
def number
+ token = lookahead
+ if token.symbol == T_NIL
+ shift_token
+ return nil
+ end
token = match(T_NUMBER)
return token.value.to_i
end