diff options
| author | Alan Mackenzie | 2019-06-01 19:56:07 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2019-06-01 19:56:07 +0000 |
| commit | 9dee49ed6439bfdf7f1c98fee767d170d144f581 (patch) | |
| tree | dd29f7505172f9ec9e6b3d502cb4b7295d6afa95 | |
| parent | 56964f3d314463c3542807645fbc3e2e969ed9b4 (diff) | |
| download | emacs-9dee49ed6439bfdf7f1c98fee767d170d144f581.tar.gz emacs-9dee49ed6439bfdf7f1c98fee767d170d144f581.zip | |
Tidy up the literal cacheing in CC Mode, optimizing c-full-pp-to-literal
(Intermediate commit)
* lisp/progmodes/cc-engine.el, lisp/progmodes/cc-fonts.el
* lisp/progmodes/cc-mode.el : Rename:
c-state-semi-nonlit-pos-cache -> c-lit-pos-cache,
c-state-semi-nonlit-pos-cache-limit -> c-lit-pos-cache-limit,
c-state-semi-nonlit-near-cache -> c-semi-lit-near-cache,
c-truncate-semi-nonlit-pos-cache -> c-truncate-lit-pos-cache,
c-state-semi-trim-near-cache -> c-semi-trim-near-cache,
c-state-semi-get-near-cache-entry -> c-semi-get-near-cache-entry,
c-state-semi-put-near-cache-entry -> c-semi-put-near-cache-entry,
c-state-semi-pp-to-literal -> c-semi-pp-to-literal,
c-state-full-pp-to-literal -> c-full-pp-to-literal,
c-state-semi-trim-cache -> c-trim-lit-pos-cache.
* lisp/progmodes/cc-engine.el (c-semi-near-cache-limit): New variable.
(c-truncate-lit-pos-cache): This now truncates the cache variables for all
three lit- sub-caches.
(c-semi-put-near-cache-entry): Increase c-semi-near-cache-limit to the
position of the new entry.
(c-full-near-cache-limit, c-full-lit-near-cache): New variables.
(c-full-trim-near-cache, c-full-get-near-cache-entry)
(c-full-put-near-cache-entry): New functions.
(c-full-pp-to-literal): Amend to use the new functions, and to optimize the
use of the available caches, similarly to c-semi-pp-to-literal.
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 325 | ||||
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 20 |
3 files changed, 227 insertions, 120 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 048f88846da..b9d4f83f256 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -2544,17 +2544,17 @@ comment at the start of cc-engine.el for more info." | |||
| 2544 | ;; states going back to the beginning of the buffer, one entry every 3000 | 2544 | ;; states going back to the beginning of the buffer, one entry every 3000 |
| 2545 | ;; characters. | 2545 | ;; characters. |
| 2546 | ;; | 2546 | ;; |
| 2547 | ;; When searching this cache, `c-state-semi-pp-to-literal' first seeks an | 2547 | ;; When searching this cache, `c-semi-pp-to-literal' first seeks an |
| 2548 | ;; exact match, then a "close" match from the near cache. If neither of these | 2548 | ;; exact match, then a "close" match from the near cache. If neither of these |
| 2549 | ;; succeed, the nearest entry in the far cache is used. | 2549 | ;; succeed, the nearest entry in the far cache is used. |
| 2550 | ;; | 2550 | ;; |
| 2551 | ;; Because either sub-cache can raise `c-state-semi-nonlit-pos-cache-limit', | 2551 | ;; Because either sub-cache can raise `c-lit-pos-cache-limit', |
| 2552 | ;; both of them are "trimmed" together after a buffer change to ensure | 2552 | ;; both of them are "trimmed" together after a buffer change to ensure |
| 2553 | ;; consistency. | 2553 | ;; consistency. |
| 2554 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 2554 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2555 | 2555 | ||
| 2556 | (defvar c-state-semi-nonlit-pos-cache nil) | 2556 | (defvar c-lit-pos-cache nil) |
| 2557 | (make-variable-buffer-local 'c-state-semi-nonlit-pos-cache) | 2557 | (make-variable-buffer-local 'c-lit-pos-cache) |
| 2558 | ;; A list of elements in descending order of POS of one of the forms: | 2558 | ;; A list of elements in descending order of POS of one of the forms: |
| 2559 | ;; o - POS (when point is not in a literal); | 2559 | ;; o - POS (when point is not in a literal); |
| 2560 | ;; o - (POS CHAR-1) (when the last character before point is potentially | 2560 | ;; o - (POS CHAR-1) (when the last character before point is potentially |
| @@ -2569,43 +2569,53 @@ comment at the start of cc-engine.el for more info." | |||
| 2569 | ;; potentially forming the first half of a two-char construct (in Emacs <= 25 | 2569 | ;; potentially forming the first half of a two-char construct (in Emacs <= 25 |
| 2570 | ;; and XEmacs) or the syntax of the character (Emacs >= 26). | 2570 | ;; and XEmacs) or the syntax of the character (Emacs >= 26). |
| 2571 | 2571 | ||
| 2572 | (defvar c-state-semi-nonlit-pos-cache-limit 1) | 2572 | (defvar c-lit-pos-cache-limit 1) |
| 2573 | (make-variable-buffer-local 'c-state-semi-nonlit-pos-cache-limit) | 2573 | (make-variable-buffer-local 'c-lit-pos-cache-limit) |
| 2574 | ;; An upper limit on valid entries in `c-state-semi-nonlit-pos-cache'. This | 2574 | ;; An upper limit on valid entries in `c-lit-pos-cache'. This |
| 2575 | ;; is reduced by buffer changes, and increased by invocations of | 2575 | ;; is reduced by buffer changes, and increased by invocations of |
| 2576 | ;; `c-parse-ps-state-below'. | 2576 | ;; `c-parse-ps-state-below'. |
| 2577 | 2577 | ||
| 2578 | (defvar c-state-semi-nonlit-near-cache nil) | 2578 | (defvar c-semi-lit-near-cache nil) |
| 2579 | (make-variable-buffer-local 'c-state-semi-nonlit-near-cache) | 2579 | (make-variable-buffer-local 'c-semi-lit-near-cache) |
| 2580 | ;; A list of up to six recent results from `c-state-semi-pp-to-literal'. Each | 2580 | ;; A list of up to six recent results from `c-semi-pp-to-literal'. Each |
| 2581 | ;; element is a cons of the buffer position and the `parse-partial-sexp' state | 2581 | ;; element is a cons of the buffer position and the `parse-partial-sexp' state |
| 2582 | ;; at that position. | 2582 | ;; at that position. |
| 2583 | 2583 | ||
| 2584 | (defsubst c-truncate-semi-nonlit-pos-cache (pos) | 2584 | (defvar c-semi-near-cache-limit 1) |
| 2585 | ;; Truncate the upper bound of the cache `c-state-semi-nonlit-pos-cache' to | 2585 | (make-variable-buffer-local 'c-semi-near-cache-limit) |
| 2586 | ;; POS, if it is higher than that position. | 2586 | ;; An upper limit on valid entries in `c-semi-lit-near-cache'. This is |
| 2587 | (setq c-state-semi-nonlit-pos-cache-limit | 2587 | ;; reduced by buffer changes, and increased by invocations of |
| 2588 | (min c-state-semi-nonlit-pos-cache-limit pos))) | 2588 | ;; `c-semi-pp-to-literal'. |
| 2589 | 2589 | ||
| 2590 | (defun c-state-semi-trim-near-cache () | 2590 | (defsubst c-truncate-lit-pos-cache (pos) |
| 2591 | ;; Remove stale entries in `c-state-semi-nonlit-near-cache', i.e. those | 2591 | ;; Truncate the upper bound of each of the three caches to POS, if it is |
| 2592 | ;; whose positions are above `c-state-semi-nonlit-pos-cache-limit'. | 2592 | ;; higher than that position. |
| 2593 | (let ((nc-list c-state-semi-nonlit-near-cache)) | 2593 | (setq c-lit-pos-cache-limit |
| 2594 | (min c-lit-pos-cache-limit pos) | ||
| 2595 | c-semi-near-cache-limit | ||
| 2596 | (min c-semi-near-cache-limit pos) | ||
| 2597 | c-full-near-cache-limit | ||
| 2598 | (min c-full-near-cache-limit pos))) | ||
| 2599 | |||
| 2600 | (defun c-semi-trim-near-cache () | ||
| 2601 | ;; Remove stale entries in `c-semi-lit-near-cache', i.e. those | ||
| 2602 | ;; whose positions are above `c-lit-pos-cache-limit'. | ||
| 2603 | (let ((nc-list c-semi-lit-near-cache)) | ||
| 2594 | (while nc-list | 2604 | (while nc-list |
| 2595 | (if (> (caar nc-list) c-state-semi-nonlit-pos-cache-limit) | 2605 | (if (> (caar nc-list) c-lit-pos-cache-limit) |
| 2596 | (setq c-state-semi-nonlit-near-cache | 2606 | (setq c-semi-lit-near-cache |
| 2597 | (delq (car nc-list) c-state-semi-nonlit-near-cache) | 2607 | (delq (car nc-list) c-semi-lit-near-cache) |
| 2598 | nc-list c-state-semi-nonlit-near-cache) ; start again in case | 2608 | nc-list c-semi-lit-near-cache) ; start again in case |
| 2599 | ; of list breakage. | 2609 | ; of list breakage. |
| 2600 | (setq nc-list (cdr nc-list)))))) | 2610 | (setq nc-list (cdr nc-list)))))) |
| 2601 | 2611 | ||
| 2602 | (defun c-state-semi-get-near-cache-entry (here) | 2612 | (defun c-semi-get-near-cache-entry (here) |
| 2603 | ;; Return the near cache entry at the highest postion before HERE, if any, | 2613 | ;; Return the near cache entry at the highest postion before HERE, if any, |
| 2604 | ;; or nil. The near cache entry is of the form (POSITION . STATE), where | 2614 | ;; or nil. The near cache entry is of the form (POSITION . STATE), where |
| 2605 | ;; STATE has the form of a result of `parse-partial-sexp'. | 2615 | ;; STATE has the form of a result of `parse-partial-sexp'. |
| 2606 | (let ((nc-pos-state | 2616 | (let ((nc-pos-state |
| 2607 | (or (assq here c-state-semi-nonlit-near-cache) | 2617 | (or (assq here c-semi-lit-near-cache) |
| 2608 | (let ((nc-list c-state-semi-nonlit-near-cache) | 2618 | (let ((nc-list c-semi-lit-near-cache) |
| 2609 | pos (nc-pos 0) cand-pos-state) | 2619 | pos (nc-pos 0) cand-pos-state) |
| 2610 | (catch 'found | 2620 | (catch 'found |
| 2611 | (while nc-list | 2621 | (while nc-list |
| @@ -2622,22 +2632,24 @@ comment at the start of cc-engine.el for more info." | |||
| 2622 | (setq nc-list (cdr nc-list))) | 2632 | (setq nc-list (cdr nc-list))) |
| 2623 | cand-pos-state))))) | 2633 | cand-pos-state))))) |
| 2624 | (when (and nc-pos-state | 2634 | (when (and nc-pos-state |
| 2625 | (not (eq nc-pos-state (car c-state-semi-nonlit-near-cache)))) | 2635 | (not (eq nc-pos-state (car c-semi-lit-near-cache)))) |
| 2626 | ;; Move the found cache entry to the front of the list. | 2636 | ;; Move the found cache entry to the front of the list. |
| 2627 | (setq c-state-semi-nonlit-near-cache | 2637 | (setq c-semi-lit-near-cache |
| 2628 | (delq nc-pos-state c-state-semi-nonlit-near-cache)) | 2638 | (delq nc-pos-state c-semi-lit-near-cache)) |
| 2629 | (push nc-pos-state c-state-semi-nonlit-near-cache)) | 2639 | (push nc-pos-state c-semi-lit-near-cache)) |
| 2630 | nc-pos-state)) | 2640 | (copy-tree nc-pos-state))) |
| 2631 | 2641 | ||
| 2632 | (defun c-state-semi-put-near-cache-entry (here state) | 2642 | (defun c-semi-put-near-cache-entry (here state) |
| 2633 | ;; Put a new near cache entry into the near cache. | 2643 | ;; Put a new near cache entry into the near cache. |
| 2634 | (while (>= (length c-state-semi-nonlit-near-cache) 6) | 2644 | (while (>= (length c-semi-lit-near-cache) 6) |
| 2635 | (setq c-state-semi-nonlit-near-cache | 2645 | (setq c-semi-lit-near-cache |
| 2636 | (delq (car (last c-state-semi-nonlit-near-cache)) | 2646 | (delq (car (last c-semi-lit-near-cache)) |
| 2637 | c-state-semi-nonlit-near-cache))) | 2647 | c-semi-lit-near-cache))) |
| 2638 | (push (cons here state) c-state-semi-nonlit-near-cache)) | 2648 | (push (cons here state) c-semi-lit-near-cache) |
| 2639 | 2649 | (setq c-semi-near-cache-limit | |
| 2640 | (defun c-state-semi-pp-to-literal (here &optional not-in-delimiter) | 2650 | (max c-semi-near-cache-limit here))) |
| 2651 | |||
| 2652 | (defun c-semi-pp-to-literal (here &optional not-in-delimiter) | ||
| 2641 | ;; Do a parse-partial-sexp from a position in the buffer before HERE which | 2653 | ;; Do a parse-partial-sexp from a position in the buffer before HERE which |
| 2642 | ;; isn't in a literal, and return information about HERE, either: | 2654 | ;; isn't in a literal, and return information about HERE, either: |
| 2643 | ;; (STATE TYPE BEG) if HERE is in a literal; or | 2655 | ;; (STATE TYPE BEG) if HERE is in a literal; or |
| @@ -2656,11 +2668,11 @@ comment at the start of cc-engine.el for more info." | |||
| 2656 | (save-excursion | 2668 | (save-excursion |
| 2657 | (save-restriction | 2669 | (save-restriction |
| 2658 | (widen) | 2670 | (widen) |
| 2659 | (c-state-semi-trim-cache) | 2671 | (c-trim-lit-pos-cache) |
| 2660 | (c-state-semi-trim-near-cache) | 2672 | (c-semi-trim-near-cache) |
| 2661 | (setq c-state-semi-nonlit-pos-cache-limit here) | 2673 | (setq c-lit-pos-cache-limit here) |
| 2662 | (save-match-data | 2674 | (save-match-data |
| 2663 | (let* ((pos-and-state (c-state-semi-get-near-cache-entry here)) | 2675 | (let* ((pos-and-state (c-semi-get-near-cache-entry here)) |
| 2664 | (pos (car pos-and-state)) | 2676 | (pos (car pos-and-state)) |
| 2665 | (near-pos pos) | 2677 | (near-pos pos) |
| 2666 | (s (cdr pos-and-state)) | 2678 | (s (cdr pos-and-state)) |
| @@ -2690,7 +2702,7 @@ comment at the start of cc-engine.el for more info." | |||
| 2690 | (not (memq (char-before here) '(?\\ ?\n))))))) | 2702 | (not (memq (char-before here) '(?\\ ?\n))))))) |
| 2691 | (setq s (parse-partial-sexp pos here nil nil s))) | 2703 | (setq s (parse-partial-sexp pos here nil nil s))) |
| 2692 | (when (not (eq near-pos here)) | 2704 | (when (not (eq near-pos here)) |
| 2693 | (c-state-semi-put-near-cache-entry here s)) | 2705 | (c-semi-put-near-cache-entry here s)) |
| 2694 | (cond | 2706 | (cond |
| 2695 | ((or (nth 3 s) | 2707 | ((or (nth 3 s) |
| 2696 | (and (nth 4 s) | 2708 | (and (nth 4 s) |
| @@ -2712,7 +2724,81 @@ comment at the start of cc-engine.el for more info." | |||
| 2712 | 2724 | ||
| 2713 | (t (list s)))))))) | 2725 | (t (list s)))))))) |
| 2714 | 2726 | ||
| 2715 | (defun c-state-full-pp-to-literal (here &optional not-in-delimiter) | 2727 | (defvar c-full-near-cache-limit 1) |
| 2728 | (make-variable-buffer-local 'c-full-near-cache-limit) | ||
| 2729 | ;; An upper limit on valid entries in `c-full-lit-near-cache'. This | ||
| 2730 | ;; is reduced by buffer changes, and increased by invocations of | ||
| 2731 | ;; `c-full-pp-to-literal'. | ||
| 2732 | |||
| 2733 | (defvar c-full-lit-near-cache nil) | ||
| 2734 | (make-variable-buffer-local 'c-full-lit-near-cache) | ||
| 2735 | ;; A list of up to six recent results from `c-full-pp-to-literal'. Each | ||
| 2736 | ;; element is a list (HERE STATE END)), where HERE is the buffer position the | ||
| 2737 | ;; function was called for, STATE is the `parse-partial-sexp' state there, and | ||
| 2738 | ;; END is the end of the literal enclosing HERE, if any, or nil otherwise. | ||
| 2739 | |||
| 2740 | (defun c-full-trim-near-cache () | ||
| 2741 | ;; Remove stale entries in `c-full-lit-near-cache', i.e. those | ||
| 2742 | ;; whose END entries, or positions, are above | ||
| 2743 | ;; `c-state-full-nonlit-pos-cache-limit'. | ||
| 2744 | (let ((nc-list c-full-lit-near-cache) elt) | ||
| 2745 | (while nc-list | ||
| 2746 | (let ((elt (car nc-list))) | ||
| 2747 | (if (if (car (cddr elt)) | ||
| 2748 | (< c-full-near-cache-limit (car (cddr elt))) | ||
| 2749 | (< c-full-near-cache-limit (car elt))) | ||
| 2750 | (setq c-full-lit-near-cache | ||
| 2751 | (delq elt c-full-lit-near-cache) | ||
| 2752 | nc-list c-full-lit-near-cache) ; start again in | ||
| 2753 | ; case of list breakage. | ||
| 2754 | (setq nc-list (cdr nc-list))))))) | ||
| 2755 | |||
| 2756 | (defun c-full-get-near-cache-entry (here) | ||
| 2757 | ;; Return a near cache entry which either represents a literal which | ||
| 2758 | ;; encloses HERE, or is at the highest position before HERE. The returned | ||
| 2759 | ;; cache entry is of the form (POSITION STATE END), where STATE has the form | ||
| 2760 | ;; of a result from `parse-partial-sexp' which is valid at POSITION and END | ||
| 2761 | ;; is the end of any enclosing literal, or nil. | ||
| 2762 | (let ((nc-pos-state | ||
| 2763 | (or (assq here c-full-lit-near-cache) | ||
| 2764 | (let ((nc-list c-full-lit-near-cache) | ||
| 2765 | elt match (nc-pos 0) cand-pos-state) | ||
| 2766 | (setq match | ||
| 2767 | (catch 'found | ||
| 2768 | (while nc-list | ||
| 2769 | (setq elt (car nc-list)) | ||
| 2770 | (when | ||
| 2771 | (and (car (cddr elt)) | ||
| 2772 | (>= here (nth 8 (cadr elt))) | ||
| 2773 | (< here (car (cddr elt)))) | ||
| 2774 | (throw 'found elt)) | ||
| 2775 | (when | ||
| 2776 | (and (< (car elt) here) | ||
| 2777 | (> (car elt) nc-pos)) | ||
| 2778 | (setq nc-pos (car elt) | ||
| 2779 | cand-pos-state elt)) | ||
| 2780 | (setq nc-list (cdr nc-list))) | ||
| 2781 | nil)) | ||
| 2782 | (or match cand-pos-state))))) | ||
| 2783 | ;; Move the found cache entry, if any, to the front of the list. | ||
| 2784 | (when (and nc-pos-state | ||
| 2785 | (not (eq nc-pos-state (car c-full-lit-near-cache)))) | ||
| 2786 | (setq c-full-lit-near-cache | ||
| 2787 | (delq nc-pos-state c-full-lit-near-cache)) | ||
| 2788 | (push nc-pos-state c-full-lit-near-cache)) | ||
| 2789 | (copy-tree nc-pos-state))) | ||
| 2790 | |||
| 2791 | (defun c-full-put-near-cache-entry (here state end) | ||
| 2792 | ;; Put a new near chace entry into the near cache. | ||
| 2793 | (while (>= (length c-full-lit-near-cache) 6) | ||
| 2794 | (setq c-full-lit-near-cache | ||
| 2795 | (delq (car (last c-full-lit-near-cache)) | ||
| 2796 | c-full-lit-near-cache))) | ||
| 2797 | (push (list here state end) c-full-lit-near-cache) | ||
| 2798 | (setq c-full-near-cache-limit | ||
| 2799 | (max c-full-near-cache-limit (or end here)))) | ||
| 2800 | |||
| 2801 | (defun c-full-pp-to-literal (here &optional not-in-delimiter) | ||
| 2716 | ;; This function will supersede c-state-pp-to-literal. | 2802 | ;; This function will supersede c-state-pp-to-literal. |
| 2717 | ;; | 2803 | ;; |
| 2718 | ;; Do a parse-partial-sexp from a position in the buffer before HERE which | 2804 | ;; Do a parse-partial-sexp from a position in the buffer before HERE which |
| @@ -2733,28 +2819,43 @@ comment at the start of cc-engine.el for more info." | |||
| 2733 | (save-excursion | 2819 | (save-excursion |
| 2734 | (save-restriction | 2820 | (save-restriction |
| 2735 | (widen) | 2821 | (widen) |
| 2736 | (c-state-semi-trim-cache) | 2822 | (c-trim-lit-pos-cache) |
| 2737 | (c-state-semi-trim-near-cache) | 2823 | (c-full-trim-near-cache) |
| 2738 | (setq c-state-semi-nonlit-pos-cache-limit here) | ||
| 2739 | (save-match-data | 2824 | (save-match-data |
| 2740 | (let* ((base-and-state (c-state-semi-get-near-cache-entry here)) | 2825 | (let* ((elt (c-full-get-near-cache-entry here)) |
| 2741 | (base (car base-and-state)) | 2826 | (base (car elt)) |
| 2742 | (near-base base) | 2827 | (near-base base) |
| 2743 | (s (cdr base-and-state)) | 2828 | (s (cadr elt)) |
| 2829 | (end (car (cddr elt))) | ||
| 2744 | far-base-and-state far-base far-s ty start) | 2830 | far-base-and-state far-base far-s ty start) |
| 2745 | (if (or (not base) | 2831 | (if (or |
| 2746 | (< base (- here 100))) | 2832 | (not base) ; FIXME!!! Compare base and far-base?? |
| 2833 | ; (2019-05-21) | ||
| 2834 | (not end) | ||
| 2835 | (> here end)) | ||
| 2747 | (progn | 2836 | (progn |
| 2748 | (setq far-base-and-state (c-parse-ps-state-below here) | 2837 | (setq far-base-and-state (c-parse-ps-state-below here) |
| 2749 | far-base (car far-base-and-state) | 2838 | far-base (car far-base-and-state) |
| 2750 | far-s (cdr far-base-and-state)) | 2839 | far-s (cdr far-base-and-state)) |
| 2751 | (when (or (not base) (> far-base base)) | 2840 | (when (or (not base) (> far-base base)) |
| 2752 | (setq base far-base | 2841 | (setq base far-base |
| 2753 | s far-s)))) | 2842 | s far-s |
| 2754 | (when (> here base) | 2843 | end nil)))) |
| 2844 | (when | ||
| 2845 | (or | ||
| 2846 | (and (> here base) (null end)) | ||
| 2847 | (null (nth 8 s)) | ||
| 2848 | (and end (> here end)) | ||
| 2849 | (not | ||
| 2850 | (or | ||
| 2851 | (and (nth 3 s) ; string | ||
| 2852 | (not (eq (char-before here) ?\\))) | ||
| 2853 | (and (nth 4 s) (not (nth 7 s)) ; Block comment | ||
| 2854 | (not (memq (char-before here) | ||
| 2855 | c-block-comment-awkward-chars))) | ||
| 2856 | (and (nth 4 s) (nth 7 s) ; Line comment | ||
| 2857 | (not (memq (char-before here) '(?\\ ?\n))))))) | ||
| 2755 | (setq s (parse-partial-sexp base here nil nil s))) | 2858 | (setq s (parse-partial-sexp base here nil nil s))) |
| 2756 | (when (not (eq near-base here)) | ||
| 2757 | (c-state-semi-put-near-cache-entry here s)) | ||
| 2758 | (cond | 2859 | (cond |
| 2759 | ((or (nth 3 s) | 2860 | ((or (nth 3 s) |
| 2760 | (and (nth 4 s) | 2861 | (and (nth 4 s) |
| @@ -2764,12 +2865,16 @@ comment at the start of cc-engine.el for more info." | |||
| 2764 | ((nth 7 s) 'c++) | 2865 | ((nth 7 s) 'c++) |
| 2765 | (t 'c))) | 2866 | (t 'c))) |
| 2766 | (setq start (nth 8 s)) | 2867 | (setq start (nth 8 s)) |
| 2767 | (parse-partial-sexp here (point-max) | 2868 | (unless end |
| 2768 | nil ; TARGETDEPTH | 2869 | (parse-partial-sexp here (point-max) |
| 2769 | nil ; STOPBEFORE | 2870 | nil ; TARGETDEPTH |
| 2770 | s ; OLDSTATE | 2871 | nil ; STOPBEFORE |
| 2771 | 'syntax-table) ; stop at end of literal | 2872 | s ; OLDSTATE |
| 2772 | (list s ty (cons start (point)))) | 2873 | 'syntax-table) ; stop at end of literal |
| 2874 | (setq end (point))) | ||
| 2875 | (unless (eq near-base here) | ||
| 2876 | (c-full-put-near-cache-entry here s end)) | ||
| 2877 | (list s ty (cons start end))) | ||
| 2773 | 2878 | ||
| 2774 | ((and (not not-in-delimiter) ; inside a comment starter | 2879 | ((and (not not-in-delimiter) ; inside a comment starter |
| 2775 | (not (bobp)) | 2880 | (not (bobp)) |
| @@ -2782,7 +2887,9 @@ comment at the start of cc-engine.el for more info." | |||
| 2782 | (forward-comment 1) | 2887 | (forward-comment 1) |
| 2783 | (list s ty (cons start (point)))) | 2888 | (list s ty (cons start (point)))) |
| 2784 | 2889 | ||
| 2785 | (t (list s)))))))) | 2890 | (t |
| 2891 | (c-full-put-near-cache-entry here s nil) | ||
| 2892 | (list s)))))))) | ||
| 2786 | 2893 | ||
| 2787 | (defun c-state-pp-to-literal (from to &optional not-in-delimiter) | 2894 | (defun c-state-pp-to-literal (from to &optional not-in-delimiter) |
| 2788 | ;; Do a parse-partial-sexp from FROM to TO, returning either | 2895 | ;; Do a parse-partial-sexp from FROM to TO, returning either |
| @@ -2833,7 +2940,7 @@ comment at the start of cc-engine.el for more info." | |||
| 2833 | (defun c-cache-to-parse-ps-state (elt) | 2940 | (defun c-cache-to-parse-ps-state (elt) |
| 2834 | ;; Create a list suitable to use as the old-state parameter to | 2941 | ;; Create a list suitable to use as the old-state parameter to |
| 2835 | ;; `parse-partial-sexp', out of ELT, a member of | 2942 | ;; `parse-partial-sexp', out of ELT, a member of |
| 2836 | ;; `c-state-semi-nonlit-pos-cache'. ELT is either just a number, or a list | 2943 | ;; `c-lit-pos-cache'. ELT is either just a number, or a list |
| 2837 | ;; with 2, 3, or 4 members (See `c-parse-ps-state-to-cache'). That number | 2944 | ;; with 2, 3, or 4 members (See `c-parse-ps-state-to-cache'). That number |
| 2838 | ;; or the car of the list is the "position element" of ELT, the position | 2945 | ;; or the car of the list is the "position element" of ELT, the position |
| 2839 | ;; where ELT is valid. | 2946 | ;; where ELT is valid. |
| @@ -2890,7 +2997,7 @@ comment at the start of cc-engine.el for more info." | |||
| 2890 | ;; Note that as of 2019-05-27, the forms involving CHAR-1 are no longer used. | 2997 | ;; Note that as of 2019-05-27, the forms involving CHAR-1 are no longer used. |
| 2891 | (defun c-parse-ps-state-to-cache (state) | 2998 | (defun c-parse-ps-state-to-cache (state) |
| 2892 | ;; Convert STATE, a `parse-partial-sexp' state valid at POINT, to an element | 2999 | ;; Convert STATE, a `parse-partial-sexp' state valid at POINT, to an element |
| 2893 | ;; for the `c-state-semi-nonlit-pos-cache' cache. This is one of | 3000 | ;; for the `c-lit-pos-cache' cache. This is one of |
| 2894 | ;; o - POINT (when point is not in a literal); | 3001 | ;; o - POINT (when point is not in a literal); |
| 2895 | ;; o - (POINT CHAR-1) (when the last character before point is potentially | 3002 | ;; o - (POINT CHAR-1) (when the last character before point is potentially |
| 2896 | ;; the first of a two-character construct | 3003 | ;; the first of a two-character construct |
| @@ -2944,18 +3051,18 @@ comment at the start of cc-engine.el for more info." | |||
| 2944 | 3051 | ||
| 2945 | (defsubst c-ps-state-cache-pos (elt) | 3052 | (defsubst c-ps-state-cache-pos (elt) |
| 2946 | ;; Get the buffer position from ELT, an element from the cache | 3053 | ;; Get the buffer position from ELT, an element from the cache |
| 2947 | ;; `c-state-semi-nonlit-pos-cache'. | 3054 | ;; `c-lit-pos-cache'. |
| 2948 | (if (atom elt) | 3055 | (if (atom elt) |
| 2949 | elt | 3056 | elt |
| 2950 | (car elt))) | 3057 | (car elt))) |
| 2951 | 3058 | ||
| 2952 | (defun c-state-semi-trim-cache () | 3059 | (defun c-trim-lit-pos-cache () |
| 2953 | ;; Trim the `c-state-semi-nonlit-pos-cache' to take account of buffer | 3060 | ;; Trim the `c-lit-pos-cache' to take account of buffer |
| 2954 | ;; changes, indicated by `c-state-semi-nonlit-pos-cache-limit'. | 3061 | ;; changes, indicated by `c-lit-pos-cache-limit'. |
| 2955 | (while (and c-state-semi-nonlit-pos-cache | 3062 | (while (and c-lit-pos-cache |
| 2956 | (> (c-ps-state-cache-pos (car c-state-semi-nonlit-pos-cache)) | 3063 | (> (c-ps-state-cache-pos (car c-lit-pos-cache)) |
| 2957 | c-state-semi-nonlit-pos-cache-limit)) | 3064 | c-lit-pos-cache-limit)) |
| 2958 | (setq c-state-semi-nonlit-pos-cache (cdr c-state-semi-nonlit-pos-cache)))) | 3065 | (setq c-lit-pos-cache (cdr c-lit-pos-cache)))) |
| 2959 | 3066 | ||
| 2960 | (defun c-parse-ps-state-below (here) | 3067 | (defun c-parse-ps-state-below (here) |
| 2961 | ;; Given a buffer position HERE, Return a cons (CACHE-POS . STATE), where | 3068 | ;; Given a buffer position HERE, Return a cons (CACHE-POS . STATE), where |
| @@ -2967,8 +3074,8 @@ comment at the start of cc-engine.el for more info." | |||
| 2967 | (save-excursion | 3074 | (save-excursion |
| 2968 | (save-restriction | 3075 | (save-restriction |
| 2969 | (widen) | 3076 | (widen) |
| 2970 | (c-state-semi-trim-cache) | 3077 | (c-trim-lit-pos-cache) |
| 2971 | (let ((c c-state-semi-nonlit-pos-cache) | 3078 | (let ((c c-lit-pos-cache) |
| 2972 | elt state npos high-elt) | 3079 | elt state npos high-elt) |
| 2973 | (while (and c (> (c-ps-state-cache-pos (car c)) here)) | 3080 | (while (and c (> (c-ps-state-cache-pos (car c)) here)) |
| 2974 | (setq high-elt (car c)) | 3081 | (setq high-elt (car c)) |
| @@ -2982,7 +3089,7 @@ comment at the start of cc-engine.el for more info." | |||
| 2982 | 3089 | ||
| 2983 | (when (not high-elt) | 3090 | (when (not high-elt) |
| 2984 | ;; We need to extend the cache. Add an element to | 3091 | ;; We need to extend the cache. Add an element to |
| 2985 | ;; `c-state-semi-nonlit-pos-cache' each iteration of the following. | 3092 | ;; `c-lit-pos-cache' each iteration of the following. |
| 2986 | (while | 3093 | (while |
| 2987 | (<= (setq npos (+ (point) c-state-nonlit-pos-interval)) here) | 3094 | (<= (setq npos (+ (point) c-state-nonlit-pos-interval)) here) |
| 2988 | (setq state (parse-partial-sexp (point) npos nil nil state)) | 3095 | (setq state (parse-partial-sexp (point) npos nil nil state)) |
| @@ -2999,11 +3106,11 @@ comment at the start of cc-engine.el for more info." | |||
| 2999 | (setcar (nthcdr 5 state) nil))) | 3106 | (setcar (nthcdr 5 state) nil))) |
| 3000 | 3107 | ||
| 3001 | (setq elt (c-parse-ps-state-to-cache state)) | 3108 | (setq elt (c-parse-ps-state-to-cache state)) |
| 3002 | (setq c-state-semi-nonlit-pos-cache | 3109 | (setq c-lit-pos-cache |
| 3003 | (cons elt c-state-semi-nonlit-pos-cache)))) | 3110 | (cons elt c-lit-pos-cache)))) |
| 3004 | 3111 | ||
| 3005 | (if (> (point) c-state-semi-nonlit-pos-cache-limit) | 3112 | (if (> (point) c-lit-pos-cache-limit) |
| 3006 | (setq c-state-semi-nonlit-pos-cache-limit (point))) | 3113 | (setq c-lit-pos-cache-limit (point))) |
| 3007 | 3114 | ||
| 3008 | (cons (point) state))))) | 3115 | (cons (point) state))))) |
| 3009 | 3116 | ||
| @@ -3932,8 +4039,8 @@ comment at the start of cc-engine.el for more info." | |||
| 3932 | c-state-cache-good-pos 1 | 4039 | c-state-cache-good-pos 1 |
| 3933 | c-state-nonlit-pos-cache nil | 4040 | c-state-nonlit-pos-cache nil |
| 3934 | c-state-nonlit-pos-cache-limit 1 | 4041 | c-state-nonlit-pos-cache-limit 1 |
| 3935 | c-state-semi-nonlit-pos-cache nil | 4042 | c-lit-pos-cache nil |
| 3936 | c-state-semi-nonlit-pos-cache-limit 1 | 4043 | c-lit-pos-cache-limit 1 |
| 3937 | c-state-brace-pair-desert nil | 4044 | c-state-brace-pair-desert nil |
| 3938 | c-state-point-min 1 | 4045 | c-state-point-min 1 |
| 3939 | c-state-point-min-lit-type nil | 4046 | c-state-point-min-lit-type nil |
| @@ -3983,7 +4090,7 @@ comment at the start of cc-engine.el for more info." | |||
| 3983 | ;; HERE. | 4090 | ;; HERE. |
| 3984 | (if (<= here c-state-nonlit-pos-cache-limit) | 4091 | (if (<= here c-state-nonlit-pos-cache-limit) |
| 3985 | (setq c-state-nonlit-pos-cache-limit (1- here))) | 4092 | (setq c-state-nonlit-pos-cache-limit (1- here))) |
| 3986 | (c-truncate-semi-nonlit-pos-cache here) | 4093 | (c-truncate-lit-pos-cache here) |
| 3987 | 4094 | ||
| 3988 | ;; `c-state-cache': | 4095 | ;; `c-state-cache': |
| 3989 | ;; Case 1: if `here' is in a literal containing point-min, everything | 4096 | ;; Case 1: if `here' is in a literal containing point-min, everything |
| @@ -4208,8 +4315,8 @@ comment at the start of cc-engine.el for more info." | |||
| 4208 | c-state-cache-good-pos | 4315 | c-state-cache-good-pos |
| 4209 | c-state-nonlit-pos-cache | 4316 | c-state-nonlit-pos-cache |
| 4210 | c-state-nonlit-pos-cache-limit | 4317 | c-state-nonlit-pos-cache-limit |
| 4211 | c-state-semi-nonlit-pos-cache | 4318 | c-lit-pos-cache |
| 4212 | c-state-semi-nonlit-pos-cache-limit | 4319 | c-lit-pos-cache-limit |
| 4213 | c-state-brace-pair-desert | 4320 | c-state-brace-pair-desert |
| 4214 | c-state-point-min | 4321 | c-state-point-min |
| 4215 | c-state-point-min-lit-type | 4322 | c-state-point-min-lit-type |
| @@ -5287,7 +5394,7 @@ Note that this function might do hidden buffer changes. See the | |||
| 5287 | comment at the start of cc-engine.el for more info." | 5394 | comment at the start of cc-engine.el for more info." |
| 5288 | (save-restriction | 5395 | (save-restriction |
| 5289 | (widen) | 5396 | (widen) |
| 5290 | (let ((lit (c-state-semi-pp-to-literal (point)))) | 5397 | (let ((lit (c-semi-pp-to-literal (point)))) |
| 5291 | (or (cadr lit) | 5398 | (or (cadr lit) |
| 5292 | (and detect-cpp | 5399 | (and detect-cpp |
| 5293 | (save-excursion (c-beginning-of-macro)) | 5400 | (save-excursion (c-beginning-of-macro)) |
| @@ -5322,7 +5429,7 @@ comment at the start of cc-engine.el for more info." | |||
| 5322 | s | 5429 | s |
| 5323 | 'syntax-table) | 5430 | 'syntax-table) |
| 5324 | (point))))) | 5431 | (point))))) |
| 5325 | (let ((pp-to-lit (c-state-full-pp-to-literal pos not-in-delimiter))) | 5432 | (let ((pp-to-lit (c-full-pp-to-literal pos not-in-delimiter))) |
| 5326 | (car (cddr pp-to-lit)))))) | 5433 | (car (cddr pp-to-lit)))))) |
| 5327 | (cond | 5434 | (cond |
| 5328 | (lit-limits) | 5435 | (lit-limits) |
| @@ -5371,7 +5478,7 @@ a known \"safe position\", i.e. outside of any string or comment." | |||
| 5371 | (and (or (nth 3 s) | 5478 | (and (or (nth 3 s) |
| 5372 | (and (nth 4 s) (not (eq (nth 7 s) 'syntax-table)))) | 5479 | (and (nth 4 s) (not (eq (nth 7 s) 'syntax-table)))) |
| 5373 | (nth 8 s))) | 5480 | (nth 8 s))) |
| 5374 | (car (cddr (c-state-semi-pp-to-literal (point)))))) | 5481 | (car (cddr (c-semi-pp-to-literal (point)))))) |
| 5375 | 5482 | ||
| 5376 | ;; In case external callers use this; it did have a docstring. | 5483 | ;; In case external callers use this; it did have a docstring. |
| 5377 | (defalias 'c-literal-limits-fast 'c-literal-limits) | 5484 | (defalias 'c-literal-limits-fast 'c-literal-limits) |
| @@ -5442,7 +5549,7 @@ comment at the start of cc-engine.el for more info." | |||
| 5442 | (c-backward-syntactic-ws) | 5549 | (c-backward-syntactic-ws) |
| 5443 | (setq start (point)) | 5550 | (setq start (point)) |
| 5444 | (let* ((pos (max (- start try-size) (point-min))) | 5551 | (let* ((pos (max (- start try-size) (point-min))) |
| 5445 | (s (c-state-semi-pp-to-literal pos)) | 5552 | (s (c-semi-pp-to-literal pos)) |
| 5446 | (cand (or (car (cddr s)) pos))) | 5553 | (cand (or (car (cddr s)) pos))) |
| 5447 | (if (>= cand (point-min)) | 5554 | (if (>= cand (point-min)) |
| 5448 | cand | 5555 | cand |
| @@ -6836,7 +6943,7 @@ comment at the start of cc-engine.el for more info." | |||
| 6836 | ;; | 6943 | ;; |
| 6837 | ;; Note: this function is dependant upon the correct syntax-table text | 6944 | ;; Note: this function is dependant upon the correct syntax-table text |
| 6838 | ;; properties being set. | 6945 | ;; properties being set. |
| 6839 | (let ((state (c-state-semi-pp-to-literal (point))) | 6946 | (let ((state (c-semi-pp-to-literal (point))) |
| 6840 | open-quote-pos open-paren-pos close-paren-pos close-quote-pos id) | 6947 | open-quote-pos open-paren-pos close-paren-pos close-quote-pos id) |
| 6841 | (save-excursion | 6948 | (save-excursion |
| 6842 | (when | 6949 | (when |
| @@ -6917,7 +7024,7 @@ comment at the start of cc-engine.el for more info." | |||
| 6917 | ;; the 'syntax-table property from all of them. | 7024 | ;; the 'syntax-table property from all of them. |
| 6918 | (setq first (c-clear-char-property-with-value-on-char | 7025 | (setq first (c-clear-char-property-with-value-on-char |
| 6919 | open-quote open-paren 'syntax-table '(1) ?\")) | 7026 | open-quote open-paren 'syntax-table '(1) ?\")) |
| 6920 | (if first (c-truncate-semi-nonlit-pos-cache first)) | 7027 | (if first (c-truncate-lit-pos-cache first)) |
| 6921 | (cond | 7028 | (cond |
| 6922 | ((null open-paren-prop) | 7029 | ((null open-paren-prop) |
| 6923 | ;; Should be a terminated raw string... | 7030 | ;; Should be a terminated raw string... |
| @@ -6927,7 +7034,7 @@ comment at the start of cc-engine.el for more info." | |||
| 6927 | (setq first (c-clear-char-property-with-value-on-char | 7034 | (setq first (c-clear-char-property-with-value-on-char |
| 6928 | (1+ (match-beginning 0)) (1- (match-end 0)) | 7035 | (1+ (match-beginning 0)) (1- (match-end 0)) |
| 6929 | 'syntax-table '(1) ?\")) | 7036 | 'syntax-table '(1) ?\")) |
| 6930 | (if first (c-truncate-semi-nonlit-pos-cache first)) | 7037 | (if first (c-truncate-lit-pos-cache first)) |
| 6931 | ;; Clear any random `syntax-table' text properties from the contents. | 7038 | ;; Clear any random `syntax-table' text properties from the contents. |
| 6932 | (let* ((closing-paren (match-beginning 0)) | 7039 | (let* ((closing-paren (match-beginning 0)) |
| 6933 | (first-st | 7040 | (first-st |
| @@ -6945,7 +7052,7 @@ comment at the start of cc-engine.el for more info." | |||
| 6945 | (when first-st | 7052 | (when first-st |
| 6946 | (c-clear-char-properties first-st (match-beginning 0) | 7053 | (c-clear-char-properties first-st (match-beginning 0) |
| 6947 | 'syntax-table) | 7054 | 'syntax-table) |
| 6948 | (c-truncate-semi-nonlit-pos-cache first-st)) | 7055 | (c-truncate-lit-pos-cache first-st)) |
| 6949 | (when (c-get-char-property (1- (match-end 0)) 'syntax-table) | 7056 | (when (c-get-char-property (1- (match-end 0)) 'syntax-table) |
| 6950 | ;; Was previously an unterminated (ordinary) string | 7057 | ;; Was previously an unterminated (ordinary) string |
| 6951 | (save-excursion | 7058 | (save-excursion |
| @@ -6953,19 +7060,19 @@ comment at the start of cc-engine.el for more info." | |||
| 6953 | (when (c-safe (c-forward-sexp)) ; to '(1) at EOL. | 7060 | (when (c-safe (c-forward-sexp)) ; to '(1) at EOL. |
| 6954 | (c-clear-char-property (1- (point)) 'syntax-table)) | 7061 | (c-clear-char-property (1- (point)) 'syntax-table)) |
| 6955 | (c-clear-char-property (1- (match-end 0)) 'syntax-table) | 7062 | (c-clear-char-property (1- (match-end 0)) 'syntax-table) |
| 6956 | (c-truncate-semi-nonlit-pos-cache (1- (match-end 0)))))))) | 7063 | (c-truncate-lit-pos-cache (1- (match-end 0)))))))) |
| 6957 | ((or (and (equal open-paren-prop '(15)) (null bound)) | 7064 | ((or (and (equal open-paren-prop '(15)) (null bound)) |
| 6958 | (equal open-paren-prop '(1))) | 7065 | (equal open-paren-prop '(1))) |
| 6959 | ;; An unterminated raw string either not in a macro, or in a macro with | 7066 | ;; An unterminated raw string either not in a macro, or in a macro with |
| 6960 | ;; the open parenthesis right up against the end of macro | 7067 | ;; the open parenthesis right up against the end of macro |
| 6961 | (c-clear-char-property open-quote 'syntax-table) | 7068 | (c-clear-char-property open-quote 'syntax-table) |
| 6962 | (c-truncate-semi-nonlit-pos-cache open-quote) | 7069 | (c-truncate-lit-pos-cache open-quote) |
| 6963 | (c-clear-char-property open-paren 'syntax-table)) | 7070 | (c-clear-char-property open-paren 'syntax-table)) |
| 6964 | (t | 7071 | (t |
| 6965 | ;; An unterminated string in a macro, with at least one char after the | 7072 | ;; An unterminated string in a macro, with at least one char after the |
| 6966 | ;; open paren | 7073 | ;; open paren |
| 6967 | (c-clear-char-property open-quote 'syntax-table) | 7074 | (c-clear-char-property open-quote 'syntax-table) |
| 6968 | (c-truncate-semi-nonlit-pos-cache open-quote) | 7075 | (c-truncate-lit-pos-cache open-quote) |
| 6969 | (c-clear-char-property open-paren 'syntax-table) | 7076 | (c-clear-char-property open-paren 'syntax-table) |
| 6970 | (c-clear-char-property-with-value (1+ open-paren) bound 'syntax-table | 7077 | (c-clear-char-property-with-value (1+ open-paren) bound 'syntax-table |
| 6971 | '(15)))))) | 7078 | '(15)))))) |
| @@ -7085,7 +7192,7 @@ comment at the start of cc-engine.el for more info." | |||
| 7085 | (while (and (skip-chars-forward "^\"" end) | 7192 | (while (and (skip-chars-forward "^\"" end) |
| 7086 | (< (point) end)) | 7193 | (< (point) end)) |
| 7087 | (c-put-char-property (point) 'syntax-table '(1)) | 7194 | (c-put-char-property (point) 'syntax-table '(1)) |
| 7088 | (c-truncate-semi-nonlit-pos-cache (point)) | 7195 | (c-truncate-lit-pos-cache (point)) |
| 7089 | (forward-char)))) | 7196 | (forward-char)))) |
| 7090 | 7197 | ||
| 7091 | (defun c-propertize-raw-string-opener (id open-quote open-paren bound) | 7198 | (defun c-propertize-raw-string-opener (id open-quote open-paren bound) |
| @@ -7112,12 +7219,12 @@ comment at the start of cc-engine.el for more info." | |||
| 7112 | (while (progn (skip-syntax-forward "^\"" end-string) | 7219 | (while (progn (skip-syntax-forward "^\"" end-string) |
| 7113 | (< (point) end-string)) | 7220 | (< (point) end-string)) |
| 7114 | (c-put-char-property (point) 'syntax-table '(1)) ; punctuation | 7221 | (c-put-char-property (point) 'syntax-table '(1)) ; punctuation |
| 7115 | (c-truncate-semi-nonlit-pos-cache (point)) | 7222 | (c-truncate-lit-pos-cache (point)) |
| 7116 | (forward-char)) | 7223 | (forward-char)) |
| 7117 | (goto-char after-quote) | 7224 | (goto-char after-quote) |
| 7118 | t) | 7225 | t) |
| 7119 | (c-put-char-property open-quote 'syntax-table '(1)) ; punctuation | 7226 | (c-put-char-property open-quote 'syntax-table '(1)) ; punctuation |
| 7120 | (c-truncate-semi-nonlit-pos-cache open-quote) | 7227 | (c-truncate-lit-pos-cache open-quote) |
| 7121 | (c-put-char-property open-paren 'syntax-table '(15)) ; generic string | 7228 | (c-put-char-property open-paren 'syntax-table '(15)) ; generic string |
| 7122 | (when bound | 7229 | (when bound |
| 7123 | ;; In a CPP construct, we try to apply a generic-string | 7230 | ;; In a CPP construct, we try to apply a generic-string |
| @@ -7148,10 +7255,10 @@ comment at the start of cc-engine.el for more info." | |||
| 7148 | (if (match-beginning 10) | 7255 | (if (match-beginning 10) |
| 7149 | (progn | 7256 | (progn |
| 7150 | (c-put-char-property (match-beginning 10) 'syntax-table '(15)) | 7257 | (c-put-char-property (match-beginning 10) 'syntax-table '(15)) |
| 7151 | (c-truncate-semi-nonlit-pos-cache (match-beginning 10))) | 7258 | (c-truncate-lit-pos-cache (match-beginning 10))) |
| 7152 | (c-put-char-property (match-beginning 5) 'syntax-table '(1)) | 7259 | (c-put-char-property (match-beginning 5) 'syntax-table '(1)) |
| 7153 | (c-put-char-property (1+ (match-beginning 5)) 'syntax-table '(15)) | 7260 | (c-put-char-property (1+ (match-beginning 5)) 'syntax-table '(15)) |
| 7154 | (c-truncate-semi-nonlit-pos-cache (1+ (match-beginning 5)))) | 7261 | (c-truncate-lit-pos-cache (1+ (match-beginning 5)))) |
| 7155 | ;; (c-put-char-property open-paren 'syntax-table '(1)) | 7262 | ;; (c-put-char-property open-paren 'syntax-table '(1)) |
| 7156 | ) | 7263 | ) |
| 7157 | (goto-char bound)) | 7264 | (goto-char bound)) |
| @@ -7179,7 +7286,7 @@ comment at the start of cc-engine.el for more info." | |||
| 7179 | (setq eoll (c-point 'eoll)) | 7286 | (setq eoll (c-point 'eoll)) |
| 7180 | (when (and (null c-old-END-literality) | 7287 | (when (and (null c-old-END-literality) |
| 7181 | (search-forward-regexp c-c++-raw-string-opener-re eoll t)) | 7288 | (search-forward-regexp c-c++-raw-string-opener-re eoll t)) |
| 7182 | (setq state (c-state-semi-pp-to-literal end)) | 7289 | (setq state (c-semi-pp-to-literal end)) |
| 7183 | (when (eq (cadr state) 'string) | 7290 | (when (eq (cadr state) 'string) |
| 7184 | (unwind-protect | 7291 | (unwind-protect |
| 7185 | ;; Temporarily insert a closing string delimiter.... | 7292 | ;; Temporarily insert a closing string delimiter.... |
| @@ -7191,7 +7298,7 @@ comment at the start of cc-engine.el for more info." | |||
| 7191 | ((eq (nth 3 (car state)) t) | 7298 | ((eq (nth 3 (car state)) t) |
| 7192 | (insert ?\") | 7299 | (insert ?\") |
| 7193 | (c-put-char-property end 'syntax-table '(15)))) | 7300 | (c-put-char-property end 'syntax-table '(15)))) |
| 7194 | (c-truncate-semi-nonlit-pos-cache end) | 7301 | (c-truncate-lit-pos-cache end) |
| 7195 | ;; ....ensure c-new-END extends right to the end of the about | 7302 | ;; ....ensure c-new-END extends right to the end of the about |
| 7196 | ;; to be un-stringed raw string.... | 7303 | ;; to be un-stringed raw string.... |
| 7197 | (save-excursion | 7304 | (save-excursion |
| @@ -7231,7 +7338,7 @@ comment at the start of cc-engine.el for more info." | |||
| 7231 | (goto-char (1- (cadr c-old-beg-rs))) | 7338 | (goto-char (1- (cadr c-old-beg-rs))) |
| 7232 | (unless (looking-at c-c++-raw-string-opener-re) | 7339 | (unless (looking-at c-c++-raw-string-opener-re) |
| 7233 | (c-clear-char-property (1+ (point)) 'syntax-table) | 7340 | (c-clear-char-property (1+ (point)) 'syntax-table) |
| 7234 | (c-truncate-semi-nonlit-pos-cache (1+ (point))) | 7341 | (c-truncate-lit-pos-cache (1+ (point))) |
| 7235 | (if (c-search-forward-char-property 'syntax-table '(15) | 7342 | (if (c-search-forward-char-property 'syntax-table '(15) |
| 7236 | (c-point 'eol)) | 7343 | (c-point 'eol)) |
| 7237 | (c-clear-char-property (1- (point)) 'syntax-table)))) | 7344 | (c-clear-char-property (1- (point)) 'syntax-table)))) |
| @@ -7250,7 +7357,7 @@ comment at the start of cc-engine.el for more info." | |||
| 7250 | (setq c-new-END (point-max)) | 7357 | (setq c-new-END (point-max)) |
| 7251 | (c-clear-char-properties (cadr c-old-beg-rs) c-new-END | 7358 | (c-clear-char-properties (cadr c-old-beg-rs) c-new-END |
| 7252 | 'syntax-table) | 7359 | 'syntax-table) |
| 7253 | (c-truncate-semi-nonlit-pos-cache (cadr c-old-beg-rs))))) | 7360 | (c-truncate-lit-pos-cache (cadr c-old-beg-rs))))) |
| 7254 | ;; Have we terminated an existing raw string by inserting or removing | 7361 | ;; Have we terminated an existing raw string by inserting or removing |
| 7255 | ;; text? | 7362 | ;; text? |
| 7256 | (when (eq c-old-END-literality 'string) | 7363 | (when (eq c-old-END-literality 'string) |
| @@ -7268,13 +7375,13 @@ comment at the start of cc-engine.el for more info." | |||
| 7268 | (while | 7375 | (while |
| 7269 | (and | 7376 | (and |
| 7270 | (setq found (search-backward (concat "R\"" id "(") nil t)) | 7377 | (setq found (search-backward (concat "R\"" id "(") nil t)) |
| 7271 | (setq state (c-state-semi-pp-to-literal (point))) | 7378 | (setq state (c-semi-pp-to-literal (point))) |
| 7272 | (memq (nth 3 (car state)) '(t ?\")))) | 7379 | (memq (nth 3 (car state)) '(t ?\")))) |
| 7273 | (when found | 7380 | (when found |
| 7274 | (setq c-new-BEG (min (point) c-new-BEG) | 7381 | (setq c-new-BEG (min (point) c-new-BEG) |
| 7275 | c-new-END (point-max)) | 7382 | c-new-END (point-max)) |
| 7276 | (c-clear-char-properties (point) c-new-END 'syntax-table) | 7383 | (c-clear-char-properties (point) c-new-END 'syntax-table) |
| 7277 | (c-truncate-semi-nonlit-pos-cache (point))))) | 7384 | (c-truncate-lit-pos-cache (point))))) |
| 7278 | 7385 | ||
| 7279 | ;; Are there any raw strings in a newly created macro? | 7386 | ;; Are there any raw strings in a newly created macro? |
| 7280 | (when (< beg end) | 7387 | (when (< beg end) |
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index ad00b59b9cc..c3dd8f85bdc 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -1681,7 +1681,7 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1681 | ;; font-lock-keyword-face. It always returns NIL to inhibit this and | 1681 | ;; font-lock-keyword-face. It always returns NIL to inhibit this and |
| 1682 | ;; prevent a repeat invocation. See elisp/lispref page "Search-based | 1682 | ;; prevent a repeat invocation. See elisp/lispref page "Search-based |
| 1683 | ;; Fontification". | 1683 | ;; Fontification". |
| 1684 | (let* ((state (c-state-semi-pp-to-literal (point))) | 1684 | (let* ((state (c-semi-pp-to-literal (point))) |
| 1685 | (string-start (and (eq (cadr state) 'string) | 1685 | (string-start (and (eq (cadr state) 'string) |
| 1686 | (car (cddr state)))) | 1686 | (car (cddr state)))) |
| 1687 | (raw-id (and string-start | 1687 | (raw-id (and string-start |
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 74fcc97226c..c4b2d7bd5dc 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -1219,7 +1219,7 @@ Note that the style variables are always made local to the buffer." | |||
| 1219 | (point-max) t t) | 1219 | (point-max) t t) |
| 1220 | (progn | 1220 | (progn |
| 1221 | (c-clear-char-property (1- (point)) 'syntax-table) | 1221 | (c-clear-char-property (1- (point)) 'syntax-table) |
| 1222 | (c-truncate-semi-nonlit-pos-cache (1- (point))) | 1222 | (c-truncate-lit-pos-cache (1- (point))) |
| 1223 | (not (memq (char-before) c-string-delims))))) | 1223 | (not (memq (char-before) c-string-delims))))) |
| 1224 | (memq (char-before) c-string-delims)) | 1224 | (memq (char-before) c-string-delims)) |
| 1225 | (progn | 1225 | (progn |
| @@ -1257,14 +1257,14 @@ Note that the style variables are always made local to the buffer." | |||
| 1257 | (backward-sexp) | 1257 | (backward-sexp) |
| 1258 | (c-clear-char-property eoll-1 'syntax-table) | 1258 | (c-clear-char-property eoll-1 'syntax-table) |
| 1259 | (c-clear-char-property (point) 'syntax-table) | 1259 | (c-clear-char-property (point) 'syntax-table) |
| 1260 | (c-truncate-semi-nonlit-pos-cache (point))) | 1260 | (c-truncate-lit-pos-cache (point))) |
| 1261 | ;; Opening " at EOB. | 1261 | ;; Opening " at EOB. |
| 1262 | (c-clear-char-property (1- (point)) 'syntax-table)) | 1262 | (c-clear-char-property (1- (point)) 'syntax-table)) |
| 1263 | (when (and (c-search-backward-char-property 'syntax-table '(15) c-new-BEG) | 1263 | (when (and (c-search-backward-char-property 'syntax-table '(15) c-new-BEG) |
| 1264 | (memq (char-after) c-string-delims)) ; Ignore an unterminated raw string's (. | 1264 | (memq (char-after) c-string-delims)) ; Ignore an unterminated raw string's (. |
| 1265 | ;; Opening " on last line of text (without EOL). | 1265 | ;; Opening " on last line of text (without EOL). |
| 1266 | (c-clear-char-property (point) 'syntax-table) | 1266 | (c-clear-char-property (point) 'syntax-table) |
| 1267 | (c-truncate-semi-nonlit-pos-cache (point)) | 1267 | (c-truncate-lit-pos-cache (point)) |
| 1268 | (setq c-new-BEG (min c-new-BEG (point)))))) | 1268 | (setq c-new-BEG (min c-new-BEG (point)))))) |
| 1269 | 1269 | ||
| 1270 | (t (goto-char end) ; point-max | 1270 | (t (goto-char end) ; point-max |
| @@ -1273,7 +1273,7 @@ Note that the style variables are always made local to the buffer." | |||
| 1273 | (c-search-backward-char-property 'syntax-table '(15) c-new-BEG) | 1273 | (c-search-backward-char-property 'syntax-table '(15) c-new-BEG) |
| 1274 | (memq (char-after) c-string-delims)) | 1274 | (memq (char-after) c-string-delims)) |
| 1275 | (c-clear-char-property (point) 'syntax-table) | 1275 | (c-clear-char-property (point) 'syntax-table) |
| 1276 | (c-truncate-semi-nonlit-pos-cache (point))))) | 1276 | (c-truncate-lit-pos-cache (point))))) |
| 1277 | 1277 | ||
| 1278 | (unless | 1278 | (unless |
| 1279 | (or (and | 1279 | (or (and |
| @@ -1285,13 +1285,13 @@ Note that the style variables are always made local to the buffer." | |||
| 1285 | (when (and (eq end-literal-type 'string) | 1285 | (when (and (eq end-literal-type 'string) |
| 1286 | (not (eq (char-before (cdr end-limits)) ?\())) | 1286 | (not (eq (char-before (cdr end-limits)) ?\())) |
| 1287 | (c-clear-char-property (1- (cdr end-limits)) 'syntax-table) | 1287 | (c-clear-char-property (1- (cdr end-limits)) 'syntax-table) |
| 1288 | (c-truncate-semi-nonlit-pos-cache (1- (cdr end-limits))) | 1288 | (c-truncate-lit-pos-cache (1- (cdr end-limits))) |
| 1289 | (setq c-new-END (max c-new-END (cdr end-limits)))) | 1289 | (setq c-new-END (max c-new-END (cdr end-limits)))) |
| 1290 | 1290 | ||
| 1291 | (when (and (eq beg-literal-type 'string) | 1291 | (when (and (eq beg-literal-type 'string) |
| 1292 | (memq (char-after (car beg-limits)) c-string-delims)) | 1292 | (memq (char-after (car beg-limits)) c-string-delims)) |
| 1293 | (c-clear-char-property (car beg-limits) 'syntax-table) | 1293 | (c-clear-char-property (car beg-limits) 'syntax-table) |
| 1294 | (c-truncate-semi-nonlit-pos-cache (car beg-limits)) | 1294 | (c-truncate-lit-pos-cache (car beg-limits)) |
| 1295 | (setq c-new-BEG (min c-new-BEG (car beg-limits))))))) | 1295 | (setq c-new-BEG (min c-new-BEG (car beg-limits))))))) |
| 1296 | 1296 | ||
| 1297 | (defun c-after-change-mark-abnormal-strings (beg end _old-len) | 1297 | (defun c-after-change-mark-abnormal-strings (beg end _old-len) |
| @@ -1587,7 +1587,7 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") | |||
| 1587 | (when (c-search-forward-char-property-with-value-on-char | 1587 | (when (c-search-forward-char-property-with-value-on-char |
| 1588 | 'syntax-table '(1) ?\' c-new-END) | 1588 | 'syntax-table '(1) ?\' c-new-END) |
| 1589 | (c-invalidate-state-cache (1- (point))) | 1589 | (c-invalidate-state-cache (1- (point))) |
| 1590 | (c-truncate-semi-nonlit-pos-cache (1- (point))) | 1590 | (c-truncate-lit-pos-cache (1- (point))) |
| 1591 | (c-clear-char-property-with-value-on-char | 1591 | (c-clear-char-property-with-value-on-char |
| 1592 | (1- (point)) c-new-END | 1592 | (1- (point)) c-new-END |
| 1593 | 'syntax-table '(1) | 1593 | 'syntax-table '(1) |
| @@ -1623,7 +1623,7 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") | |||
| 1623 | (setq num-beg (match-beginning 0) | 1623 | (setq num-beg (match-beginning 0) |
| 1624 | num-end (match-end 0)) | 1624 | num-end (match-end 0)) |
| 1625 | (c-invalidate-state-cache num-beg) | 1625 | (c-invalidate-state-cache num-beg) |
| 1626 | (c-truncate-semi-nonlit-pos-cache num-beg) | 1626 | (c-truncate-lit-pos-cache num-beg) |
| 1627 | (c-put-char-properties-on-char num-beg num-end | 1627 | (c-put-char-properties-on-char num-beg num-end |
| 1628 | 'syntax-table '(1) ?') | 1628 | 'syntax-table '(1) ?') |
| 1629 | (c-put-char-properties-on-char num-beg num-end | 1629 | (c-put-char-properties-on-char num-beg num-end |
| @@ -1635,13 +1635,13 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") | |||
| 1635 | (goto-char (match-end 0))) | 1635 | (goto-char (match-end 0))) |
| 1636 | ((looking-at "\\\\'") ; Anomalous construct. | 1636 | ((looking-at "\\\\'") ; Anomalous construct. |
| 1637 | (c-invalidate-state-cache (1- (point))) | 1637 | (c-invalidate-state-cache (1- (point))) |
| 1638 | (c-truncate-semi-nonlit-pos-cache (1- (point))) | 1638 | (c-truncate-lit-pos-cache (1- (point))) |
| 1639 | (c-put-char-properties-on-char (1- (point)) (+ (point) 2) | 1639 | (c-put-char-properties-on-char (1- (point)) (+ (point) 2) |
| 1640 | 'syntax-table '(1) ?') | 1640 | 'syntax-table '(1) ?') |
| 1641 | (goto-char (match-end 0))) | 1641 | (goto-char (match-end 0))) |
| 1642 | (t | 1642 | (t |
| 1643 | (c-invalidate-state-cache (1- (point))) | 1643 | (c-invalidate-state-cache (1- (point))) |
| 1644 | (c-truncate-semi-nonlit-pos-cache (1- (point))) | 1644 | (c-truncate-lit-pos-cache (1- (point))) |
| 1645 | (c-put-char-property (1- (point)) 'syntax-table '(1)))) | 1645 | (c-put-char-property (1- (point)) 'syntax-table '(1)))) |
| 1646 | ;; Prevent the next `c-quoted-number-straddling-point' getting | 1646 | ;; Prevent the next `c-quoted-number-straddling-point' getting |
| 1647 | ;; confused by already processed single quotes. | 1647 | ;; confused by already processed single quotes. |