[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 0dc770d 42/95: Prevent infinite loop in TeX-comm
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 0dc770d 42/95: Prevent infinite loop in TeX-command-expand |
Date: |
Sun, 16 Apr 2017 01:26:51 -0400 (EDT) |
branch: externals/auctex
commit 0dc770d000808696879dfad60dedf82f052f46fe
Author: Mosè Giordano <address@hidden>
Commit: Mosè Giordano <address@hidden>
Prevent infinite loop in TeX-command-expand
* tex-buf.el (TeX-command-expand): Throw an error if `string' is not a
string.
This prevents an infinite loop.
* tex.el (TeX-engine-in-engine-alist): New function to pick up an engine
from
`TeX-engine-alist' and throw an error if the engine is not there.
(TeX-expand-list-builtin): Use `TeX-engine-in-engine-alist'.
* context.el (ConTeXt-expand-options): Use `TeX-engine-in-engine-alist'.
* tests/tex/command-expansion.el (TeX-command-expansion-errors): Add tests
for
error handling of `TeX-command-expand'.
---
context.el | 2 +-
tests/tex/command-expansion.el | 13 +++++++++++++
tex-buf.el | 6 +++++-
tex.el | 15 +++++++++++++--
4 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/context.el b/context.el
index e220c43..2f302b3 100644
--- a/context.el
+++ b/context.el
@@ -1623,7 +1623,7 @@ Use `ConTeXt-Mark-version' to choose the command."
;; In any other case fall back on Mark II.
(t
(concat
- (let ((engine (eval (nth 4 (assq TeX-engine (TeX-engine-alist))))))
+ (let ((engine (eval (nth 4 (TeX-engine-in-engine-alist TeX-engine)))))
(when engine
(format "--engine=%s " engine)))
(unless (eq ConTeXt-current-interface "en")
diff --git a/tests/tex/command-expansion.el b/tests/tex/command-expansion.el
index ebdb6d1..17759d1 100644
--- a/tests/tex/command-expansion.el
+++ b/tests/tex/command-expansion.el
@@ -33,6 +33,19 @@
'TeX-master-file))
"%% \"\\input\"")))
+(ert-deftest TeX-command-expansion-errors ()
+ "Test error handling in `TeX-command-expand'."
+ (should-error
+ ;; This should prevent an infinite loop.
+ (let ((TeX-expand-list '(("%(nil)" "nil"))))
+ (TeX-command-expand "%(nil)"
+ 'TeX-master-file)))
+ (should-error
+ ;; This error is actually thrown by `TeX-engine-in-engine-alist', but we
want
+ ;; to be sure that `TeX-command-expand' fails when the engine is not valid.
+ (let ((TeX-engine 'non-existing-engine))
+ (TeX-command-expand "%l" 'TeX-master-file))))
+
(ert-deftest TeX-view-command-raw-errors ()
"Tests to trigger errors in `TeX-view-command-raw'."
;; Viewer specification should be either a command line string or a Lisp
diff --git a/tex-buf.el b/tex-buf.el
index 6497777..b893706 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -585,7 +585,11 @@ without further expansion."
(error "Nonexpansion %s" expansion)))))
(if (stringp string)
(setq command
- (replace-match string t t command)))))
+ (replace-match string t t command))
+ ;; If `string' is not a string, `command' will not be updated and
+ ;; `while' would enter an infinite loop. Prevent it by throwing an
+ ;; error.
+ (error "Nonexpansion %s" expansion))))
command)
(defun TeX-check-files (derived originals extensions)
diff --git a/tex.el b/tex.el
index 11a40e0..64e5ea2 100644
--- a/tex.el
+++ b/tex.el
@@ -478,8 +478,8 @@ string."
("%(file-line-error)"
(lambda () (if TeX-file-line-error " -file-line-error" "")))
("%(o?)" (lambda () (if (eq TeX-engine 'omega) "o" "")))
- ("%(tex)" (lambda () (eval (nth 2 (assq TeX-engine (TeX-engine-alist))))))
- ("%(latex)" (lambda () (eval (nth 3 (assq TeX-engine
(TeX-engine-alist))))))
+ ("%(tex)" (lambda () (eval (nth 2 (TeX-engine-in-engine-alist
TeX-engine)))))
+ ("%(latex)" (lambda () (eval (nth 3 (TeX-engine-in-engine-alist
TeX-engine)))))
("%(cntxcom)" ConTeXt-expand-command)
("%(execopts)" ConTeXt-expand-options)
("%(extraopts)" (lambda () TeX-command-extra-options))
@@ -1664,6 +1664,17 @@ The function appends the built-in engine specs from
where an entry with the same car exists in the user-defined part."
(TeX-delete-dups-by-car (append TeX-engine-alist TeX-engine-alist-builtin)))
+(defun TeX-engine-in-engine-alist (engine)
+ "Return the `engine' entry in `TeX-engine-alist'.
+
+Throw an error if `engine' is not present in the alist."
+ (or
+ (assq engine (TeX-engine-alist))
+ (error "`%s' is not a known engine. Valid values are: %s." engine
+ (mapconcat
+ (lambda (x) (prin1-to-string (car x)))
+ (TeX-engine-alist) ", "))))
+
(defcustom TeX-engine 'default
(concat "Type of TeX engine to use.
It should be one of the following symbols:\n\n"
- [elpa] externals/auctex 4fcee32 68/95: Use the variable `LaTeX-listing-label', (continued)
- [elpa] externals/auctex 4fcee32 68/95: Use the variable `LaTeX-listing-label', Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 77974e6 71/95: * style/minted.el ("minted"): Add key=val query for \mint and \mintinline., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 43b07d9 70/95: Use `TeX-line-number-at-pos' further for older emacsen, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 9e7f21e 69/95: Use compatibility function `TeX-line-number-at-pos' for older emacsen, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex c360b9a 76/95: Adapt fontification for \lstinline, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 2182b6f 30/95: Append "lstlisting" to `LaTeX-label-alist', Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 337ce76 33/95: Add new keys for package version 4.00, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 6bb49cc 39/95: * style/subfiles.el (LaTeX-subfiles-class-options): New function., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 4992f5a 46/95: Make customization to face specification to appear in, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex c97a654 48/95: * tex-ispell.el (TeX-ispell-skip-setcdr): Add entry for filecontents package., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 0dc770d 42/95: Prevent infinite loop in TeX-command-expand,
Tassilo Horn <=
- [elpa] externals/auctex 841d4cb 45/95: Unify treatment of face argument over the relevant functions., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 72a6943 54/95: Add fallback for indentation when & is omitted, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 8fdc494 63/95: ; Provide fallback when no locale information is available, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 9d12a06 66/95: Use `TeX-replace-regexp-in-string' in style files, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex a71a72d 74/95: Add support for Japanese font command, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 88a7563 81/95: Fix last improvement for skipping of inline verbatim macros, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 16f24dd 90/95: ; * style/minted.el (LaTeX-minted-add-syntactic-keywords-extra): Fix doc string., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex a46c307 77/95: Improve fontification of verbatim macros in style/minted.el, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 83890d6 86/95: Update package options in style/amsmath.el, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 94b227d 89/95: * doc/auctex.texi (Selecting a Command): Document `TeX-ispell-verb-delimiters'., Tassilo Horn, 2017/04/16