summaryrefslogtreecommitdiff
path: root/lisp/progmodes
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/cc-engine.el61
-rw-r--r--lisp/progmodes/cc-mode.el4
-rw-r--r--lisp/progmodes/gdb-mi.el16
-rw-r--r--lisp/progmodes/perl-mode.el6
4 files changed, 68 insertions, 19 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 3b33ac894f2..cf38001c123 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -236,7 +236,7 @@
(defun c-invalidate-macro-cache (beg end)
;; Called from a before-change function. If the change region is before or
- ;; in the macro characterised by `c-macro-cache' etc., nullify it
+ ;; in the macro characterized by `c-macro-cache' etc., nullify it
;; appropriately. BEG and END are the standard before-change-functions
;; parameters. END isn't used.
(cond
@@ -1246,7 +1246,7 @@ comment at the start of cc-engine.el for more info."
(c-at-vsemi-p))))
(throw 'done vsemi-pos))
;; In a string/comment?
- ((setq lit-range (c-literal-limits))
+ ((setq lit-range (c-literal-limits from))
(goto-char (cdr lit-range)))
((eq (char-after) ?:)
(forward-char)
@@ -2163,7 +2163,7 @@ comment at the start of cc-engine.el for more info."
(make-variable-buffer-local 'c-state-semi-nonlit-pos-cache-limit)
;; An upper limit on valid entries in `c-state-semi-nonlit-pos-cache'. This is
;; reduced by buffer changes, and increased by invocations of
-;; `c-state-literal-at'. FIMXE!!!
+;; `c-state-literal-at'. FIXME!!!
(defsubst c-state-pp-to-literal (from to)
;; Do a parse-partial-sexp from FROM to TO, returning either
@@ -3250,8 +3250,7 @@ comment at the start of cc-engine.el for more info."
(if scan-forward-p
(progn (narrow-to-region (point-min) here)
(c-append-to-state-cache good-pos))
-
- (c-get-cache-scan-pos good-pos))))
+ good-pos)))
(t ; (eq strategy 'IN-LIT)
(setq c-state-cache nil
@@ -4563,6 +4562,38 @@ comment at the start of cc-engine.el for more info."
(point-min))
(t
(c-determine-limit (- how-far-back count) base try-size))))))
+
+(defun c-determine-+ve-limit (how-far &optional start-pos)
+ ;; Return a buffer position about HOW-FAR non-literal characters forward
+ ;; from START-POS (default point), which must not be inside a literal.
+ (save-excursion
+ (let ((pos (or start-pos (point)))
+ (count how-far)
+ (s (parse-partial-sexp (point) (point)))) ; null state
+ (while (and (not (eobp))
+ (> count 0))
+ ;; Scan over counted characters.
+ (setq s (parse-partial-sexp
+ pos
+ (min (+ pos count) (point-max))
+ nil ; target-depth
+ nil ; stop-before
+ s ; state
+ 'syntax-table)) ; stop-comment
+ (setq count (- count (- (point) pos) 1)
+ pos (point))
+ ;; Scan over literal characters.
+ (if (nth 8 s)
+ (setq s (parse-partial-sexp
+ pos
+ (point-max)
+ nil ; target-depth
+ nil ; stop-before
+ s ; state
+ 'syntax-table) ; stop-comment
+ pos (point))))
+ (point))))
+
;; `c-find-decl-spots' and accompanying stuff.
@@ -7670,8 +7701,8 @@ comment at the start of cc-engine.el for more info."
(and
(eq (c-beginning-of-statement-1 lim) 'same)
- (not (or (c-major-mode-is 'objc-mode)
- (c-forward-objc-directive)))
+ (not (and (c-major-mode-is 'objc-mode)
+ (c-forward-objc-directive)))
(setq id-start
(car-safe (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))
@@ -8635,7 +8666,6 @@ comment at the start of cc-engine.el for more info."
(setq pos (point)))
(and
c-macro-with-semi-re
- (not (c-in-literal))
(eq (skip-chars-backward " \t") 0)
;; Check we've got nothing after this except comments and empty lines
@@ -8666,7 +8696,9 @@ comment at the start of cc-engine.el for more info."
(c-backward-syntactic-ws)
t))
(c-simple-skip-symbol-backward)
- (looking-at c-macro-with-semi-re)))))
+ (looking-at c-macro-with-semi-re)
+ (goto-char pos)
+ (not (c-in-literal)))))) ; The most expensive check last.
(defun c-macro-vsemi-status-unknown-p () t) ; See cc-defs.el.
@@ -9207,6 +9239,10 @@ comment at the start of cc-engine.el for more info."
containing-sexp nil)))
(setq lim (1+ containing-sexp))))
(setq lim (point-min)))
+ (when (c-beginning-of-macro)
+ (goto-char indent-point)
+ (let ((lim1 (c-determine-limit 2000)))
+ (setq lim (max lim lim1))))
;; If we're in a parenthesis list then ',' delimits the
;; "statements" rather than being an operator (with the
@@ -9571,7 +9607,8 @@ comment at the start of cc-engine.el for more info."
;; CASE 5B: After a function header but before the body (or
;; the ending semicolon if there's no body).
((save-excursion
- (when (setq placeholder (c-just-after-func-arglist-p lim))
+ (when (setq placeholder (c-just-after-func-arglist-p
+ (max lim (c-determine-limit 500))))
(setq tmp-pos (point))))
(cond
@@ -9779,7 +9816,7 @@ comment at the start of cc-engine.el for more info."
;; top level construct. Or, perhaps, an unrecognized construct.
(t
(while (and (setq placeholder (point))
- (eq (car (c-beginning-of-decl-1 containing-sexp))
+ (eq (car (c-beginning-of-decl-1 containing-sexp)) ; Can't use `lim' here.
'same)
(save-excursion
(c-backward-syntactic-ws)
@@ -9882,7 +9919,7 @@ comment at the start of cc-engine.el for more info."
(eq (cdar c-state-cache) (point)))
;; Speed up the backward search a bit.
(goto-char (caar c-state-cache)))
- (c-beginning-of-decl-1 containing-sexp)
+ (c-beginning-of-decl-1 containing-sexp) ; Can't use `lim' here.
(setq placeholder (point))
(if (= start (point))
;; The '}' is unbalanced.
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 985214db1dc..7c018feefbb 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -925,8 +925,8 @@ Note that the style variables are always made local to the buffer."
;; inside a string, comment, or macro.
(setq new-bounds (c-extend-font-lock-region-for-macros
c-new-BEG c-new-END old-len))
- (setq c-new-BEG (car new-bounds)
- c-new-END (cdr new-bounds))
+ (setq c-new-BEG (max (car new-bounds) (c-determine-limit 500 begg))
+ c-new-END (min (cdr new-bounds) (c-determine-+ve-limit 500 endd)))
;; Clear all old relevant properties.
(c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1))
(c-clear-char-property-with-value c-new-BEG c-new-END 'category 'c-cpp-delimiter)
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 8ea255e49dd..89450cd2276 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -3269,8 +3269,12 @@ DOC is an optional documentation string."
(let* ((frame (gdb-current-buffer-frame))
(file (bindat-get-field frame 'fullname))
(line (bindat-get-field frame 'line)))
- (when file
- (format "-data-disassemble -f %s -l %s -n -1 -- 0" file line)))
+ (if file
+ (format "-data-disassemble -f %s -l %s -n -1 -- 0" file line)
+ ;; If we're unable to get a file name / line for $PC, simply
+ ;; follow $PC, disassembling the next 10 (x ~15 (on IA) ==
+ ;; 150 bytes) instructions.
+ "-data-disassemble -s $pc -e \"$pc + 150\" -- 0"))
gdb-disassembly-handler
;; We update disassembly only after we have actual frame information
;; about all threads, so no there's `update' signal in this list
@@ -3329,8 +3333,12 @@ DOC is an optional documentation string."
(gdb-table-add-row table
(list
(bindat-get-field instr 'address)
- (apply #'format "<%s+%s>:"
- (gdb-get-many-fields instr 'func-name 'offset))
+ (let
+ ((func-name (bindat-get-field instr 'func-name))
+ (offset (bindat-get-field instr 'offset)))
+ (if func-name
+ (format "<%s+%s>:" func-name offset)
+ ""))
(bindat-get-field instr 'inst)))
(when (string-equal (bindat-get-field instr 'address)
address)
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index e7afd0e0e67..de728da236d 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -388,7 +388,11 @@ The expansion is entirely correct because it uses the C preprocessor."
;; In case of error, make sure we don't move backward.
(scan-error (goto-char startpos) nil))
(not (or (nth 8 (parse-partial-sexp
- (point) limit nil nil state 'syntax-table))
+ ;; Since we don't know if point is within
+ ;; the first or the scond arg, we have to
+ ;; start from the beginning.
+ (if twoargs (1+ (nth 8 state)) (point))
+ limit nil nil state 'syntax-table))
;; If we have a self-paired opener and a twoargs
;; command, the form is s/../../ so we have to skip
;; a second time.