Function: math-do-arg-check

math-do-arg-check is a byte-compiled function defined in calc-prog.el.gz.

Signature

(math-do-arg-check ARG VAR IS-OPT IS-REST)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-prog.el.gz
(defun math-do-arg-check (arg var is-opt is-rest)
  (if is-opt
      (let ((chk (math-do-arg-check arg var nil nil)))
	(list (cons 'and
		    (cons var
			  (if (cdr chk)
			      `((progn ,@chk))
			    chk)))))
    (when (consp arg)
      (let* ((rest (math-do-arg-check (nth 1 arg) var is-opt is-rest))
	     (qual (car arg))
	     (qual-name (symbol-name qual))
	     (chk (intern (concat "math-check-" qual-name))))
	(if (fboundp chk)
	    (append rest
		    (if is-rest
			`((setq ,var (mapcar ',chk ,var)))
		      `((setq ,var (,chk ,var)))))
	  (if (fboundp (setq chk (intern (concat "math-" qual-name))))
	      (append rest
		      (if is-rest
                          `((mapcar (lambda (x)
                                      (or (,chk x)
                                          (math-reject-arg x ',qual)))
				    ,var))
			`((or (,chk ,var)
			      (math-reject-arg ,var ',qual)))))
	    (if (and (string-match "\\`not-\\(.*\\)\\'" qual-name)
		     (fboundp (setq chk (intern
					 (concat "math-"
						 (math-match-substring
						  qual-name 1))))))
		(append rest
			(if is-rest
                            `((mapcar (lambda (x)
                                        (and (,chk x)
                                             (math-reject-arg x ',qual)))
				      ,var))
			  `((and
			     (,chk ,var)
			     (math-reject-arg ,var ',qual)))))
	      (error "Unknown qualifier `%s'" qual-name))))))))