1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* misc/ruby-mode.el (ruby-calculate-indent): proper indentation

inside of parentheses.  [ruby-dev:22308]

* hash.c (delete_if_i): do not use ST_DELETE for thread safety.
  [ruby-dev:21899]  (not fully solved)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-12-19 17:29:09 +00:00
parent 5076ed519b
commit e6f473c3a0
4 changed files with 66 additions and 52 deletions

View file

@ -1,3 +1,11 @@
Sat Dec 20 02:18:31 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* misc/ruby-mode.el (ruby-calculate-indent): proper indentation
inside of parentheses. [ruby-dev:22308]
* hash.c (delete_if_i): do not use ST_DELETE for thread safety.
[ruby-dev:21899] (not fully solved)
Fri Dec 19 21:24:22 2003 GOTOU Yuuzou <gotoyuzo@notwork.org> Fri Dec 19 21:24:22 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httprequest.rb (meta_vers): should not set * lib/webrick/httprequest.rb (meta_vers): should not set

18
hash.c
View file

@ -460,12 +460,12 @@ rb_hash_shift(hash)
} }
static enum st_retval static enum st_retval
delete_if_i(key, value) delete_if_i(key, value, keys)
VALUE key, value; VALUE key, value, keys;
{ {
if (key == Qundef) return ST_CONTINUE; if (key != Qundef && RTEST(rb_yield_values(2, key, value))) {
if (RTEST(rb_yield_values(2, key, value))) rb_ary_push(keys, key);
return ST_DELETE; }
return ST_CONTINUE; return ST_CONTINUE;
} }
@ -473,8 +473,14 @@ VALUE
rb_hash_delete_if(hash) rb_hash_delete_if(hash)
VALUE hash; VALUE hash;
{ {
VALUE keys = rb_ary_new();
long i;
rb_hash_modify(hash); rb_hash_modify(hash);
rb_hash_foreach(hash, delete_if_i, 0); rb_hash_foreach(hash, delete_if_i, keys);
for (i=0; i<RARRAY(keys)->len; i++) {
st_delete(RHASH(hash)->tbl, &RARRAY(keys)->ptr[i], 0);
}
return hash; return hash;
} }

View file

@ -125,7 +125,7 @@ class Rational
def ** (other) def ** (other)
if other.kind_of?(Rational) if other.kind_of?(Rational)
if self < 0 if self < 0
return Complex(self, 0) ** other return Complex.new!(self, 0) ** other
elsif other == 0 elsif other == 0
return Rational(1,1) return Rational(1,1)
elsif self == 0 elsif self == 0

View file

@ -611,34 +611,25 @@ The variable ruby-indent-level controls the amount of indentation.
((nth 0 state) ; within string ((nth 0 state) ; within string
(setq indent nil)) ; do nothing (setq indent nil)) ; do nothing
((car (nth 1 state)) ; in paren ((car (nth 1 state)) ; in paren
(cond (goto-char (setq begin (cdr (nth 1 state))))
((and (eq (car (nth 1 state)) ?\{) ; brace block (let ((deep (ruby-deep-indent-paren-p (car (nth 1 state)))))
(save-excursion (if deep
(goto-char (1- (cdr (nth 1 state)))) (cond ((and (eq deep t) (eq (car (nth 1 state)) paren))
(not (ruby-expr-beg)))) (skip-syntax-backward " ")
(setq paren nil) (setq indent (1- (current-column))))
(back-to-indentation) ((let ((s (ruby-parse-region (point) indent-point)))
(setq indent (ruby-indent-size (current-column) (nth 2 state)))) (and (nth 2 s) (> (nth 2 s) 0)
(t (or (goto-char (cdr (nth 1 s))) t)))
(goto-char (setq begin (cdr (nth 1 state)))) (forward-word -1)
(let ((deep (ruby-deep-indent-paren-p (car (nth 1 state))))) (setq indent (ruby-indent-size (current-column) (nth 2 state))))
(if deep (t
(cond ((and (eq deep t) (eq (car (nth 1 state)) paren)) (setq indent (current-column))
(skip-syntax-backward " ") (cond ((eq deep 'space))
(setq indent (1- (current-column)))) (paren (setq indent (1- indent)))
((let ((s (ruby-parse-region (point) indent-point))) (t (setq indent (ruby-indent-size (1- indent) 1))))))
(and (nth 2 s) (> (nth 2 s) 0) (if (nth 3 state) (goto-char (nth 3 state))
(or (goto-char (cdr (nth 1 s))) t))) (goto-char parse-start) (back-to-indentation))
(forward-word -1) (setq indent (ruby-indent-size (current-column) (nth 2 state))))))
(setq indent (ruby-indent-size (current-column) (nth 2 state))))
(t
(setq indent (current-column))
(cond ((eq deep 'space))
(paren (setq indent (1- indent)))
(t (setq indent (ruby-indent-size (1- indent) 1))))))
(if (nth 3 state) (goto-char (nth 3 state))
(goto-char parse-start) (back-to-indentation))
(setq indent (ruby-indent-size (current-column) (nth 2 state))))))))
((and (nth 2 state) (> (nth 2 state) 0)) ; in nest ((and (nth 2 state) (> (nth 2 state) 0)) ; in nest
(if (null (cdr (nth 1 state))) (if (null (cdr (nth 1 state)))
(error "invalid nest")) (error "invalid nest"))
@ -655,7 +646,6 @@ The variable ruby-indent-level controls the amount of indentation.
((and (nth 2 state) (< (nth 2 state) 0)) ; in negative nest ((and (nth 2 state) (< (nth 2 state) 0)) ; in negative nest
(setq indent (ruby-indent-size (current-column) (nth 2 state))))) (setq indent (ruby-indent-size (current-column) (nth 2 state)))))
(when indent (when indent
(goto-char indent-point) (goto-char indent-point)
(end-of-line) (end-of-line)
@ -709,22 +699,32 @@ The variable ruby-indent-level controls the amount of indentation.
(not (looking-at "[a-z_]")))) (not (looking-at "[a-z_]"))))
(and (looking-at ruby-operator-re) (and (looking-at ruby-operator-re)
(not (ruby-special-char-p)) (not (ruby-special-char-p))
(or (not (eq ?/ (char-after (point)))) (let ((c (char-after (point))))
(null (nth 0 (ruby-parse-region parse-start (point))))) (and
(or (not (eq ?| (char-after (point)))) (or (not (eq ?, c))
(save-excursion (null begin)
(or (eolp) (forward-char -1)) (save-excursion
(cond (goto-char begin)
((search-backward "|" nil t) (skip-chars-forward " \t")
(skip-chars-backward " \t\n") (not (or (eolp) (looking-at "#")
(and (not (eolp)) (and (eq (car (nth 1 state)) ?{)
(progn (looking-at "|"))))))
(forward-char -1) (or (not (eq ?/ c))
(not (looking-at "{"))) (null (nth 0 (ruby-parse-region (or begin parse-start) (point)))))
(progn (or (not (eq ?| (char-after (point))))
(forward-word -1) (save-excursion
(not (looking-at "do\\>[^_]"))))) (or (eolp) (forward-char -1))
(t t)))))) (cond
((search-backward "|" nil t)
(skip-chars-backward " \t\n")
(and (not (eolp))
(progn
(forward-char -1)
(not (looking-at "{")))
(progn
(forward-word -1)
(not (looking-at "do\\>[^_]")))))
(t t))))))))
(setq indent (setq indent
(cond (cond
((and ((and