home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / wp_dtp / detex24.lha / detex.c < prev    next >
C/C++ Source or Header  |  1993-01-02  |  55KB  |  1,988 lines

  1. /* A lexical scanner generated by flex */
  2.  
  3. /* scanner skeleton version:
  4.  * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $
  5.  */
  6.  
  7. #define FLEX_SCANNER
  8.  
  9. #include <stdio.h>
  10.  
  11.  
  12. /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  13. #ifdef c_plusplus
  14. #ifndef __cplusplus
  15. #define __cplusplus
  16. #endif
  17. #endif
  18.  
  19.  
  20. #ifdef __cplusplus
  21.  
  22. #include <stdlib.h>
  23. #include <osfcn.h>
  24.  
  25. /* use prototypes in function declarations */
  26. #define YY_USE_PROTOS
  27.  
  28. /* the "const" storage-class-modifier is valid */
  29. #define YY_USE_CONST
  30.  
  31. #else    /* ! __cplusplus */
  32.  
  33. #ifdef __STDC__
  34.  
  35. #ifdef __GNUC__
  36. #include <stddef.h>
  37. void *malloc( size_t );
  38. void free( void* );
  39. #else
  40. #include <stdlib.h>
  41. #endif    /* __GNUC__ */
  42.  
  43. #define YY_USE_PROTOS
  44. #define YY_USE_CONST
  45.  
  46. #endif    /* __STDC__ */
  47. #endif    /* ! __cplusplus */
  48.  
  49.  
  50. #ifdef __TURBOC__
  51. #define YY_USE_CONST
  52. #endif
  53.  
  54.  
  55. #ifndef YY_USE_CONST
  56. #define const
  57. #endif
  58.  
  59.  
  60. #ifdef YY_USE_PROTOS
  61. #define YY_PROTO(proto) proto
  62. #else
  63. #define YY_PROTO(proto) ()
  64. /* we can't get here if it's an ANSI C compiler, or a C++ compiler,
  65.  * so it's got to be a K&R compiler, and therefore there's no standard
  66.  * place from which to include these definitions
  67.  */
  68. char *malloc();
  69. int free();
  70. int read();
  71. #endif
  72.  
  73.  
  74. /* amount of stuff to slurp up with each read */
  75. #ifndef YY_READ_BUF_SIZE
  76. #define YY_READ_BUF_SIZE 8192
  77. #endif
  78.  
  79. /* returned upon end-of-file */
  80. #define YY_END_TOK 0
  81.  
  82. /* copy whatever the last rule matched to the standard output */
  83.  
  84. /* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
  85. /* this used to be an fputs(), but since the string might contain NUL's,
  86.  * we now use fwrite()
  87.  */
  88. #define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
  89.  
  90. /* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  91.  * is returned in "result".
  92.  */
  93. #define YY_INPUT(buf,result,max_size) \
  94.     if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
  95.         YY_FATAL_ERROR( "read() in flex scanner failed" );
  96. #define YY_NULL 0
  97.  
  98. /* no semi-colon after return; correct usage is to write "yyterminate();" -
  99.  * we don't want an extra ';' after the "return" because that will cause
  100.  * some compilers to complain about unreachable statements.
  101.  */
  102. #define yyterminate() return ( YY_NULL )
  103.  
  104. /* report a fatal error */
  105.  
  106. /* The funky do-while is used to turn this macro definition into
  107.  * a single C statement (which needs a semi-colon terminator).
  108.  * This avoids problems with code like:
  109.  *
  110.  *     if ( something_happens )
  111.  *        YY_FATAL_ERROR( "oops, the something happened" );
  112.  *    else
  113.  *        everything_okay();
  114.  *
  115.  * Prior to using the do-while the compiler would get upset at the
  116.  * "else" because it interpreted the "if" statement as being all
  117.  * done when it reached the ';' after the YY_FATAL_ERROR() call.
  118.  */
  119.  
  120. #define YY_FATAL_ERROR(msg) \
  121.     do \
  122.         { \
  123.         (void) fputs( msg, stderr ); \
  124.         (void) putc( '\n', stderr ); \
  125.         exit( 1 ); \
  126.         } \
  127.     while ( 0 )
  128.  
  129. /* default yywrap function - always treat EOF as an EOF */
  130. #define yywrap() 1
  131.  
  132. /* enter a start condition.  This macro really ought to take a parameter,
  133.  * but we do it the disgusting crufty way forced on us by the ()-less
  134.  * definition of BEGIN
  135.  */
  136. #define BEGIN yy_start = 1 + 2 *
  137.  
  138. /* action number for EOF rule of a given start state */
  139. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  140.  
  141. /* special action meaning "start processing a new file" */
  142. #define YY_NEW_FILE \
  143.     do \
  144.         { \
  145.         yy_init_buffer( yy_current_buffer, yyin ); \
  146.         yy_load_buffer_state(); \
  147.         } \
  148.     while ( 0 )
  149.  
  150. /* default declaration of generated scanner - a define so the user can
  151.  * easily add parameters
  152.  */
  153. #define YY_DECL int yylex YY_PROTO(( void )) 
  154.  
  155. /* code executed at the end of each rule */
  156. #define YY_BREAK break;
  157.  
  158. #define YY_END_OF_BUFFER_CHAR 0
  159.  
  160. #ifndef YY_BUF_SIZE
  161. #define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
  162. #endif
  163.  
  164. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  165.  
  166. #define YY_CHAR unsigned char
  167. #define INITIAL 0
  168. #ifndef lint
  169. static char    rcsid[] = "$Header: /usr/src/local/bin/detex/RCS/detex.l,v 2.14 1992/09/02 15:35:44 trinkle Exp $";
  170. #endif
  171.  
  172. /*
  173.  * detex [-e environment-list] [-c] [-l] [-n] [-s] [-t] [-w] [file[.tex]]
  174.  *
  175.  *    This program is used to remove TeX or LaTeX constructs from a text
  176.  *    file.
  177.  *
  178.  * Written by:
  179.  *    Daniel Trinkle
  180.  *    Department of Computer Science
  181.  *    Purdue University
  182.  *
  183.  */
  184.  
  185. #include "detex.h"
  186. #ifdef USG
  187. #include <string.h>
  188. #define    index    strchr
  189. #define    rindex    strrchr
  190. #else
  191. #include <strings.h>
  192. #endif
  193. #ifndef MAXPATHLEN
  194. #include <sys/param.h>
  195. #endif
  196.  
  197. #define    LaBEGIN        if (fLatex) BEGIN
  198. #define    CITEBEGIN    if (fLatex && !fCite) BEGIN
  199. #define    IGNORE        if (fSpace && !fWord) putchar(' ')
  200. #define    SPACE        if (!fWord) putchar(' ')
  201. #define    NEWLINE        if (!fWord) putchar('\n')
  202.  
  203. #ifdef FLEX_SCANNER
  204. #undef yywrap
  205. #endif
  206.  
  207. #ifndef __STDC__
  208. char    *malloc();
  209. #else
  210. #include <stdio.h>
  211. #include <stdlib.h>
  212. #include <fcntl.h>
  213. #include "detex_protos.h"
  214. #endif
  215.  
  216. char    *rgsbEnvIgnore[MAXENVS];    /* list of environments ignored */
  217. char    *rgsbIncList[MAXINCLIST];    /* list of includeonly files */
  218. char    *rgsbInputPaths[MAXINPUTPATHS];    /* list of input paths in order */
  219. char    sbCurrentEnv[CCHMAXENV];    /* current environment being ignored */
  220. char    *sbProgName;            /* name we were invoked with */
  221. FILE    *rgfp[NOFILE+1];        /* stack of input/include files */
  222. int    cfp = 0;            /* count of files in stack */
  223. int    cOpenBrace = 0;            /* count of `{' in <LaMacro2> */
  224. int    csbEnvIgnore;            /* count of environments ignored */
  225. int    csbIncList = 0;            /* count of includeonly files */
  226. int    csbInputPaths;            /* count of input paths */
  227. int    fLatex = 0;            /* flag to indicated delatex */
  228. int    fWord = 0;            /* flag for -w option */
  229. int    fFollow = 1;            /* flag to follow input/include */
  230. int    fCite = 0;            /* flag to echo \cite and \ref args */
  231. int    fSpace = 0;            /* flag to replace \cs with space */
  232. int    fForcetex = 0;            /* flag to inhibit latex mode */
  233. #define Define 1
  234. #define Display 2
  235. #define IncludeOnly 3
  236. #define Input 4
  237. #define Math 5
  238. #define Normal 6
  239. #define Control 7
  240. #define LaBegin 8
  241. #define LaDisplay 9
  242. #define LaEnd 10
  243. #define LaEnv 11
  244. #define LaFormula 12
  245. #define LaInclude 13
  246. #define LaMacro 14
  247. #define LaMacro2 15
  248. #define LaVerbatim 16
  249.  
  250. /* done after the current pattern has been matched and before the
  251.  * corresponding action - sets up yytext
  252.  */
  253. #define YY_DO_BEFORE_ACTION \
  254.     yytext = yy_bp; \
  255.     yyleng = yy_cp - yy_bp; \
  256.     yy_hold_char = *yy_cp; \
  257.     *yy_cp = '\0'; \
  258.     yy_c_buf_p = yy_cp;
  259.  
  260. #define EOB_ACT_CONTINUE_SCAN 0
  261. #define EOB_ACT_END_OF_FILE 1
  262. #define EOB_ACT_LAST_MATCH 2
  263.  
  264. /* return all but the first 'n' matched characters back to the input stream */
  265. #define yyless(n) \
  266.     do \
  267.         { \
  268.         /* undo effects of setting up yytext */ \
  269.         *yy_cp = yy_hold_char; \
  270.         yy_c_buf_p = yy_cp = yy_bp + n; \
  271.         YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  272.         } \
  273.     while ( 0 )
  274.  
  275. #define unput(c) yyunput( c, yytext )
  276.  
  277.  
  278. struct yy_buffer_state
  279.     {
  280.     FILE *yy_input_file;
  281.  
  282.     YY_CHAR *yy_ch_buf;        /* input buffer */
  283.     YY_CHAR *yy_buf_pos;    /* current position in input buffer */
  284.  
  285.     /* size of input buffer in bytes, not including room for EOB characters*/
  286.     int yy_buf_size;    
  287.  
  288.     /* number of characters read into yy_ch_buf, not including EOB characters */
  289.     int yy_n_chars;
  290.  
  291.     int yy_eof_status;        /* whether we've seen an EOF on this buffer */
  292. #define EOF_NOT_SEEN 0
  293.     /* "pending" happens when the EOF has been seen but there's still
  294.      * some text process
  295.      */
  296. #define EOF_PENDING 1
  297. #define EOF_DONE 2
  298.     };
  299.  
  300. static YY_BUFFER_STATE yy_current_buffer;
  301.  
  302. /* we provide macros for accessing buffer states in case in the
  303.  * future we want to put the buffer states in a more general
  304.  * "scanner state"
  305.  */
  306. #define YY_CURRENT_BUFFER yy_current_buffer
  307.  
  308.  
  309. /* yy_hold_char holds the character lost when yytext is formed */
  310. static YY_CHAR yy_hold_char;
  311.  
  312. static int yy_n_chars;        /* number of characters read into yy_ch_buf */
  313.  
  314.  
  315.  
  316. #ifndef YY_USER_ACTION
  317. #define YY_USER_ACTION
  318. #endif
  319.  
  320. #ifndef YY_USER_INIT
  321. #define YY_USER_INIT
  322. #endif
  323.  
  324. extern YY_CHAR *yytext;
  325. extern int yyleng;
  326. extern FILE *yyin, *yyout;
  327.  
  328. YY_CHAR *yytext;
  329. int yyleng;
  330.  
  331. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  332.  
  333. #define YY_END_OF_BUFFER 88
  334. typedef int yy_state_type;
  335. static const short int yy_accept[278] =
  336.     {   0,
  337.         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  338.         0,    0,    0,    0,   79,   79,    0,    0,    0,    0,
  339.         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  340.         0,    0,    0,    0,   88,   87,   40,   39,   38,   52,
  341.        51,   52,   63,   66,   65,   64,   68,   70,   69,   57,
  342.        55,   54,   57,   86,   86,   53,    1,   85,   86,   81,
  343.        81,   83,   80,   79,   78,   77,   80,   80,    9,    9,
  344.         8,    7,    9,   48,   47,   48,   16,   15,   13,   14,
  345.        12,   11,   12,   44,   43,   44,   59,   61,   60,   32,
  346.        31,   30,   36,   35,   33,   34,    6,    6,   50,   63,
  347.  
  348.        68,   56,   82,   49,    1,   85,    0,   84,   75,   74,
  349.        41,   73,   73,   73,   73,   45,   73,   73,   73,   73,
  350.        73,   73,   73,   73,   73,   73,   73,   73,   79,   77,
  351.        77,    0,   76,    0,    0,    7,    0,    0,   46,   13,
  352.         0,   42,   59,    0,   84,   73,   73,   72,   73,   73,
  353.        73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
  354.         0,    0,    0,   71,   73,   73,   73,   37,   73,   22,
  355.        73,   73,   73,   73,   73,   27,   73,   73,    0,   10,
  356.         0,   73,   73,   73,   73,   20,   73,   73,   73,   73,
  357.        73,   73,   73,   29,    0,    0,    0,    3,   73,   73,
  358.  
  359.        73,   73,   73,   23,   67,   24,   73,   73,   73,    0,
  360.         0,    0,    0,    0,   73,   73,   73,   73,   73,   73,
  361.        73,   73,    0,    0,    0,    0,   17,   73,   73,   73,
  362.        58,   25,   73,   73,    0,    0,    0,   73,   19,   73,
  363.        73,   73,   73,    0,    0,    0,   73,   73,   73,   26,
  364.        73,    0,    4,    0,    0,   73,   73,   73,   28,    0,
  365.         0,   73,   73,   62,    0,    0,   18,   73,    0,    0,
  366.        21,    0,    5,    0,    0,    2,    0
  367.     } ;
  368.  
  369. static const YY_CHAR yy_ec[256] =
  370.     {   0,
  371.         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
  372.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  373.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  374.         1,    4,    5,    1,    1,    6,    7,    1,    8,    9,
  375.        10,    1,    1,   11,   12,    1,    1,   13,   13,   13,
  376.        13,   13,   13,   13,   13,   13,   13,    1,    1,    1,
  377.        12,    1,    5,   14,   15,   16,   16,   16,   17,   16,
  378.        16,   16,   16,   16,   16,   18,   16,   16,   19,   16,
  379.        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  380.        20,   21,   22,    1,    1,   23,   24,   25,   26,   27,
  381.  
  382.        28,   29,   30,   31,   32,   18,   16,   33,   34,   35,
  383.        36,   37,   16,   38,   39,   40,   41,   42,   16,   43,
  384.        44,   16,   45,   46,   47,   48,    1,    1,    1,    1,
  385.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  386.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  387.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  388.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  389.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  390.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  391.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  392.  
  393.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  394.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  395.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  396.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  397.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  398.         1,    1,    1,    1,    1
  399.     } ;
  400.  
  401. static const YY_CHAR yy_meta[49] =
  402.     {   0,
  403.         1,    2,    3,    2,    1,    1,    1,    4,    1,    1,
  404.         5,    6,    6,    7,    8,    8,    8,    8,    8,    1,
  405.         1,    1,    6,    8,    8,    8,    8,    8,    8,    8,
  406.         8,    8,    8,    8,    8,    8,    8,    8,    8,    8,
  407.         8,    8,    8,    8,    2,    1,    9,    1
  408.     } ;
  409.  
  410. static const short int yy_base[303] =
  411.     {   0,
  412.         0,    0,    0,    1,    2,    3,    8,   11,   14,   21,
  413.        23,   27,   68,    0,  116,    0,  164,    0,   17,   18,
  414.       212,    0,   28,   29,   31,   33,  259,  262,    4,  264,
  415.       265,  268,   39,   44,  709,  710,  710,  710,  710,  710,
  416.       710,  702,    0,  710,  710,  710,    0,  710,  710,  710,
  417.       710,  710,  701,  710,  683,  699,    0,  691,  695,  315,
  418.       710,  710,  710,  273,  710,    0,  261,    0,  710,  362,
  419.       365,    0,  369,  710,  710,  680,  710,  710,    0,  710,
  420.       710,  710,  673,  710,  710,  690,    0,  710,  710,  710,
  421.       710,  710,  710,  710,  710,  710,  710,  671,  710,    0,
  422.  
  423.         0,  710,  710,  710,    0,  685,  689,  688,  710,  710,
  424.       710,    0,   20,  691,   23,  710,   39,  242,  662,  244,
  425.       658,  279,  272,  274,  668,  663,  251,  662,  372,    0,
  426.         0,  274,    0,  375,  379,    0,  382,  661,  710,    0,
  427.       653,  710,    0,  652,  675,    0,  678,  710,  651,  649,
  428.       633,  637,  632,  630,  261,  629,  623,  623,  604,  598,
  429.       597,  603,  601,  710,  595,  260,  479,    0,  465,    0,
  430.       471,  475,  460,  472,  470,    0,  471,  470,  469,  710,
  431.       385,  458,  452,  459,  450,    0,  455,  447,  443,  445,
  432.       451,  256,  447,    0,  458,  388,  392,  395,  453,  444,
  433.  
  434.       435,  450,  450,    0,    0,    0,  448,  435,  433,  433,
  435.       399,  444,  402,  410,  437,  440,  436,  433,  439,  437,
  436.       405,  413,  414,  407,  423,  403,    0,  400,  408,  395,
  437.       396,    0,  398,  389,  394,  398,  396,  395,    0,  379,
  438.       381,  387,  381,  440,  384,  359,  356,  340,  342,    0,
  439.       332,  449,  710,  268,  271,  272,  257,  256,    0,  259,
  440.       261,  241,  248,    0,   30,   27,    0,   29,  452,    3,
  441.         0,  455,  710,  458,  461,  710,  710,  508,  517,  526,
  442.       535,  544,  553,  562,  571,  580,  589,  598,  607,  616,
  443.       625,  633,  641,  647,  655,  661,  663,   33,   20,  671,
  444.  
  445.       676,  678
  446.     } ;
  447.  
  448. static const short int yy_def[303] =
  449.     {   0,
  450.       278,  278,  279,  279,  280,  280,  281,  281,  282,  282,
  451.       283,  283,  277,   13,  277,   15,  277,   17,  284,  284,
  452.       277,   21,  285,  285,  286,  286,  287,  287,  288,  288,
  453.       289,  289,  290,  290,  277,  277,  277,  277,  277,  277,
  454.       277,  277,  291,  277,  277,  277,  292,  277,  277,  277,
  455.       277,  277,  277,  277,  277,  277,  293,  277,  294,  277,
  456.       277,  277,  277,  277,  277,  295,  296,  297,  277,  277,
  457.       277,  298,  277,  277,  277,  277,  277,  277,  299,  277,
  458.       277,  277,  277,  277,  277,  277,  300,  277,  277,  277,
  459.       277,  277,  277,  277,  277,  277,  277,  277,  277,  291,
  460.  
  461.       292,  277,  277,  277,  293,  277,  301,  294,  277,  277,
  462.       277,  302,  302,  302,  302,  277,  302,  302,  302,  302,
  463.       302,  302,  302,  302,  302,  302,  302,  302,  277,  295,
  464.       295,  296,  297,  277,  277,  298,  277,  277,  277,  299,
  465.       277,  277,  300,  277,  301,  302,  302,  277,  302,  302,
  466.       302,  302,  302,  302,  302,  302,  302,  302,  302,  302,
  467.       277,  277,  277,  277,  302,  302,  302,  302,  302,  302,
  468.       302,  302,  302,  302,  302,  302,  302,  302,  277,  277,
  469.       277,  302,  302,  302,  302,  302,  302,  302,  302,  302,
  470.       302,  302,  302,  302,  277,  277,  277,  302,  302,  302,
  471.  
  472.       302,  302,  302,  302,  302,  302,  302,  302,  302,  277,
  473.       277,  277,  277,  277,  302,  302,  302,  302,  302,  302,
  474.       302,  302,  277,  277,  277,  277,  302,  302,  302,  302,
  475.       302,  302,  302,  302,  277,  277,  277,  302,  302,  302,
  476.       302,  302,  302,  277,  277,  277,  302,  302,  302,  302,
  477.       302,  277,  277,  277,  277,  302,  302,  302,  302,  277,
  478.       277,  302,  302,  302,  277,  277,  302,  302,  277,  277,
  479.       302,  277,  277,  277,  277,  277,    0,  277,  277,  277,
  480.       277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
  481.       277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
  482.  
  483.       277,  277
  484.     } ;
  485.  
  486. static const short int yy_nxt[759] =
  487.     {   0,
  488.       277,  277,   38,   38,   41,   41,   91,   42,   42,   44,
  489.        45,   44,   44,   45,   44,   48,   49,   48,   44,   75,
  490.        75,   44,   48,   49,   48,   51,  148,  140,   52,   51,
  491.        82,   82,   52,   85,  147,   85,  147,   76,   76,  147,
  492.       136,   36,  274,   53,   39,   39,   36,   53,   83,   83,
  493.        92,   86,   44,   86,   46,   44,  271,   46,   48,   98,
  494.        48,  270,  147,  269,   98,   48,  147,   48,   54,   54,
  495.        54,   54,   55,   56,   57,   54,   54,   54,   54,   54,
  496.        58,   54,   59,   59,   59,   59,   59,   54,   60,   54,
  497.        54,   59,   59,   59,   59,   59,   59,   59,   59,   59,
  498.  
  499.        59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
  500.        59,   59,   61,   61,   61,   62,   63,   64,   65,   64,
  501.        63,   63,   63,   66,   63,   63,   63,   66,   67,   67,
  502.        67,   67,   67,   67,   67,   63,   68,   63,   66,   67,
  503.        67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
  504.        67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
  505.        64,   63,   63,   63,   69,   70,   71,   70,   69,   69,
  506.        69,   69,   69,   69,   69,   69,   69,   69,   72,   72,
  507.        72,   72,   72,   69,   69,   69,   69,   72,   72,   72,
  508.        72,   72,   72,   72,   72,   72,   72,   72,   72,   72,
  509.  
  510.        72,   72,   72,   72,   72,   72,   72,   72,   73,   69,
  511.        69,   69,   77,   77,   78,   77,   77,   77,   77,   77,
  512.        77,   77,   77,   77,   77,   77,   79,   79,   79,   79,
  513.        79,   77,   77,   77,   77,   79,   79,   79,   79,   79,
  514.        79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
  515.        79,   79,   79,   79,   79,   79,   77,   77,   80,   77,
  516.        88,   89,   88,   88,   89,   88,   91,   94,  131,  149,
  517.        94,  152,  131,  150,  129,  148,  129,  148,  159,  153,
  518.       268,  131,  148,  131,  267,  131,  171,  172,  266,  147,
  519.       265,  183,  184,  207,  208,  156,  131,  173,  185,  264,
  520.  
  521.       263,  147,  262,   88,  261,   88,   88,  260,   88,   95,
  522.        92,   96,   95,  155,   96,  109,  109,  129,  110,  109,
  523.       109,  109,  109,  111,  109,  109,  109,  109,  112,  113,
  524.       112,  112,  114,  115,  116,  109,  109,  109,  117,  118,
  525.       119,  120,  121,  112,  112,  112,  122,  123,  112,  112,
  526.       124,  125,  126,  127,  112,  112,  128,  112,  112,  109,
  527.       109,  109,  109,  134,  134,  134,  134,  134,  134,  259,
  528.       137,  137,  137,  129,  258,  129,  134,  134,  134,  257,
  529.       137,  137,  137,  137,  137,  137,  196,  196,  196,  196,
  530.       196,  196,  256,  211,  211,  211,  213,  213,  213,  255,
  531.  
  532.       211,  211,  211,  213,  213,  213,  135,  254,  251,  135,
  533.       138,  225,  225,  225,  250,  249,  129,  248,  247,  135,
  534.       138,  246,  245,  138,  225,  225,  225,  244,  243,  197,
  535.       242,  241,  197,  212,  240,  239,  226,  238,  237,  214,
  536.       212,  252,  252,  252,  236,  235,  214,  234,  233,  226,
  537.       252,  252,  252,  272,  272,  272,  272,  272,  272,  275,
  538.       275,  275,  275,  275,  275,  232,  231,  230,  229,  228,
  539.       227,  224,  223,  222,  221,  220,  219,  218,  217,  216,
  540.       215,  210,  209,  206,  205,  204,  253,  203,  202,  201,
  541.       200,  199,  198,  195,  194,  253,  193,  192,  273,  191,
  542.  
  543.       190,  273,  189,  188,  276,  187,  186,  276,   36,   36,
  544.        36,   36,   36,   36,   36,   36,   36,   37,   37,   37,
  545.        37,   37,   37,   37,   37,   37,   40,   40,   40,   40,
  546.        40,   40,   40,   40,   40,   43,   43,   43,   43,   43,
  547.        43,   43,   43,   43,   47,   47,   47,   47,   47,   47,
  548.        47,   47,   47,   50,   50,   50,   50,   50,   50,   50,
  549.        50,   50,   74,   74,   74,   74,   74,   74,   74,   74,
  550.        74,   81,   81,   81,   81,   81,   81,   81,   81,   81,
  551.        84,   84,   84,   84,   84,   84,   84,   84,   84,   87,
  552.        87,   87,   87,   87,   87,   87,   87,   87,   90,   90,
  553.  
  554.        90,   90,   90,   90,   90,   90,   90,   93,   93,   93,
  555.        93,   93,   93,   93,   93,   93,   97,   97,   97,   97,
  556.        97,   97,   97,   97,   97,  100,  182,  181,  100,  180,
  557.       100,  100,  100,  101,  179,  178,  101,  101,  101,  101,
  558.       101,  105,  105,  177,  105,  105,  105,  105,  105,  105,
  559.       108,  176,  175,  174,  108,  130,  170,  169,  130,  130,
  560.       130,  130,  130,  130,  132,  168,  132,  132,  132,  133,
  561.       133,  143,  167,  166,  143,  143,  143,  143,  143,  145,
  562.       165,  164,  277,  145,  146,  146,  163,  162,  161,  160,
  563.       158,  157,  154,  151,  148,  107,  107,  106,  144,  142,
  564.  
  565.       141,  139,  107,  106,  104,  103,  102,   99,  277,   35,
  566.       277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
  567.       277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
  568.       277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
  569.       277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
  570.       277,  277,  277,  277,  277,  277,  277,  277
  571.     } ;
  572.  
  573. static const short int yy_chk[759] =
  574.     {   0,
  575.         0,    0,    3,    4,    5,    6,   29,    5,    6,    7,
  576.         7,    7,    8,    8,    8,    9,    9,    9,    7,   19,
  577.        20,    8,   10,   10,   10,   11,  115,  299,   11,   12,
  578.        23,   24,   12,   25,  113,   26,  113,   19,   20,  115,
  579.       298,   33,  270,   11,    3,    4,   34,   12,   23,   24,
  580.        29,   25,    7,   26,    7,    8,  268,    8,    9,   33,
  581.         9,  266,  117,  265,   34,   10,  117,   10,   13,   13,
  582.        13,   13,   13,   13,   13,   13,   13,   13,   13,   13,
  583.        13,   13,   13,   13,   13,   13,   13,   13,   13,   13,
  584.        13,   13,   13,   13,   13,   13,   13,   13,   13,   13,
  585.  
  586.        13,   13,   13,   13,   13,   13,   13,   13,   13,   13,
  587.        13,   13,   13,   13,   13,   13,   15,   15,   15,   15,
  588.        15,   15,   15,   15,   15,   15,   15,   15,   15,   15,
  589.        15,   15,   15,   15,   15,   15,   15,   15,   15,   15,
  590.        15,   15,   15,   15,   15,   15,   15,   15,   15,   15,
  591.        15,   15,   15,   15,   15,   15,   15,   15,   15,   15,
  592.        15,   15,   15,   15,   17,   17,   17,   17,   17,   17,
  593.        17,   17,   17,   17,   17,   17,   17,   17,   17,   17,
  594.        17,   17,   17,   17,   17,   17,   17,   17,   17,   17,
  595.        17,   17,   17,   17,   17,   17,   17,   17,   17,   17,
  596.  
  597.        17,   17,   17,   17,   17,   17,   17,   17,   17,   17,
  598.        17,   17,   21,   21,   21,   21,   21,   21,   21,   21,
  599.        21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
  600.        21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
  601.        21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
  602.        21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
  603.        27,   27,   27,   28,   28,   28,   30,   31,   67,  118,
  604.        32,  120,   67,  118,   64,  123,   64,  124,  127,  120,
  605.       263,  132,  122,   67,  262,  132,  155,  155,  261,  127,
  606.       260,  166,  166,  192,  192,  123,  132,  155,  166,  258,
  607.  
  608.       257,  124,  256,   27,  255,   27,   28,  254,   28,   31,
  609.        30,   31,   32,  122,   32,   60,   60,   64,   60,   60,
  610.        60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
  611.        60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
  612.        60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
  613.        60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
  614.        60,   60,   60,   70,   70,   70,   71,   71,   71,  251,
  615.        73,   73,   73,  129,  249,  129,  134,  134,  134,  248,
  616.       135,  135,  135,  137,  137,  137,  181,  181,  181,  196,
  617.       196,  196,  247,  197,  197,  197,  198,  198,  198,  246,
  618.  
  619.       211,  211,  211,  213,  213,  213,   70,  245,  243,   71,
  620.        73,  214,  214,  214,  242,  241,  129,  240,  238,  134,
  621.       135,  237,  236,  137,  225,  225,  225,  235,  234,  181,
  622.       233,  231,  196,  197,  230,  229,  214,  228,  226,  198,
  623.       211,  244,  244,  244,  224,  223,  213,  222,  221,  225,
  624.       252,  252,  252,  269,  269,  269,  272,  272,  272,  274,
  625.       274,  274,  275,  275,  275,  220,  219,  218,  217,  216,
  626.       215,  212,  210,  209,  208,  207,  203,  202,  201,  200,
  627.       199,  195,  193,  191,  190,  189,  244,  188,  187,  185,
  628.       184,  183,  182,  179,  178,  252,  177,  175,  269,  174,
  629.  
  630.       173,  272,  172,  171,  274,  169,  167,  275,  278,  278,
  631.       278,  278,  278,  278,  278,  278,  278,  279,  279,  279,
  632.       279,  279,  279,  279,  279,  279,  280,  280,  280,  280,
  633.       280,  280,  280,  280,  280,  281,  281,  281,  281,  281,
  634.       281,  281,  281,  281,  282,  282,  282,  282,  282,  282,
  635.       282,  282,  282,  283,  283,  283,  283,  283,  283,  283,
  636.       283,  283,  284,  284,  284,  284,  284,  284,  284,  284,
  637.       284,  285,  285,  285,  285,  285,  285,  285,  285,  285,
  638.       286,  286,  286,  286,  286,  286,  286,  286,  286,  287,
  639.       287,  287,  287,  287,  287,  287,  287,  287,  288,  288,
  640.  
  641.       288,  288,  288,  288,  288,  288,  288,  289,  289,  289,
  642.       289,  289,  289,  289,  289,  289,  290,  290,  290,  290,
  643.       290,  290,  290,  290,  290,  291,  165,  163,  291,  162,
  644.       291,  291,  291,  292,  161,  160,  292,  292,  292,  292,
  645.       292,  293,  293,  159,  293,  293,  293,  293,  293,  293,
  646.       294,  158,  157,  156,  294,  295,  154,  153,  295,  295,
  647.       295,  295,  295,  295,  296,  152,  296,  296,  296,  297,
  648.       297,  300,  151,  150,  300,  300,  300,  300,  300,  301,
  649.       149,  147,  145,  301,  302,  302,  144,  141,  138,  128,
  650.       126,  125,  121,  119,  114,  108,  107,  106,   98,   86,
  651.  
  652.        83,   76,   59,   58,   56,   55,   53,   42,   35,  277,
  653.       277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
  654.       277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
  655.       277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
  656.       277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
  657.       277,  277,  277,  277,  277,  277,  277,  277
  658.     } ;
  659.  
  660. static yy_state_type yy_last_accepting_state;
  661. static YY_CHAR *yy_last_accepting_cpos;
  662.  
  663. /* the intent behind this definition is that it'll catch
  664.  * any uses of REJECT which flex missed
  665.  */
  666. #define REJECT reject_used_but_not_detected
  667. #define yymore() yymore_used_but_not_detected
  668. #define YY_MORE_ADJ 0
  669.  
  670. /* these variables are all declared out here so that section 3 code can
  671.  * manipulate them
  672.  */
  673. /* points to current character in buffer */
  674. static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
  675. static int yy_init = 1;        /* whether we need to initialize */
  676. static int yy_start = 0;    /* start state number */
  677.  
  678. /* flag which is used to allow yywrap()'s to do buffer switches
  679.  * instead of setting up a fresh yyin.  A bit of a hack ...
  680.  */
  681. static int yy_did_buffer_switch_on_eof;
  682.  
  683. static yy_state_type yy_get_previous_state YY_PROTO(( void ));
  684. static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
  685. static int yy_get_next_buffer YY_PROTO(( void ));
  686. static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
  687. void yyrestart YY_PROTO(( FILE *input_file ));
  688. void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
  689. void yy_load_buffer_state YY_PROTO(( void ));
  690. YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
  691. void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  692. void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
  693.  
  694. #define yy_new_buffer yy_create_buffer
  695.  
  696. #ifdef __cplusplus
  697. static int yyinput YY_PROTO(( void ));
  698. #else
  699. static int input YY_PROTO(( void ));
  700. #endif
  701.  
  702. YY_DECL
  703.     {
  704.     register yy_state_type yy_current_state;
  705.     register YY_CHAR *yy_cp, *yy_bp;
  706.     register int yy_act;
  707.  
  708.  
  709.  
  710.     if ( yy_init )
  711.     {
  712.     YY_USER_INIT;
  713.  
  714.     if ( ! yy_start )
  715.         yy_start = 1;    /* first start state */
  716.  
  717.     if ( ! yyin )
  718.         yyin = stdin;
  719.  
  720.     if ( ! yyout )
  721.         yyout = stdout;
  722.  
  723.     if ( yy_current_buffer )
  724.         yy_init_buffer( yy_current_buffer, yyin );
  725.     else
  726.         yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  727.  
  728.     yy_load_buffer_state();
  729.  
  730.     yy_init = 0;
  731.     }
  732.  
  733.     while ( 1 )        /* loops until end-of-file is reached */
  734.     {
  735.     yy_cp = yy_c_buf_p;
  736.  
  737.     /* support of yytext */
  738.     *yy_cp = yy_hold_char;
  739.  
  740.     /* yy_bp points to the position in yy_ch_buf of the start of the
  741.      * current run.
  742.      */
  743.     yy_bp = yy_cp;
  744.  
  745.     yy_current_state = yy_start;
  746. yy_match:
  747.     do
  748.         {
  749.         register YY_CHAR yy_c = yy_ec[*yy_cp];
  750.         if ( yy_accept[yy_current_state] )
  751.         {
  752.         yy_last_accepting_state = yy_current_state;
  753.         yy_last_accepting_cpos = yy_cp;
  754.         }
  755.         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  756.         {
  757.         yy_current_state = yy_def[yy_current_state];
  758.         if ( yy_current_state >= 278 )
  759.             yy_c = yy_meta[yy_c];
  760.         }
  761.         yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  762.         ++yy_cp;
  763.         }
  764.     while ( yy_current_state != 277 );
  765.     yy_cp = yy_last_accepting_cpos;
  766.     yy_current_state = yy_last_accepting_state;
  767.  
  768. yy_find_action:
  769.     yy_act = yy_accept[yy_current_state];
  770.  
  771.     YY_DO_BEFORE_ACTION;
  772.     YY_USER_ACTION;
  773.  
  774. do_action:    /* this label is used only to access EOF actions */
  775.  
  776.  
  777.     switch ( yy_act )
  778.         {
  779.         case 0: /* must backtrack */
  780.         /* undo the effects of YY_DO_BEFORE_ACTION */
  781.         *yy_cp = yy_hold_char;
  782.         yy_cp = yy_last_accepting_cpos;
  783.         yy_current_state = yy_last_accepting_state;
  784.         goto yy_find_action;
  785.  
  786. case 1:
  787. /* ignore comments */    ;
  788.     YY_BREAK
  789. case 2:
  790. {fLatex = !fForcetex; IGNORE;}
  791.     YY_BREAK
  792. case 3:
  793. /* environment start */    {LaBEGIN LaBegin; IGNORE;}
  794.     YY_BREAK
  795. case 4:
  796. {   if (BeginEnv("verbatim"))
  797.                             BEGIN LaEnv;
  798.                             else
  799.                             BEGIN LaVerbatim;
  800.                             IGNORE;
  801.                         }
  802.     YY_BREAK
  803. case 5:
  804. /* verbatim mode */    {BEGIN Normal; IGNORE;}
  805.     YY_BREAK
  806. case 6:
  807. ECHO;
  808.     YY_BREAK
  809. case 7:
  810. {   if (BeginEnv(yytext))
  811.                             BEGIN LaEnv;
  812.                             else
  813.                             BEGIN LaMacro;
  814.                             IGNORE;
  815.                         }
  816.     YY_BREAK
  817. case 8:
  818. NEWLINE;
  819.     YY_BREAK
  820. case 9:
  821. ;
  822.     YY_BREAK
  823. case 10:
  824. /* absorb some environments */    {LaBEGIN LaEnd; IGNORE;}
  825.     YY_BREAK
  826. case 11:
  827. NEWLINE;
  828.     YY_BREAK
  829. case 12:
  830. ;
  831.     YY_BREAK
  832. case 13:
  833. /* end environment */    {   if (EndEnv(yytext))
  834.                             BEGIN Normal;
  835.                             IGNORE;
  836.                         }
  837.     YY_BREAK
  838. case 14:
  839. {BEGIN LaEnv; IGNORE;}
  840.     YY_BREAK
  841. case 15:
  842. NEWLINE;
  843.     YY_BREAK
  844. case 16:
  845. ;
  846.     YY_BREAK
  847. case 17:
  848. /* ignore args  */    {LaBEGIN LaMacro2; IGNORE;}
  849.     YY_BREAK
  850. case 18:
  851. /* of these \cs */    {LaBEGIN LaMacro; IGNORE;}
  852.     YY_BREAK
  853. case 19:
  854. {LaBEGIN LaMacro; IGNORE;}
  855.     YY_BREAK
  856. case 20:
  857. {CITEBEGIN LaMacro2; IGNORE;}
  858.     YY_BREAK
  859. case 21:
  860. {LaBEGIN LaMacro; IGNORE;}
  861.     YY_BREAK
  862. case 22:
  863. {LaBEGIN LaMacro; IGNORE;}
  864.     YY_BREAK
  865. case 23:
  866. {LaBEGIN LaMacro2; SPACE;}
  867.     YY_BREAK
  868. case 24:
  869. {LaBEGIN LaMacro; IGNORE;}
  870.     YY_BREAK
  871. case 25:
  872. {CITEBEGIN LaMacro; IGNORE;}
  873.     YY_BREAK
  874. case 26:
  875. {LaBEGIN LaMacro; IGNORE;}
  876.     YY_BREAK
  877. case 27:
  878. {CITEBEGIN LaMacro; IGNORE;}
  879.     YY_BREAK
  880. case 28:
  881. {LaBEGIN LaMacro; IGNORE;}
  882.     YY_BREAK
  883. case 29:
  884. /* ignore \verb<char>...<char> */ {   if (fLatex) {
  885.                              char verbchar, c;
  886.                              verbchar = input();
  887.                              while ((c = input()) != verbchar)
  888.                                 if (c == '\n')
  889.                                 NEWLINE;
  890.                             }
  891.                             IGNORE;
  892.                         }
  893.     YY_BREAK
  894. case 30:
  895. BEGIN Normal;
  896.     YY_BREAK
  897. case 31:
  898. NEWLINE;
  899.     YY_BREAK
  900. case 32:
  901. ;
  902.     YY_BREAK
  903. case 33:
  904. {   cOpenBrace++; }
  905.     YY_BREAK
  906. case 34:
  907. {   cOpenBrace--;
  908.                             if (cOpenBrace == 0)
  909.                             BEGIN Normal;
  910.                         }
  911.     YY_BREAK
  912. case 35:
  913. NEWLINE;
  914.     YY_BREAK
  915. case 36:
  916. ;
  917.     YY_BREAK
  918. case 37:
  919. /* ignore def begin */    {BEGIN Define; IGNORE;}
  920.     YY_BREAK
  921. case 38:
  922. BEGIN Normal;
  923.     YY_BREAK
  924. case 39:
  925. NEWLINE;
  926.     YY_BREAK
  927. case 40:
  928. ;
  929.     YY_BREAK
  930. case 41:
  931. /* formula mode */    {LaBEGIN LaFormula; IGNORE;}
  932.     YY_BREAK
  933. case 42:
  934. BEGIN Normal;
  935.     YY_BREAK
  936. case 43:
  937. NEWLINE;
  938.     YY_BREAK
  939. case 44:
  940. ;
  941.     YY_BREAK
  942. case 45:
  943. /* display mode */    {LaBEGIN LaDisplay; IGNORE;}
  944.     YY_BREAK
  945. case 46:
  946. BEGIN Normal;
  947.     YY_BREAK
  948. case 47:
  949. NEWLINE;
  950.     YY_BREAK
  951. case 48:
  952. ;
  953.     YY_BREAK
  954. case 49:
  955. /* display mode */    {BEGIN Display; IGNORE;}
  956.     YY_BREAK
  957. case 50:
  958. BEGIN Normal;
  959.     YY_BREAK
  960. case 51:
  961. NEWLINE;
  962.     YY_BREAK
  963. case 52:
  964. ;
  965.     YY_BREAK
  966. case 53:
  967. /* math mode */        {BEGIN Math; IGNORE;}
  968.     YY_BREAK
  969. case 54:
  970. BEGIN Normal;
  971.     YY_BREAK
  972. case 55:
  973. NEWLINE;
  974.     YY_BREAK
  975. case 56:
  976. ;
  977.     YY_BREAK
  978. case 57:
  979. ;
  980.     YY_BREAK
  981. case 58:
  982. /* process files */    {LaBEGIN LaInclude; IGNORE;}
  983.     YY_BREAK
  984. case 59:
  985. {   IncludeFile(yytext);
  986.                             BEGIN Normal;
  987.                         }
  988.     YY_BREAK
  989. case 60:
  990. NEWLINE;
  991.     YY_BREAK
  992. case 61:
  993. ;
  994.     YY_BREAK
  995. case 62:
  996. {BEGIN IncludeOnly; IGNORE;}
  997.     YY_BREAK
  998. case 63:
  999. AddInclude(yytext);
  1000.     YY_BREAK
  1001. case 64:
  1002. {   if (csbIncList == 0)
  1003.                             rgsbIncList[csbIncList++] = '\0';
  1004.                             BEGIN Normal;
  1005.                         }
  1006.     YY_BREAK
  1007. case 65:
  1008. NEWLINE;
  1009.     YY_BREAK
  1010. case 66:
  1011. ;
  1012.     YY_BREAK
  1013. case 67:
  1014. {BEGIN Input; IGNORE;}
  1015.     YY_BREAK
  1016. case 68:
  1017. {   InputFile(yytext);
  1018.                             BEGIN Normal;
  1019.                         }
  1020.     YY_BREAK
  1021. case 69:
  1022. NEWLINE;
  1023.     YY_BREAK
  1024. case 70:
  1025. ;
  1026.     YY_BREAK
  1027. case 71:
  1028. /* handle ligatures */ {printf("%.2s", yytext+1);}
  1029.     YY_BREAK
  1030. case 72:
  1031. {printf("%.1s", yytext+1);}
  1032.     YY_BREAK
  1033. case 73:
  1034. /* ignore other \cs */    {BEGIN Control; IGNORE;}
  1035.     YY_BREAK
  1036. case 74:
  1037. SPACE;
  1038.     YY_BREAK
  1039. case 75:
  1040. IGNORE;
  1041.     YY_BREAK
  1042. case 76:
  1043. IGNORE;
  1044.     YY_BREAK
  1045. case 77:
  1046. IGNORE;
  1047.     YY_BREAK
  1048. case 78:
  1049. {BEGIN Normal; NEWLINE;}
  1050.     YY_BREAK
  1051. case 79:
  1052. {BEGIN Normal; IGNORE;}
  1053.     YY_BREAK
  1054. case 80:
  1055. {yyless(0);BEGIN Normal;}
  1056.     YY_BREAK
  1057. case 81:
  1058. /* special characters */    IGNORE;
  1059.     YY_BREAK
  1060. case 82:
  1061. IGNORE;
  1062.     YY_BREAK
  1063. case 83:
  1064. SPACE;
  1065.     YY_BREAK
  1066. case 84:
  1067. {   if (fWord)
  1068.                             printf("%s\n", yytext);
  1069.                             else
  1070.                             ECHO;
  1071.                         }
  1072.     YY_BREAK
  1073. case 85:
  1074. if (!fWord) ECHO;
  1075.     YY_BREAK
  1076. case 86:
  1077. if (!fWord) ECHO;
  1078.     YY_BREAK
  1079. case 87:
  1080. ECHO;
  1081.     YY_BREAK
  1082. case YY_STATE_EOF(INITIAL):
  1083. case YY_STATE_EOF(Define):
  1084. case YY_STATE_EOF(Display):
  1085. case YY_STATE_EOF(IncludeOnly):
  1086. case YY_STATE_EOF(Input):
  1087. case YY_STATE_EOF(Math):
  1088. case YY_STATE_EOF(Normal):
  1089. case YY_STATE_EOF(Control):
  1090. case YY_STATE_EOF(LaBegin):
  1091. case YY_STATE_EOF(LaDisplay):
  1092. case YY_STATE_EOF(LaEnd):
  1093. case YY_STATE_EOF(LaEnv):
  1094. case YY_STATE_EOF(LaFormula):
  1095. case YY_STATE_EOF(LaInclude):
  1096. case YY_STATE_EOF(LaMacro):
  1097. case YY_STATE_EOF(LaMacro2):
  1098. case YY_STATE_EOF(LaVerbatim):
  1099.     yyterminate();
  1100.  
  1101.         case YY_END_OF_BUFFER:
  1102.         {
  1103.         /* amount of text matched not including the EOB char */
  1104.         int yy_amount_of_matched_text = yy_cp - yytext - 1;
  1105.  
  1106.         /* undo the effects of YY_DO_BEFORE_ACTION */
  1107.         *yy_cp = yy_hold_char;
  1108.  
  1109.         /* note that here we test for yy_c_buf_p "<=" to the position
  1110.          * of the first EOB in the buffer, since yy_c_buf_p will
  1111.          * already have been incremented past the NUL character
  1112.          * (since all states make transitions on EOB to the end-
  1113.          * of-buffer state).  Contrast this with the test in yyinput().
  1114.          */
  1115.         if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1116.             /* this was really a NUL */
  1117.             {
  1118.             yy_state_type yy_next_state;
  1119.  
  1120.             yy_c_buf_p = yytext + yy_amount_of_matched_text;
  1121.  
  1122.             yy_current_state = yy_get_previous_state();
  1123.  
  1124.             /* okay, we're now positioned to make the
  1125.              * NUL transition.  We couldn't have
  1126.              * yy_get_previous_state() go ahead and do it
  1127.              * for us because it doesn't know how to deal
  1128.              * with the possibility of jamming (and we
  1129.              * don't want to build jamming into it because
  1130.              * then it will run more slowly)
  1131.              */
  1132.  
  1133.             yy_next_state = yy_try_NUL_trans( yy_current_state );
  1134.  
  1135.             yy_bp = yytext + YY_MORE_ADJ;
  1136.  
  1137.             if ( yy_next_state )
  1138.             {
  1139.             /* consume the NUL */
  1140.             yy_cp = ++yy_c_buf_p;
  1141.             yy_current_state = yy_next_state;
  1142.             goto yy_match;
  1143.             }
  1144.  
  1145.             else
  1146.             {
  1147.                 yy_cp = yy_last_accepting_cpos;
  1148.                 yy_current_state = yy_last_accepting_state;
  1149.             goto yy_find_action;
  1150.             }
  1151.             }
  1152.  
  1153.         else switch ( yy_get_next_buffer() )
  1154.             {
  1155.             case EOB_ACT_END_OF_FILE:
  1156.             {
  1157.             yy_did_buffer_switch_on_eof = 0;
  1158.  
  1159.             if ( yywrap() )
  1160.                 {
  1161.                 /* note: because we've taken care in
  1162.                  * yy_get_next_buffer() to have set up yytext,
  1163.                  * we can now set up yy_c_buf_p so that if some
  1164.                  * total hoser (like flex itself) wants
  1165.                  * to call the scanner after we return the
  1166.                  * YY_NULL, it'll still work - another YY_NULL
  1167.                  * will get returned.
  1168.                  */
  1169.                 yy_c_buf_p = yytext + YY_MORE_ADJ;
  1170.  
  1171.                 yy_act = YY_STATE_EOF((yy_start - 1) / 2);
  1172.                 goto do_action;
  1173.                 }
  1174.  
  1175.             else
  1176.                 {
  1177.                 if ( ! yy_did_buffer_switch_on_eof )
  1178.                 YY_NEW_FILE;
  1179.                 }
  1180.             }
  1181.             break;
  1182.  
  1183.             case EOB_ACT_CONTINUE_SCAN:
  1184.             yy_c_buf_p = yytext + yy_amount_of_matched_text;
  1185.  
  1186.             yy_current_state = yy_get_previous_state();
  1187.  
  1188.             yy_cp = yy_c_buf_p;
  1189.             yy_bp = yytext + YY_MORE_ADJ;
  1190.             goto yy_match;
  1191.  
  1192.             case EOB_ACT_LAST_MATCH:
  1193.             yy_c_buf_p =
  1194.                 &yy_current_buffer->yy_ch_buf[yy_n_chars];
  1195.  
  1196.             yy_current_state = yy_get_previous_state();
  1197.  
  1198.             yy_cp = yy_c_buf_p;
  1199.             yy_bp = yytext + YY_MORE_ADJ;
  1200.             goto yy_find_action;
  1201.             }
  1202.         break;
  1203.         }
  1204.  
  1205.         default:
  1206. #ifdef FLEX_DEBUG
  1207.         printf( "action # %d\n", yy_act );
  1208. #endif
  1209.         YY_FATAL_ERROR(
  1210.             "fatal flex scanner internal error--no action found" );
  1211.         }
  1212.     }
  1213.     }
  1214.  
  1215.  
  1216. /* yy_get_next_buffer - try to read in a new buffer
  1217.  *
  1218.  * synopsis
  1219.  *     int yy_get_next_buffer();
  1220.  *     
  1221.  * returns a code representing an action
  1222.  *     EOB_ACT_LAST_MATCH - 
  1223.  *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  1224.  *     EOB_ACT_END_OF_FILE - end of file
  1225.  */
  1226.  
  1227. static int yy_get_next_buffer()
  1228.  
  1229.     {
  1230.     register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
  1231.     register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
  1232.     register int number_to_move, i;
  1233.     int ret_val;
  1234.  
  1235.     if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  1236.     YY_FATAL_ERROR(
  1237.         "fatal flex scanner internal error--end of buffer missed" );
  1238.  
  1239.     /* try to read more data */
  1240.  
  1241.     /* first move last chars to start of buffer */
  1242.     number_to_move = yy_c_buf_p - yytext;
  1243.  
  1244.     for ( i = 0; i < number_to_move; ++i )
  1245.     *(dest++) = *(source++);
  1246.  
  1247.     if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
  1248.     /* don't do the read, it's not guaranteed to return an EOF,
  1249.      * just force an EOF
  1250.      */
  1251.     yy_n_chars = 0;
  1252.  
  1253.     else
  1254.     {
  1255.     int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
  1256.  
  1257.     if ( num_to_read > YY_READ_BUF_SIZE )
  1258.         num_to_read = YY_READ_BUF_SIZE;
  1259.  
  1260.     else if ( num_to_read <= 0 )
  1261.         YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
  1262.  
  1263.     /* read in more data */
  1264.     YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  1265.           yy_n_chars, num_to_read );
  1266.     }
  1267.  
  1268.     if ( yy_n_chars == 0 )
  1269.     {
  1270.     if ( number_to_move == 1 )
  1271.         {
  1272.         ret_val = EOB_ACT_END_OF_FILE;
  1273.         yy_current_buffer->yy_eof_status = EOF_DONE;
  1274.         }
  1275.  
  1276.     else
  1277.         {
  1278.         ret_val = EOB_ACT_LAST_MATCH;
  1279.         yy_current_buffer->yy_eof_status = EOF_PENDING;
  1280.         }
  1281.     }
  1282.  
  1283.     else
  1284.     ret_val = EOB_ACT_CONTINUE_SCAN;
  1285.  
  1286.     yy_n_chars += number_to_move;
  1287.     yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  1288.     yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  1289.  
  1290.     /* yytext begins at the second character in yy_ch_buf; the first
  1291.      * character is the one which preceded it before reading in the latest
  1292.      * buffer; it needs to be kept around in case it's a newline, so
  1293.      * yy_get_previous_state() will have with '^' rules active
  1294.      */
  1295.  
  1296.     yytext = &yy_current_buffer->yy_ch_buf[1];
  1297.  
  1298.     return ( ret_val );
  1299.     }
  1300.  
  1301.  
  1302. /* yy_get_previous_state - get the state just before the EOB char was reached
  1303.  *
  1304.  * synopsis
  1305.  *     yy_state_type yy_get_previous_state();
  1306.  */
  1307.  
  1308. static yy_state_type yy_get_previous_state()
  1309.  
  1310.     {
  1311.     register yy_state_type yy_current_state;
  1312.     register YY_CHAR *yy_cp;
  1313.  
  1314.     yy_current_state = yy_start;
  1315.  
  1316.     for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  1317.     {
  1318.     register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
  1319.     if ( yy_accept[yy_current_state] )
  1320.         {
  1321.         yy_last_accepting_state = yy_current_state;
  1322.         yy_last_accepting_cpos = yy_cp;
  1323.         }
  1324.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1325.         {
  1326.         yy_current_state = yy_def[yy_current_state];
  1327.         if ( yy_current_state >= 278 )
  1328.         yy_c = yy_meta[yy_c];
  1329.         }
  1330.     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  1331.     }
  1332.  
  1333.     return ( yy_current_state );
  1334.     }
  1335.  
  1336.  
  1337. /* yy_try_NUL_trans - try to make a transition on the NUL character
  1338.  *
  1339.  * synopsis
  1340.  *     next_state = yy_try_NUL_trans( current_state );
  1341.  */
  1342.  
  1343. #ifdef YY_USE_PROTOS
  1344. static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
  1345. #else
  1346. static yy_state_type yy_try_NUL_trans( yy_current_state )
  1347. register yy_state_type yy_current_state;
  1348. #endif
  1349.  
  1350.     {
  1351.     register int yy_is_jam;
  1352.     register YY_CHAR *yy_cp = yy_c_buf_p;
  1353.  
  1354.     register YY_CHAR yy_c = 1;
  1355.     if ( yy_accept[yy_current_state] )
  1356.     {
  1357.     yy_last_accepting_state = yy_current_state;
  1358.     yy_last_accepting_cpos = yy_cp;
  1359.     }
  1360.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1361.     {
  1362.     yy_current_state = yy_def[yy_current_state];
  1363.     if ( yy_current_state >= 278 )
  1364.         yy_c = yy_meta[yy_c];
  1365.     }
  1366.     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  1367.     yy_is_jam = (yy_current_state == 277);
  1368.  
  1369.     return ( yy_is_jam ? 0 : yy_current_state );
  1370.     }
  1371.  
  1372.  
  1373. #ifdef YY_USE_PROTOS
  1374. static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
  1375. #else
  1376. static void yyunput( c, yy_bp )
  1377. YY_CHAR c;
  1378. register YY_CHAR *yy_bp;
  1379. #endif
  1380.  
  1381.     {
  1382.     register YY_CHAR *yy_cp = yy_c_buf_p;
  1383.  
  1384.     /* undo effects of setting up yytext */
  1385.     *yy_cp = yy_hold_char;
  1386.  
  1387.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  1388.     { /* need to shift things up to make room */
  1389.     register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  1390.     register YY_CHAR *dest =
  1391.         &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
  1392.     register YY_CHAR *source =
  1393.         &yy_current_buffer->yy_ch_buf[number_to_move];
  1394.  
  1395.     while ( source > yy_current_buffer->yy_ch_buf )
  1396.         *--dest = *--source;
  1397.  
  1398.     yy_cp += dest - source;
  1399.     yy_bp += dest - source;
  1400.     yy_n_chars = yy_current_buffer->yy_buf_size;
  1401.  
  1402.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  1403.         YY_FATAL_ERROR( "flex scanner push-back overflow" );
  1404.     }
  1405.  
  1406.     if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  1407.     yy_cp[-2] = '\n';
  1408.  
  1409.     *--yy_cp = c;
  1410.  
  1411.     /* note: the formal parameter *must* be called "yy_bp" for this
  1412.      *       macro to now work correctly
  1413.      */
  1414.     YY_DO_BEFORE_ACTION; /* set up yytext again */
  1415.     }
  1416.  
  1417.  
  1418. #ifdef __cplusplus
  1419. static int yyinput()
  1420. #else
  1421. static int input()
  1422. #endif
  1423.  
  1424.     {
  1425.     int c;
  1426.     YY_CHAR *yy_cp = yy_c_buf_p;
  1427.  
  1428.     *yy_cp = yy_hold_char;
  1429.  
  1430.     if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  1431.     {
  1432.     /* yy_c_buf_p now points to the character we want to return.
  1433.      * If this occurs *before* the EOB characters, then it's a
  1434.      * valid NUL; if not, then we've hit the end of the buffer.
  1435.      */
  1436.     if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1437.         /* this was really a NUL */
  1438.         *yy_c_buf_p = '\0';
  1439.  
  1440.     else
  1441.         { /* need more input */
  1442.         yytext = yy_c_buf_p;
  1443.         ++yy_c_buf_p;
  1444.  
  1445.         switch ( yy_get_next_buffer() )
  1446.         {
  1447.         case EOB_ACT_END_OF_FILE:
  1448.             {
  1449.             if ( yywrap() )
  1450.             {
  1451.             yy_c_buf_p = yytext + YY_MORE_ADJ;
  1452.             return ( EOF );
  1453.             }
  1454.  
  1455.             YY_NEW_FILE;
  1456.  
  1457. #ifdef __cplusplus
  1458.             return ( yyinput() );
  1459. #else
  1460.             return ( input() );
  1461. #endif
  1462.             }
  1463.             break;
  1464.  
  1465.         case EOB_ACT_CONTINUE_SCAN:
  1466.             yy_c_buf_p = yytext + YY_MORE_ADJ;
  1467.             break;
  1468.  
  1469.         case EOB_ACT_LAST_MATCH:
  1470. #ifdef __cplusplus
  1471.             YY_FATAL_ERROR( "unexpected last match in yyinput()" );
  1472. #else
  1473.             YY_FATAL_ERROR( "unexpected last match in input()" );
  1474. #endif
  1475.         }
  1476.         }
  1477.     }
  1478.  
  1479.     c = *yy_c_buf_p;
  1480.     yy_hold_char = *++yy_c_buf_p;
  1481.  
  1482.     return ( c );
  1483.     }
  1484.  
  1485.  
  1486. #ifdef YY_USE_PROTOS
  1487. void yyrestart( FILE *input_file )
  1488. #else
  1489. void yyrestart( input_file )
  1490. FILE *input_file;
  1491. #endif
  1492.  
  1493.     {
  1494.     yy_init_buffer( yy_current_buffer, input_file );
  1495.     yy_load_buffer_state();
  1496.     }
  1497.  
  1498.  
  1499. #ifdef YY_USE_PROTOS
  1500. void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  1501. #else
  1502. void yy_switch_to_buffer( new_buffer )
  1503. YY_BUFFER_STATE new_buffer;
  1504. #endif
  1505.  
  1506.     {
  1507.     if ( yy_current_buffer == new_buffer )
  1508.     return;
  1509.  
  1510.     if ( yy_current_buffer )
  1511.     {
  1512.     /* flush out information for old buffer */
  1513.     *yy_c_buf_p = yy_hold_char;
  1514.     yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  1515.     yy_current_buffer->yy_n_chars = yy_n_chars;
  1516.     }
  1517.  
  1518.     yy_current_buffer = new_buffer;
  1519.     yy_load_buffer_state();
  1520.  
  1521.     /* we don't actually know whether we did this switch during
  1522.      * EOF (yywrap()) processing, but the only time this flag
  1523.      * is looked at is after yywrap() is called, so it's safe
  1524.      * to go ahead and always set it.
  1525.      */
  1526.     yy_did_buffer_switch_on_eof = 1;
  1527.     }
  1528.  
  1529.  
  1530. #ifdef YY_USE_PROTOS
  1531. void yy_load_buffer_state( void )
  1532. #else
  1533. void yy_load_buffer_state()
  1534. #endif
  1535.  
  1536.     {
  1537.     yy_n_chars = yy_current_buffer->yy_n_chars;
  1538.     yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  1539.     yyin = yy_current_buffer->yy_input_file;
  1540.     yy_hold_char = *yy_c_buf_p;
  1541.     }
  1542.  
  1543.  
  1544. #ifdef YY_USE_PROTOS
  1545. YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  1546. #else
  1547. YY_BUFFER_STATE yy_create_buffer( file, size )
  1548. FILE *file;
  1549. int size;
  1550. #endif
  1551.  
  1552.     {
  1553.     YY_BUFFER_STATE b;
  1554.  
  1555.     b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );
  1556.  
  1557.     if ( ! b )
  1558.     YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1559.  
  1560.     b->yy_buf_size = size;
  1561.  
  1562.     /* yy_ch_buf has to be 2 characters longer than the size given because
  1563.      * we need to put in 2 end-of-buffer characters.
  1564.      */
  1565.     b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );
  1566.  
  1567.     if ( ! b->yy_ch_buf )
  1568.     YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1569.  
  1570.     yy_init_buffer( b, file );
  1571.  
  1572.     return ( b );
  1573.     }
  1574.  
  1575.  
  1576. #ifdef YY_USE_PROTOS
  1577. void yy_delete_buffer( YY_BUFFER_STATE b )
  1578. #else
  1579. void yy_delete_buffer( b )
  1580. YY_BUFFER_STATE b;
  1581. #endif
  1582.  
  1583.     {
  1584.     if ( b == yy_current_buffer )
  1585.     yy_current_buffer = (YY_BUFFER_STATE) 0;
  1586.  
  1587.     free( (char *) b->yy_ch_buf );
  1588.     free( (char *) b );
  1589.     }
  1590.  
  1591.  
  1592. #ifdef YY_USE_PROTOS
  1593. void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
  1594. #else
  1595. void yy_init_buffer( b, file )
  1596. YY_BUFFER_STATE b;
  1597. FILE *file;
  1598. #endif
  1599.  
  1600.     {
  1601.     b->yy_input_file = file;
  1602.  
  1603.     /* we put in the '\n' and start reading from [1] so that an
  1604.      * initial match-at-newline will be true.
  1605.      */
  1606.  
  1607.     b->yy_ch_buf[0] = '\n';
  1608.     b->yy_n_chars = 1;
  1609.  
  1610.     /* we always need two end-of-buffer characters.  The first causes
  1611.      * a transition to the end-of-buffer state.  The second causes
  1612.      * a jam in that state.
  1613.      */
  1614.     b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  1615.     b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
  1616.  
  1617.     b->yy_buf_pos = &b->yy_ch_buf[1];
  1618.  
  1619.     b->yy_eof_status = EOF_NOT_SEEN;
  1620.     }
  1621.  
  1622. /******
  1623. ** main --
  1624. **    Set sbProgName to the base of arg 0.
  1625. **    Set the input paths.
  1626. **    Check for options
  1627. **        -c        echo LaTeX \cite, \ref, and \pageref values
  1628. **        -e <env-list>    list of LaTeX environments to ignore
  1629. **        -l        force latex mode
  1630. **        -n        do not follow \input and \include
  1631. **        -s        replace control sequences with space
  1632. **        -t        force tex mode
  1633. **        -w        word only output
  1634. **    Set the list of LaTeX environments to ignore.
  1635. **    Process each input file.
  1636. **    If no input files are specified on the command line, process stdin.
  1637. ******/
  1638.  
  1639. main(int cArgs, char *rgsbArgs[])
  1640. {
  1641.     char    *pch, *sbEnvList = DEFAULTENV, sbBadOpt[2];
  1642. #ifndef __STDC__
  1643.     FILE    *TexOpen();
  1644. #endif
  1645.     int    fSawFile = 0, iArgs = 1;
  1646.  
  1647.     /* get base name and decide what we are doing, detex or delatex */
  1648.     if ((sbProgName = rindex(rgsbArgs[0], '/')) != NULL)
  1649.         sbProgName++;
  1650.     else
  1651.         sbProgName = rgsbArgs[0];
  1652.     if (strcmp("delatex",sbProgName) == 0)
  1653.         fLatex = 1;
  1654.  
  1655.     /* set rgsbInputPaths for use with TexOpen() */
  1656.     SetInputPaths();
  1657.  
  1658.     /* process command line options */
  1659.     while (iArgs < cArgs && *(pch = rgsbArgs[iArgs]) == CHOPT) {
  1660.         while (*++pch)
  1661.             switch (*pch) {
  1662.             case CHCITEOPT:
  1663.             fCite = 1;
  1664.             break;
  1665.             case CHENVOPT:
  1666.             sbEnvList = rgsbArgs[++iArgs];
  1667.             break;
  1668.             case CHLATEXOPT:
  1669.             fLatex = 1;
  1670.             break;
  1671.             case CHNOFOLLOWOPT:
  1672.             fFollow = 0;
  1673.             break;
  1674.             case CHSPACEOPT:
  1675.             fSpace = 1;
  1676.             break;
  1677.             case CHTEXOPT:
  1678.             fForcetex = 1;
  1679.             break;
  1680.             case CHWORDOPT:
  1681.             fWord = 1;
  1682.             break;
  1683.             default:
  1684.             sbBadOpt[0] = *pch;
  1685.             sbBadOpt[1] = '\0';
  1686.             Warning("unknown option ignored -", sbBadOpt);
  1687.             }
  1688.         iArgs++;
  1689.     }
  1690.     SetEnvIgnore(sbEnvList);
  1691.  
  1692.     /* process input files */
  1693.     for (; iArgs < cArgs; iArgs++) {
  1694.         fSawFile++;
  1695.         if ((yyin = TexOpen(rgsbArgs[iArgs])) == NULL) {
  1696.         Warning("can't open file", rgsbArgs[iArgs]);
  1697.         continue;;
  1698.         }
  1699.         BEGIN Normal;
  1700.         (void)yylex();
  1701.     }
  1702.  
  1703.     /* if there were no input files, assume stdin */
  1704.     if (!fSawFile) {
  1705.         yyin = stdin;
  1706.         BEGIN Normal;
  1707.         (void)yylex();
  1708.     }
  1709. #ifndef FLEX_SCANNER
  1710.     if (YYSTATE != Normal)
  1711.         ErrorExit("input contains an unterminated mode or environment");
  1712. #endif
  1713.     exit(0);
  1714. }
  1715.  
  1716. /******
  1717. ** yywrap -- handles EOF for lex.  Check to see if the stack of open files
  1718. **    has anything on it.  If it does, set yyin to the to value.  If not
  1719. **    return the termination signal for lex.
  1720. ******/
  1721.  
  1722. int yywrap(void)
  1723. {
  1724.     (void)fclose(yyin);
  1725.     if (cfp > 0) {
  1726.         yyin = rgfp[--cfp];
  1727.         return(0);
  1728.     }
  1729.     return(1);
  1730. }
  1731.  
  1732. /******
  1733. ** SetEnvIgnore -- sets rgsbEnvIgnore to the values indicated by the
  1734. **    sbEnvList.
  1735. ******/
  1736.  
  1737. void SetEnvIgnore(char *sbEnvList)
  1738. {
  1739.     csbEnvIgnore = SeparateList(sbEnvList, rgsbEnvIgnore, CHENVSEP, MAXENVS);
  1740.     if (csbEnvIgnore == ERROR)
  1741.         ErrorExit("The environtment list contains too many environments");
  1742. }
  1743.  
  1744. /******
  1745. ** BeginEnv -- checks to see if sbEnv is in the list rgsbEnvIgnore.  If it
  1746. **    is, sbCurrentEnv is set to sbEnv.
  1747. ******/
  1748.  
  1749. int BeginEnv(char *sbEnv)
  1750. {
  1751.     int    i;
  1752.  
  1753.     if (!fLatex) return(0);
  1754.     for (i = 0; i < csbEnvIgnore; i++)
  1755.         if (strcmp(sbEnv, rgsbEnvIgnore[i]) == 0) {
  1756.         (void)strcpy(sbCurrentEnv, sbEnv);
  1757.         return(1);
  1758.         }
  1759.     return(0);
  1760. }
  1761.  
  1762. /******
  1763. ** EndEnv -- checks to see if sbEnv is the current environment being ignored.
  1764. ******/
  1765.  
  1766. int EndEnv(char *sbEnv)
  1767. {
  1768.     if (!fLatex) return(0);
  1769.     if (strcmp(sbEnv, sbCurrentEnv) == 0)
  1770.         return(1);
  1771.     return(0);
  1772. }
  1773.  
  1774. /******
  1775. ** InputFile -- push the current yyin and open sbFile.  If the open fails,
  1776. **    the sbFile is ignored.
  1777. ******/
  1778.  
  1779. void InputFile(char *sbFile)
  1780. {
  1781. #ifndef __STDC__
  1782.     FILE    *TexOpen();
  1783. #endif
  1784.  
  1785.     if (!fFollow)
  1786.         return;
  1787.     rgfp[cfp++] = yyin;
  1788.     if ((yyin = TexOpen(sbFile)) == NULL) {
  1789.         Warning("can't open \\input file", sbFile);
  1790.         yyin = rgfp[--cfp];
  1791.     }
  1792. }
  1793.  
  1794. /******
  1795. ** IncludeFile -- if sbFile is not in the rgsbIncList, push current yyin
  1796. **    and open sbFile.  If the open fails, the sbFile is ignored.
  1797. ******/
  1798.  
  1799. void IncludeFile(char *sbFile)
  1800. {
  1801. #ifndef __STDC__
  1802.     FILE    *TexOpen();
  1803. #endif
  1804.  
  1805.     if (!fFollow)
  1806.         return;
  1807.     if (!InList(sbFile))
  1808.         return;
  1809.     rgfp[cfp++] = yyin;
  1810.     if ((yyin = TexOpen(sbFile)) == NULL) {
  1811.         Warning("can't open \\include file", sbFile);
  1812.         yyin = rgfp[--cfp];
  1813.     }
  1814. }
  1815.  
  1816. /******
  1817. ** AddInclude -- adds sbFile to the rgsbIncList and increments csbIncList.
  1818. **    If the include list is too long, sbFile is ignored.
  1819. ******/
  1820.  
  1821. void AddInclude(char *sbFile)
  1822. {
  1823.     if (!fFollow)
  1824.         return;
  1825.     if (csbIncList >= MAXINCLIST)
  1826.         Warning("\\includeonly list is too long, ignoring", sbFile);
  1827.     rgsbIncList[csbIncList] = malloc((unsigned)(strlen(sbFile) + 1));
  1828.     (void)strcpy(rgsbIncList[csbIncList++], sbFile);
  1829. }
  1830.  
  1831. /******
  1832. ** InList -- checks to see if sbFile is in the rgsbIncList.  If there is
  1833. **    no list, all files are assumed to be "in the list".
  1834. ******/
  1835.  
  1836. int InList(char *sbFile)
  1837. {
  1838.     char    *pch, sbBase[MAXPATHLEN];
  1839.     int    i;
  1840.  
  1841.     if (csbIncList == 0)    /* no list */
  1842.         return(1);
  1843.     (void)strcpy(sbBase, sbFile);
  1844.     if ((pch = rindex(sbBase, '.')) != NULL)
  1845.         *pch = '\0';
  1846.     i = 0;
  1847.     while ((i < csbIncList) && rgsbIncList[i])
  1848.         if (strcmp(rgsbIncList[i++], sbBase) == 0)
  1849.             return(1);
  1850.     return(0);
  1851. }
  1852.  
  1853. /******
  1854. ** SetInputPaths -- sets rgsbInputPaths to the values indicated by the
  1855. **    TEXINPUTS environment variable if set or else DEFAULTINPUTS.
  1856. ******/
  1857.  
  1858. void SetInputPaths(void)
  1859. {
  1860.     char *sb, *sbPaths, *getenv();
  1861.  
  1862.     if ((sb = getenv("TEXINPUTS")) == NULL)
  1863.     sbPaths = DEFAULTINPUTS;
  1864.     else {
  1865.     sbPaths = malloc((unsigned)(strlen(sb) + 1));
  1866.     (void)strcpy(sbPaths, sb);
  1867.     }
  1868.  
  1869.     csbInputPaths = SeparateList(sbPaths, rgsbInputPaths, CHPATHSEP, MAXINPUTPATHS);
  1870.     if (csbInputPaths == ERROR)
  1871.     ErrorExit("TEXINPUTS environment variable has too many paths");
  1872. }
  1873.  
  1874. /******
  1875. ** SeparateList -- takes a chSep separated list sbList, replaces the
  1876. **    chSep's with NULLs and sets rgsbList[i] to the beginning of
  1877. **    the ith word in sbList.  The number of words is returned.  A
  1878. **    ERROR is returned if there are more than csbMax words.
  1879. ******/
  1880.  
  1881. int SeparateList(char *sbList, char *rgsbList[], char chSep, int csbMax)
  1882. {
  1883.     int    csbList = 0;
  1884.  
  1885.     while (sbList && *sbList && csbList < csbMax) {
  1886.         rgsbList[csbList++] = sbList;
  1887.         if (sbList = index(sbList, chSep))
  1888.         *sbList++ = '\0';
  1889.     }
  1890.     return(sbList && *sbList ? ERROR : csbList);
  1891. }
  1892.  
  1893. /******
  1894. ** TexOpen -- tries to open sbFile in each of the rgsbInputPaths in turn.
  1895. **    For each input path the following order is used:
  1896. **        file.tex - must be as named, if not there go to the next path
  1897. **        file.ext - random extension, try it
  1898. **        file     - base name, add .tex and try it
  1899. **        file     - try it as is
  1900. **    Notice that if file exists in the first path and file.tex exists in
  1901. **    one of the other paths, file in the first path is what is opened.
  1902. **    If the sbFile begins with a '/', no paths are searched.
  1903. ******/
  1904.  
  1905. FILE *TexOpen(char *sbFile)
  1906. {
  1907.     char    *pch, *sbNew;
  1908.     FILE    *fp;
  1909.     int    iPath;
  1910.     static char    sbFullPath[MAXPATHLEN];
  1911.  
  1912.     for (iPath = 0; iPath < csbInputPaths; iPath++) {
  1913. #ifdef _AMIGA
  1914.         if(strchr(sbFile,':')) {
  1915. #else
  1916.         if (*sbFile == '/') {    /* absolute path */
  1917. #endif
  1918.             (void)sprintf(sbFullPath, "%s", sbFile);
  1919.             iPath = csbInputPaths;    /* only check once */
  1920.         } else {
  1921. #ifdef _AMIGA
  1922.             if(0 == strcmp(rgsbInputPaths[iPath],".")) {
  1923.                 (void) sprintf(sbFullPath, "%s", sbFile);
  1924.             } else {
  1925.                 char *tmp = rgsbInputPaths[iPath];
  1926.  
  1927.                 if(tmp[strlen(tmp)-1] == ':' || tmp[strlen(tmp)-1] == '/') {
  1928.                     (void)sprintf(sbFullPath, "%s%s", rgsbInputPaths[iPath], sbFile);
  1929.                 } else {
  1930.                     (void)sprintf(sbFullPath, "%s/%s", rgsbInputPaths[iPath], sbFile);
  1931.                 }
  1932.             }
  1933. #else
  1934.             (void)sprintf(sbFullPath, "%s/%s", rgsbInputPaths[iPath], sbFile);
  1935. #endif
  1936.         }
  1937.  
  1938.         /* If sbFile ends in .tex then it must be there */
  1939.         if ((pch = rindex(sbFullPath, '.')) != NULL
  1940.             && (strcmp(pch, ".tex") == 0))
  1941.         if ((fp = fopen(sbFullPath, "r")) != NULL)
  1942.             return(fp);
  1943.         else
  1944.             continue;
  1945.  
  1946.         /* if .<ext> then try to open it.  the '.' represents   */
  1947.         /* the beginning of an extension if it is not the first */
  1948.         /* character and it does not follow a '.' or a '/'      */
  1949.         if (pch != NULL && pch > &(sbFullPath[0])
  1950.                     && *(pch - 1) != '.' && *(pch - 1) != '/'
  1951.             && (fp = fopen(sbFullPath, "r")) != NULL)
  1952.         return(fp);
  1953.  
  1954.         /* just base name, add .tex to the name */
  1955.         sbNew = malloc((unsigned)(strlen(sbFullPath) + 5));
  1956.         (void)strcpy(sbNew, sbFullPath);
  1957.         (void)strcat(sbNew, ".tex");
  1958.         if ((fp = fopen(sbNew, "r")) != NULL)
  1959.         return(fp);
  1960.  
  1961.         /* try sbFile regardless */
  1962.         if ((fp = fopen(sbFullPath, "r")) != NULL)
  1963.         return(fp);
  1964.     }
  1965.     return((FILE *)NULL);
  1966. }
  1967.  
  1968. /******
  1969. ** Warning -- print a warning message preceded by the program name.
  1970. ******/
  1971.  
  1972. void Warning(char *sb1, char *sb2)
  1973. {
  1974.     fprintf(stderr, "%s: warning: %s %s\n", sbProgName, sb1, sb2);
  1975. }
  1976.  
  1977. /******
  1978. ** ErrorExit -- print an error message preceded by the program name.
  1979. **    Stdout is flushed and detex exits.
  1980. ******/
  1981.  
  1982. void ErrorExit(char *sb1)
  1983. {
  1984.     (void)fflush(stdout);
  1985.     fprintf(stderr, "%s: error: %s\n", sbProgName, sb1);
  1986.     exit(1);
  1987. }
  1988.