* 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
Родитель 5076ed519b
Коммит e6f473c3a0
4 изменённых файлов: 66 добавлений и 52 удалений

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

@ -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>
* lib/webrick/httprequest.rb (meta_vers): should not set

18
hash.c
Просмотреть файл

@ -460,12 +460,12 @@ rb_hash_shift(hash)
}
static enum st_retval
delete_if_i(key, value)
VALUE key, value;
delete_if_i(key, value, keys)
VALUE key, value, keys;
{
if (key == Qundef) return ST_CONTINUE;
if (RTEST(rb_yield_values(2, key, value)))
return ST_DELETE;
if (key != Qundef && RTEST(rb_yield_values(2, key, value))) {
rb_ary_push(keys, key);
}
return ST_CONTINUE;
}
@ -473,8 +473,14 @@ VALUE
rb_hash_delete_if(hash)
VALUE hash;
{
VALUE keys = rb_ary_new();
long i;
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;
}

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

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

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

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