emacs-diffs
[Top][All Lists]
Advanced

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

feature/tramp-thread-safe 47156f1: Merge remote-tracking branch 'origin/


From: Michael Albinus
Subject: feature/tramp-thread-safe 47156f1: Merge remote-tracking branch 'origin/master' into feature/tramp-thread-safe
Date: Mon, 17 Feb 2020 03:57:36 -0500 (EST)

branch: feature/tramp-thread-safe
commit 47156f117b9cb2482733ba09ab46677cace601fe
Merge: ac98caa 556cc72
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Merge remote-tracking branch 'origin/master' into feature/tramp-thread-safe
---
 doc/lispref/searching.texi               |  9 ++---
 doc/lispref/variables.texi               |  4 +++
 etc/NEWS.27                              |  7 ----
 lisp/emacs-lisp/package.el               |  6 ++--
 lisp/emacs-lisp/regexp-opt.el            | 43 +++++------------------
 lisp/progmodes/cc-engine.el              | 58 +++++++++++++++-----------------
 lisp/progmodes/cc-langs.el               | 36 ++++++--------------
 lisp/progmodes/compile.el                |  7 ----
 lisp/sort.el                             | 17 +++++++---
 src/callproc.c                           |  5 +--
 src/editfns.c                            |  2 +-
 src/lread.c                              | 18 ++++++++++
 src/unexmacosx.c                         | 47 +++++++++++++-------------
 test/lisp/emacs-lisp/bytecomp-tests.el   | 11 ------
 test/lisp/emacs-lisp/regexp-opt-tests.el | 44 ++++--------------------
 15 files changed, 122 insertions(+), 192 deletions(-)

diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi
index 5f4509a..1f6db06 100644
--- a/doc/lispref/searching.texi
+++ b/doc/lispref/searching.texi
@@ -1745,7 +1745,7 @@ any special characters.
 @end defun
 
 @cindex optimize regexp
-@defun regexp-opt strings &optional paren keep-order
+@defun regexp-opt strings &optional paren
 This function returns an efficient regular expression that will match
 any of the strings in the list @var{strings}.  This is useful when you
 need to make matching or searching as fast as possible---for example,
@@ -1783,11 +1783,8 @@ if it is necessary to ensure that a postfix operator 
appended to
 it will apply to the whole expression.
 @end table
 
-The optional argument @var{keep-order}, if non-@code{nil}, forces the
-match to be performed in the order given, as if the strings were made
-into a regexp by joining them with the @samp{\|} operator.  If nil or
-omitted, the returned regexp will always match the longest string
-possible.
+The returned regexp is ordered in such a way that it will always match
+the longest string possible.
 
 Up to reordering, the resulting regexp of @code{regexp-opt} is
 equivalent to but usually more efficient than that of a simplified
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 1e35775..35eb4d5 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -1229,6 +1229,10 @@ This function returns non-@code{nil} if @var{symbol} is 
a special
 variable (i.e., it has a @code{defvar}, @code{defcustom}, or
 @code{defconst} variable definition).  Otherwise, the return value is
 @code{nil}.
+
+Note that since this is a function, it can only return
+non-@code{nil} for variables which are permanently special, but not
+for those that are only special in the current lexical scope.
 @end defun
 
   The use of a special variable as a formal argument in a function is
diff --git a/etc/NEWS.27 b/etc/NEWS.27
index 312869f..380ac71 100644
--- a/etc/NEWS.27
+++ b/etc/NEWS.27
@@ -3527,13 +3527,6 @@ This is currently supported on GNUish hosts and on 
modern versions of
 MS-Windows.
 
 +++
