<commit_before>;;;;; tré – Copyright (c) 2006–2008,2011–2013 <NAME> <<EMAIL>>

(defstruct format-info
  stream
  text
  args
  (processed-args 0))

(defun %format-directive-eol (inf txt args)
  (terpri (format-info-stream inf))
  (%format inf txt args))

(defun %format-directive-placeholder (inf txt args)
  (? args
     (? (cons? args.)
		(late-print args. (format-info-stream inf))
        (princ args. (format-info-stream inf)))
     (error "Argument ~A specified in format \"~A\" is missing." (format-info-processed-args inf) (format-info-text inf)))
  (%format inf txt .args))

(defun %format-directive-force-output (inf txt args)
  (force-output (format-info-stream inf))
  (%format inf txt args))

(defun %format-directive-tilde (inf txt args)
  (princ #\~ (format-info-stream inf))
  (%format inf txt args))

(defun %format-directive (inf txt args)
  (++! (format-info-processed-args inf))
  (case (char-upcase txt.) :test #'character==
    #\% (%format-directive-eol inf .txt args)
    #\A (%format-directive-placeholder inf .txt args)
    #\F (%format-directive-force-output inf .txt args)
    (%format-directive-tilde inf txt args)))

(defun %format (inf txt args)
  (when txt
    (? (character== txt. #\~)
       (%format-directive inf .txt args)
       (progn
         (princ txt. (format-info-stream inf))
         (%format inf .txt args)))))

(defun format (str txt &rest args)
  (with-default-stream nstr str
    (with-temporary *print-automatic-newline?* nil
      (%format (make-format-info :stream nstr :text txt :args args) (string-list txt) args))))<commit_msg>FORMAT can escape characters in format string.<commit_after>;;;;; tré – Copyright (c) 2006–2008,2011–2013 <NAME> <<EMAIL>>

(defstruct format-info
  stream
  text
  args
  (processed-args 0))

(defun %format-directive-eol (inf txt args)
  (terpri (format-info-stream inf))
  (%format inf txt args))

(defun %format-directive-placeholder (inf txt args)
  (? args
     (? (cons? args.)
		(late-print args. (format-info-stream inf))
        (princ args. (format-info-stream inf)))
     (error "Argument ~A specified in format \"~A\" is missing." (format-info-processed-args inf) (format-info-text inf)))
  (%format inf txt .args))

(defun %format-directive-force-output (inf txt args)
  (force-output (format-info-stream inf))
  (%format inf txt args))

(defun %format-directive-tilde (inf txt args)
  (princ #\~ (format-info-stream inf))
  (%format inf txt args))

(defun %format-directive (inf txt args)
  (++! (format-info-processed-args inf))
  (case (char-upcase txt.) :test #'character==
    #\% (%format-directive-eol inf .txt args)
    #\A (%format-directive-placeholder inf .txt args)
    #\F (%format-directive-force-output inf .txt args)
    (%format-directive-tilde inf txt args)))

(defun %format (inf txt args)
  (when txt
    (alet (format-info-stream inf)
      (?
        (character== txt. #\\)  (progn
                                  (princ txt. !)
                                  (princ .txt. !)
                                  (%format inf ..txt args))
        (character== txt. #\~)  (%format-directive inf .txt args)
        (progn
          (princ txt. !)
          (%format inf .txt args))))))

(defun format (str txt &rest args)
  (with-default-stream nstr str
    (with-temporary *print-automatic-newline?* nil
      (%format (make-format-info :stream nstr :text txt :args args) (string-list txt) args))))
{'fraction_non_alphanumeric': 0.15978928884986832, 'fraction_numerical': 0.009950248756218905, 'mean_word_length': 2.9107551487414187, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2243782', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1119, 'n_words': 335}