Function: byte-compile-format-warn

byte-compile-format-warn is a byte-compiled function defined in bytecomp.el.gz.

Signature

(byte-compile-format-warn FORM)

Documentation

Warn if FORM is format-like with inconsistent args.

Applies if head of FORM is a symbol with non-nil property byte-compile-format-like and first arg is a constant string. Then check the number of format fields matches the number of extra args.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
(defun byte-compile-format-warn (form)
  "Warn if FORM is `format'-like with inconsistent args.
Applies if head of FORM is a symbol with non-nil property
`byte-compile-format-like' and first arg is a constant string.
Then check the number of format fields matches the number of
extra args."
  (when (and (symbolp (car form))
	     (stringp (nth 1 form))
	     (get (car form) 'byte-compile-format-like))
    (let ((nfields (with-temp-buffer
		     (insert (nth 1 form))
		     (goto-char (point-min))
		     (let ((i 0) (n 0))
		       (while (re-search-forward "%." nil t)
                         (backward-char)
			 (unless (eq ?% (char-after))
                           (setq i (if (looking-at "\\([0-9]+\\)\\$")
                                       (string-to-number (match-string 1) 10)
                                     (1+ i))
                                 n (max n i)))
                         (forward-char))
		       n)))
	  (nargs (- (length form) 2)))
      (unless (= nargs nfields)
	(byte-compile-warn
	 "`%s' called with %d args to fill %d format field(s)" (car form)
	 nargs nfields)))))