-** The function 'regexp-opt' accepts an additional optional argument.
-By default, the regexp returned by 'regexp-opt' may match the strings
-in any order.  If the new third argument is non-nil, the match is
-guaranteed to be performed in the order given, as if the strings were
-made into a regexp by joining them with '\|'.
-
-+++
 ** The function 'regexp-opt', when given an empty list of strings, now
 returns a regexp that never matches anything, which is an identity for
 this operation.  Previously, the empty string was returned in this
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index c4f7518..c91ee44 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2701,9 +2701,8 @@ either a full name or nil, and EMAIL is a valid email 
address."
     ["Help" package-menu-quick-help :help "Show short key binding help for 
package-menu-mode"]
     "--"
     ["Refresh Package List" revert-buffer
-     :help "Redownload the ELPA archive"
+     :help "Redownload the package archive(s)"
      :active (not package--downloads-in-progress)]
-    ["Redisplay buffer" revert-buffer :help "Update the buffer with current 
list of packages"]
     ["Execute Marked Actions" package-menu-execute :help "Perform all the 
marked actions"]
 
     "--"
@@ -3197,7 +3196,8 @@ The default regexp will hide only the package whose name 
is at point."
   (declare (interactive-only "change `package-hidden-regexps' instead."))
   (let* ((name (when (derived-mode-p 'package-menu-mode)
                  (concat "\\`" (regexp-quote (symbol-name (package-desc-name
-                                                           
(tabulated-list-get-id)))))))
+                                                           
(tabulated-list-get-id))))
+                         "\\'")))
          (re (read-string "Hide packages matching regexp: " name)))
     ;; Test if it is valid.
     (string-match re "")
diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el
index 2cce4e6..35a5fda 100644
--- a/lisp/emacs-lisp/regexp-opt.el
+++ b/lisp/emacs-lisp/regexp-opt.el
@@ -84,7 +84,7 @@
 ;;; Code:
 
 ;;;###autoload
