add -r switch for onlcr translation
authormickey <mickey@openbsd.org>
Mon, 6 Jan 1997 11:06:45 +0000 (11:06 +0000)
committermickey <mickey@openbsd.org>
Mon, 6 Jan 1997 11:06:45 +0000 (11:06 +0000)
usr.sbin/lpr/filters/lpf.c

index 5335f31..d964146 100644 (file)
@@ -66,6 +66,7 @@ int   length = 66;    /* page length */
 int    indent;         /* indentation length */
 int    npages = 1;
 int    literal;        /* print control characters */
+int    onlcr;          /* map nl->cr-nl */
 char   *name;          /* user's login name */
 char   *host;          /* user's machine name */
 char   *acctfile;      /* accounting information file */
@@ -107,6 +108,10 @@ main(argc, argv)
                                indent = atoi(&cp[2]);
                                break;
 
+                       case 'r':       /* map nl->cr-nl */
+                               onlcr++;
+                               break;
+
                        case 'c':       /* Print control chars */
                                literal++;
                                break;
@@ -195,8 +200,11 @@ main(argc, argv)
                        }
                        if (i < maxrep)
                                putc('\r', o);
-                       else
+                       else {
+                               if (onlcr)
+                                       putc('\r', o);
                                putc(ch, o);
+                       }
                        if (++lineno >= length) {
                                fflush(o);
                                npages++;