comparison lisp/emacs-lisp/rx.el @ 69266:a080fc579e98

(rx-check-any, rx-check-not): Quote "]"s in regexps when they have no special meaning.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 03 Mar 2006 12:19:21 +0000
parents 067115a6e738
children 7a3f13e2dd57 a7364c1a561e
comparison
equal deleted inserted replaced
69265:268da31ddfc5 69266:a080fc579e98
370 (error "String arg for Rx `any' must not be empty")) 370 (error "String arg for Rx `any' must not be empty"))
371 ;; Quote ^ at start; don't bother to check whether this is first arg. 371 ;; Quote ^ at start; don't bother to check whether this is first arg.
372 (if (eq ?^ (aref arg 0)) 372 (if (eq ?^ (aref arg 0))
373 (setq arg (concat "\\" arg))) 373 (setq arg (concat "\\" arg)))
374 ;; Remove ] and set flag for adding it to start of overall result. 374 ;; Remove ] and set flag for adding it to start of overall result.
375 (when (string-match "]" arg) 375 (when (string-match "\\]" arg)
376 (setq arg (replace-regexp-in-string "]" "" arg) 376 (setq arg (replace-regexp-in-string "\\]" "" arg)
377 rx-bracket "]"))) 377 rx-bracket "]")))
378 (when (symbolp arg) 378 (when (symbolp arg)
379 (let ((translation (condition-case nil 379 (let ((translation (condition-case nil
380 (rx-to-string arg 'no-group) 380 (rx-to-string arg 'no-group)
381 (error nil)))) 381 (error nil))))
403 403
404 404
405 (defun rx-check-not (arg) 405 (defun rx-check-not (arg)
406 "Check arg ARG for Rx `not'." 406 "Check arg ARG for Rx `not'."
407 (unless (or (and (symbolp arg) 407 (unless (or (and (symbolp arg)
408 (string-match "\\`\\[\\[:[-a-z]:]]\\'" 408 (string-match "\\`\\[\\[:[-a-z]:\\]\\]\\'"
409 (condition-case nil 409 (condition-case nil
410 (rx-to-string arg 'no-group) 410 (rx-to-string arg 'no-group)
411 (error "")))) 411 (error ""))))
412 (eq arg 'word-boundary) 412 (eq arg 'word-boundary)
413 (and (consp arg) 413 (and (consp arg)