emacs-diffs
[Top][All Lists]
Advanced

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

master 482fa0d 5/5: Merge from origin/emacs-27


From: Glenn Morris
Subject: master 482fa0d 5/5: Merge from origin/emacs-27
Date: Wed, 9 Sep 2020 10:56:40 -0400 (EDT)

branch: master
commit 482fa0d9ed3d1b5ef6b95e908b5684a1f24cef4a
Merge: a5cc024 366a97c
Author: Glenn Morris <rgm@gnu.org>
Commit: Glenn Morris <rgm@gnu.org>

    Merge from origin/emacs-27
    
    366a97c980 (origin/emacs-27) Avoid crashes when trying to load bad GI...
    7938713105 C++ Mode: handle comma separated brace initializers.
    2b95300cf8 * lisp/display-fill-column-indicator.el: Fix bug#41145
---
 lisp/cus-dep.el                       |  2 +-
 lisp/display-fill-column-indicator.el |  4 ++-
 lisp/progmodes/cc-engine.el           | 53 +++++++++++++++++++++++------------
 lisp/progmodes/cc-langs.el            | 14 +++++++++
 src/image.c                           | 24 +++++++++-------
 5 files changed, 67 insertions(+), 30 deletions(-)

diff --git a/lisp/cus-dep.el b/lisp/cus-dep.el
index f1061a8..b1027ce 100644
--- a/lisp/cus-dep.el
+++ b/lisp/cus-dep.el
@@ -99,7 +99,7 @@ Usage: emacs -batch -l ./cus-dep.el -f 
custom-make-dependencies DIRS"
                   (setq name (intern name)))
               (condition-case nil
                   (while (re-search-forward
-                          "^(def\\(custom\\|face\\|group\\)" nil t)
+                          
"^(def\\(custom\\|face\\|group\\|ine\\(?:-globalized\\)?-minor-mode\\)" nil t)
                     (beginning-of-line)
                     (let ((type (match-string 1))
                          (expr (read (current-buffer))))
diff --git a/lisp/display-fill-column-indicator.el 
b/lisp/display-fill-column-indicator.el
index 3f947bd..3391aa3 100644
--- a/lisp/display-fill-column-indicator.el
+++ b/lisp/display-fill-column-indicator.el
@@ -73,7 +73,9 @@ See Info node `Displaying Boundaries' for details."
 
 ;;;###autoload
 (define-globalized-minor-mode global-display-fill-column-indicator-mode
-  display-fill-column-indicator-mode display-fill-column-indicator--turn-on)
+  display-fill-column-indicator-mode display-fill-column-indicator--turn-on
+  ;; See bug#41145
+  :group 'display-fill-column-indicator)
 
 (provide 'display-fill-column-indicator)
 
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 7b8b174..7ff424c 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -9102,7 +9102,7 @@ This function might do hidden buffer changes."
   (let
       ((cdd-pos (point)) cdd-next-pos cdd-id-start cdd-id-end
        cdd-decl-res cdd-got-func cdd-got-type cdd-got-init
-       c-last-identifier-range cdd-exhausted)
+       c-last-identifier-range cdd-exhausted cdd-after-block)
 
     ;; The following `while' applies `cdd-function' to a single declarator id
     ;; each time round.  It loops only when CDD-LIST is non-nil.
@@ -9155,23 +9155,25 @@ This function might do hidden buffer changes."
                 (c-forward-syntactic-ws cdd-limit)
               (setq cdd-exhausted t))) ; unbalanced parens
 
