aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2013-08-25 12:27:13 +0200
committerJoakim Verona2013-08-25 12:27:13 +0200
commit37f54c5079d36bae4ee4f133c45d349bab564c48 (patch)
tree44d51d5aa187fa7b97fdfc7a3e984119eb924d0c
parentb8e2acdd013a259b64c97292d229d78e9da2e3cd (diff)
parentb5eb9035266f58e99695fd424cba84f994db9a0e (diff)
downloademacs-37f54c5079d36bae4ee4f133c45d349bab564c48.tar.gz
emacs-37f54c5079d36bae4ee4f133c45d349bab564c48.zip
merge from trunk
-rw-r--r--lisp/ChangeLog18
-rw-r--r--lisp/progmodes/cc-awk.el81
-rw-r--r--lisp/progmodes/cc-engine.el3
3 files changed, 73 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b47258330f1..4d4227a2a0f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,21 @@
12013-08-25 Alan Mackenzie <acm@muc.de>
2
3 Handle "/"s more accurately in test for virtual semicolons (AWK Mode).
4
5 * progmodes/cc-awk.el (c-awk-one-line-possibly-open-string-re)
6 (c-awk-regexp-one-line-possibly-open-char-list-re)
7 (c-awk-one-line-possibly-open-regexp-re)
8 (c-awk-one-line-non-syn-ws*-re): Remove.
9 (c-awk-possibly-open-string-re, c-awk-non-/-syn-ws*-re)
10 (c-awk-space*-/-re, c-awk-space*-regexp-/-re)
11 (c-awk-space*-unclosed-regexp-/-re): New constants.
12 (c-awk-at-vsemi-p): Reformulate better to recognize "/"s which
13 aren't regexp delimiters.
14
15 * progmodes/cc-engine.el (c-crosses-statement-barrier-p): Add in
16 handling for a rare situation in AWK Mode involving unterminated
17 strings/regexps.
18
12013-08-23 Glenn Morris <rgm@gnu.org> 192013-08-23 Glenn Morris <rgm@gnu.org>
2 20
3 * files.el (auto-mode-alist): Use sh-mode for .bash_history. 21 * files.el (auto-mode-alist): Use sh-mode for .bash_history.
diff --git a/lisp/progmodes/cc-awk.el b/lisp/progmodes/cc-awk.el
index 4b3fc91b0ff..b5216b43ed9 100644
--- a/lisp/progmodes/cc-awk.el
+++ b/lisp/progmodes/cc-awk.el
@@ -169,9 +169,9 @@
169 (concat "\\=_?\"" c-awk-string-innards-re)) 169 (concat "\\=_?\"" c-awk-string-innards-re))
170;; Matches an AWK string at point up to, but not including, any terminator. 170;; Matches an AWK string at point up to, but not including, any terminator.
171;; A gawk 3.1+ string may look like _"localizable string". 171;; A gawk 3.1+ string may look like _"localizable string".
172(defconst c-awk-one-line-possibly-open-string-re 172(defconst c-awk-possibly-open-string-re
173 (concat "\"\\(" c-awk-string-ch-re "\\|" c-awk-non-eol-esc-pair-re "\\)*" 173 (concat "\"\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*"
174 "\\(\"\\|\\\\?$\\|\\'\\)")) 174 "\\(\"\\|$\\|\\'\\)"))
175 175
176;; REGEXPS FOR AWK REGEXPS. 176;; REGEXPS FOR AWK REGEXPS.
177(defconst c-awk-regexp-normal-re "[^[/\\\n\r]") 177(defconst c-awk-regexp-normal-re "[^[/\\\n\r]")
@@ -192,25 +192,13 @@
192 "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)")) 192 "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)"))
193;; Matches a regexp char list, up to (but not including) EOL if the ] is 193;; Matches a regexp char list, up to (but not including) EOL if the ] is
194;; missing. 194;; missing.
195(defconst c-awk-regexp-one-line-possibly-open-char-list-re
196 (concat "\\[\\]?\\(" c-awk-non-eol-esc-pair-re "\\|" "[^]\n\r]" "\\)*"
197 "\\(]\\|\\\\?$\\|\\'\\)"))
198;; Matches the head (or all) of a regexp char class, up to (but not
199;; including) the first EOL.
200(defconst c-awk-regexp-innards-re 195(defconst c-awk-regexp-innards-re
201 (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re 196 (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re
202 "\\|" c-awk-regexp-normal-re "\\)*")) 197 "\\|" c-awk-regexp-normal-re "\\)*"))
203;; Matches the inside of an AWK regexp (i.e. without the enclosing /s) 198;; Matches the inside of an AWK regexp (i.e. without the enclosing /s)
204(defconst c-awk-regexp-without-end-re 199(defconst c-awk-regexp-without-end-re
205 (concat "/" c-awk-regexp-innards-re)) 200 (concat "/" c-awk-regexp-innards-re))
206;; Matches an AWK regexp up to, but not including, any terminating /. 201;; Matches an AWK regexp up to, but not including, any terminating /.
207(defconst c-awk-one-line-possibly-open-regexp-re
208 (concat "/\\(" c-awk-non-eol-esc-pair-re
209 "\\|" c-awk-regexp-one-line-possibly-open-char-list-re
210 "\\|" c-awk-regexp-normal-re "\\)*"
211 "\\(/\\|\\\\?$\\|\\'\\)"))
212;; Matches as much of the head of an AWK regexp which fits on one line,
213;; possibly all of it.
214 202
215;; REGEXPS used for scanning an AWK buffer in order to decide IF A '/' IS A 203;; REGEXPS used for scanning an AWK buffer in order to decide IF A '/' IS A
216;; REGEXP OPENER OR A DIVISION SIGN. By "state" in the following is meant 204;; REGEXP OPENER OR A DIVISION SIGN. By "state" in the following is meant
@@ -262,15 +250,24 @@
262 250
263;; REGEXPS USED FOR FINDING THE POSITION OF A "virtual semicolon" 251;; REGEXPS USED FOR FINDING THE POSITION OF A "virtual semicolon"
264(defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]") 252(defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]")
265;; NEW VERSION! (which will be restricted to the current line) 253(defconst c-awk-non-/-syn-ws*-re
266(defconst c-awk-one-line-non-syn-ws*-re 254 (concat
267 (concat "\\([ \t]*" 255 "\\(" c-awk-escaped-nls*-with-space*
268 "\\(" c-awk-_-harmless-nonws-char-re "\\|" 256 "\\(" c-awk-_-harmless-nonws-char-re "\\|"
269 c-awk-non-eol-esc-pair-re "\\|" 257 c-awk-non-eol-esc-pair-re "\\|"
270 c-awk-one-line-possibly-open-string-re "\\|" 258 c-awk-possibly-open-string-re
271 c-awk-one-line-possibly-open-regexp-re 259 "\\)"
272 "\\)" 260 "\\)*"))
273 "\\)*")) 261(defconst c-awk-space*-/-re (concat c-awk-escaped-nls*-with-space* "/"))
262;; Matches optional whitespace followed by "/".
263(defconst c-awk-space*-regexp-/-re
264 (concat c-awk-escaped-nls*-with-space* "\\s\""))
265;; Matches optional whitespace followed by a "/" with string syntax (a matched
266;; regexp delimiter).
267(defconst c-awk-space*-unclosed-regexp-/-re
268 (concat c-awk-escaped-nls*-with-space* "\\s\|"))
269;; Matches optional whitespace followed by a "/" with string fence syntax (an
270;; unmatched regexp delimiter).
274 271
275 272
276;; ACM, 2002/5/29: 273;; ACM, 2002/5/29:
@@ -549,10 +546,36 @@
549(defun c-awk-at-vsemi-p (&optional pos) 546(defun c-awk-at-vsemi-p (&optional pos)
550 ;; Is there a virtual semicolon at POS (or POINT)? 547 ;; Is there a virtual semicolon at POS (or POINT)?
551 (save-excursion 548 (save-excursion
552 (let (nl-prop 549 (let* (nl-prop
553 (pos-or-point (progn (if pos (goto-char pos)) (point)))) 550 (pos-or-point (progn (if pos (goto-char pos)) (point)))
554 (forward-line 0) 551 (bol (c-point 'bol)) (eol (c-point 'eol)))
555 (search-forward-regexp c-awk-one-line-non-syn-ws*-re) 552 (c-awk-beginning-of-logical-line)
553 ;; Next `while' goes round one logical line (ending in, e.g. "\\") per
554 ;; iteration. Such a line is rare, and can only be an open string
555 ;; ending in an escaped \.
556 (while
557 (progn
558 ;; Next `while' goes over a division sign or /regexp/ per iteration.
559 (while
560 (and
561 (< (point) eol)
562 (progn
563 (search-forward-regexp c-awk-non-/-syn-ws*-re eol)
564 (looking-at c-awk-space*-/-re)))
565 (cond
566 ((looking-at c-awk-space*-regexp-/-re) ; /regexp/
567 (forward-sexp))
568 ((looking-at c-awk-space*-unclosed-regexp-/-re) ; Unclosed /regexp
569 (condition-case nil
570 (progn
571 (forward-sexp)
572 (backward-char)) ; Move to end of (logical) line.
573 (error (end-of-line)))) ; Happens at EOB.
574 (t ; division sign
575 (c-forward-syntactic-ws)
576 (forward-char))))
577 (< (point) bol))
578 (forward-line))
556 (and (eq (point) pos-or-point) 579 (and (eq (point) pos-or-point)
557 (progn 580 (progn
558 (while (and (eq (setq nl-prop (c-awk-get-NL-prop-cur-line)) ?\\) 581 (while (and (eq (setq nl-prop (c-awk-get-NL-prop-cur-line)) ?\\)
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index c2ff5011a0e..2b9b6548e6f 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -1271,6 +1271,9 @@ comment at the start of cc-engine.el for more info."
1271 (throw 'done (point))))) 1271 (throw 'done (point)))))
1272 ;; In trailing space after an as yet undetected virtual semicolon? 1272 ;; In trailing space after an as yet undetected virtual semicolon?
1273 (c-backward-syntactic-ws from) 1273 (c-backward-syntactic-ws from)
1274 (when (and (bolp) (not (bobp))) ; Can happen in AWK Mode with an
1275 ; unterminated string/regexp.
1276 (backward-char))
1274 (if (and (< (point) to) 1277 (if (and (< (point) to)
1275 (c-at-vsemi-p)) 1278 (c-at-vsemi-p))
1276 (point) 1279 (point)