* lib/net/imap.rb (string): accept NIL.

* lib/net/imap.rb (body_type_basic): allow body-fields omissions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2004-05-06 02:47:37 +00:00
parent 3d33a14369
commit 7cb6dfb8fc
2 changed files with 33 additions and 8 deletions

View File

@ -1,3 +1,9 @@
Thu May 6 11:40:28 2004 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (string): accept NIL.
* lib/net/imap.rb (body_type_basic): allow body-fields omissions.
Thu May 6 01:59:04 2004 Dave Thomas <dave@pragprog.com> Thu May 6 01:59:04 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/generators/html_generator.rb (Generators::HtmlMethod::params): * lib/rdoc/generators/html_generator.rb (Generators::HtmlMethod::params):

View File

@ -2123,6 +2123,10 @@ module Net # :nodoc:
def body_type_basic def body_type_basic
mtype, msubtype = media_type mtype, msubtype = media_type
token = lookahead
if token.symbol == T_RPAR
return BodyTypeBasic.new(mtype, msubtype)
end
match(T_SPACE) match(T_SPACE)
param, content_id, desc, enc, size = body_fields param, content_id, desc, enc, size = body_fields
md5, disposition, language, extension = body_ext_1part md5, disposition, language, extension = body_ext_1part
@ -2175,7 +2179,7 @@ module Net # :nodoc:
parts.push(body) parts.push(body)
end end
mtype = "MULTIPART" mtype = "MULTIPART"
msubtype = string.upcase msubtype = case_insensitive_string
param, disposition, language, extension = body_ext_mpart param, disposition, language, extension = body_ext_mpart
return BodyTypeMultipart.new(mtype, msubtype, parts, return BodyTypeMultipart.new(mtype, msubtype, parts,
param, disposition, language, param, disposition, language,
@ -2183,9 +2187,9 @@ module Net # :nodoc:
end end
def media_type def media_type
mtype = string.upcase mtype = case_insensitive_string
match(T_SPACE) match(T_SPACE)
msubtype = string.upcase msubtype = case_insensitive_string
return mtype, msubtype return mtype, msubtype
end end
@ -2196,7 +2200,7 @@ module Net # :nodoc:
match(T_SPACE) match(T_SPACE)
desc = nstring desc = nstring
match(T_SPACE) match(T_SPACE)
enc = string.upcase enc = case_insensitive_string
match(T_SPACE) match(T_SPACE)
size = number size = number
return param, content_id, desc, enc, size return param, content_id, desc, enc, size
@ -2219,7 +2223,7 @@ module Net # :nodoc:
when T_SPACE when T_SPACE
shift_token shift_token
end end
name = string.upcase name = case_insensitive_string
match(T_SPACE) match(T_SPACE)
val = string val = string
param[name] = val param[name] = val
@ -2300,7 +2304,7 @@ module Net # :nodoc:
return nil return nil
end end
match(T_LPAR) match(T_LPAR)
dsp_type = string.upcase dsp_type = case_insensitive_string
match(T_SPACE) match(T_SPACE)
param = body_fld_param param = body_fld_param
match(T_RPAR) match(T_RPAR)
@ -2321,7 +2325,7 @@ module Net # :nodoc:
when T_SPACE when T_SPACE
shift_token shift_token
end end
result.push(string.upcase) result.push(case_insensitive_string)
end end
else else
lang = nstring lang = nstring
@ -2829,16 +2833,31 @@ module Net # :nodoc:
end end
def string def string
token = lookahead
if token.symbol == T_NIL
shift_token
return nil
end
token = match(T_QUOTED, T_LITERAL) token = match(T_QUOTED, T_LITERAL)
return token.value return token.value
end end
STRING_TOKENS = [T_QUOTED, T_LITERAL] STRING_TOKENS = [T_QUOTED, T_LITERAL, T_NIL]
def string_token?(token) def string_token?(token)
return STRING_TOKENS.include?(token.symbol) return STRING_TOKENS.include?(token.symbol)
end end
def case_insensitive_string
token = lookahead
if token.symbol == T_NIL
shift_token
return nil
end
token = match(T_QUOTED, T_LITERAL)
return token.value.upcase
end
def atom def atom
result = "" result = ""
while true while true