commit 862d6438cfa6c6c035033697751f3d002357b024 (HEAD, refs/remotes/origin/master) Author: Tom Tromey Date: Sun Feb 5 11:40:18 2017 -0700 Recognize JS regexp literals more correctly Bug#25529 * lisp/progmodes/js.el (js--syntax-propertize-regexp-regexp): New constant. (js-syntax-propertize-regexp): Use it. Remove "end" argument. (js--syntax-propertize-regexp-syntax-table): Remove. (js-syntax-propertize): Update. * test/lisp/progmodes/js-tests.el (js-mode-regexp-syntax-bug-25529): New test. diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index e42e01481b..b42b2bca82 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -1687,29 +1687,36 @@ This performs fontification according to `js--class-styles'." js--font-lock-keywords-3) "Font lock keywords for `js-mode'. See `font-lock-keywords'.") -(defconst js--syntax-propertize-regexp-syntax-table - (let ((st (make-char-table 'syntax-table (string-to-syntax ".")))) - (modify-syntax-entry ?\[ "(]" st) - (modify-syntax-entry ?\] ")[" st) - (modify-syntax-entry ?\\ "\\" st) - st)) +(defconst js--syntax-propertize-regexp-regexp + (rx + ;; Start of regexp. + "/" + (0+ (or + ;; Match characters outside of a character class. + (not (any ?\[ ?/ ?\\)) + ;; Match backslash quoted characters. + (and "\\" not-newline) + ;; Match character class. + (and + "[" + (0+ (or + (not (any ?\] ?\\)) + (and "\\" not-newline))) + "]"))) + (group "/")) + "Regular expression matching a JavaScript regexp literal.") (defun js-syntax-propertize-regexp (end) (let ((ppss (syntax-ppss))) (when (eq (nth 3 ppss) ?/) ;; A /.../ regexp. - (while - (when (re-search-forward "\\(?:\\=\\|[^\\]\\)\\(?:\\\\\\\\\\)*/" - end 'move) - (if (nth 1 (with-syntax-table - js--syntax-propertize-regexp-syntax-table - (let ((parse-sexp-lookup-properties nil)) - (parse-partial-sexp (nth 8 ppss) (point))))) - ;; A / within a character class is not the end of a regexp. - t - (put-text-property (1- (point)) (point) - 'syntax-table (string-to-syntax "\"/")) - nil)))))) + (goto-char (nth 8 ppss)) + (when (and (looking-at js--syntax-propertize-regexp-regexp) + ;; Don't touch text after END. + (<= (match-end 1) end)) + (put-text-property (match-beginning 1) (match-end 1) + 'syntax-table (string-to-syntax "\"/")) + (goto-char (match-end 0)))))) (defun js-syntax-propertize (start end) ;; JavaScript allows immediate regular expression objects, written /.../. diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el index 7cb737c30e..d61f084e0d 100644 --- a/test/lisp/progmodes/js-tests.el +++ b/test/lisp/progmodes/js-tests.el @@ -23,6 +23,7 @@ (require 'ert) (require 'js) +(require 'syntax) (ert-deftest js-mode-fill-bug-19399 () (with-temp-buffer @@ -99,6 +100,22 @@ if (!/[ (:,='\"]/.test(value)) { (forward-line) (should (looking-at " \\* test")))) +(ert-deftest js-mode-regexp-syntax-bug-25529 () + (dolist (regexp-contents '("[^[]" + "[/]" + ;; A comment with the regexp on the next + ;; line. + "*comment*/\n/regexp")) + (with-temp-buffer + (js-mode) + (insert "let x = /" regexp-contents "/;\n") + (save-excursion (insert "something();\n")) + ;; The failure mode was that the regexp literal was not + ;; recognized, causing the next line to be given string syntax; + ;; but check for comment syntax as well to prevent an + ;; implementation not recognizing the comment example. + (should-not (syntax-ppss-context (syntax-ppss)))))) + (provide 'js-tests) ;;; js-tests.el ends here commit c2e19a73401eb37d5c13f6c8589dc1e5d706d239 Author: Tom Tromey Date: Sat Feb 11 08:43:33 2017 -0700 Fix bug in css--mdn-find-symbol * lisp/textmodes/css-mode.el (css--mdn-find-symbol): Skip whitespace before skipping word characters. test/lisp/textmodes/css-mode-tests.el (css-mdn-symbol-guessing): Add regression test. diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 19746c68e6..cd86db639a 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1190,8 +1190,10 @@ to look up will be substituted there." "A helper for `css-lookup-symbol' that finds the symbol at point. Returns the symbol, a string, or nil if none found." (save-excursion - ;; Skip backward over a word first. - (skip-chars-backward "-[:alnum:] \t") + ;; Skip any whitespace between the word and point. + (skip-chars-backward "- \t") + ;; Skip backward over a word. + (skip-chars-backward "-[:alnum:]") ;; Now skip ":" or "@" to see if it's a pseudo-element or at-id. (skip-chars-backward "@:") (if (looking-at css--mdn-symbol-regexp) diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index 5372c37a17..d601f43002 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -226,7 +226,8 @@ ("a:v" "isited" ":visited") ("border-" "color: red" "border-color") ("border-color: red" ";" "border-color") - ("border-color: red; color: green" ";" "color"))) + ("border-color: red; color: green" ";" "color") + (" border-collapse " ": collapse;" "border-collapse"))) (with-temp-buffer (css-mode) (insert (nth 0 item)) commit ac83b2dfe4504babfbafc5efb37dbde4bed34fed Author: Eli Zaretskii Date: Sat Feb 11 11:55:11 2017 +0200 Fix handling of XBM images on MS-Windows * src/image.c (xbm_load) [HAVE_NTGUI]: Fix calculation of 'nbytes' when inverting XBM data bits. (Bug#25661) diff --git a/src/image.c b/src/image.c index a7a9416528..1e8ebfd40d 100644 --- a/src/image.c +++ b/src/image.c @@ -3110,8 +3110,8 @@ xbm_load (struct frame *f, struct image *img) int nbytes, i; /* Windows mono bitmaps are reversed compared with X. */ invertedBits = bits; - nbytes = (img->width + CHAR_BIT - 1) / CHAR_BIT; - SAFE_NALLOCA (bits, nbytes, img->height); + nbytes = (img->width + CHAR_BIT - 1) / CHAR_BIT * img->height; + SAFE_NALLOCA (bits, 1, nbytes); for (i = 0; i < nbytes; i++) bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]); }