Mod.sources:  Volume 4, Issue 114
Submitted by: Guido van Rossum <seismo!mcvax!guido>

Here's something a colleague of mind wrote one or two years ago, and
which recently prompted some interest on the net.  Unfortunately it is
not a very finished product; I post this so that others can benefit from
it and change it to fit their needs.  I tried to compile and run it (on
a VAX running 4.2BSD) and it gave sensible output when fed with itself
as input -- I can't say more about the quality.  Foreseen use is
something like:
        printfck file.c >temp.c
        lint temp.c procent.c
Lint warnings about improper usage of any of the procent_* functions
mean you're using an incorrect argument to a % escape.  For variable
strings used as formats it doesn't help you; see also the comments at
the begin of the program.
Look in the program to find the command line options (you can feed it
your own list of printf-like functions).

I'm sorry I can't spend more time on this (well I can but don't intend
to since I have no need for it right now).  If anybody comes up with a
manual, an improved version or any other changes, I'd like to hear about
it.

Greetings,
        Guido van Rossum, CWI, Amsterdam <guido@mcvax.UUCP>

/* printfck.c - check all uses of %d, %ld, %s, %u etc. - 850325 aeb@mcvax*/
/* small fixes, made more robust, process cmdline arg - 850402 guido@boring*/
/* Copyright 1985,1986 Stichting Mathematisch Centrum. Use at own risk. */
#include        <stdio.h>

/* Feed with a list of routine names and descriptions:
 *      printf("",...)
 *      sprintf(s,"",...)
 *      fprintf(f,"",...)
 * and with a source file; produce output in which occurrences of e.g.
 *      sprintf(buf, "%s%ld", s, l)
 * are replaced by
 *      sprintf(buf, "%s%ld", procent_s(s), procent_L(l))
 * Now let lint do the checking.
 * Bugs:
 *      Cases where the format string is not explicitly given (e.g., is the
 *      result of some other routine, or looks like  bool ? "s1" : "s2")
 *      are not handled.
 *      Cases where the preprocessor produces quotes or comment delimiters
 *      or concatenates partial identifiers are not handled.
 *      We do not distinguish two sets of identifiers.
 *      Only the parts lint sees get checked - not parts between (false)
 *      #ifdef's. If the call to printf is outside #ifdef's, but some
 *      args are inside, printfck may get confused. However, this is easy
 *      to avoid:
 *
 *      THIS FAILS                      THIS WORKS
 *      ----------                      ----------
 *              printf("%s%d",                  printf("%s%d", (
 *      #ifdef debug                    #ifdef debug
 *                      "foo"                           "foo"
 *      #else                           #else
 *                      "bar"                           "bar"
 *      #endif debug                    #endif debug
 *                      , num);                         ), num);
 *
 */


30/5/86         W.T. Roberts <liam@cs.qmc.ac.uk>

I have modified printfck to handle scanf() as well as printf(),
produced a manual page and a Makefile.
