Function: xsdre-range-list-difference

xsdre-range-list-difference is a byte-compiled function defined in xsd-regexp.el.gz.

Signature

(xsdre-range-list-difference ORIG SUBTRACT)

Documentation

Return a range-list for the difference of two range-lists.

Source Code

;; Defined in /usr/src/emacs/lisp/nxml/xsd-regexp.el.gz
(defun xsdre-range-list-difference (orig subtract)
  "Return a range-list for the difference of two range-lists."
  (when orig
    (let (new head first last)
      (while orig
	(setq head (car orig))
	(setq first (xsdre-range-first head))
	(setq last (xsdre-range-last head))
	(while (and subtract
		    (< (xsdre-range-last (car subtract)) first))
	  (setq subtract (cdr subtract)))
	(while (and subtract
		    (<= first last)
		    (<= (xsdre-range-first (car subtract)) last))
	  (when (< first (xsdre-range-first (car subtract)))
	    (setq new
		  (cons (xsdre-make-range
			 first
			 (1- (xsdre-range-first (car subtract))))
			new)))
	  (if (< (xsdre-range-last (car subtract)) last)
	      (progn
		(setq first (1+ (xsdre-range-last (car subtract))))
		(setq subtract (cdr subtract)))
	    (setq first (1+ last))))
	(when (<= first last)
	  (setq new (cons (xsdre-make-range first last) new)))
	(setq orig (cdr orig)))
      (nreverse new))))