-
- (if (and (vectorp c-in-literal-cache)
- (= (point) (aref c-in-literal-cache 0)))
- (aref c-in-literal-cache 1)
- (let ((rtn (save-excursion
- (let* ((pos (point))
- (lim (or lim (progn
- (c-beginning-of-syntax)
- (point))))
- (state (parse-partial-sexp lim pos)))
- (cond
- ((elt state 3) 'string)
- ((elt state 4) (if (elt state 7) 'c++ 'c))
- ((and detect-cpp (c-beginning-of-macro lim)) 'pound)
- (t nil))))))
- ;; cache this result if the cache is enabled
- (if (not c-in-literal-cache)
- (setq c-in-literal-cache (vector (point) rtn)))
- rtn)))
-
-;; XEmacs has a built-in function that should make this much quicker.
-;; I don't think we even need the cache, which makes our lives more
-;; complicated anyway. In this case, lim is only used to detect
-;; cpp directives.
-;;
-;; Note that there is a bug in Xemacs's buffer-syntactic-context when used in
-;; conjunction with syntax-table-properties. The bug is present in, e.g.,
-;; Xemacs 21.4.4. It manifested itself thus:
-;;
-;; Starting with an empty AWK Mode buffer, type
-;; /regexp/ {<C-j>
-;; Point gets wrongly left at column 0, rather than being indented to tab-width.
-;;
-;; AWK Mode is designed such that when the first / is typed, it gets the
-;; syntax-table property "string fence". When the second / is typed, BOTH /s
-;; are given the s-t property "string". However, buffer-syntactic-context
-;; fails to take account of the change of the s-t property on the opening / to
-;; "string", and reports that the { is within a string started by the second /.
-;;
-;; The workaround for this is for the AWK Mode initialisation to switch the
-;; defalias for c-in-literal to c-slow-in-literal. This will slow down other
-;; cc-modes in Xemacs whenever an awk-buffer has been initialised.
-;;
-;; (Alan Mackenzie, 2003/4/30).
-
-(defun c-fast-in-literal (&optional lim detect-cpp)
- ;; This function might do hidden buffer changes.
- (let ((context (buffer-syntactic-context)))
- (cond
- ((eq context 'string) 'string)
- ((eq context 'comment) 'c++)
- ((eq context 'block-comment) 'c)
- ((and detect-cpp (save-excursion (c-beginning-of-macro lim))) 'pound))))
-
-(defalias 'c-in-literal
- (if (fboundp 'buffer-syntactic-context)
- 'c-fast-in-literal ; XEmacs
- 'c-slow-in-literal)) ; GNU Emacs
-
-;; The defalias above isn't enough to shut up the byte compiler.
-(cc-bytecomp-defun c-in-literal)