From 549c345cefe03ab3f35b9cca1192a0062f288eca Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 7 Jun 2005 08:22:42 +0000 Subject: [PATCH] * parse.y (parser_yylex): allow ';;' to be block terminator in place of 'end'. [highly experimental] * misc/ruby-mode.el (ruby-block-end-re): allow ';;' for a negative indent trigger. [highly experimental] * parse.y (parser_yylex): "respond_to?:foo" should be interpreted as "respond_to? :foo" at the command level. [ruby-talk:144303] * sprintf.c (rb_f_sprintf): raise exception on debug mode (-d), not verbose mode (-w/-w). [ruby-core:05123] * sprintf.c (rb_f_sprintf): warn always on verbose mode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 20 ++++++++++++++++++++ misc/ruby-mode.el | 15 ++++++++------- parse.y | 7 ++++++- sprintf.c | 6 ++++-- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index af66965c0c..de9e4f42fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +Tue Jun 7 17:20:39 2005 Yukihiro Matsumoto + + * parse.y (parser_yylex): allow ';;' to be block terminator in + place of 'end'. [highly experimental] + + * misc/ruby-mode.el (ruby-block-end-re): allow ';;' for a negative + indent trigger. [highly experimental] + +Tue Jun 7 16:45:49 2005 Yukihiro Matsumoto + + * parse.y (parser_yylex): "respond_to?:foo" should be interpreted + as "respond_to? :foo" at the command level. [ruby-talk:144303] + +Tue Jun 7 16:32:53 2005 Yukihiro Matsumoto + + * sprintf.c (rb_f_sprintf): raise exception on debug mode (-d), + not verbose mode (-w/-w). [ruby-core:05123] + + * sprintf.c (rb_f_sprintf): warn always on verbose mode. + Tue Jun 7 10:30:49 2005 Hidetoshi NAGAI * ext/tk/lib/multi-tk.rb: slave-ip fails to call procedures diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index 7f2bcabd58..4a93054e99 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -45,7 +45,7 @@ (concat ruby-modifier-beg-re "\\|" ruby-block-op-re) ) -(defconst ruby-block-end-re "end") +(defconst ruby-block-end-re "\\\\|;;") (defconst ruby-here-doc-beg-re "<<\\(-\\)?\\(\\([a-zA-Z0-9_]+\\)\\|[\"]\\([^\"]+\\)[\"]\\|[']\\([^']+\\)[']\\)") @@ -61,13 +61,13 @@ (defconst ruby-delimiter (concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\(" ruby-block-beg-re - "\\|" ruby-block-end-re - "\\)\\>\\|^=begin\\|" ruby-here-doc-beg-re) + "\\>\\|" ruby-block-end-re + "\\)\\|^=begin\\|" ruby-here-doc-beg-re) ) (defconst ruby-negative (concat "^[ \t]*\\(\\(" ruby-block-mid-re "\\)\\>\\|\\(" - ruby-block-end-re "\\)\\>\\|}\\|\\]\\)") + ruby-block-end-re "\\)\\|}\\|\\]\\)") ) (defconst ruby-operator-chars "-,.+*/%&|^~=<>:") @@ -453,7 +453,7 @@ The variable ruby-indent-level controls the amount of indentation. (setq depth (1- depth))) (setq nest (cdr nest)) (goto-char pnt)) - ((looking-at (concat "\\<\\(" ruby-block-end-re "\\)\\>")) + ((looking-at ruby-block-end-re) (if (or (and (not (bolp)) (progn (forward-char -1) @@ -776,7 +776,8 @@ An end of a defun is found by moving forward from the beginning of one." (defun ruby-move-to-block (n) (let (start pos done down) (setq start (ruby-calculate-indent)) - (setq down (looking-at (concat "\\<\\(" (if (< n 0) ruby-block-end-re ruby-block-beg-re) "\\)\\>"))) + (setq down (looking-at (if (< n 0) ruby-block-end-re + (concat "\\<\\(" ruby-block-beg-re "\\)\\>")))) (while (and (not done) (not (if (< n 0) (bobp) (eobp)))) (forward-line n) (cond @@ -887,7 +888,7 @@ An end of a defun is found by moving forward from the beginning of one." (?: (forward-char -1) (eq (char-before) :))))) - (if (looking-at (concat "\\<\\(" ruby-block-end-re "\\)\\>")) + (if (looking-at ruby-block-end-re) (ruby-beginning-of-block)) nil)) (setq i (1- i))) diff --git a/parse.y b/parse.y index b5e040944d..0037f603d4 100644 --- a/parse.y +++ b/parse.y @@ -6304,6 +6304,11 @@ parser_yylex(parser) return '^'; case ';': + if ((c = nextc()) == ';') { + lex_state = EXPR_END; + return kEND; + } + pushback(c); command_start = Qtrue; case ',': lex_state = EXPR_BEG; @@ -6700,7 +6705,7 @@ parser_yylex(parser) } } - if (lex_state == EXPR_BEG || + if ((lex_state == EXPR_BEG && !cmd_state) || lex_state == EXPR_ARG || lex_state == EXPR_CMDARG) { if (peek(':') && !(lex_p + 1 < lex_pend && lex_p[1] == ':')) { diff --git a/sprintf.c b/sprintf.c index 0b7dd28385..59195450bc 100644 --- a/sprintf.c +++ b/sprintf.c @@ -770,8 +770,10 @@ rb_f_sprintf(argc, argv) sprint_exit: /* XXX - We cannot validiate the number of arguments if (digit)$ style used. */ - if (RTEST(ruby_verbose) && posarg >= 0 && nextarg < argc) { - rb_raise(rb_eArgError, "too many arguments for format string"); + if (posarg >= 0 && nextarg < argc) { + const char *mesg = "too many arguments for format string"; + if (RTEST(ruby_debug)) rb_raise(rb_eArgError, mesg); + if (RTEST(ruby_verbose)) rb_warn(mesg); } rb_str_resize(result, blen);