aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2020-09-09 07:51:14 -0700
committerGlenn Morris2020-09-09 07:51:14 -0700
commit482fa0d9ed3d1b5ef6b95e908b5684a1f24cef4a (patch)
tree3734bdc916a9895eed4dfbe2fbc05bb2597f38d4
parenta5cc0242ebe174152a1488ddec26210f404fdd0f (diff)
parent366a97c980f068a3ed665d337d644ee58cd25ca0 (diff)
downloademacs-482fa0d9ed3d1b5ef6b95e908b5684a1f24cef4a.tar.gz
emacs-482fa0d9ed3d1b5ef6b95e908b5684a1f24cef4a.zip
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
-rw-r--r--lisp/cus-dep.el2
-rw-r--r--lisp/display-fill-column-indicator.el4
-rw-r--r--lisp/progmodes/cc-engine.el53
-rw-r--r--lisp/progmodes/cc-langs.el14
-rw-r--r--src/image.c24
5 files changed, 67 insertions, 30 deletions
diff --git a/lisp/cus-dep.el b/lisp/cus-dep.el
index f1061a8621b..b1027ce34f9 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"
99 (setq name (intern name))) 99 (setq name (intern name)))
100 (condition-case nil 100 (condition-case nil
101 (while (re-search-forward 101 (while (re-search-forward
102 "^(def\\(custom\\|face\\|group\\)" nil t) 102 "^(def\\(custom\\|face\\|group\\|ine\\(?:-globalized\\)?-minor-mode\\)" nil t)
103 (beginning-of-line) 103 (beginning-of-line)
104 (let ((type (match-string 1)) 104 (let ((type (match-string 1))
105 (expr (read (current-buffer)))) 105 (expr (read (current-buffer))))
diff --git a/lisp/display-fill-column-indicator.el b/lisp/display-fill-column-indicator.el
index 3f947bdc1c9..3391aa371b7 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."
73 73
74;;;###autoload 74;;;###autoload
75(define-globalized-minor-mode global-display-fill-column-indicator-mode 75(define-globalized-minor-mode global-display-fill-column-indicator-mode
76 display-fill-column-indicator-mode display-fill-column-indicator--turn-on) 76 display-fill-column-indicator-mode display-fill-column-indicator--turn-on
77 ;; See bug#41145
78 :group 'display-fill-column-indicator)
77 79
78(provide 'display-fill-column-indicator) 80(provide 'display-fill-column-indicator)
79 81
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 7b8b174c430..7ff424c6a7e 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -9102,7 +9102,7 @@ This function might do hidden buffer changes."
9102 (let 9102 (let
9103 ((cdd-pos (point)) cdd-next-pos cdd-id-start cdd-id-end 9103 ((cdd-pos (point)) cdd-next-pos cdd-id-start cdd-id-end
9104 cdd-decl-res cdd-got-func cdd-got-type cdd-got-init 9104 cdd-decl-res cdd-got-func cdd-got-type cdd-got-init
9105 c-last-identifier-range cdd-exhausted) 9105 c-last-identifier-range cdd-exhausted cdd-after-block)
9106 9106
9107 ;; The following `while' applies `cdd-function' to a single declarator id 9107 ;; The following `while' applies `cdd-function' to a single declarator id
9108 ;; each time round. It loops only when CDD-LIST is non-nil. 9108 ;; each time round. It loops only when CDD-LIST is non-nil.
@@ -9155,23 +9155,25 @@ This function might do hidden buffer changes."
9155 (c-forward-syntactic-ws cdd-limit) 9155 (c-forward-syntactic-ws cdd-limit)
9156 (setq cdd-exhausted t))) ; unbalanced parens 9156 (setq cdd-exhausted t))) ; unbalanced parens
9157 9157
9158 (cdd-got-init ; "=" sign OR opening "(", "[", or "{" 9158 (cdd-got-init ; "=" sign OR opening "(", "[", or "("
9159 ;; Skip an initializer expression. If we're at a '=' 9159 ;; Skip an initializer expression in braces, whether or not (in
9160 ;; then accept a brace list directly after it to cope 9160 ;; C++ Mode) preceded by an "=". Be careful that the brace list
9161 ;; with array initializers. Otherwise stop at braces 9161 ;; isn't a code block or a struct (etc.) block.
9162 ;; to avoid going past full function and class blocks. 9162 (cond
9163 (if (and (if (and (eq cdd-got-init ?=) 9163 ((and (eq cdd-got-init ?=)
9164 (= (c-forward-token-2 1 nil cdd-limit) 0) 9164 (zerop (c-forward-token-2 1 nil cdd-limit))
9165 (looking-at "{")) 9165 (eq (char-after) ?{)
9166 (c-go-list-forward (point) cdd-limit) 9166 (c-go-list-forward (point) cdd-limit)))
9167 t) 9167 ((and (eq cdd-got-init ?{)
9168 ;; FIXME: Should look for c-decl-end markers here; 9168 c-recognize-bare-brace-inits
9169 ;; we might go far into the following declarations 9169 (setq cdd-after-block
9170 ;; in e.g. ObjC mode (see e.g. methods-4.m). 9170 (save-excursion
9171 (c-syntactic-re-search-forward "[;,{]" cdd-limit 'move t)) 9171 (c-go-list-forward (point) cdd-limit)))
9172 (not (c-looking-at-statement-block)))
9173 (goto-char cdd-after-block)))
9174 (if (c-syntactic-re-search-forward "[;,{]" cdd-limit 'move t)
9172 (backward-char) 9175 (backward-char)
9173 (setq cdd-exhausted t) 9176 (setq cdd-exhausted t)))
9174 ))
9175 9177
9176 (t (c-forward-syntactic-ws cdd-limit))) 9178 (t (c-forward-syntactic-ws cdd-limit)))
9177 9179
@@ -11749,7 +11751,22 @@ comment at the start of cc-engine.el for more info."
11749 (save-excursion (c-backward-syntactic-ws) (point)) 11751 (save-excursion (c-backward-syntactic-ws) (point))
11750 nil nil)) 11752 nil nil))
11751 (and (consp res) 11753 (and (consp res)
11752 (eq (car res) after-type-id-pos)))))) 11754 (cond
11755 ((eq (car res) after-type-id-pos))
11756 ((> (car res) after-type-id-pos) nil)
11757 (t
11758 (catch 'find-decl
11759 (save-excursion
11760 (goto-char (car res))
11761 (c-do-declarators
11762 (point-max) t nil nil
11763 (lambda (id-start id-end tok not-top func init)
11764 (cond
11765 ((> id-start after-type-id-pos)
11766 (throw 'find-decl nil))
11767 ((eq id-start after-type-id-pos)
11768 (throw 'find-decl t)))))
11769 nil)))))))))
11753 (cons bufpos (or in-paren inexpr-brace-list))) 11770 (cons bufpos (or in-paren inexpr-brace-list)))
11754 ((or (eq (char-after) ?\;) 11771 ((or (eq (char-after) ?\;)
11755 ;; Brace lists can't contain a semicolon, so we're done. 11772 ;; 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 b77bf3303b6..bf035c9a9e3 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -3701,6 +3701,20 @@ Foo bar = gnu;"
3701 c++ t) 3701 c++ t)
3702(c-lang-defvar c-recognize-paren-inits (c-lang-const c-recognize-paren-inits)) 3702(c-lang-defvar c-recognize-paren-inits (c-lang-const c-recognize-paren-inits))
3703 3703
3704(c-lang-defconst c-recognize-bare-brace-inits
3705 "Non-nil means that brace initializers without \"=\" exist,
3706i.e. constructs like
3707
3708int foo[] {1, 2, 3};
3709
3710in addition to the more classic
3711
3712int foo[] = {1, 2, 3};"
3713 t nil
3714 c++ t)
3715(c-lang-defvar c-recognize-bare-brace-inits
3716 (c-lang-const c-recognize-bare-brace-inits))
3717
3704(c-lang-defconst c-recognize-paren-inexpr-blocks 3718(c-lang-defconst c-recognize-paren-inexpr-blocks
3705 "Non-nil to recognize gcc style in-expression blocks, 3719 "Non-nil to recognize gcc style in-expression blocks,
3706i.e. compound statements surrounded by parentheses inside expressions." 3720i.e. compound statements surrounded by parentheses inside expressions."
diff --git a/src/image.c b/src/image.c
index d8c34669cc4..6ecf6a70fe2 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8276,11 +8276,13 @@ gif_load (struct frame *f, struct image *img)
8276 if (gif == NULL) 8276 if (gif == NULL)
8277 { 8277 {
8278#if HAVE_GIFERRORSTRING 8278#if HAVE_GIFERRORSTRING
8279 image_error ("Cannot open `%s': %s", 8279 const char *errstr = GifErrorString (gif_err);
8280 file, build_string (GifErrorString (gif_err))); 8280 if (errstr)
8281#else 8281 image_error ("Cannot open `%s': %s", file, build_string (errstr));
8282 image_error ("Cannot open `%s'", file); 8282 else
8283#endif 8283#endif
8284 image_error ("Cannot open `%s'", file);
8285
8284 return 0; 8286 return 0;
8285 } 8287 }
8286 } 8288 }
@@ -8306,11 +8308,13 @@ gif_load (struct frame *f, struct image *img)
8306 if (!gif) 8308 if (!gif)
8307 { 8309 {
8308#if HAVE_GIFERRORSTRING 8310#if HAVE_GIFERRORSTRING
8309 image_error ("Cannot open memory source `%s': %s", 8311 const char *errstr = GifErrorString (gif_err);
8310 img->spec, build_string (GifErrorString (gif_err))); 8312 if (errstr)
8311#else 8313 image_error ("Cannot open memory source `%s': %s",
8312 image_error ("Cannot open memory source `%s'", img->spec); 8314 img->spec, build_string (errstr));
8315 else
8313#endif 8316#endif
8317 image_error ("Cannot open memory source `%s'", img->spec);
8314 return 0; 8318 return 0;
8315 } 8319 }
8316 } 8320 }
@@ -8593,9 +8597,9 @@ gif_load (struct frame *f, struct image *img)
8593 if (error_text) 8597 if (error_text)
8594 image_error ("Error closing `%s': %s", 8598 image_error ("Error closing `%s': %s",
8595 img->spec, build_string (error_text)); 8599 img->spec, build_string (error_text));
8596#else 8600 else
8597 image_error ("Error closing `%s'", img->spec);
8598#endif 8601#endif
8602 image_error ("Error closing `%s'", img->spec);
8599 } 8603 }
8600 8604
8601 /* Maybe fill in the background field while we have ximg handy. */ 8605 /* Maybe fill in the background field while we have ximg handy. */