Function: detect-circular-map-nesting

Documentation

Detects circular and undefined url mappings.

Source

(defun detect-circular-map-nesting (urlmap)
  "Detects circular and undefined url mappings."
  (let ((*all-maps* (make-hash-table)))
    (labels ((rec-test (urlmap2)
	       (if urlmap2
		   (dolist (map-name (get-nest-map-names urlmap2))
		     (let ((nested-urlmap (get-urlmap map-name)))
		       (cond ((null nested-urlmap)
			      (error 'wisp-undefined-nested-urlmap
				     :nested-map map-name
				     :root-map urlmap))
			     ((gethash nested-urlmap *all-maps*)
			      (error 'wisp-circular-nested-urlmap
				     :circular-map nested-urlmap
				     :parent-map urlmap2
				     :root-map urlmap))
			     (t (setf (gethash nested-urlmap *all-maps*) t)
				;; recursively test for cicularity
				(dolist (map-name (get-nest-map-names nested-urlmap))
				  (aif (get-urlmap map-name)
				       (rec-test it)
				       (error 'wisp-undefined-nested-urlmap
					      :nested-map map-name
					      :root-map nested-urlmap))))))))))
      (setf (gethash urlmap *all-maps*) t)
      (rec-test urlmap))))
Source Context