-(defun regexp-opt (strings &optional paren keep-order)
+(defun regexp-opt (strings &optional paren)
   "Return a regexp to match a string in the list STRINGS.
 Each member of STRINGS is treated as a fixed string, not as a regexp.
 Optional PAREN specifies how the returned regexp is surrounded by
@@ -114,11 +114,8 @@ nil
     necessary to ensure that a postfix operator appended to it will
     apply to the whole expression.
 
-The optional argument KEEP-ORDER, if non-nil, forces the match to
-be performed in the order given, as if the strings were made into
-a regexp by joining them with the `\\|' operator.  If nil or
-omitted, the returned regexp is will always match the longest
-string possible.
+The returned regexp is ordered in such a way that it will always
+match the longest string possible.
 
 Up to reordering, the resulting regexp is equivalent to but
 usually more efficient than that of a simplified version:
@@ -140,34 +137,12 @@ usually more efficient than that of a simplified version:
           (completion-ignore-case nil)
           (completion-regexp-list nil)
           (open (cond ((stringp paren) paren) (paren "\\(")))
-          (re
-            (cond
-             ;; No strings: return an unmatchable regexp.
-             ((null strings)
-              (concat (or open "\\(?:") regexp-unmatchable "\\)"))
-
-             ;; The algorithm will generate a pattern that matches
-             ;; longer strings in the list before shorter.  If the
-             ;; list order matters, then no string must come after a
-             ;; proper prefix of that string.  To check this, verify
-             ;; that a straight or-pattern matches each string
-             ;; entirely.
-             ((and keep-order
-                   (let* ((case-fold-search nil)
-                          (alts (mapconcat #'regexp-quote strings "\\|")))
-                     (and (let ((s strings))
-                            (while (and s
-                                        (string-match alts (car s))
-                                        (= (match-end 0) (length (car s))))
-                              (setq s (cdr s)))
-                            ;; If we exited early, we found evidence that
-                            ;; regexp-opt-group cannot be used.
-                            s)
-                          (concat (or open "\\(?:") alts "\\)")))))
-             (t
-              (regexp-opt-group
-               (delete-dups (sort (copy-sequence strings) 'string-lessp))
-               (or open t) (not open))))))
+          (re (if strings
+                   (regexp-opt-group
+                    (delete-dups (sort (copy-sequence strings) 'string-lessp))
+                    (or open t) (not open))
+                 ;; No strings: return an unmatchable regexp.
+                 (concat (or open "\\(?:") regexp-unmatchable "\\)"))))
       (cond ((eq paren 'words)
             (concat "\\<" re "\\>"))
            ((eq paren 'symbols)
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 23fb1ef..0964c04 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -358,7 +358,8 @@ comment at the start of cc-engine.el for more info."
   "Go to the end of a preprocessor directive.
 More accurately, move the point to the end of the closest following
 line that doesn't end with a line continuation backslash - no check is
-done that the point is inside a cpp directive to begin with.
+done that the point is inside a cpp directive to begin with, although
+it is assumed that point isn't inside a comment or string.
 
 If LIM is provided, it is a limit position at which point is left
 if the end of the macro doesn't occur earlier.
@@ -379,35 +380,32 @@ comment at the start of cc-engine.el for more info."
              c-macro-cache-syntactic nil
              c-macro-cache-no-comment nil))
       (save-match-data
-       (while
-           (progn
-             (while (progn
-                      (end-of-line)
-                      (when (and (eq (char-before) ?\\)
-                                 (not (eobp)))
-                        (forward-char)
-                        t)))
-             (let ((cand-EOM (point)))
-               (if (and c-open-c-comment-on-logical-line-re
-                        (re-search-backward
-                         c-open-c-comment-on-logical-line-re
-                         nil t)
-                        (match-beginning 1)
-                        (progn
-                          (goto-char (match-beginning 1))
-                          (and (c-forward-single-comment)
-                               (> (point) cand-EOM))))
-                   t
-                 (goto-char cand-EOM)
-                 nil)))))
-
-      (when (and (car c-macro-cache)
-                (> (point) (car c-macro-cache)) ; in case we have a
-                                                ; zero-sized region.
-                (bolp)
-                (not (eq (char-before (1- (point))) ?\\)))
-       (setcdr c-macro-cache (point))
-       (setq c-macro-cache-syntactic nil)))))
+       (let ((safe-pos (point)))       ; a point ouside any literal.
+         ;; Move over stuff followed by a multiline block comment lacking
+         ;; escaped newlines each time around this loop.
+         (while
+             (progn
+               (while (progn
+                        (end-of-line)
+                        (when (and (eq (char-before) ?\\)
+                                   (not (eobp)))
+                          (forward-char)
+                          t)))
+               (let ((s (parse-partial-sexp safe-pos (point))))
+                 (when ;; Are we in a block comment?
+                     (and (nth 4 s) (not (nth 7 s)))
+                   (progn
+                     ;; Move to after the block comment.
+                     (parse-partial-sexp
+                      (point) (point-max) nil nil s 'syntax-table)
+                     (setq safe-pos (point)))))))
+
+         (when (and (car c-macro-cache)
+                    (> (point) (car c-macro-cache)) ; in case we have a
+                                       ; zero-sized region.
+                    (not (eq (char-before (1- (point))) ?\\)))
+           (setcdr c-macro-cache (point))
+           (setq c-macro-cache-syntactic nil)))))))
 
 (defun c-syntactic-end-of-macro ()
   ;; Go to the end of a CPP directive, or a "safe" pos just before.
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 6675617..e7e7cfd 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -1706,32 +1706,16 @@ ender."
 (c-lang-defvar c-last-c-comment-end-on-line-re
               (c-lang-const c-last-c-comment-end-on-line-re))
 
-(c-lang-defconst c-last-open-c-comment-start-on-line-re
-  "Do NOT use this constant any more.  Instead use
-`c-open-c-comment-on-logical-line-re' (2020-02-10).
-
-Regexp which matches the last block comment start on the
-current ine, if any, or nil in those languages without block
-comments.  When a match is found, submatch 1 contains the comment
-starter."
-  t "\\(/\\*\\)\\([^*]\\|\\*+\\([^*/]\\|$\\)\\)*$"
-  awk nil)
-(c-lang-defvar c-last-open-c-comment-start-on-line-re
-              (c-lang-const c-last-open-c-comment-start-on-line-re))
-(make-obsolete-variable 'c-last-open-c-comment-start-on-line-re
-                       'c-open-c-comment-on-logical-line-re
-                       "5.35")
-
-(c-lang-defconst c-open-c-comment-on-logical-line-re
-  "Regexp which matches an open block comment on the current logical line.
-It is intended for searching backwards from the end of a line.
-Such a search will stop at the first encountered non-escaped
-newline or open block comment.  If the comment is found, submatch
-1 contains the comment starter."
-t "[^\\\n][\r\n]\\|\\(/\\*\\)\\([^*]\\|\\*+\\([^*/]\\|$\\)\\)*$"
-awk nil)
-(c-lang-defvar c-open-c-comment-on-logical-line-re
-              (c-lang-const c-open-c-comment-on-logical-line-re))
+;; The following is no longer used (2020-02-16).
+;; (c-lang-defconst c-last-open-c-comment-start-on-line-re
+;;   "Regexp which matches the last block comment start on the
+;; current ine, if any, or nil in those languages without block
+;; comments.  When a match is found, submatch 1 contains the comment
+;; starter."
+;;   t "\\(/\\*\\)\\([^*]\\|\\*+\\([^*/]\\|$\\)\\)*$"
+;;   awk nil)
+;; (c-lang-defvar c-last-open-c-comment-start-on-line-re
+;;   (c-lang-const c-last-open-c-comment-start-on-line-re))
 
 (c-lang-defconst c-literal-start-regexp
   ;; Regexp to match the start of comments and string literals.
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index a7350f4..48ac85a 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -391,13 +391,6 @@ of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1))
     (mips-2
      " in \\([^()\n ]+\\)(\\([0-9]+\\))$" 1 2)
 
