* 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:
parent
fc63eb3a77
commit
46e1454dea
@ -1,9 +1,8 @@
|
|||||||
Sat Aug 23 02:32:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
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
|
* enum.c (each_with_index_i): typo.
|
||||||
calling rb_yield_0().
|
|
||||||
|
|
||||||
Fri Aug 22 17:07:05 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Fri Aug 22 17:07:05 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
17
eval.c
17
eval.c
@ -4254,11 +4254,20 @@ VALUE
|
|||||||
rb_yield_splat(values)
|
rb_yield_splat(values)
|
||||||
VALUE values;
|
VALUE values;
|
||||||
{
|
{
|
||||||
values = svalue_to_avalue(values);
|
VALUE tmp;
|
||||||
if (RARRAY(values)->len == 0) {
|
int avalue = Qfalse;
|
||||||
return rb_yield_0(Qundef, 0, 0, Qfalse, 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
|
static VALUE
|
||||||
|
@ -47,11 +47,26 @@
|
|||||||
|
|
||||||
(defconst ruby-block-end-re "end")
|
(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
|
(defconst ruby-delimiter
|
||||||
(concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\("
|
(concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\("
|
||||||
ruby-block-beg-re
|
ruby-block-beg-re
|
||||||
"\\|" ruby-block-end-re
|
"\\|" ruby-block-end-re
|
||||||
"\\)\\>\\|^=begin")
|
"\\)\\>\\|^=begin\\|" ruby-here-doc-beg-re)
|
||||||
)
|
)
|
||||||
|
|
||||||
(defconst ruby-negative
|
(defconst ruby-negative
|
||||||
@ -518,6 +533,12 @@ The variable ruby-indent-level controls the amount of indentation.
|
|||||||
(goto-char pnt))))
|
(goto-char pnt))))
|
||||||
((looking-at "^__END__$")
|
((looking-at "^__END__$")
|
||||||
(goto-char pnt))
|
(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
|
(t
|
||||||
(error (format "bad string %s"
|
(error (format "bad string %s"
|
||||||
(buffer-substring (point) pnt)
|
(buffer-substring (point) pnt)
|
||||||
@ -1047,6 +1068,35 @@ balanced expression is found."
|
|||||||
(modify-syntax-entry ?_ "w" tbl)
|
(modify-syntax-entry ?_ "w" tbl)
|
||||||
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
|
(defvar ruby-font-lock-keywords
|
||||||
(list
|
(list
|
||||||
;; functions
|
;; functions
|
||||||
@ -1109,6 +1159,13 @@ balanced expression is found."
|
|||||||
0 font-lock-comment-face t)
|
0 font-lock-comment-face t)
|
||||||
'(ruby-font-lock-maybe-docs
|
'(ruby-font-lock-maybe-docs
|
||||||
0 font-lock-comment-face t)
|
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
|
;; constants
|
||||||
'("\\(^\\|[^_]\\)\\b\\([A-Z]+\\(\\w\\|_\\)*\\)"
|
'("\\(^\\|[^_]\\)\\b\\([A-Z]+\\(\\w\\|_\\)*\\)"
|
||||||
2 font-lock-type-face)
|
2 font-lock-type-face)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user