home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / plbin.zip / pl / man / dvi2tty / dvi2tty.c < prev    next >
C/C++ Source or Header  |  1992-05-26  |  23KB  |  632 lines

  1. /******************************************************************************
  2.  * Marcel Mol: 1989-01-19  (UUCP: duteca!marcel)
  3.  *               Changed in option handling, no change
  4.  *               in user interface (only the undocumented 
  5.  *               feature -e).
  6.  *               Version 3.1.
  7.  * Marcel Mol: 1989-01-11  (UUCP: duteca!marcel)
  8.  *               Changed some longs to ints.
  9.  *               It now also runs on MSDOS Microsoft C 5.1
  10.  *               New version: 3.0
  11.  * Marcel Mol: 1989-01-03  (UUCP: duteca!marcel)
  12.  *               Fixed a bugs concerning pager programs
  13.  *               and scanning environment variable DVI2TTY.
  14.  * Marcel Mol: 1988-10-25  (UUCP: duteca!marcel)
  15.  *        dvi2tty.c dvi2tty.h dvistuff.c commands.h
  16.  *               Converted program to C.
  17.  *               improved spacing between words/characters.
  18.  * bogart:/usr/alla/zap/dvitty/dvitty.p  1986-08-15 20:24:31,
  19.  *               Version to be sent to mod.sources ready.
  20.  * New option since last version:
  21.  *   -Fprog      Pipe output to prog. Can be used to get a different
  22.  *               pager than the default.
  23.  * bogart:/usr/alla/zap/dvitty/dvitty.p  1986-01-13 21:49:31,
  24.  *   Environment variable DVITTY is read and options can be set from it.
  25.  *   These are the currently implemented options:
  26.  *      -ofile   Write output to file, else write to stdout,
  27.  *               possibly piped through a pager if stdout is a tty.
  28.  *      -plist   Print pages whos TeX-page-number are in list.
  29.  *               List is on the form  1,3:6,8  to choose pages
  30.  *               1,3-6 and 8. TeX-nrs can be negative: -p-1:-4,4
  31.  *      -Plist   Print pages whos sequential number are in list.
  32.  *      -wn      Print the lines with width n characters, default is
  33.  *               80. Wider lines gives better results.
  34.  *      -q       Don't try to pipe to a pager.
  35.  *      -f       Try to pipe to a pager if output is a tty.
  36.  *      -Fname   Specify a pager program.                  
  37.  *               Default of -q and -f is a compile time option, a constant.
  38.  *      -l       Write '^L' instead of formfeed between pages.
  39.  *      -u       Don't try to find Scandinavian characters (they will
  40.  *               print as a:s and o:s if this option is choosen).
  41.  *      -s       Scandinavian characters printed as }{|][\.
  42.  *               Default of -s and -u is a compile time option, a constant.
  43.  * bogart:/usr/alla/zap/dvitty/dvitty.p  1986-01-10 18:51:03,
  44.  *   Argument parsing, and random access functions (external, in C)
  45.  *   and other OS-dependent stuff (in C). Removed private 'pager' &
  46.  *   tries to pipe through PAGER (environment var) or, if PAGER not
  47.  *   defined, /usr/ucb/more. Some changes for efficency.
  48.  * bogart:/usr/alla/svante/dvitty/dvitty.p  1985-07-15 20:51:00,
  49.  *   The code for processing dvi-files running on UNIX (UCB-Pascal)
  50.  *   but no argument parsing.
  51.  * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.140, 30-Mar-85 05:43:56,
  52.  *   Edit: Svante Lindahl
  53.  * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.136, 15-Jan-85 13:52:59,
  54.  *   Edit: Svante Lindahl, final Twenex version !!!??
  55.  * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.121, 14-Jan-85 03:10:22,
  56.  *   Edit: Svante Lindahl, cleaned up and fixed a lot of little things
  57.  * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.25, 15-Dec-84 05:29:56,
  58.  *   Edit: Svante Lindahl, COMND-interface, including command line scanning
  59.  * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.23, 10-Dec-84 21:24:41,
  60.  *   Edit: Svante Lindahl, added command line scanning with Rscan-JSYS
  61.  * VERA::<SVANTE-LINDAHL.DVITTY>DVITTY.PAS.48,  8-Oct-84 13:26:30,
  62.  *  Edit: Svante Lindahl, fixed switch-parsing, destroyed by earlier patches
  63.  * VERA::<SVANTE-LINDAHL.DVITTY>DVITTY.PAS.45, 29-Sep-84 18:29:53,
  64.  *  Edit: Svante Lindahl
  65.  *
  66.  * dvitty - get an ascii representation of a dvi-file, suitable for ttys
  67.  *
  68.  * This program, and any documentation for it, is copyrighted by Svante
  69.  * Lindahl. It may be copied for non-commercial use only, provided that
  70.  * any and all copyright notices are preserved.
  71.  *
  72.  * Please report any bugs and/or fixes to:
  73.  *
  74.  * UUCP: {seismo,mcvax,cernvax,diku,ukc,unido}!enea!ttds!zap
  75.  * ARPA: enea!ttds!zap@seismo.CSS.GOV
  76.  *  or   Svante_Lindahl_NADA%QZCOM.MAILNET@MIT-MULTICS.ARPA
  77.  * EAN:  zap@cs.kth.sunet
  78.  */
  79.  
  80.  
  81. #include "dvi2tty.h"
  82.  
  83.     /*-----------------------------------------------------------------------*/
  84.     /* The following constants may be toggled before compilation to          */
  85.     /* customize the default behaviour of the program for your site.         */
  86.     /* Whichever their settings are, the defaults can be overridden at       */
  87.     /* runtime.                                                              */
  88.     /*-----------------------------------------------------------------------*/
  89.  
  90. #define DEFSCAND    FALSE     /* default is Scandinavian, toggle this if you */
  91.                               /* don't have terminals with Scand. nat. chars */
  92. #define WANTPAGER   TRUE      /* default: try to pipe through a pager (like  */
  93.                               /* more) if stdout is tty and no -o switch     */
  94. #define DEFPAGER    "/usr/bin/pg"   /* CHANGE TO YOUR LOCAL PAGER            */
  95.  
  96.     /*------------------ end of customization constants ---------------------*/
  97.  
  98. #define MAXLEN          100    /* size of char-arrays for strings            */
  99. #if defined(MSDOS)
  100. #define OPTSET      "wepPousl"   /* legal options                            */
  101. #define OPTWARG     "wepPo"      /* options with argument                    */
  102. #else
  103. #define OPTSET      "wepPousqlfF"/* legal options                            */
  104. #define OPTWARG     "wepPoF"     /* options with argument                    */
  105. #endif
  106.  
  107. /*
  108.  * USAGE CODES
  109.  */
  110.  
  111. #define wrnge  1                /* width switch arg out of range     */
  112. #define ign    2                /* ignore cause, print 'Usage:..'    */
  113. #define nan    3                /* not a number where one expected   */
  114. #define gae    4                /* garbage at end                    */
  115. #define bdlst  5                /* bad page-numberlist               */
  116. #define onef   6                /* only one dvifile allowed          */
  117. #define bdopt  7                /* bad option                        */
  118. #define onepp  8                /* only one page list allowed        */
  119. #define noarg  9                /* argument expected                 */
  120.  
  121. /* char *dvi2tty = "(#)@  dvi2tty.c  3.1 23/01/89 M.J.E. Mol (c) 1989" */
  122.  
  123. /*---------------------------------------------------------------------------*/
  124.  
  125. printlisttype * currentpage;    /* current page to print                     */
  126. printlisttype * firstpage;      /* first page selected                       */
  127. printlisttype * lastpage;       /* last page selected                        */
  128.  
  129. FILE *          DVIfile;
  130. FILE *          output;
  131. bool            outputtofile;   /* tells if output goes to file or stdout    */
  132. int             ttywidth;       /* max nr of chars per printed line          */
  133. int             espace;         /* to fake calcs with ttywidth               */
  134.  
  135. long            foo;            /* utility variable, "register"              */
  136. #if !defined(MSDOS)
  137. bool            pager;          /* tells if output is piped to a pager       */
  138. char  *         path;           /* name of the pager to run                  */
  139. #endif
  140. char  *         progname;       /* our name                                  */
  141. int             Argc;
  142. char **         Argv;
  143. char            DVIfilename[MAXLEN];
  144. char *          OUTfilename;
  145. char            optch;          /* for option handling                       */
  146.  
  147. /*---------------------------------------------------------------------------*/
  148.  
  149. #if defined(MSDOS)
  150. void    main      (int, char **); 
  151. void    setoption (char *);
  152. void    getargs   (void);
  153. void    getpages  (int, char *);
  154. void    plcnxt    (int);
  155. void    getname   (char *);
  156. int     getinteger(int *, int *, char *);
  157. void    usage     (int);
  158. #else
  159. char *  getenv    ();
  160. FILE *  popen     ();
  161.  
  162. void    main      (); 
  163. void    setoption ();
  164. void    getargs   ();
  165. void    getpages  ();
  166. void    plcnxt    ();
  167. void    getname   ();
  168. int     getinteger();
  169. void    usage     ();
  170. #endif
  171.  
  172.  
  173. /****************************************************************************/
  174. /*                                                                          */
  175. /*                                 M A I N                                  */
  176. /*                                                                          */
  177. /****************************************************************************/
  178.  
  179. void main(argc, argv)
  180. int argc;
  181. char ** argv;
  182. {
  183.  
  184.     progname = *argv;
  185.     Argc = argc;
  186.     Argv = argv;
  187.  
  188.     getargs();                              /* read command line arguments   */
  189. #if defined(MSDOS)
  190.     if ((DVIfile = fopen(DVIfilename, "rb")) == NULL)
  191. #else
  192.     if ((DVIfile = fopen(DVIfilename, "r")) == NULL)
  193. #endif
  194.         errorexit(filop);                   /* can't open dvifile            */
  195.  
  196.     if (outputtofile) {                     /* open the outfile, if needed   */
  197.         if ((output = fopen(OUTfilename, "w")) == NULL)
  198.             errorexit(filcr);
  199. #if !defined(MSDOS)
  200.         pager = FALSE;
  201. #endif
  202.     }
  203.     else {
  204.         output = stdout;
  205. #if !defined(MSDOS)
  206.         if (isatty(fileno(output)) && pager) {   /* try to pipe to a pager   */
  207.             if ((output = popen(path, "w")) == NULL) /* get pipe to pager    */
  208.                 errorexit(pipcr);                /* make output to output    */
  209.         }
  210.         else
  211.             pager = FALSE;
  212. #endif
  213.     }
  214.  
  215.     dvimain();
  216.  
  217. #if !defined(MSDOS)
  218.     if (pager)
  219.         pclose(output);                     /* close pipe to pager            */
  220. #endif
  221.  
  222.     exit(0);
  223.  
  224. } /* main */
  225.  
  226. /*----------------------------------------------------------------------------*/
  227.  
  228. void setoption(optarg)
  229. char *optarg;
  230. {
  231.     int j = 0;
  232.     int ret;
  233.    
  234.     while (strchr(OPTSET, optch) != NULL) {
  235.         switch (optch) {
  236. #if !defined(MSDOS)
  237.         case 'q' : pager = FALSE; break;
  238.         case 'f' : pager = TRUE; break;
  239. #endif
  240.         case 'l' : noffd = TRUE; break;
  241.         case 's' : scascii = TRUE; break;
  242.         case 'u' : scascii = FALSE; break;
  243.             case 'P' :
  244.                sequenceon = TRUE;     /* fall through */
  245.             case 'p' :
  246.                        if (pageswitchon)
  247.                            usage(onepp);
  248.                        getpages(j, optarg);
  249.                        break;
  250.             case 'w' :
  251.                if (getinteger(&ttywidth, &j, optarg))
  252.                            usage(nan);
  253.                        if (optarg[j] != '\0') 
  254.                            usage(gae);
  255.                        if ((ttywidth < 16) || (ttywidth > 132))
  256.                            usage(wrnge);
  257.                        break;
  258.             case 'e' :
  259.                if (getinteger(&espace, &j, optarg))
  260.                            usage(nan);
  261.                        if (optarg[j] != '\0') 
  262.                            usage(gae);
  263.                        break;
  264.             case 'o' :
  265.                        OUTfilename = optarg;
  266.                outputtofile = TRUE;
  267.                        j = strlen(optarg);
  268.                        break;
  269. #if !defined(MSDOS)
  270.             case 'F' :
  271.                        pager = TRUE;
  272.                        path = optarg;
  273.                        j = strlen(optarg);
  274.                        break;
  275. #endif
  276.             default  : 
  277.                        usage(bdopt);
  278.         }
  279.         if ((optch = optarg[j]) == '\0')
  280.             break;
  281.         j++;
  282.         if ((strchr(OPTWARG, optch) != NULL) && (optarg[j]='\0')) {
  283.                 if (--Argc <= 0)
  284.                     usage(noarg);
  285.                 optarg = *++Argv;
  286.                 j = 0;
  287.             }
  288.     }
  289. } /* setoption */
  290.  
  291. /*----------------------------------------------------------------------------*/
  292.  
  293. void getargs()
  294. {
  295.     char *str, *envp;
  296.     bool DVIfound;                      /* if a dvi filename found           */
  297.  
  298.     if (Argc <= 1)
  299.         usage(ign);
  300.  
  301.     pageswitchon = FALSE;       /* show all pages                            */
  302.     sequenceon   = FALSE;       /* selected pages are TeX-numbered           */
  303.     outputtofile = FALSE;       /* write to stdout                           */
  304. #if !defined(MSDOS)
  305.     pager        = WANTPAGER;   /* want paging, compile time option          */
  306. #endif
  307.     noffd        = FALSE;       /* print formfeed between pages              */
  308.     scascii      = DEFSCAND;    /* scandinavian, compile time option         */
  309.     ttywidth     = 80;          /* default terminal width                    */
  310.     espace       = 0;           /* to fake ttywith calcs                     */
  311.     DVIfound     = FALSE;
  312.  
  313. #if !defined(MSDOS)
  314.     if ((path = getenv("PAGER")) == NULL)   /* find default pathname of page */
  315.             path = DEFPAGER;             /* program in case paging is wanted */
  316. #endif
  317.  
  318.     if ((envp = getenv("DVI2TTY")) != NULL) {
  319.         while (*envp == ' ')
  320.              envp++;
  321.         while (*envp) {                     /* environment var args          */
  322.             if (strchr(OPTSET, optch = *envp++) != NULL) {
  323.                 /*
  324.                  * we always pass one option, and arrange for optarg ourselfves,
  325.                  * so setoption does not mesh up Argv
  326.                  */
  327.                 if (strchr(OPTWARG, optch) != NULL) {
  328.                     while (*envp == ' ') 
  329.                         envp++;
  330.                     if (*envp == '\0')
  331.                         usage(noarg);
  332.                     str = envp;             /* str points to optarg          */
  333.                     while ((*envp != ' ') && (*envp != '\0'))
  334.                         *envp++;            /* set envp just after optarg    */
  335.                     if (*envp != '\0')
  336.                         *envp++ = '\0';     /* end optarg string             */
  337.                 }
  338.                 else
  339.                     str = "";
  340.                 setoption(str);
  341.             }
  342.             else
  343.                 usage(bdopt);
  344.             while (*envp == ' ')
  345.                  envp++;
  346.         }
  347.     }
  348.  
  349.     while (--Argc > 0) {                    /* command line args             */
  350.         str = *++Argv;
  351.         if (*str != '-') {                  /* argument is not an option     */
  352.             if (DVIfound)                   /* only one dvi file allowed     */
  353.                 usage(onef);
  354.             getname(str);
  355.             DVIfound = TRUE;
  356.         }
  357.         else if (strchr(OPTSET, optch = *++str) != NULL) {
  358.             str++;                      /* point to rest of argument if any  */
  359.             if ((strchr(OPTWARG, optch) != NULL) && (*str == '\0')) {
  360.                 if (--Argc <= 0)
  361.                     usage(noarg);
  362.                 str = *++Argv;
  363.             }
  364.             setoption(str);
  365.         }
  366.         else
  367.             usage(bdopt);
  368.     }
  369.  
  370.     if (!DVIfound)
  371.         usage(ign);
  372.  
  373. } /* getargs */
  374.  
  375. /*---------------------------------------------------------------------------*/
  376.  
  377. void getpages(j, str)
  378. int j;
  379. char *str;
  380. {
  381.     int i, c;
  382.     int num;
  383.  
  384.     pageswitchon = TRUE;
  385.     firstpage = (printlisttype *) malloc(sizeof(printlisttype));
  386.     firstpage->all = FALSE;
  387.     firstpage->nxt = nil;
  388.     firstpage->pag = 0;
  389.     lastpage = firstpage;
  390.     currentpage = firstpage;
  391.     if (getinteger(&num, &j, str))
  392.         usage(nan);
  393.     plcnxt((int) num);
  394.     while (str[j]) {
  395.         c = str[j];
  396.         if (c == ',' || c == ':') {
  397.             j++;
  398.             if (getinteger(&num, &j, str))
  399.                 usage(nan);
  400.         }
  401.         else
  402.             break;
  403.         if (c == ',')
  404.             plcnxt(num);
  405.         else {
  406.             if (currentpage->pag < 0) {
  407.                 if (num > 0) {
  408.                     currentpage->all = TRUE;
  409.                     plcnxt(num);
  410.                 }
  411.                 else if (num < currentpage->pag)
  412.                     for (i = currentpage->pag - 1; i >= num; i--)
  413.                         plcnxt(i);
  414.                 else
  415.                     usage(bdlst);
  416.             }
  417.             else {
  418.                 if (num < currentpage->pag)
  419.                     usage(bdlst);
  420.                 for (i = currentpage->pag + 1; i <= num; i++)
  421.                     plcnxt(i);
  422.             }
  423.         }
  424.     }
  425.     if ((str[j] != ' ') && (str[j] != NULL)) {
  426.         usage(gae);
  427.     }
  428.     currentpage = firstpage;
  429.  
  430. } /* getpages */
  431.  
  432.  
  433. void plcnxt(pagnr)      /* place page-nr next in list */
  434. int pagnr;
  435. {
  436.     currentpage = lastpage;
  437.     currentpage->pag = pagnr;
  438.     lastpage = (printlisttype *) malloc(sizeof(printlisttype));
  439.     lastpage->all = FALSE;
  440.     lastpage->nxt = nil;
  441.     lastpage->pag = 0;
  442.     currentpage->nxt = lastpage;
  443.  
  444. } /* plcnxt */
  445.  
  446. /*----------------------------------------------------------------------------*/
  447.  
  448. void getname(str)
  449. char *str;
  450. {
  451.     int   i;
  452.  
  453.     i = strlen(str);
  454.     if (i == 0)
  455.         usage(ign);
  456.     strcpy(DVIfilename, str);
  457.     if (!((i >= 5) && (str[i-1] == 'i') && (str[i-2] == 'v') &&
  458.           (str[i-3] = 'd') && (str[i-4] = '.'))) {
  459.         strcat(DVIfilename, ".dvi");
  460.     }
  461.  
  462. } /* getname */
  463.  
  464. /*----------------------------------------------------------------------------*/
  465.  
  466. int getinteger(dest, j, str)
  467. int *dest;
  468. int *j;
  469. char *str;
  470. {
  471.     int  cum;
  472.     int  sgn;
  473.     char ch;
  474.  
  475.     ch = str[*j];
  476.     if (ch == '-') {
  477.         sgn = -1;
  478.         ch  = str[++(*j)];
  479.     }
  480.     else
  481.         sgn = 1;
  482.     if ((ch >= '0') && (ch <= '9')) {
  483.         cum = 0;
  484.         while ((ch >= '0') && (ch <= '9')) {
  485.             cum = cum*10 + ch - '0';
  486.             ch = str[++(*j)];
  487.         }
  488.         *dest = sgn * cum;
  489.         return 0;                   /* return ok */
  490.     }
  491.     return 1;                       /* return error */
  492.  
  493. }   /* getinteger */
  494.  
  495. /*----------------------------------------------------------------------------*/
  496.  
  497. void errorexit(errorcode)
  498. int errorcode;
  499. {
  500.  
  501.     fprintf(stderr, "%s: ", progname);
  502.     switch (errorcode) {
  503.         case  illop : fprintf(stderr, "Illegal op-code found: %d\n", opcode);
  504.                       break;
  505.         case  stkof : fprintf(stderr, "Stack overflow\n");
  506.                       break;
  507.         case  stkuf : fprintf(stderr, "Stack underflow\n");
  508.                       break;
  509.         case  stkrq : fprintf(stderr, "Cannot create dvi stack\n");
  510.                       break;
  511.         case  lnerq : fprintf(stderr, "Cannot allocate memory\n");
  512.                       break;
  513.         case  badid : fprintf(stderr, "Id-byte is not correct: %d\n ", opcode);
  514.                       break;
  515.         case  bdsgn : fprintf(stderr, "Bad signature: %d (not 223)\n",
  516.                                       (int) foo);
  517.                       break;
  518.         case  fwsgn : fprintf(stderr, "%d signature bytes (min. 4)\n",
  519.                                       (int) foo);
  520.                       break;
  521.         case  nopre : fprintf(stderr, "Missing preamble\n");
  522.                       break;
  523.         case  nobop : fprintf(stderr, "Missing beginning-of-page command\n");
  524.                       break;
  525.         case  nopp  : fprintf(stderr, "Missing post-post command\n");
  526.                       break;
  527.         case  bdpre : fprintf(stderr, "Preamble occured inside a page\n");
  528.                       break;
  529.         case  bdbop : fprintf(stderr, "BOP-command occured inside a page\n");
  530.                       break;
  531.         case  bdpst : fprintf(stderr, "Postamble occured before end-of-page\n");
  532.                       break;
  533.         case  bdpp  : fprintf(stderr, "Postpost occured before post-command\n");
  534.                       break;
  535.         case  nopst : fprintf(stderr, "Missing postamble\n");
  536.                       break;
  537.         case  illch : fprintf(stderr, "Character code out of range, 0..127\n");
  538.                       break;
  539.         case  filop : fprintf(stderr, "Cannot open dvifile\n");
  540.                       break;
  541.         case  filcr : fprintf(stderr, "Cannot create outfile\n");
  542.                       break;
  543. #if !defined(MSDOS)
  544.         case  pipcr : fprintf(stderr, "Cannot create pipe to pager\n");
  545.                       break;
  546. #endif
  547.         default     : fprintf(stderr, "Unkown error code\n");
  548.                       break;
  549.     };
  550.     if (outputtofile)
  551.         unlink(OUTfilename);
  552.     exit(errorcode);
  553.  
  554. }  /* errorexit */
  555.  
  556. /*----------------------------------------------------------------------------*/
  557.  
  558. void usage(uerr)
  559. int uerr;
  560. {
  561.  
  562.     if (uerr != ign) {
  563.         fprintf(stderr,"%s: ", progname);
  564.         switch (uerr) {
  565.             case   ign    : fprintf(stderr, "%s", Copyright);
  566.                             break;
  567.             case   wrnge  : fprintf(stderr, "width arg out of range:16-132");
  568.                             break;
  569.             case   nan    : fprintf(stderr, "numeric argument expected for option %c",
  570.                                             optch);
  571.                             break;
  572.             case   gae    : fprintf(stderr, "garbage in argument for option %c",
  573.                                             optch);
  574.                             break;
  575.             case   bdlst  : fprintf(stderr, "mal-formed list of pagenumbers");
  576.                             break;
  577.             case   onef   : fprintf(stderr, "only one infile argument allowed");
  578.                             break;
  579.             case   noarg  : fprintf(stderr, "option argument expected for option %c",
  580.                                             optch);
  581.                             break;
  582.             case   bdopt  : fprintf(stderr, "bad option %c", optch);
  583.                             break;
  584.             case   onepp  : fprintf(stderr, "only one pagelist allowed");
  585.                             break;
  586.             default       : fprintf(stderr, "unknown usage error");
  587.                             break;
  588.         }
  589.         fprintf(stderr, "\n");
  590.     }
  591.     fprintf(stderr, "Usage: %s [ options ] dvifile[.dvi]\n", progname);
  592.     fprintf(stderr, "Options are:\n");
  593.     fprintf(stderr,
  594.             " -ofile   Write output to file, else write to stdout.\n");
  595.     fprintf(stderr,
  596.             " -plist   Print pages whos TeX-page-number are in list.\n");
  597.     fprintf(stderr,
  598.             " -Plist   Print pages whos sequential number are in list.\n");
  599.     fprintf(stderr,
  600.             " -wn      Print the lines with width n characters, default 80.\n");
  601. #if !defined(MSDOS)
  602.     fprintf(stderr, " -f       Try to pipe to a pager if output is a tty");
  603.     if (WANTPAGER)
  604.         fprintf(stderr, " (default).\n");
  605.     else
  606.         fprintf(stderr, ".\n");
  607.     fprintf(stderr, " -q       Don't try to pipe to a pager");
  608.     if (WANTPAGER)
  609.         fprintf(stderr, ".\n");
  610.     else
  611.         fprintf(stderr, " (default).\n");
  612.     fprintf(stderr, " -Fprog   Pipe output to pager prog.\n");
  613. #endif
  614.     fprintf(stderr,
  615.             " -l       Write ''^L'' instead of formfeed between pages.\n");
  616.     fprintf(stderr,
  617.             " -u       National Swedish characters printed as aaoAAO");
  618.     if (DEFSCAND)
  619.         fprintf(stderr, ".\n");
  620.     else
  621.         fprintf(stderr, " (default).\n");
  622.     fprintf(stderr,
  623.             " -s       National Swedish characters printed as }{|][\\");
  624.     if (DEFSCAND)
  625.         fprintf(stderr, " (default).\n");
  626.     else
  627.         fprintf(stderr, ".\n");
  628.     exit(uerr);
  629.  
  630. } /* usage */
  631.  
  632.