;;; cc-engine.el --- core syntax guessing engine for CC mode -*- coding: utf-8 -*-
-;; Copyright (C) 1985, 1987, 1992-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2015 Free Software Foundation, Inc.
;; Authors: 2001- Alan Mackenzie
;; 1998- Martin Stjernholm
(defmacro c-declare-lang-variables ()
`(progn
- ,@(mapcan (lambda (init)
- `(,(if (elt init 2)
- `(defvar ,(car init) nil ,(elt init 2))
- `(defvar ,(car init) nil))
- (make-variable-buffer-local ',(car init))))
- (cdr c-lang-variable-inits))))
+ ,@(c--mapcan (lambda (init)
+ `(,(if (elt init 2)
+ `(defvar ,(car init) nil ,(elt init 2))
+ `(defvar ,(car init) nil))
+ (make-variable-buffer-local ',(car init))))
+ (cdr c-lang-variable-inits))))
(c-declare-lang-variables)
\f
(while
;; Add an element to `c-state-nonlit-pos-cache' each iteration.
(and
- (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here)
+ (setq npos
+ (when (<= (+ pos c-state-nonlit-pos-interval) here)
+ (+ pos c-state-nonlit-pos-interval)))
;; Test for being in a literal. If so, go to after it.
(progn
;; Add one extra element above HERE so as to to avoid the previous
;; expensive calculation when the next call is close to the current
;; one. This is especially useful when inside a large macro.
- (setq c-state-nonlit-pos-cache (cons npos c-state-nonlit-pos-cache)))
+ (when npos
+ (setq c-state-nonlit-pos-cache
+ (cons npos c-state-nonlit-pos-cache))))
(if (> pos c-state-nonlit-pos-cache-limit)
(setq c-state-nonlit-pos-cache-limit pos))
(setq dropped-cons (consp (car c-state-cache)))
(setq c-state-cache (cdr c-state-cache))
(setq pos pa))
- ;; At this stage, (> pos here);
+ ;; At this stage, (>= pos here);
;; (< (c-state-cache-top-lparen) here) (or is nil).
(cond
nil)) ; for the cond
((save-restriction
- (narrow-to-region too-far-back (point-max))
- (setq ren (c-safe (c-sc-scan-lists pos -1 -1))))
-
+ (narrow-to-region too-far-back (point-max))
+ (setq ren (c-safe (c-sc-scan-lists pos -1 -1))))
;; CASE 3: After a }/)/] before `here''s BOL.
(list (1+ ren) (and dropped-cons pos) nil)) ; Return value
+ ((progn (setq good-pos (c-state-lit-beg (c-point 'bopl here-bol)))
+ (>= cache-pos good-pos))
+ ;; CASE 3.5: Just after an existing entry in `c-state-cache' on `here''s
+ ;; line or the previous line.
+ (list cache-pos nil nil))
+
(t
;; CASE 4; Best of a bad job: BOL before `here-bol', or beginning of
;; literal containing it.
- (setq good-pos (c-state-lit-beg (c-point 'bopl here-bol)))
(list good-pos (and dropped-cons good-pos) nil)))))
(defun c-literal-type (range)
"Convenience function that given the result of `c-literal-limits',
returns nil or the type of literal that the range surrounds, one
-of the symbols 'c, 'c++ or 'string. It's much faster than using
+of the symbols `c', `c++' or `string'. It's much faster than using
`c-in-literal' and is intended to be used when you need both the
type of a literal and its limits.
;; This should be called with point inside an argument list.
;;
;; Only one level of enclosing parentheses is considered, so for
- ;; instance `nil' is returned when in a function call within an asm
+ ;; instance nil is returned when in a function call within an asm
;; operand.
;;
;; This function might do hidden buffer changes.