summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-23 04:05:42 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-23 04:05:42 +0000
commit46e1454dea07eeb4396a85f41dc5753055a17b06 (patch)
treee44b364903181a7f769eb1def459e817a82be00b
parentfc63eb3a7763d460a451af88dc34403a7977749a (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--eval.c17
-rw-r--r--misc/ruby-mode.el59
3 files changed, 73 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index afaea8d176..34045a9280 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
diff --git a/eval.c b/eval.c
index 7b480990c8..fc5e88befd 100644
--- a/eval.c
+++ b/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
diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
index 3b03e0ffc1..d07d1da485 100644
--- a/misc/ruby-mode.el
+++ b/misc/ruby-mode.el
@@ -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)