comparison lisp/progmodes/cc-cmds.el @ 76811:72a276765477

(c-forward-to-nth-EOF-}): Fix EOB bug.
author Alan Mackenzie <acm@muc.de>
date Fri, 30 Mar 2007 20:20:35 +0000
parents 0cca0f6a0522
children 831765c54f39
comparison
equal deleted inserted replaced
76810:af7f21e5508f 76811:72a276765477
1475 (setq n (1- n))) 1475 (setq n (1- n)))
1476 ((eq where 'in-header) 1476 ((eq where 'in-header)
1477 (c-syntactic-re-search-forward "{") 1477 (c-syntactic-re-search-forward "{")
1478 (backward-char) 1478 (backward-char)
1479 (setq n (1- n))) 1479 (setq n (1- n)))
1480 (;; (or (eq where 'at-header) (eq where 'outwith-function) 1480 ((memq where '(at-header outwith-function at-function-end in-trailer))
1481 ;; (eq where 'at-function-end) (eq where 'in-trailer))
1482 (memq where '(at-header outwith-function at-function-end in-trailer))
1483 (c-syntactic-skip-backward "^}") 1481 (c-syntactic-skip-backward "^}")
1484 (when (eq (char-before) ?\}) 1482 (when (eq (char-before) ?\})
1485 (backward-sexp) 1483 (backward-sexp)
1486 (setq n (1- n)))) 1484 (setq n (1- n))))
1487 (t (error "Unknown `where' %s in c-backward-to-nth-EOF-{" where))) 1485 (t (error "Unknown `where' %s in c-backward-to-nth-EOF-{" where)))
1524 (setq where (c-where-wrt-brace-construct)) 1522 (setq where (c-where-wrt-brace-construct))
1525 1523
1526 (if (< arg 0) 1524 (if (< arg 0)
1527 ;; Move forward to the closing brace of a function. 1525 ;; Move forward to the closing brace of a function.
1528 (progn 1526 (progn
1529 (if ;; (or (eq where 'at-function-end) (eq where 'outwith-function)) 1527 (if (memq where '(at-function-end outwith-function))
1530 (memq where '(at-function-end outwith-function))
1531 (setq arg (1+ arg))) 1528 (setq arg (1+ arg)))
1532 (if (< arg 0) 1529 (if (< arg 0)
1533 (setq arg (c-forward-to-nth-EOF-} (- arg) where))) 1530 (setq arg (c-forward-to-nth-EOF-} (- arg) where)))
1534 ;; Move forward to the next opening brace.... 1531 ;; Move forward to the next opening brace....
1535 (when (and (= arg 0) 1532 (when (and (= arg 0)
1585 (forward-sexp) 1582 (forward-sexp)
1586 (setq n (1- n))) 1583 (setq n (1- n)))
1587 ((eq where 'in-trailer) 1584 ((eq where 'in-trailer)
1588 (c-syntactic-skip-backward "^}") 1585 (c-syntactic-skip-backward "^}")
1589 (setq n (1- n))) 1586 (setq n (1- n)))
1590 (;; (or (eq where 'at-function-end) (eq where 'outwith-function) 1587 ((memq where '(at-function-end outwith-function at-header in-header))
1591 ;; (eq where 'at-header) (eq where 'in-header)) 1588 (when (c-syntactic-re-search-forward "{" nil 'eob)
1592 (memq where '(at-function-end outwith-function at-header in-header)) 1589 (backward-char)
1593 (c-syntactic-re-search-forward "{") 1590 (forward-sexp)
1594 (backward-char) 1591 (setq n (1- n))))
1595 (forward-sexp)
1596 (setq n (1- n)))
1597 (t (error "c-forward-to-nth-EOF-}: `where' is %s" where))) 1592 (t (error "c-forward-to-nth-EOF-}: `where' is %s" where)))
1598 1593
1599 ;; Each time round the loop, go forward to a "}" at the outermost level. 1594 ;; Each time round the loop, go forward to a "}" at the outermost level.
1600 (while (and (> n 0) (not (eobp))) 1595 (while (and (> n 0) (not (eobp)))
1601 ;(c-parse-state) ; This call speeds up the following one by a factor 1596 ;(c-parse-state) ; This call speeds up the following one by a factor
1629 (setq where (c-where-wrt-brace-construct)) 1624 (setq where (c-where-wrt-brace-construct))
1630 1625
1631 (if (< arg 0) 1626 (if (< arg 0)
1632 ;; Move backwards to the } of a function 1627 ;; Move backwards to the } of a function
1633 (progn 1628 (progn
1634 (if ;; (or (eq where 'at-header) (eq where 'outwith-function)) 1629 (if (memq where '(at-header outwith-function))
1635 (memq where '(at-header outwith-function))
1636 (setq arg (1+ arg))) 1630 (setq arg (1+ arg)))
1637 (if (< arg 0) 1631 (if (< arg 0)
1638 (setq arg (c-backward-to-nth-BOF-{ (- arg) where))) 1632 (setq arg (c-backward-to-nth-BOF-{ (- arg) where)))
1639 (when (and (= arg 0) 1633 (when (and (= arg 0)
1640 (c-syntactic-skip-backward "^}") 1634 (c-syntactic-skip-backward "^}")