-    (msft
-     ;; The message may be a "warning", "error", or "fatal error" with
-     ;; an error code, or "see declaration of" without an error code.
-     "^ *\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \
-: \\(?:see declaration\\|\\(?:warnin\\(g\\)\\|[a-z ]+\\) C[0-9]+:\\)"
-     2 3 nil (4))
-
     (omake
      ;; "omake -P" reports "file foo changed"
      ;; (useful if you do "cvs up" and want to see what has changed)
diff --git a/lisp/sort.el b/lisp/sort.el
index 40347e6..e4ff2af 100644
--- a/lisp/sort.el
+++ b/lisp/sort.el
@@ -544,23 +544,30 @@ Use \\[untabify] to convert tabs to spaces before 
sorting."
 ;;;###autoload
 (defun reverse-region (beg end)
   "Reverse the order of lines in a region.
-From a program takes two point or marker arguments, BEG and END."
+When called from Lisp, takes two point or marker arguments, BEG and END.
+If BEG is not at the beginning of a line, the first line of those
+to be reversed is the line starting after BEG.
+If END is not at the end of a line, the last line to be reversed
+is the one that ends before END."
   (interactive "r")
   (if (> beg end)
       (let (mid) (setq mid end end beg beg mid)))
   (save-excursion
-    ;; put beg at the start of a line and end and the end of one --
-    ;; the largest possible region which fits this criteria
+    (when (or (< (line-beginning-position) beg)
+              (< end (line-end-position)))
+      (user-error "There are no full lines in the region"))
+    ;; Put beg at the start of a line and end and the end of one --
+    ;; the largest possible region which fits this criteria.
     (goto-char beg)
     (or (bolp) (forward-line 1))
     (setq beg (point))
     (goto-char end)
-    ;; the test for bolp is for those times when end is on an empty line;
+    ;; The test for bolp is for those times when end is on an empty line;
     ;; it is probably not the case that the line should be included in the
     ;; reversal; it isn't difficult to add it afterward.
     (or (and (eolp) (not (bolp))) (progn (forward-line -1) (end-of-line)))
     (setq end (point-marker))
-    ;; the real work.  this thing cranks through memory on large regions.
+    ;; The real work.  This thing cranks through memory on large regions.
     (let (ll (do t))
       (while do
        (goto-char beg)
diff --git a/src/callproc.c b/src/callproc.c
index 07dcc4c..8883415 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -811,7 +811,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int 
filefd,
                   && ! CODING_MAY_REQUIRE_DECODING (&process_coding))
             {
               insert_1_both (buf, nread, nread, 0, 0, 0);
-              signal_after_change (PT, 0, nread);
+              signal_after_change (PT - nread, 0, nread);
             }
          else
            {                   /* We have to decode the input.  */
@@ -854,7 +854,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int 
filefd,
 
              TEMP_SET_PT_BOTH (PT + process_coding.produced_char,
                                PT_BYTE + process_coding.produced);
-              signal_after_change (PT, 0, process_coding.produced_char);
+              signal_after_change (PT - process_coding.produced_char,
+                                   0, process_coding.produced_char);
              carryover = process_coding.carryover_bytes;
              if (carryover > 0)
                memcpy (buf, process_coding.carryover,
diff --git a/src/editfns.c b/src/editfns.c
index 05ad392..ddf190b 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -863,7 +863,7 @@ instead.
 This does not take narrowing into account; to count the number of
 characters in the accessible portion of the current buffer, use
 `(- (point-max) (point-min))', and to count the number of characters
-in some other BUFFER, use
+in the accessible portion of some other BUFFER, use
 `(with-current-buffer BUFFER (- (point-max) (point-min)))'.  */)
   (Lisp_Object buffer)
 {
diff --git a/src/lread.c b/src/lread.c
index c124d5a..70984d3 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2974,6 +2974,24 @@ read1 (Lisp_Object readcharfun, int *pch, bool 
first_in_list)
          vec = XVECTOR (tmp);
          if (vec->header.size == 0)
            invalid_syntax ("Empty byte-code object");
+
+         if (COMPILED_DOC_STRING < vec->header.size
+             && EQ (AREF (tmp, COMPILED_DOC_STRING), make_fixnum (0)))
+           {
+             /* read_list found a docstring like '(#$ . 5521)' and treated it
+                as 0.  This placeholder 0 would lead to accidental sharing in
+                purecopy's hash-consing, so replace it with a (hopefully)
+                unique integer placeholder, which is negative so that it is
+                not confused with a DOC file offset (the USE_LSB_TAG shift
+                relies on the fact that VALMASK is one bit narrower than
+                INTMASK).  Eventually Snarf-documentation should replace the
+                placeholder with the actual docstring.  */
+             verify (INTMASK & ~VALMASK);
+             EMACS_UINT hash = ((XHASH (tmp) >> USE_LSB_TAG)
+                                | (INTMASK - INTMASK / 2));
+             ASET (tmp, COMPILED_DOC_STRING, make_ufixnum (hash));
+           }
+
          make_byte_code (vec);
          return tmp;
        }
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index 8d13241..59cbe3c 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -503,22 +503,34 @@ unexec_regions_sort_compare (const void *a, const void *b)
 static void
 unexec_regions_merge (void)
 {
-  int i, n;
-  unexec_region_info r;
-  vm_size_t padsize;
-
   qsort (unexec_regions, num_unexec_regions, sizeof (unexec_regions[0]),
         &unexec_regions_sort_compare);
-  n = 0;
-  r = unexec_regions[0];
-  padsize = r.range.address & (pagesize - 1);
-  if (padsize)
+
+  /* Align each region start address to a page boundary.  */
+  for (unexec_region_info *cur = unexec_regions;
+       cur < unexec_regions + num_unexec_regions; cur++)
     {
-      r.range.address -= padsize;
-      r.range.size += padsize;
-      r.filesize += padsize;
+      vm_size_t padsize = cur->range.address & (pagesize - 1);
+      if (padsize)
+       {
+         cur->range.address -= padsize;
+         cur->range.size += padsize;
+         cur->filesize += padsize;
+
+         unexec_region_info *prev = cur == unexec_regions ? NULL : cur - 1;
+         if (prev
+             && prev->range.address + prev->range.size > cur->range.address)
+           {
+             prev->range.size = cur->range.address - prev->range.address;
+             if (prev->filesize > prev->range.size)
+               prev->filesize = prev->range.size;
+           }
+       }
     }
-  for (i = 1; i < num_unexec_regions; i++)
+
+  int n = 0;
+  unexec_region_info r = unexec_regions[0];
+  for (int i = 1; i < num_unexec_regions; i++)
     {
       if (r.range.address + r.range.size == unexec_regions[i].range.address
          && r.range.size - r.filesize < 2 * pagesize)
@@ -530,17 +542,6 @@ unexec_regions_merge (void)
        {
          unexec_regions[n++] = r;
          r = unexec_regions[i];
-         padsize = r.range.address & (pagesize - 1);
-         if (padsize)
-           {
-             if ((unexec_regions[n-1].range.address
-                  + unexec_regions[n-1].range.size) == r.range.address)
-               unexec_regions[n-1].range.size -= padsize;
-
-             r.range.address -= padsize;
-             r.range.size += padsize;
-             r.filesize += padsize;
-           }
        }
     }
   unexec_regions[n++] = r;
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el 
b/test/lisp/emacs-lisp/bytecomp-tests.el
index a16adfe..de11ae2 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -615,17 +615,6 @@ literals (Bug#20852)."
         (let ((byte-compile-dest-file-function (lambda (_) destination)))
           (should (byte-compile-file source)))))))
 
-(ert-deftest bytecomp-tests--old-style-backquotes ()
-  "Check that byte compiling warns about old-style backquotes."
-  (bytecomp-tests--with-temp-file source
-    (write-region "(` (a b))" nil source)
-    (bytecomp-tests--with-temp-file destination
-      (let* ((byte-compile-dest-file-function (lambda (_) destination))
-             (byte-compile-debug t)
-             (err (should-error (byte-compile-file source))))
-        (should (equal (cdr err) '("Old-style backquotes detected!")))))))
-
-
 (ert-deftest bytecomp-tests-function-put ()
   "Check `function-put' operates during compilation."
   (bytecomp-tests--with-temp-file source
diff --git a/test/lisp/emacs-lisp/regexp-opt-tests.el 
b/test/lisp/emacs-lisp/regexp-opt-tests.el
index 9b4567c..0179ac4 100644
--- a/test/lisp/emacs-lisp/regexp-opt-tests.el
+++ b/test/lisp/emacs-lisp/regexp-opt-tests.el
@@ -47,43 +47,13 @@
   (mapcar (lambda (i) (regexp-opt-test--permutation i list))
           (number-sequence 0 (1- (regexp-opt-test--factorial (length list))))))
 
-(defun regexp-opt-test--match-all (words re)
-  (mapcar (lambda (w) (and (string-match re w)
-                           (match-string 0 w)))
-          words))
-
-(defun regexp-opt-test--check-perm (perm)
-  (let* ((ref-re (mapconcat #'regexp-quote perm "\\|"))
-         (opt-re (regexp-opt perm nil t))
-         (ref (regexp-opt-test--match-all perm ref-re))
-         (opt (regexp-opt-test--match-all perm opt-re)))
-    (equal opt ref)))
-
-(defun regexp-opt-test--explain-perm (perm)
-  (let* ((ref-re (mapconcat #'regexp-quote perm "\\|"))
-         (opt-re (regexp-opt perm nil t))
-         (ref (regexp-opt-test--match-all perm ref-re))
-         (opt (regexp-opt-test--match-all perm opt-re)))
-    (concat "\n"
-            (format "Naïve regexp:     %s\n" ref-re)
-            (format "Optimized regexp: %s\n" opt-re)
-            (format "Got:      %s\n" opt)
-            (format "Expected: %s\n" ref))))
-
-(put 'regexp-opt-test--check-perm 'ert-explainer 
'regexp-opt-test--explain-perm)
-
-(ert-deftest regexp-opt-keep-order ()
-  "Check that KEEP-ORDER works."
-  (dolist (perm (regexp-opt-test--permutations '("abc" "bca" "cab")))
-    (should (regexp-opt-test--check-perm perm)))
-  (dolist (perm (regexp-opt-test--permutations '("abc" "ab" "bca" "bc")))
-    (should (regexp-opt-test--check-perm perm)))
-  (dolist (perm (regexp-opt-test--permutations '("abxy" "cdxy")))
-    (should (regexp-opt-test--check-perm perm)))
-  (dolist (perm (regexp-opt-test--permutations '("afgx" "bfgx" "afgy" "bfgy")))
-    (should (regexp-opt-test--check-perm perm)))
-  (dolist (perm (regexp-opt-test--permutations '("a" "ab" "ac" "abc")))
-    (should (regexp-opt-test--check-perm perm))))
+(ert-deftest regexp-opt-longest-match ()
+  "Check that the regexp always matches as much as possible."
+  (let ((s "abcd"))
+    (dolist (perm (regexp-opt-test--permutations '("a" "ab" "ac" "abc")))
+      (should (equal (and (string-match (regexp-opt perm) s)
+                          (match-string 0 s))
+                     "abc")))))
 
 (ert-deftest regexp-opt-charset ()
   (should (equal (regexp-opt-charset '(?a ?b ?a)) "[ab]"))



reply via email to

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