commit 5c158d1320c55ce7fcb01532ad9911f89930ba81 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Sat Feb 16 10:17:33 2019 -0800 * src/lread.c (readevalloop): Simplify via suffix_p. diff --git a/src/lread.c b/src/lread.c index ddef135687..6389e3ed48 100644 --- a/src/lread.c +++ b/src/lread.c @@ -1070,14 +1070,15 @@ This uses the variables `load-suffixes' and `load-file-rep-suffixes'. */) return Fnreverse (lst); } -/* Returns true if STRING ends with SUFFIX */ +/* Return true if STRING ends with SUFFIX. */ static bool suffix_p (Lisp_Object string, const char *suffix) { ptrdiff_t suffix_len = strlen (suffix); ptrdiff_t string_len = SBYTES (string); - return string_len >= suffix_len && !strcmp (SSDATA (string) + string_len - suffix_len, suffix); + return (suffix_len <= string_len + && strcmp (SSDATA (string) + string_len - suffix_len, suffix) == 0); } static void @@ -1932,9 +1933,7 @@ readevalloop (Lisp_Object readcharfun, Lisp_Object macroexpand = intern ("internal-macroexpand-for-load"); if (NILP (Ffboundp (macroexpand)) - || (STRINGP (sourcename) - && SBYTES (sourcename) >= 4 - && !strcmp (".elc", SSDATA (sourcename) + SBYTES (sourcename) - 4))) + || (STRINGP (sourcename) && suffix_p (sourcename, ".elc"))) /* Don't macroexpand before the corresponding function is defined and don't bother macroexpanding in .elc files, since it should have been done already. */ commit 2208c01264cb9fe95c857eb57dafa9ea8570b325 Author: Eli Zaretskii Date: Sat Feb 16 16:52:53 2019 +0200 * lisp/startup.el (load--user-init-file): Support early-init.elc as well. diff --git a/lisp/startup.el b/lisp/startup.el index 55ebd4d38c..a9b58c5e01 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -906,11 +906,17 @@ init-file, or to a default value if loading is not possible." ;; the name of the file that it loads into ;; `user-init-file'. (setq user-init-file t) - (load init-file-name 'noerror 'nomessage) + (load (if (equal (file-name-extension init-file-name) + "el") + (file-name-sans-extension init-file-name) + init-file-name) + 'noerror 'nomessage) (when (and (eq user-init-file t) alternate-filename-function) - (load (funcall alternate-filename-function) - 'noerror 'nomessage)) + (let ((alt-file (funcall alternate-filename-function))) + (and (equal (file-name-extension alt-file) "el") + (setq alt-file (file-name-sans-extension alt-file))) + (load alt-file 'noerror 'nomessage))) ;; If we did not find the user's init file, set ;; user-init-file conclusively. Don't let it be commit 6b7b85b60e76c5e867f77387e7c57d49f4c0a2cd Author: Stefan Monnier Date: Sat Feb 16 09:19:33 2019 -0500 * lisp/startup.el: Rename load-user-init-file Remove redundant :groups. (startup--load-user-init-file): Rename from load-user-init-file. diff --git a/lisp/startup.el b/lisp/startup.el index 112b9b2596..55ebd4d38c 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -60,8 +60,7 @@ string or function value that this variable has." (const :tag "Remember Mode notes buffer" remember-notes) (function :tag "Function") (const :tag "Lisp scratch buffer" t)) - :version "23.1" - :group 'initialization) + :version "23.1") (defvaralias 'inhibit-splash-screen 'inhibit-startup-screen) (defvaralias 'inhibit-startup-message 'inhibit-startup-screen) @@ -71,8 +70,7 @@ string or function value that this variable has." This is for use in your personal init file (but NOT site-start.el), once you are familiar with the contents of the startup screen." - :type 'boolean - :group 'initialization) + :type 'boolean) (defvar startup-screen-inhibit-startup-screen nil) @@ -101,18 +99,15 @@ instead: Thus, someone else using a copy of your init file will see the startup message unless he personally acts to inhibit it." :type '(choice (const :tag "Don't inhibit") - (string :tag "Enter your user name, to inhibit")) - :group 'initialization) + (string :tag "Enter your user name, to inhibit"))) (defcustom inhibit-default-init nil "Non-nil inhibits loading the `default' library." - :type 'boolean - :group 'initialization) + :type 'boolean) (defcustom inhibit-startup-buffer-menu nil "Non-nil inhibits display of buffer list when more than 2 files are loaded." - :type 'boolean - :group 'initialization) + :type 'boolean) (defvar command-switch-alist nil "Alist of command-line switches. @@ -336,8 +331,7 @@ is due to historical reasons, and does not reflect its purpose very well.)") (defcustom initial-major-mode 'lisp-interaction-mode "Major mode command symbol to use for the initial `*scratch*' buffer." - :type 'function - :group 'initialization) + :type 'function) (defvar init-file-user nil "Identity of user whose init file is or was read. @@ -376,7 +370,6 @@ it visible in the relevant context. However, actually customizing it is not allowed, since it would not work anyway. The only way to set this variable usefully is to set it while building and dumping Emacs." :type '(choice (const :tag "none" nil) string) - :group 'initialization :initialize #'custom-initialize-default :set (lambda (_variable _value) (error "Customizing `site-run-file' does not work"))) @@ -886,7 +879,7 @@ If STYLE is nil, display appropriately for the terminal." (when standard-display-table (aset standard-display-table char nil))))))) -(defun load-user-init-file +(defun startup--load-user-init-file (filename-function &optional alternate-filename-function load-defaults) "Load a user init-file. FILENAME-FUNCTION is called with no arguments and should return @@ -1164,11 +1157,11 @@ please check its value") :error)))) ;; Load the early init file, if found. - (load-user-init-file + (startup--load-user-init-file (lambda () (expand-file-name ;; We use an explicit .el extension here to force - ;; load-user-init-file to set user-init-file to "early-init.el", + ;; startup--load-user-init-file to set user-init-file to "early-init.el", ;; with the .el extension, if the file doesn't exist, not just ;; "early-init" without an extension, as it does for ".emacs". "early-init.el" @@ -1308,7 +1301,7 @@ please check its value") (load site-run-file t t))) ;; Load that user's init file, or the default one, or none. - (load-user-init-file + (startup--load-user-init-file (lambda () (cond ((eq system-type 'ms-dos) @@ -1481,8 +1474,7 @@ settings will be marked as \"CHANGED outside of Customize\"." "Initial documentation displayed in *scratch* buffer at startup. If this is nil, no message will be displayed." :type '(choice (text :tag "Message") - (const :tag "none" nil)) - :group 'initialization) + (const :tag "none" nil))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1636,13 +1628,13 @@ Each element in the list should be a list of strings or pairs (defgroup fancy-splash-screen () + ;; FIXME: Do we really need this group with a single custom var? "Fancy splash screen when Emacs starts." :version "21.1" :group 'initialization) (defcustom fancy-splash-image nil "The image to show in the splash screens, or nil for defaults." - :group 'fancy-splash-screen :type '(choice (const :tag "Default" nil) (file :tag "File"))) commit 478bbf7c80e71ff84f0e4e1363bf86e93d9c51c3 Author: Mattias Engdegård Date: Fri Feb 15 19:27:48 2019 +0100 Prevent over-eager rx character range condensation `rx' incorrectly considers character ranges between ASCII and raw bytes to cover all codes in-between, which includes all non-ASCII Unicode chars. This causes (any "\000-\377" ?Å) to be simplified to (any "\000-\377"), which is not at all the same thing: [\000-\377] really means [\000-\177\200-\377] (Bug#34492). * lisp/emacs-lisp/rx.el (rx-any-condense-range): Split ranges going from ASCII to raw bytes. * test/lisp/emacs-lisp/rx-tests.el (rx-char-any-raw-byte): Add test case. * etc/NEWS: Mention the overall change (Bug#33205). diff --git a/etc/NEWS b/etc/NEWS index 70a50c02c4..0cafbaae96 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1101,6 +1101,14 @@ subexpression. When there is no menu for a mode, display the mode name after the indicator instead of just the indicator (which is sometimes cryptic). +** rx + +--- +*** rx now handles raw bytes in character alternatives correctly, +when given in a string. Previously, '(any "\x80-\xff")' would match +characters U+0080...U+00FF. Now the expression matches raw bytes in +the 128...255 range, as expected. + * New Modes and Packages in Emacs 27.1 diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index b2299030a1..715cd608c4 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -429,6 +429,13 @@ Only both edges of each range is checked." ;; set L list of all ranges (mapc (lambda (e) (cond ((stringp e) (push e str)) ((numberp e) (push (cons e e) l)) + ;; Ranges between ASCII and raw bytes are split, + ;; to prevent accidental inclusion of Unicode + ;; characters later on. + ((and (<= (car e) #x7f) + (>= (cdr e) #x3fff80)) + (push (cons (car e) #x7f) l) + (push (cons #x3fff80 (cdr e)) l)) (t (push e l)))) args) ;; condense overlapped ranges in L diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index f15e1016f7..e14feda347 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el @@ -53,7 +53,11 @@ ;; Range of raw characters, multibyte. (should (equal (string-match-p (rx (any "Å\211\326-\377\177")) "XY\355\177\327") - 2))) + 2)) + ;; Split range; \177-\377ÿ should not be optimised to \177-\377. + (should (equal (string-match-p (rx (any "\177-\377" ?ÿ)) + "ÿA\310B") + 0))) (ert-deftest rx-pcase () (should (equal (pcase "a 1 2 3 1 1 b"