* eval.c (rb_yield_splat): should check if "values" is array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-08-23 04:05:42 +00:00
Родитель fc63eb3a77
Коммит 46e1454dea
3 изменённых файлов: 73 добавлений и 8 удалений

Просмотреть файл

@ -1,9 +1,8 @@
Sat Aug 23 02:32:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* enum.c (each_with_index_i): typo.
* eval.c (rb_yield_splat): should check if "values" is array.
* eval.c (rb_yield_splat): should call svalue_to_avalue() before
calling rb_yield_0().
* enum.c (each_with_index_i): typo.
Fri Aug 22 17:07:05 2003 Yukihiro Matsumoto <matz@ruby-lang.org>

17
eval.c
Просмотреть файл

@ -4254,11 +4254,20 @@ VALUE
rb_yield_splat(values)
VALUE values;
{
values = svalue_to_avalue(values);
if (RARRAY(values)->len == 0) {
return rb_yield_0(Qundef, 0, 0, Qfalse, Qfalse);
VALUE tmp;
int avalue = Qfalse;
tmp = rb_check_array_type(values);
if (!NIL_P(tmp)) {
if (RARRAY(tmp)->len == 0) {
values = Qundef;
}
else {
values = tmp;
avalue = Qtrue;
}
}
return rb_yield_0(values, 0, 0, Qfalse, Qtrue);
return rb_yield_0(values, 0, 0, Qfalse, avalue);
}
static VALUE

Просмотреть файл

@ -47,11 +47,26 @@
(defconst ruby-block-end-re "end")
(defconst ruby-here-doc-beg-re
(concat "<<\\([-]\\)?\\([a-zA-Z0-9]+\\)\\|"
"<<\\([-]\\)?[\"]\\([^\"]+\\)[\"]\\|"
"<<\\([-]\\)?[']\\([^']+\\)[']"))
(defun ruby-here-doc-end-match ()
(concat "^"
(if (or (match-string 1)
(match-string 3)
(match-string 5))
"[ \t]*" nil)
(or (match-string 2)
(match-string 4)
(match-string 6))))
(defconst ruby-delimiter
(concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\("
ruby-block-beg-re
"\\|" ruby-block-end-re
"\\)\\>\\|^=begin")
"\\)\\>\\|^=begin\\|" ruby-here-doc-beg-re)
)
(defconst ruby-negative
@ -518,6 +533,12 @@ The variable ruby-indent-level controls the amount of indentation.
(goto-char pnt))))
((looking-at "^__END__$")
(goto-char pnt))
((looking-at ruby-here-doc-beg-re)
(if (re-search-forward (ruby-here-doc-end-match)
indent-point t)
(forward-line 1)
(setq in-string (match-end 0))
(goto-char indent-point)))
(t
(error (format "bad string %s"
(buffer-substring (point) pnt)
@ -1047,6 +1068,35 @@ balanced expression is found."
(modify-syntax-entry ?_ "w" tbl)
tbl))
(defun ruby-font-lock-here-docs (limit)
(if (re-search-forward ruby-here-doc-beg-re limit t)
(let (beg)
(beginning-of-line)
(forward-line)
(setq beg (point))
(if (re-search-forward (ruby-here-doc-end-match) nil t)
(progn
(set-match-data (list beg (point)))
t)))))
(defun ruby-font-lock-maybe-here-docs (limit)
(let (beg)
(save-excursion
(if (re-search-backward ruby-here-doc-beg-re nil t)
(progn
(beginning-of-line)
(forward-line)
(setq beg (point)))))
(let ((end-match (ruby-here-doc-end-match)))
(if (and beg
(not (re-search-backward end-match beg t))
(re-search-forward end-match nil t))
(progn
(set-match-data (list beg (point)))
t)
nil))))
(defvar ruby-font-lock-keywords
(list
;; functions
@ -1109,6 +1159,13 @@ balanced expression is found."
0 font-lock-comment-face t)
'(ruby-font-lock-maybe-docs
0 font-lock-comment-face t)
;; "here" document
'(ruby-font-lock-here-docs
0 font-lock-string-face t)
'(ruby-font-lock-maybe-here-docs
0 font-lock-string-face t)
`(,ruby-here-doc-beg-re
0 font-lock-string-face t)
;; constants
'("\\(^\\|[^_]\\)\\b\\([A-Z]+\\(\\w\\|_\\)*\\)"
2 font-lock-type-face)