-           (cdd-got-init       ; "=" sign OR opening "(", "[", or "{"
-            ;; Skip an initializer expression.  If we're at a '='
-            ;; then accept a brace list directly after it to cope
-            ;; with array initializers.  Otherwise stop at braces
-            ;; to avoid going past full function and class blocks.
-            (if (and (if (and (eq cdd-got-init ?=)
-                              (= (c-forward-token-2 1 nil cdd-limit) 0)
-                              (looking-at "{"))
-                         (c-go-list-forward (point) cdd-limit)
-                       t)
-                     ;; FIXME: Should look for c-decl-end markers here;
-                     ;; we might go far into the following declarations
-                     ;; in e.g. ObjC mode (see e.g. methods-4.m).
-                     (c-syntactic-re-search-forward "[;,{]" cdd-limit 'move t))
+           (cdd-got-init               ; "=" sign OR opening "(", "[", or "("
+            ;; Skip an initializer expression in braces, whether or not (in
+            ;; C++ Mode) preceded by an "=".  Be careful that the brace list
+            ;; isn't a code block or a struct (etc.) block.
+            (cond
+             ((and (eq cdd-got-init ?=)
+                   (zerop (c-forward-token-2 1 nil  cdd-limit))
+                   (eq (char-after) ?{)
+                   (c-go-list-forward (point) cdd-limit)))
+             ((and (eq cdd-got-init ?{)
+                   c-recognize-bare-brace-inits
+                   (setq cdd-after-block
+                         (save-excursion
+                           (c-go-list-forward (point) cdd-limit)))
+                   (not (c-looking-at-statement-block)))
+              (goto-char cdd-after-block)))
+            (if (c-syntactic-re-search-forward "[;,{]" cdd-limit 'move t)
                 (backward-char)
-              (setq cdd-exhausted t)
-              ))
+              (setq cdd-exhausted t)))
 
            (t (c-forward-syntactic-ws cdd-limit)))
 
@@ -11749,7 +11751,22 @@ comment at the start of cc-engine.el for more info."
                           (save-excursion (c-backward-syntactic-ws) (point))
                           nil nil))
                    (and (consp res)
-                        (eq (car res) after-type-id-pos))))))
+                        (cond
+                         ((eq (car res) after-type-id-pos))
+                         ((> (car res) after-type-id-pos) nil)
+                         (t
+                          (catch 'find-decl
+                            (save-excursion
+                              (goto-char (car res))
+                              (c-do-declarators
+                               (point-max) t nil nil
+                               (lambda (id-start id-end tok not-top func init)
+                                 (cond
+                                  ((> id-start after-type-id-pos)
+                                   (throw 'find-decl nil))
+                                  ((eq id-start after-type-id-pos)
+                                   (throw 'find-decl t)))))
+                              nil)))))))))
          (cons bufpos (or in-paren inexpr-brace-list)))
         ((or (eq (char-after) ?\;)
              ;; Brace lists can't contain a semicolon, so we're done.
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index b77bf33..bf035c9 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -3701,6 +3701,20 @@ Foo bar = gnu;"
   c++ t)
 (c-lang-defvar c-recognize-paren-inits (c-lang-const c-recognize-paren-inits))
 
+(c-lang-defconst c-recognize-bare-brace-inits
+  "Non-nil means that brace initializers without \"=\" exist,
+i.e. constructs like
+
+int foo[] {1, 2, 3};
+
+in addition to the more classic
+
+int foo[] = {1, 2, 3};"
+  t nil
+  c++ t)
+(c-lang-defvar c-recognize-bare-brace-inits
+              (c-lang-const c-recognize-bare-brace-inits))
+
 (c-lang-defconst c-recognize-paren-inexpr-blocks
   "Non-nil to recognize gcc style in-expression blocks,
 i.e. compound statements surrounded by parentheses inside expressions."
diff --git a/src/image.c b/src/image.c
index d8c3466..6ecf6a7 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8276,11 +8276,13 @@ gif_load (struct frame *f, struct image *img)
       if (gif == NULL)
        {
 #if HAVE_GIFERRORSTRING
-         image_error ("Cannot open `%s': %s",
-                      file, build_string (GifErrorString (gif_err)));
-#else
-         image_error ("Cannot open `%s'", file);
+         const char *errstr = GifErrorString (gif_err);
+         if (errstr)
+           image_error ("Cannot open `%s': %s", file, build_string (errstr));
+         else
 #endif
+         image_error ("Cannot open `%s'", file);
+
          return 0;
        }
     }
@@ -8306,11 +8308,13 @@ gif_load (struct frame *f, struct image *img)
       if (!gif)
        {
 #if HAVE_GIFERRORSTRING
-         image_error ("Cannot open memory source `%s': %s",
-                      img->spec, build_string (GifErrorString (gif_err)));
-#else
-         image_error ("Cannot open memory source `%s'", img->spec);
+         const char *errstr = GifErrorString (gif_err);
+         if (errstr)
+           image_error ("Cannot open memory source `%s': %s",
+                        img->spec, build_string (errstr));
+         else
 #endif
+         image_error ("Cannot open memory source `%s'", img->spec);
          return 0;
        }
     }
@@ -8593,9 +8597,9 @@ gif_load (struct frame *f, struct image *img)
       if (error_text)
        image_error ("Error closing `%s': %s",
                     img->spec, build_string (error_text));
-#else
-      image_error ("Error closing `%s'", img->spec);
+      else
 #endif
+      image_error ("Error closing `%s'", img->spec);
     }
 
   /* Maybe fill in the background field while we have ximg handy. */



reply via email to

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