changeset: 4504:b82fdf7305eef16a68a94d48a5b532a589f0e55b
tag: tip
user: Aidan Kehoe <kehoea(a)parhasard.net>
date: Wed Aug 27 21:47:21 2008 +0200
files: lisp/ChangeLog lisp/subr.el tests/ChangeLog tests/automated/regexp-tests.el
description:
Correct the implementation, add a few basic tests for #'skip-chars-quote.
tests/ChangeLog addition:
2008-08-27 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/regexp-tests.el:
Add a few basic #'skip-chars-forward, #'skip-chars-backward
tests.
lisp/ChangeLog addition:
2008-08-27 Aidan Kehoe <kehoea(a)parhasard.net>
* subr.el (skip-chars-quote):
Correct the implementation, following the docstring of
#'skip-char-forward more closely rather than the documentation of
character classes in the Lispref.
diff -r af95657e0bfdbc887ab4900b5627cbaaf21e112a -r
b82fdf7305eef16a68a94d48a5b532a589f0e55b lisp/ChangeLog
--- a/lisp/ChangeLog Wed Aug 27 00:39:09 2008 +0200
+++ b/lisp/ChangeLog Wed Aug 27 21:47:21 2008 +0200
@@ -1,3 +1,10 @@ 2008-08-23 Aidan Kehoe <kehoea@parhasa
+2008-08-27 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * subr.el (skip-chars-quote):
+ Correct the implementation, following the docstring of
+ #'skip-char-forward more closely rather than the documentation of
+ character classes in the Lispref.
+
2008-08-23 Aidan Kehoe <kehoea(a)parhasard.net>
* custom.el: Move #'custom-variable-p to C, since it's now called
diff -r af95657e0bfdbc887ab4900b5627cbaaf21e112a -r
b82fdf7305eef16a68a94d48a5b532a589f0e55b lisp/subr.el
--- a/lisp/subr.el Wed Aug 27 00:39:09 2008 +0200
+++ b/lisp/subr.el Wed Aug 27 21:47:21 2008 +0200
@@ -1730,17 +1730,15 @@ Ranges and carets are not treated specia
Ranges and carets are not treated specially. This implementation is
in Lisp; do not use it in performance-critical code."
(let ((list (delete-duplicates (string-to-list string) :test #'=)))
- (when (equal list '((?- ?\[) (?\[ ?\-)))
- (error 'invalid-argument
- "Cannot create `skip-chars-forward' arg from string"
- string))
- (when (memq ?\] list)
- (setq list (cons ?\] (delq ?\] list))))
- (when (eq ?^ (car list))
- (setq list (nconc (cdr list) '(?^))))
- (when (memq ?- list)
- (setq list (delq ?- list)
- list (nconc list (list (second list) ?- (second list) ?-))))
+ (when (/= 1 (length list)) ;; No quoting needed in a string of length 1.
+ (when (eq ?^ (car list))
+ (setq list (nconc (cdr list) '(?^))))
+ (when (memq ?\\ list)
+ (setq list (delq ?\\ list)
+ list (nconc (list ?\\ ?\\) list)))
+ (when (memq ?- list)
+ (setq list (delq ?- list)
+ list (nconc list '(?\\ ?-)))))
(apply #'string list)))
;;; subr.el ends here
diff -r af95657e0bfdbc887ab4900b5627cbaaf21e112a -r
b82fdf7305eef16a68a94d48a5b532a589f0e55b tests/ChangeLog
--- a/tests/ChangeLog Wed Aug 27 00:39:09 2008 +0200
+++ b/tests/ChangeLog Wed Aug 27 21:47:21 2008 +0200
@@ -1,3 +1,9 @@ 2008-08-10 Aidan Kehoe <kehoea@parhasa
+2008-08-27 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * automated/regexp-tests.el:
+ Add a few basic #'skip-chars-forward, #'skip-chars-backward
+ tests.
+
2008-08-10 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/mule-tests.el (featurep): Update the list of character
diff -r af95657e0bfdbc887ab4900b5627cbaaf21e112a -r
b82fdf7305eef16a68a94d48a5b532a589f0e55b tests/automated/regexp-tests.el
--- a/tests/automated/regexp-tests.el Wed Aug 27 00:39:09 2008 +0200
+++ b/tests/automated/regexp-tests.el Wed Aug 27 21:47:21 2008 +0200
@@ -522,6 +522,22 @@ baaaa
2))
)))
+;; Not very comprehensive tests of skip-chars-forward, skip-chars-background:
+
+(with-string-as-buffer-contents
+ "-]-----------------------------][]]------------------------"
+ (skip-chars-forward (skip-chars-quote "-[]"))
+ (Assert (= (point) (point-max)))
+ (skip-chars-backward (skip-chars-quote "-[]"))
+ (Assert (= (point) (point-min)))
+ ;; Testing in passing for an old bug in #'skip-chars-forward where I
+ ;; thought it was impossible to call it with a string containing only ?-
+ ;; and ?]:
+ (Assert (= (skip-chars-forward (skip-chars-quote "-]"))
+ (position ?[ (buffer-string) :test #'=)))
+ ;; This used to error, incorrectly:
+ (Assert (skip-chars-quote "[-")))
+
;; replace-match (REPLACEMENT &optional FIXEDCASE LITERAL STRING STRBUFFER)
;; #### Write some tests! Much functionality is implicitly tested above
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches