GNU bug report logs - #18620
25.0.50; cfengine3-make-syntax-cache

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Fri, 3 Oct 2014 10:30:04 UTC

Severity: normal

Found in version 25.0.50

Done: Leo Liu <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ted Zlatanov <tzz <at> lifelogs.com>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 18620 <at> debbugs.gnu.org
Subject: bug#18620: 25.0.50; cfengine3-make-syntax-cache
Date: Mon, 06 Oct 2014 22:31:09 -0400
[Message part 1 (text/plain, inline)]
On Fri, 03 Oct 2014 18:28:22 +0800 Leo Liu <sdl.web <at> gmail.com> wrote: 

LL> There are multiple problems with cfengine3-make-syntax-cache:

LL> 1. call-process-shell-command changed in trunk; simply replace it with
LL>    process-file.

LL> 2. it doesn't always return a `syntax' value

Thanks for catching this, I had not noticed it sooner. Please see the
patch below; does it work for you? If so I will commit and close the
bug.

LL> 3. cf-promises doesn't have -s option in Centos 6.5 (cfengine 3.3)

I think that's all right, we will default to the fallback syntax. The
`-s' option was added after 3.3 but IMO the fallback syntax is good
enough for all 3.x work.

(Unfortunately the Red Hat ecosystem has no CFEngine package maintainers
so to get the latest you have to install from the official CFEngine
package repo as directed by their website.)

Thanks
Ted

[18620-cfengine-syntax.patch (text/x-patch, inline)]
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2014-10-06 17:47:56 +0000
+++ lisp/ChangeLog	2014-10-07 02:18:14 +0000
@@ -1,3 +1,9 @@
+2014-10-07  Teodor Zlatanov  <tzz <at> lifelogs.com>
+
+	* progmodes/cfengine.el (cfengine3-make-syntax-cache): Use
+	`process-file' instead of `call-process-shell-command'.  Check if
+	the returned CFEngine syntax is reasonably valid (bug#18620).
+
 2014-10-06  Stefan Monnier  <monnier <at> iro.umontreal.ca>
 
 	* term/w32-win.el: Move all code from 32-common-fns.el here.

=== modified file 'lisp/progmodes/cfengine.el'
--- lisp/progmodes/cfengine.el	2014-01-30 07:42:57 +0000
+++ lisp/progmodes/cfengine.el	2014-10-07 02:15:16 +0000
@@ -1238,21 +1238,25 @@
         (or syntax
             (with-demoted-errors
                 (with-temp-buffer
-                  (call-process-shell-command cfengine-cf-promises
-                                              nil   ; no input
-                                              t     ; current buffer
-                                              nil   ; no redisplay
-                                              "-s" "json")
+                  (process-file cfengine-cf-promises
+                                nil   ; no input
+                                t     ; current buffer
+                                nil   ; no redisplay
+                                "-s" "json")
                   (goto-char (point-min))
                   (setq syntax (json-read))
-                  (setq cfengine-mode-syntax-cache
-                        (cons (cons cfengine-cf-promises syntax)
-                              cfengine-mode-syntax-cache))
-                  (setq cfengine-mode-syntax-functions-regex
-                        (regexp-opt (mapcar (lambda (def)
-                                              (format "%s" (car def)))
-                                            (cdr (assq 'functions syntax)))
-                                    'symbols))))))
+
+                  ;; if we got a valid syntax...
+                  (when (and (listp syntax)
+                             (assq 'functions syntax))
+                    (setq cfengine-mode-syntax-cache
+                          (cons (cons cfengine-cf-promises syntax)
+                                cfengine-mode-syntax-cache))
+                    (setq cfengine-mode-syntax-functions-regex
+                          (regexp-opt (mapcar (lambda (def)
+                                                (format "%s" (car def)))
+                                              (cdr (assq 'functions syntax)))
+                                      'symbols)))))))
     cfengine3-fallback-syntax))
 
 (defun cfengine3-documentation-function ()


This bug report was last modified 10 years and 230 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.