[comp.bugs.4bsd] lpd bug

mark@sickkids.UUCP (Mark Bartelt) (01/24/89)

First off, a minor error in the printcap(5) man page.  It says ...

        [lpd's] if filter is invoked with arguments:

             if [ -c ] -wwidth -llength [ ... ]

        [ ... ]  Width and length specify the page width and length
        (from pw and pl respectively) in characters.

Actually, it probably ought to add that the width value passed to the if
filter is the printcap "pw" value *unless* it's overridden by a W line in
the daemon control file (from invoking lpr with "-wnnn").

However, it doesn't really default to the pw value at all.  In printjob.c,
the following excerpt from init() does the correct thing:

        if ((PW = pgetnum("pw")) < 0)
                PW = DEFWIDTH;
        sprintf(&width[2], "%d", PW);
        if ((PL = pgetnum("pl")) < 0)
                PL = DEFLENGTH;
        sprintf(&length[2], "%d", PL);

However, near the beginning of printit() we find the following:

        strcpy(width+2, "0");

This causes the if filter to always be invoked with "-w0", unless printit()
encounters a W line in the daemon control file.

Is there any justification for the above strcpy()?  Or, more specifically,
can anyone think of a reason not to replace it with:

        sprintf(&width[2], "%d", PW);

Mark Bartelt                          UUCP: {utzoo,decvax}!sickkids!mark
Hospital for Sick Children, Toronto   BITNET: mark@sickkids.utoronto
416/598-6442                          INTERNET: mark@sickkids.toronto.edu