emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/emacs-lisp/regexp-opt.el [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/emacs-lisp/regexp-opt.el [lexbind]
Date: Tue, 14 Oct 2003 19:32:26 -0400

Index: emacs/lisp/emacs-lisp/regexp-opt.el
diff -c emacs/lisp/emacs-lisp/regexp-opt.el:1.20.4.1 
emacs/lisp/emacs-lisp/regexp-opt.el:1.20.4.2
*** emacs/lisp/emacs-lisp/regexp-opt.el:1.20.4.1        Fri Apr  4 01:20:16 2003
--- emacs/lisp/emacs-lisp/regexp-opt.el Tue Oct 14 19:32:21 2003
***************
*** 110,115 ****
--- 110,133 ----
           (re (regexp-opt-group sorted-strings open)))
        (if words (concat "\\<" re "\\>") re))))
  
+ (defconst regexp-opt-not-groupie*-re
+   (let* ((harmless-ch "[^\\\\[]")
+          (esc-pair-not-lp "\\\\[^(]")
+          (class-harmless-ch "[^][]")
+          (class-lb-harmless "[^]:]")
+          (class-lb-colon-maybe-charclass ":\\([a-z]+:]\\)?")
+          (class-lb (concat "\\[\\(" class-lb-harmless
+                            "\\|" class-lb-colon-maybe-charclass "\\)"))
+          (class
+           (concat "\\[^?]?"
+                   "\\(" class-harmless-ch
+                   "\\|" class-lb "\\)*"
+                   "\\[?]"))         ; special handling for bare [ at end of re
+          (shy-lp "\\\\(\\?:"))
+     (concat "\\(" harmless-ch "\\|" esc-pair-not-lp
+             "\\|" class "\\|" shy-lp "\\)*"))
+   "Matches any part of a regular expression EXCEPT for non-shy \"\\\\(\"s")
+ 
  ;;;###autoload
  (defun regexp-opt-depth (regexp)
    "Return the depth of REGEXP.
***************
*** 120,130 ****
      (string-match regexp "")
      ;; Count the number of open parentheses in REGEXP.
      (let ((count 0) start)
!       (while (string-match "\\(\\`\\|[^\\]\\)\\\\\\(\\\\\\\\\\)*([^?]"
!                          regexp start)
!       (setq count (1+ count)
!             ;; Go back 2 chars (one for [^?] and one for [^\\]).
!             start (- (match-end 0) 2)))
        count)))
  
  ;;; Workhorse functions.
--- 138,149 ----
      (string-match regexp "")
      ;; Count the number of open parentheses in REGEXP.
      (let ((count 0) start)
!       (while
!           (progn
!             (string-match regexp-opt-not-groupie*-re regexp start)
!             (setq start ( + (match-end 0) 2))  ; +2 for "\\(" after match-end.
!             (<= start (length regexp)))
!         (setq count (1+ count)))
        count)))
  
  ;;; Workhorse functions.
***************
*** 280,283 ****
--- 299,303 ----
  
  (provide 'regexp-opt)
  
+ ;;; arch-tag: 6c5a66f4-29af-4fd6-8c3b-4b554d5b4370
  ;;; regexp-opt.el ends here




reply via email to

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