auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. d418e9a064e4158556dac


From: Mosè Giordano
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. d418e9a064e4158556dacb33744d610097eff04b
Date: Tue, 12 Apr 2016 23:13:08 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  d418e9a064e4158556dacb33744d610097eff04b (commit)
      from  6eb95e66962c446aae4f81a993bcd2d6c560f3c7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d418e9a064e4158556dacb33744d610097eff04b
Author: Mosè Giordano <address@hidden>
Date:   Wed Apr 13 01:09:52 2016 +0200

    Prevent infinite loop in TeX-command-expand
    
    * tex.el (TeX-view-command-raw): This function should always return a
      string.  Throw an error if fails to do so.  This prevents an infinite
      loop in `TeX-command-expand' in the case in which `command' is nil
      because of a malformed viewer specification.
    * tests/tex/command-expansion.el (TeX-view-command-raw-errors): Add
      tests to trigger errors in `TeX-view-command-raw'.

diff --git a/tests/tex/command-expansion.el b/tests/tex/command-expansion.el
index d6dfc89..ebdb6d1 100644
--- a/tests/tex/command-expansion.el
+++ b/tests/tex/command-expansion.el
@@ -33,4 +33,47 @@
                                 'TeX-master-file))
            "%%  \"\\input\"")))
 
+(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
+  ;; function name to be executed.  This test makes sure that the functions
+  ;; throws an error if the selected viewer has a wrong specification (for
+  ;; example a function call, not the function name) such that the returned
+  ;; value `command' isn't a string.  This prevents an infinite loop in
+  ;; `TeX-command-expand'.
+  (should-error
+   (with-temp-buffer
+     (let ((TeX-view-program-list '(("viewer"
+                                    (wrong-specification))))
+          (TeX-view-program-selection
+           '((output-pdf "viewer"))))
+       (TeX-mode)
+       (TeX-view-command-raw)))
+   :type 'error)
+  ;; Signal an error when a nonexistent viewer is selected.
+  (should-error
+   (with-temp-buffer
+     (let ((TeX-view-program-selection
+           '((output-pdf "does-not-exist"))))
+       (TeX-mode)
+       (TeX-view-command-raw)))
+   :type 'error)
+  ;; Signal an error if the binary associated to the viewer cannot be found.
+  (should-error
+   (with-temp-buffer
+     (let ((TeX-view-program-list
+           '(("viewer" "viewer %o" "**this-program-does-not-exist**")))
+          (TeX-view-program-selection
+           '((output-pdf "viewer"))))
+       (TeX-mode)
+       (TeX-view-command-raw)))
+   :type 'error)
+  ;; Error if there is no selected viewer for current buffer.
+  (should-error
+   (with-temp-buffer
+     (let (TeX-view-program-selection)
+       (TeX-mode)
+       (TeX-view-command-raw)))
+   :type 'error))
+
 ;;; command-expansion.el ends here
diff --git a/tex.el b/tex.el
index f7b5bc4..fb734f4 100644
--- a/tex.el
+++ b/tex.el
@@ -1598,7 +1598,11 @@ Check the `TeX-view-program-selection' variable" 
viewer)))
                   ((listp elt)
                    (when (TeX-view-match-predicate (car elt))
                      (setq command (concat command (cadr elt)))))))
-          command))))
+          (if (stringp command)
+              command
+            ;; Signal an error if `command' isn't a string.  This prevents an
+            ;; infinite loop in `TeX-command-expand' if `command' is nil.
+            (error "Wrong viewer specification in 
`TeX-view-program-list'"))))))
 
 ;;; Engine
 

-----------------------------------------------------------------------

Summary of changes:
 tests/tex/command-expansion.el |   43 ++++++++++++++++++++++++++++++++++++++++
 tex.el                         |    6 ++++-
 2 files changed, 48 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

[Prev in Thread] Current Thread [Next in Thread]