home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / forut062.zip / ForUtil-0.62 / commons / scan_commons.c < prev    next >
C/C++ Source or Header  |  1996-08-28  |  65KB  |  2,479 lines

  1. /* A lexical scanner generated by flex */
  2.  
  3. /* Scanner skeleton version:
  4.  * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.85 95/04/24 10:48:47 vern Exp $
  5.  */
  6.  
  7. #define FLEX_SCANNER
  8. #define YY_FLEX_MAJOR_VERSION 2
  9. #define YY_FLEX_MINOR_VERSION 5
  10.  
  11. #include <stdio.h>
  12.  
  13.  
  14. /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  15. #ifdef c_plusplus
  16. #ifndef __cplusplus
  17. #define __cplusplus
  18. #endif
  19. #endif
  20.  
  21.  
  22. #ifdef __cplusplus
  23.  
  24. #include <stdlib.h>
  25. #include <unistd.h>
  26.  
  27. /* Use prototypes in function declarations. */
  28. #define YY_USE_PROTOS
  29.  
  30. /* The "const" storage-class-modifier is valid. */
  31. #define YY_USE_CONST
  32.  
  33. #else    /* ! __cplusplus */
  34.  
  35. #if __STDC__
  36.  
  37. #define YY_USE_PROTOS
  38. #define YY_USE_CONST
  39.  
  40. #endif    /* __STDC__ */
  41. #endif    /* ! __cplusplus */
  42.  
  43. #ifdef __TURBOC__
  44.  #pragma warn -rch
  45.  #pragma warn -use
  46. #include <io.h>
  47. #include <stdlib.h>
  48. #define YY_USE_CONST
  49. #define YY_USE_PROTOS
  50. #endif
  51.  
  52. #ifdef YY_USE_CONST
  53. #define yyconst const
  54. #else
  55. #define yyconst
  56. #endif
  57.  
  58.  
  59. #ifdef YY_USE_PROTOS
  60. #define YY_PROTO(proto) proto
  61. #else
  62. #define YY_PROTO(proto) ()
  63. #endif
  64.  
  65. /* Returned upon end-of-file. */
  66. #define YY_NULL 0
  67.  
  68. /* Promotes a possibly negative, possibly signed char to an unsigned
  69.  * integer for use as an array index.  If the signed char is negative,
  70.  * we want to instead treat it as an 8-bit unsigned char, hence the
  71.  * double cast.
  72.  */
  73. #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
  74.  
  75. /* Enter a start condition.  This macro really ought to take a parameter,
  76.  * but we do it the disgusting crufty way forced on us by the ()-less
  77.  * definition of BEGIN.
  78.  */
  79. #define BEGIN yy_start = 1 + 2 *
  80.  
  81. /* Translate the current start state into a value that can be later handed
  82.  * to BEGIN to return to the state.  The YYSTATE alias is for lex
  83.  * compatibility.
  84.  */
  85. #define YY_START ((yy_start - 1) / 2)
  86. #define YYSTATE YY_START
  87.  
  88. /* Action number for EOF rule of a given start state. */
  89. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  90.  
  91. /* Special action meaning "start processing a new file". */
  92. #define YY_NEW_FILE yyrestart( yyin )
  93.  
  94. #define YY_END_OF_BUFFER_CHAR 0
  95.  
  96. /* Size of default input buffer. */
  97. #define YY_BUF_SIZE 16384
  98.  
  99. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  100.  
  101. extern int yyleng;
  102. extern FILE *yyin, *yyout;
  103.  
  104. #define EOB_ACT_CONTINUE_SCAN 0
  105. #define EOB_ACT_END_OF_FILE 1
  106. #define EOB_ACT_LAST_MATCH 2
  107.  
  108. /* The funky do-while in the following #define is used to turn the definition
  109.  * int a single C statement (which needs a semi-colon terminator).  This
  110.  * avoids problems with code like:
  111.  *
  112.  *     if ( condition_holds )
  113.  *        yyless( 5 );
  114.  *    else
  115.  *        do_something_else();
  116.  *
  117.  * Prior to using the do-while the compiler would get upset at the
  118.  * "else" because it interpreted the "if" statement as being all
  119.  * done when it reached the ';' after the yyless() call.
  120.  */
  121.  
  122. /* Return all but the first 'n' matched characters back to the input stream. */
  123.  
  124. #define yyless(n) \
  125.     do \
  126.         { \
  127.         /* Undo effects of setting up yytext. */ \
  128.         *yy_cp = yy_hold_char; \
  129.         yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
  130.         YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  131.         } \
  132.     while ( 0 )
  133.  
  134. #define unput(c) yyunput( c, yytext_ptr )
  135.  
  136. /* The following is because we cannot portably get our hands on size_t
  137.  * (without autoconf's help, which isn't available because we want
  138.  * flex-generated scanners to compile on their own).
  139.  */
  140. typedef unsigned int yy_size_t;
  141.  
  142.  
  143. struct yy_buffer_state
  144.     {
  145.     FILE *yy_input_file;
  146.  
  147.     char *yy_ch_buf;        /* input buffer */
  148.     char *yy_buf_pos;        /* current position in input buffer */
  149.  
  150.     /* Size of input buffer in bytes, not including room for EOB
  151.      * characters.
  152.      */
  153.     yy_size_t yy_buf_size;
  154.  
  155.     /* Number of characters read into yy_ch_buf, not including EOB
  156.      * characters.
  157.      */
  158.     int yy_n_chars;
  159.  
  160.     /* Whether we "own" the buffer - i.e., we know we created it,
  161.      * and can realloc() it to grow it, and should free() it to
  162.      * delete it.
  163.      */
  164.     int yy_is_our_buffer;
  165.  
  166.     /* Whether this is an "interactive" input source; if so, and
  167.      * if we're using stdio for input, then we want to use getc()
  168.      * instead of fread(), to make sure we stop fetching input after
  169.      * each newline.
  170.      */
  171.     int yy_is_interactive;
  172.  
  173.     /* Whether we're considered to be at the beginning of a line.
  174.      * If so, '^' rules will be active on the next match, otherwise
  175.      * not.
  176.      */
  177.     int yy_at_bol;
  178.  
  179.     /* Whether to try to fill the input buffer when we reach the
  180.      * end of it.
  181.      */
  182.     int yy_fill_buffer;
  183.  
  184.     int yy_buffer_status;
  185. #define YY_BUFFER_NEW 0
  186. #define YY_BUFFER_NORMAL 1
  187.     /* When an EOF's been seen but there's still some text to process
  188.      * then we mark the buffer as YY_EOF_PENDING, to indicate that we
  189.      * shouldn't try reading from the input source any more.  We might
  190.      * still have a bunch of tokens to match, though, because of
  191.      * possible backing-up.
  192.      *
  193.      * When we actually see the EOF, we change the status to "new"
  194.      * (via yyrestart()), so that the user can continue scanning by
  195.      * just pointing yyin at a new input file.
  196.      */
  197. #define YY_BUFFER_EOF_PENDING 2
  198.     };
  199.  
  200. static YY_BUFFER_STATE yy_current_buffer = 0;
  201.  
  202. /* We provide macros for accessing buffer states in case in the
  203.  * future we want to put the buffer states in a more general
  204.  * "scanner state".
  205.  */
  206. #define YY_CURRENT_BUFFER yy_current_buffer
  207.  
  208.  
  209. /* yy_hold_char holds the character lost when yytext is formed. */
  210. static char yy_hold_char;
  211.  
  212. static int yy_n_chars;        /* number of characters read into yy_ch_buf */
  213.  
  214.  
  215. int yyleng;
  216.  
  217. /* Points to current character in buffer. */
  218. static char *yy_c_buf_p = (char *) 0;
  219. static int yy_init = 1;        /* whether we need to initialize */
  220. static int yy_start = 0;    /* start state number */
  221.  
  222. /* Flag which is used to allow yywrap()'s to do buffer switches
  223.  * instead of setting up a fresh yyin.  A bit of a hack ...
  224.  */
  225. static int yy_did_buffer_switch_on_eof;
  226.  
  227. void yyrestart YY_PROTO(( FILE *input_file ));
  228.  
  229. void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
  230. void yy_load_buffer_state YY_PROTO(( void ));
  231. YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
  232. void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  233. void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
  234. void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  235. #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
  236.  
  237. YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
  238. YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str ));
  239. YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
  240.  
  241. static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
  242. static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
  243. static void yy_flex_free YY_PROTO(( void * ));
  244.  
  245. #define yy_new_buffer yy_create_buffer
  246.  
  247. #define yy_set_interactive(is_interactive) \
  248.     { \
  249.     if ( ! yy_current_buffer ) \
  250.         yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
  251.     yy_current_buffer->yy_is_interactive = is_interactive; \
  252.     }
  253.  
  254. #define yy_set_bol(at_bol) \
  255.     { \
  256.     if ( ! yy_current_buffer ) \
  257.         yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
  258.     yy_current_buffer->yy_at_bol = at_bol; \
  259.     }
  260.  
  261. #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
  262.  
  263.  
  264. #define YY_USES_REJECT
  265. typedef unsigned char YY_CHAR;
  266. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  267. typedef int yy_state_type;
  268. extern int yylineno;
  269. int yylineno = 1;
  270. extern char *yytext;
  271. #define yytext_ptr yytext
  272.  
  273. static yy_state_type yy_get_previous_state YY_PROTO(( void ));
  274. static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
  275. static int yy_get_next_buffer YY_PROTO(( void ));
  276. static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
  277.  
  278. /* Done after the current pattern has been matched and before the
  279.  * corresponding action - sets up yytext.
  280.  */
  281. #define YY_DO_BEFORE_ACTION \
  282.     yytext_ptr = yy_bp; \
  283.     yyleng = (int) (yy_cp - yy_bp); \
  284.     yy_hold_char = *yy_cp; \
  285.     *yy_cp = '\0'; \
  286.     yy_c_buf_p = yy_cp;
  287.  
  288. #define YY_NUM_RULES 19
  289. #define YY_END_OF_BUFFER 20
  290. static yyconst short int yy_acclist[26] =
  291.     {   0,
  292.        20,   18,   19,   19,   18,   19,   18,   19,    1,   12,
  293.         4,   16,   10,    8,    6,    2,   13,    5,   14,   17,
  294.        11,    9,    7,    3,   15
  295.     } ;
  296.  
  297. static yyconst short int yy_accept[177] =
  298.     {   0,
  299.         1,    1,    1,    1,    1,    2,    4,    5,    7,    9,
  300.         9,    9,    9,   10,   10,   10,   10,   10,   10,   10,
  301.        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
  302.        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
  303.        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
  304.        10,   10,   10,   11,   11,   11,   11,   11,   11,   11,
  305.        11,   11,   11,   12,   12,   12,   12,   12,   12,   12,
  306.        12,   12,   13,   13,   14,   15,   15,   15,   15,   15,
  307.        15,   15,   15,   15,   15,   15,   16,   16,   16,   16,
  308.        16,   16,   17,   17,   17,   17,   17,   17,   17,   17,
  309.  
  310.        17,   17,   17,   17,   17,   17,   17,   17,   17,   17,
  311.        17,   17,   17,   17,   17,   17,   17,   17,   17,   17,
  312.        17,   17,   17,   17,   17,   17,   17,   17,   17,   17,
  313.        17,   17,   17,   17,   18,   18,   18,   18,   18,   18,
  314.        18,   18,   18,   18,   19,   19,   19,   20,   20,   20,
  315.        20,   20,   20,   20,   21,   21,   22,   23,   23,   23,
  316.        23,   23,   23,   23,   24,   24,   25,   25,   25,   25,
  317.        25,   25,   25,   25,   26,   26
  318.     } ;
  319.  
  320. static yyconst int yy_ec[256] =
  321.     {   0,
  322.         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
  323.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  324.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  325.         1,    4,    5,    5,    5,    5,    5,    5,    5,    5,
  326.         5,    6,    5,    5,    5,    5,    5,    5,    5,    5,
  327.         5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
  328.         5,    5,    5,    5,    7,    8,    9,   10,   11,    5,
  329.        12,   13,   14,    5,    5,   15,   16,   17,   18,   19,
  330.         5,   20,   21,   22,   23,    5,    5,   24,    5,    5,
  331.         5,    5,    5,    5,    5,    5,    7,    8,    9,   10,
  332.  
  333.        11,    5,   12,   13,   14,    5,    5,   15,   16,   17,
  334.        18,   19,    5,   20,   21,   22,   23,    5,    5,   24,
  335.         5,    5,    5,    5,    5,    5,    1,    1,    1,    1,
  336.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  337.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  338.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  339.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  340.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  341.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  342.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  343.  
  344.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  345.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  346.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  347.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  348.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  349.         1,    1,    1,    1,    1
  350.     } ;
  351.  
  352. static yyconst int yy_meta[25] =
  353.     {   0,
  354.         1,    2,    3,    4,    5,    5,    5,    5,    5,    5,
  355.         5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
  356.         5,    5,    5,    5
  357.     } ;
  358.  
  359. static yyconst short int yy_base[203] =
  360.     {   0,
  361.       287,    0,    0,    0,  289,  291,  291,  284,    0,  283,
  362.       283,  281,  291,  280,  279,    6,    0,    0,  264,  264,
  363.       262,  272,  267,  270,  260,  252,  252,  261,  252,  264,
  364.       250,    3,  261,  257,  253,  259,  250,  257,  245,  247,
  365.       246,  248,  250,  242,    0,  248,  239,  244,  243,  242,
  366.       245,  240,  247,  227,    0,  224,  243,  226,  230,  222,
  367.       239,  231,  238,    0,  221,    0,    0,  228,  234,  217,
  368.       232,  232,  214,  230,  229,  211,  226,    0,  225,  224,
  369.       216,  222,  221,    0,  220,  220,  218,  217,  211,  215,
  370.       214,  214,  212,  211,  210,  209,  198,  207,  206,  205,
  371.  
  372.         0,  204,  203,  202,  184,  200,  199,  198,    3,  197,
  373.         0,  196,  185,  194,  191,  188,   10,  182,   25,    0,
  374.       164,    0,    0,  175,   28,   21,  169,   31,   32,  152,
  375.        35,   36,  159,  156,    0,   39,   42,   44,    0,   45,
  376.        48,    0,   49,  150,   52,   55,  148,   57,   60,   62,
  377.        65,   67,   68,  142,  137,  131,  128,   71,   74,   77,
  378.       123,   79,   82,  103,   70,   24,   13,    7,    0,   84,
  379.        85,   88,   91,    4,  291,   94,   99,  104,  106,  108,
  380.       110,  112,  114,  116,  118,  123,  128,  132,  137,  142,
  381.       147,  151,  156,  160,  162,  166,  170,  175,  179,  183,
  382.  
  383.       188,  192
  384.     } ;
  385.  
  386. static yyconst short int yy_def[203] =
  387.     {   0,
  388.       176,  176,  177,  177,  175,  175,  175,  175,  178,  175,
  389.       178,  175,  175,  175,  175,  175,   16,  175,  175,  175,
  390.       175,  175,  175,  175,  175,  175,  175,  175,  175,  175,
  391.       175,  175,  175,  175,  175,  175,  175,  175,  175,  175,
  392.       175,  175,  175,  175,  179,  175,  175,  175,  175,  175,
  393.       175,  175,  179,  175,  180,  175,  175,  175,  175,  175,
  394.       175,  175,  180,  181,  175,  182,  183,  175,  175,  175,
  395.       175,  181,  175,  182,  183,  175,  175,  184,  175,  175,
  396.       175,  175,  175,  185,  175,  184,  175,  175,  175,  175,
  397.       175,  185,  175,  175,  175,  175,  175,  175,  175,  175,
  398.  
  399.       186,  175,  175,  175,  175,  175,  175,  175,  175,  175,
  400.       187,  175,  175,  175,  175,  175,  188,  175,  175,  189,
  401.       175,  190,  191,  175,  188,  188,  175,  192,  175,  175,
  402.       175,  175,  175,  175,  193,  192,  192,  194,  195,  196,
  403.       197,  198,  175,  175,  194,  194,  195,  196,  196,  197,
  404.       197,  175,  199,  175,  175,  175,  175,  200,  199,  199,
  405.       175,  200,  200,  175,  175,  175,  175,  175,  201,  175,
  406.       202,  202,  202,  175,    0,  175,  175,  175,  175,  175,
  407.       175,  175,  175,  175,  175,  175,  175,  175,  175,  175,
  408.       175,  175,  175,  175,  175,  175,  175,  175,  175,  175,
  409.  
  410.       175,  175
  411.     } ;
  412.  
  413. static yyconst short int yy_nxt[316] =
  414.     {   0,
  415.       175,  175,    7,    8,  117,    9,  117,  161,    9,   17,
  416.       169,  117,   24,  125,   18,   19,  168,   25,   39,   20,
  417.        21,   40,  175,  134,   22,   23,  128,  108,  128,  117,
  418.       134,  125,  128,  138,  136,  138,  140,  141,  140,  141,
  419.       128,  144,  136,  175,  144,  138,  140,  145,  148,  141,
  420.       153,  150,  153,  138,  154,  145,  175,  154,  140,  156,
  421.       148,  175,  156,  141,  157,  150,  175,  157,  158,  153,
  422.       158,  159,  158,  167,  162,  153,  164,  159,  175,  164,
  423.       158,  166,  162,  175,  166,  171,  171,  171,  172,  171,
  424.       174,  172,  175,  174,    6,    6,    6,    6,    6,    7,
  425.  
  426.         7,    7,    7,    7,   11,   11,  102,   11,   11,   53,
  427.        53,   63,   63,   72,   72,   74,   74,   75,   75,   86,
  428.        86,   92,   92,  109,  109,  109,  165,  109,  119,  119,
  429.       119,   91,  119,  126,   90,  126,  126,  129,  129,  129,
  430.       161,  129,  131,  131,  131,   88,  131,  132,  132,  132,
  431.       155,  132,  137,   79,  137,  137,  143,  143,  143,   69,
  432.       143,  146,  142,  146,  146,  147,  147,  149,  139,  149,
  433.       149,  151,  135,  151,  151,  152,  152,  152,  133,  152,
  434.       160,  130,  160,  160,  163,  127,  163,  163,  170,  170,
  435.       170,  124,  170,  173,  123,  173,  173,  122,  121,  120,
  436.  
  437.       118,  116,  115,  114,  113,  112,  111,  110,  108,  107,
  438.       106,  105,  104,  103,  102,  101,  100,   99,   98,   97,
  439.        96,   95,   94,   93,   91,   90,   89,   88,   87,   85,
  440.        84,   83,   82,   81,   80,   79,   78,   77,   76,   73,
  441.        71,   70,   69,   68,   67,   66,   65,   64,   62,   61,
  442.        60,   59,   58,   57,   56,   55,   54,   52,   51,   50,
  443.        49,   48,   47,   46,   45,   44,   43,   42,   41,   38,
  444.        37,   36,   35,   34,   33,   32,   31,   30,   29,   28,
  445.        27,   26,   16,   15,   14,   13,   12,   10,  175,    7,
  446.         5,  175,  175,  175,  175,  175,  175,  175,  175,  175,
  447.  
  448.       175,  175,  175,  175,  175,  175,  175,  175,  175,  175,
  449.       175,  175,  175,  175,  175
  450.     } ;
  451.  
  452. static yyconst short int yy_chk[316] =
  453.     {   0,
  454.         0,    0,    2,    2,  109,    2,  109,  174,    2,   16,
  455.       168,  117,   18,  117,   16,   16,  167,   18,   32,   16,
  456.        16,   32,  126,  126,   16,   16,  119,  166,  119,  125,
  457.       125,  125,  128,  129,  128,  129,  131,  132,  131,  132,
  458.       136,  136,  136,  137,  137,  138,  140,  138,  140,  141,
  459.       143,  141,  143,  145,  145,  145,  146,  146,  148,  148,
  460.       148,  149,  149,  150,  150,  150,  151,  151,  152,  153,
  461.       152,  153,  158,  165,  158,  159,  159,  159,  160,  160,
  462.       162,  162,  162,  163,  163,  170,  171,  170,  171,  172,
  463.       172,  172,  173,  173,  176,  176,  176,  176,  176,  177,
  464.  
  465.       177,  177,  177,  177,  178,  178,  164,  178,  178,  179,
  466.       179,  180,  180,  181,  181,  182,  182,  183,  183,  184,
  467.       184,  185,  185,  186,  186,  186,  161,  186,  187,  187,
  468.       187,  157,  187,  188,  156,  188,  188,  189,  189,  189,
  469.       155,  189,  190,  190,  190,  154,  190,  191,  191,  191,
  470.       147,  191,  192,  144,  192,  192,  193,  193,  193,  134,
  471.       193,  194,  133,  194,  194,  195,  195,  196,  130,  196,
  472.       196,  197,  127,  197,  197,  198,  198,  198,  124,  198,
  473.       199,  121,  199,  199,  200,  118,  200,  200,  201,  201,
  474.       201,  116,  201,  202,  115,  202,  202,  114,  113,  112,
  475.  
  476.       110,  108,  107,  106,  105,  104,  103,  102,  100,   99,
  477.        98,   97,   96,   95,   94,   93,   92,   91,   90,   89,
  478.        88,   87,   86,   85,   83,   82,   81,   80,   79,   77,
  479.        76,   75,   74,   73,   72,   71,   70,   69,   68,   65,
  480.        63,   62,   61,   60,   59,   58,   57,   56,   54,   53,
  481.        52,   51,   50,   49,   48,   47,   46,   44,   43,   42,
  482.        41,   40,   39,   38,   37,   36,   35,   34,   33,   31,
  483.        30,   29,   28,   27,   26,   25,   24,   23,   22,   21,
  484.        20,   19,   15,   14,   12,   11,   10,    8,    5,    1,
  485.       175,  175,  175,  175,  175,  175,  175,  175,  175,  175,
  486.  
  487.       175,  175,  175,  175,  175,  175,  175,  175,  175,  175,
  488.       175,  175,  175,  175,  175
  489.     } ;
  490.  
  491. static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;
  492. static char *yy_full_match;
  493. static int yy_lp;
  494. #define REJECT \
  495. { \
  496. *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
  497. yy_cp = yy_full_match; /* restore poss. backed-over text */ \
  498. ++yy_lp; \
  499. goto find_rule; \
  500. }
  501. #define yymore() yymore_used_but_not_detected
  502. #define YY_MORE_ADJ 0
  503. char *yytext;
  504. #line 1 "scan_commons.l"
  505. #define INITIAL 0
  506. #line 2 "scan_commons.l"
  507. #ifndef lint
  508. static char rcsId[]="$Header: /usr/local/rcs/ForUtil/Commons/RCS/scan_commons.l,v 1.9 1996/08/28 17:44:20 koen Exp koen $";
  509. #endif
  510. /*****
  511. * scan_commons.l : database builder for stuff defined in common blocks
  512. *
  513. * This file Version    $Revision: 1.9 $
  514. *
  515. * Creation date:    Fri Mar 15 18:02:11 GMT+0100 1996
  516. * Last modification:     $Date: 1996/08/28 17:44:20 $
  517. * By:            $Author: koen $
  518. * Current State:    $State: Exp $
  519. *
  520. * Author:        koen
  521. * (C)Copyright 1995-1996 Ripley Software Development
  522. * All Rights Reserved
  523. *
  524. * This program has three undocumented switches for debugging purposes:
  525. * -c: dump core on errors
  526. * -t: do not install signal traps, needed for debugging
  527. * -m for memory information under msdos
  528. *****/
  529. /*****
  530. * ChangeLog 
  531. * $Log: scan_commons.l,v $
  532. * Revision 1.9  1996/08/28 17:44:20  koen
  533. * Added print_version_id
  534. *
  535. * Revision 1.8  1996/08/27 19:13:29  koen
  536. * Changed scanner routines to support scanning of source files.
  537. *
  538. * Revision 1.7  1996/08/07 21:11:04  koen
  539. * Updated the rules and added a rule for PARAMETER
  540. *
  541. * Revision 1.6  1996/08/02 14:49:29  koen
  542. * moved all system dependencies to lib/sysdeps.h
  543. *
  544. * Revision 1.5  1996/07/30 01:58:16  koen
  545. * Changed rule for common blocks to use every possible char as a 
  546. * continuation character. 
  547. * Implemented the ignore_this_file routine. 
  548. * Reorganized output stuff and command line handling. 
  549. * Added version information.
  550. *
  551. * Revision 1.4  1996/07/16 00:38:14  koen
  552. * minor (cosmetic) changes.
  553. *
  554. * Revision 1.3  1996/05/06 00:33:02  koen
  555. * Adapted for MSDOS. Added some showing of files to scan when -v is used.
  556. *
  557. * Revision 1.2  1996/04/25 02:27:04  koen
  558. * Cleanup and comments added.
  559. *
  560. * Revision 1.1  1996/03/15 04:16:42  koen
  561. * Initial Revision
  562. *
  563. *****/ 
  564. #ifdef HAVE_CONFIG_H
  565. #include "autoconf.h"
  566. #endif
  567.  
  568. #include <signal.h>
  569.  
  570. #include "lib_commons.h"
  571. #include "forutil.h"
  572. #include "memmacros.h"
  573. #include "version.h"
  574.  
  575. #define MAXDIRS        64
  576. #define MAXIGNORE    64
  577. #define MAXEXTS        8
  578.  
  579. #define YY_EXIT_FAILURE    13
  580.  
  581. /****
  582. * Local variables
  583. ****/
  584. datum content;
  585. int verbose;
  586. static char progname[32];
  587. static int quiet, full_names, replace, dump_core, no_signal;
  588. static int num_total, num_total_accepted, num_total_rejected;
  589. static int num_total_replaced, num_total_stored;
  590. static int num_common_total, num_common_rejected, num_common_accepted;
  591. static int num_common_replaced, num_common_stored, fast;
  592. static int reorganize, curr_file_num, ign_file_num;
  593. static char *outfile;
  594. static char curr_path[512], curr_file[128];
  595. static int num_dirs_to_visit, num_extensions, num_ignore;
  596. static char *dirs_to_visit[MAXDIRS];
  597. static char *ext_table[MAXEXTS];
  598. static char *ignore_list[MAXIGNORE];
  599.  
  600. int num_files;
  601. static int num_warnings, num_errors;
  602. char **file_list;
  603.  
  604. #ifdef __MSDOS__
  605. unsigned long dir_mem, ext_mem, file_mem, ign_mem;
  606. static int need_mem_info_for_msdos;
  607. #endif
  608.  
  609. /* the database file */
  610. static GDBM_FILE db_file;
  611.  
  612. /****
  613. * Local function prototypes
  614. ****/
  615. static void get_common_contents(char *text);
  616.  
  617. static void (*gdbm_proto_func)();    /* generic gdbm insertion proto */
  618. static void replace_item(datum key);    /* replace & update an item */
  619. static void insert_item(datum key);    /* insert an item */
  620.  
  621. static char *usage = {"Usage: %s [-afhqrsv] [-Eext] [-Idir] [-ddatabase] [-xname] [files]\n\n"
  622. " Scan f77 include files for commons and stores them for use with get_common\n"
  623. "\n Options:\n"
  624. "\t-a: add instead of rejecting duplicate commons in different files\n"
  625. "\t-f: Store filenames only. Default is full filenames.\n"
  626. "\t-h, --help: print this help\n"
  627. "\t-q: be really quiet (usefull if called from a script)\n"
  628. "\t-r: re-organize after updating. This may take a _long_ time.\n"
  629. "\t-s: safe operation, resync database after each update (safe but slower)\n"
  630. "\t-v: verbose\n"
  631. "\t--version: display version number\n"
  632. "\t-E[ext] : extensions to use when searching files. Multiple -E allowed\n"
  633. "\t          Use -E- to specify no extension.\n"
  634. "\t-I[dir] : get files from directory dir. Multiple -I allowed\n"
  635. "\t-d[database]: name of database to create/update\n"
  636. "\t-x[name]: name of file to ignore when scanning directories\n"
  637. " Using -f can help reduce the size of the created database.\n"
  638. " To automate updates, scan_commons looks at the value of the environment\n"
  639. " variable COMMON_DATABASE if no database is given.\n\n"
  640. "(C)Copyright 1995-1996 by Ripley Software Development\n"};
  641.  
  642. /****
  643. * A Note on the regular expressions used.
  644. *
  645. * We scan for a number of defined types in common include files.
  646. * (common, character, real and logical)
  647. * The scanning sequence is as follows:
  648. * 1. A scan is made for lines containing the COMMON, LOGICAL, REAL,
  649. *    DOUBLE, COMPLEX and CHARACTER keywords. These lines must begin with
  650. *    at least 6 spaces and must be followed by characters defining that param.
  651. *    The contents of the text found are scanned for ``real'' definitions by 
  652. *    get_common_contents
  653. * 2. When step 1 is complete, a further scan is done to see if the
  654. *    common block found has continuation lines, identified by the 
  655. *    BEGIN GETBLOCK statement. 
  656. *    All lines following any of the keywords mentioned above that begin
  657. *    with five spaces and a continuation character contain additional
  658. *    contents of that parameter block and are picked up by the scanner.
  659. *
  660. * The ``+'' after both regexp tells lex it must match one or more of these
  661. * regular expressions. 
  662. *****/
  663. #define GETBLOCK 1
  664.  
  665. #line 667 "lex.yy.c"
  666.  
  667. /* Macros after this point can all be overridden by user definitions in
  668.  * section 1.
  669.  */
  670.  
  671. #ifndef YY_SKIP_YYWRAP
  672. #ifdef __cplusplus
  673. extern "C" int yywrap YY_PROTO(( void ));
  674. #else
  675. extern int yywrap YY_PROTO(( void ));
  676. #endif
  677. #endif
  678.  
  679. #ifndef YY_NO_UNPUT
  680. static void yyunput YY_PROTO(( int c, char *buf_ptr ));
  681. #endif
  682.  
  683. #ifndef yytext_ptr
  684. static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
  685. #endif
  686.  
  687. #ifndef YY_NO_INPUT
  688. #ifdef __cplusplus
  689. static int yyinput YY_PROTO(( void ));
  690. #else
  691. static int input YY_PROTO(( void ));
  692. #endif
  693. #endif
  694.  
  695. #if YY_STACK_USED
  696. static int yy_start_stack_ptr = 0;
  697. static int yy_start_stack_depth = 0;
  698. static int *yy_start_stack = 0;
  699. #ifndef YY_NO_PUSH_STATE
  700. static void yy_push_state YY_PROTO(( int new_state ));
  701. #endif
  702. #ifndef YY_NO_POP_STATE
  703. static void yy_pop_state YY_PROTO(( void ));
  704. #endif
  705. #ifndef YY_NO_TOP_STATE
  706. static int yy_top_state YY_PROTO(( void ));
  707. #endif
  708.  
  709. #else
  710. #define YY_NO_PUSH_STATE 1
  711. #define YY_NO_POP_STATE 1
  712. #define YY_NO_TOP_STATE 1
  713. #endif
  714.  
  715. #ifdef YY_MALLOC_DECL
  716. YY_MALLOC_DECL
  717. #else
  718. #if __STDC__
  719. #ifndef __cplusplus
  720. #include <stdlib.h>
  721. #endif
  722. #else
  723. /* Just try to get by without declaring the routines.  This will fail
  724.  * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
  725.  * or sizeof(void*) != sizeof(int).
  726.  */
  727. #endif
  728. #endif
  729.  
  730. /* Amount of stuff to slurp up with each read. */
  731. #ifndef YY_READ_BUF_SIZE
  732. #define YY_READ_BUF_SIZE 8192
  733. #endif
  734.  
  735. /* Copy whatever the last rule matched to the standard output. */
  736.  
  737. #ifndef ECHO
  738. /* This used to be an fputs(), but since the string might contain NUL's,
  739.  * we now use fwrite().
  740.  */
  741. #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
  742. #endif
  743.  
  744. /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  745.  * is returned in "result".
  746.  */
  747. #ifndef YY_INPUT
  748. #define YY_INPUT(buf,result,max_size) \
  749.     if ( yy_current_buffer->yy_is_interactive ) \
  750.         { \
  751.         int c = '*', n; \
  752.         for ( n = 0; n < max_size && \
  753.                  (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
  754.             buf[n] = (char) c; \
  755.         if ( c == '\n' ) \
  756.             buf[n++] = (char) c; \
  757.         if ( c == EOF && ferror( yyin ) ) \
  758.             YY_FATAL_ERROR( "input in flex scanner failed" ); \
  759.         result = n; \
  760.         } \
  761.     else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
  762.           && ferror( yyin ) ) \
  763.         YY_FATAL_ERROR( "input in flex scanner failed" );
  764. #endif
  765.  
  766. /* No semi-colon after return; correct usage is to write "yyterminate();" -
  767.  * we don't want an extra ';' after the "return" because that will cause
  768.  * some compilers to complain about unreachable statements.
  769.  */
  770. #ifndef yyterminate
  771. #define yyterminate() return YY_NULL
  772. #endif
  773.  
  774. /* Number of entries by which start-condition stack grows. */
  775. #ifndef YY_START_STACK_INCR
  776. #define YY_START_STACK_INCR 25
  777. #endif
  778.  
  779. /* Report a fatal error. */
  780. #ifndef YY_FATAL_ERROR
  781. #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
  782. #endif
  783.  
  784. /* Default declaration of generated scanner - a define so the user can
  785.  * easily add parameters.
  786.  */
  787. #ifndef YY_DECL
  788. #define YY_DECL int yylex YY_PROTO(( void ))
  789. #endif
  790.  
  791. /* Code executed at the beginning of each rule, after yytext and yyleng
  792.  * have been set up.
  793.  */
  794. #ifndef YY_USER_ACTION
  795. #define YY_USER_ACTION
  796. #endif
  797.  
  798. /* Code executed at the end of each rule. */
  799. #ifndef YY_BREAK
  800. #define YY_BREAK break;
  801. #endif
  802.  
  803. #define YY_RULE_SETUP \
  804.     if ( yyleng > 0 ) \
  805.         yy_current_buffer->yy_at_bol = \
  806.                 (yytext[yyleng - 1] == '\n'); \
  807.     YY_USER_ACTION
  808.  
  809. YY_DECL
  810.     {
  811.     register yy_state_type yy_current_state;
  812.     register char *yy_cp, *yy_bp;
  813.     register int yy_act;
  814.  
  815. #line 177 "scan_commons.l"
  816.  
  817. #line 819 "lex.yy.c"
  818.  
  819.     if ( yy_init )
  820.         {
  821.         yy_init = 0;
  822.  
  823. #ifdef YY_USER_INIT
  824.         YY_USER_INIT;
  825. #endif
  826.  
  827.         if ( ! yy_start )
  828.             yy_start = 1;    /* first start state */
  829.  
  830.         if ( ! yyin )
  831.             yyin = stdin;
  832.  
  833.         if ( ! yyout )
  834.             yyout = stdout;
  835.  
  836.         if ( ! yy_current_buffer )
  837.             yy_current_buffer =
  838.                 yy_create_buffer( yyin, YY_BUF_SIZE );
  839.  
  840.         yy_load_buffer_state();
  841.         }
  842.  
  843.     while ( 1 )        /* loops until end-of-file is reached */
  844.         {
  845.         yy_cp = yy_c_buf_p;
  846.  
  847.         /* Support of yytext. */
  848.         *yy_cp = yy_hold_char;
  849.  
  850.         /* yy_bp points to the position in yy_ch_buf of the start of
  851.          * the current run.
  852.          */
  853.         yy_bp = yy_cp;
  854.  
  855.         yy_current_state = yy_start;
  856.         yy_current_state += YY_AT_BOL();
  857.         yy_state_ptr = yy_state_buf;
  858.         *yy_state_ptr++ = yy_current_state;
  859. yy_match:
  860.         do
  861.             {
  862.             register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
  863.             while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  864.                 {
  865.                 yy_current_state = (int) yy_def[yy_current_state];
  866.                 if ( yy_current_state >= 176 )
  867.                     yy_c = yy_meta[(unsigned int) yy_c];
  868.                 }
  869.             yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  870.             *yy_state_ptr++ = yy_current_state;
  871.             ++yy_cp;
  872.             }
  873.         while ( yy_base[yy_current_state] != 291 );
  874.  
  875. yy_find_action:
  876.         yy_current_state = *--yy_state_ptr;
  877.         yy_lp = yy_accept[yy_current_state];
  878. find_rule: /* we branch to this label when backing up */
  879.         for ( ; ; ) /* until we find what rule we matched */
  880.             {
  881.             if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )
  882.                 {
  883.                 yy_act = yy_acclist[yy_lp];
  884.                     {
  885.                     yy_full_match = yy_cp;
  886.                     break;
  887.                     }
  888.                 }
  889.             --yy_cp;
  890.             yy_current_state = *--yy_state_ptr;
  891.             yy_lp = yy_accept[yy_current_state];
  892.             }
  893.  
  894.         YY_DO_BEFORE_ACTION;
  895.  
  896.         if ( yy_act != YY_END_OF_BUFFER )
  897.             {
  898.             int yyl;
  899.             for ( yyl = 0; yyl < yyleng; ++yyl )
  900.                 if ( yytext[yyl] == '\n' )
  901.                     ++yylineno;
  902.             }
  903.  
  904. do_action:    /* This label is used only to access EOF actions. */
  905.  
  906.  
  907.         switch ( yy_act )
  908.     { /* beginning of action switch */
  909. case 1:
  910. YY_RULE_SETUP
  911. #line 178 "scan_commons.l"
  912. BEGIN(INITIAL);
  913.     YY_BREAK
  914. case 2:
  915. #line 181 "scan_commons.l"
  916. case 3:
  917. YY_RULE_SETUP
  918. #line 181 "scan_commons.l"
  919. {
  920.             get_common_contents(yytext);
  921.             BEGIN 0;
  922.         }
  923.     YY_BREAK
  924. case 4:
  925. #line 186 "scan_commons.l"
  926. case 5:
  927. YY_RULE_SETUP
  928. #line 186 "scan_commons.l"
  929. {
  930.             get_common_contents(yytext);
  931.             BEGIN 0;
  932.         }
  933.     YY_BREAK
  934. case 6:
  935. #line 191 "scan_commons.l"
  936. case 7:
  937. YY_RULE_SETUP
  938. #line 191 "scan_commons.l"
  939. {
  940.             get_common_contents(yytext);
  941.             BEGIN 0;
  942.         }
  943.     YY_BREAK
  944. case 8:
  945. #line 196 "scan_commons.l"
  946. case 9:
  947. YY_RULE_SETUP
  948. #line 196 "scan_commons.l"
  949. {
  950.             get_common_contents(yytext);
  951.             BEGIN 0;
  952.         }
  953.     YY_BREAK
  954. case 10:
  955. #line 201 "scan_commons.l"
  956. case 11:
  957. YY_RULE_SETUP
  958. #line 201 "scan_commons.l"
  959. {
  960.             get_common_contents(yytext);
  961.             BEGIN 0;
  962.         }
  963.     YY_BREAK
  964. case 12:
  965. #line 206 "scan_commons.l"
  966. case 13:
  967. YY_RULE_SETUP
  968. #line 206 "scan_commons.l"
  969. {
  970.             get_common_contents(yytext);
  971.             BEGIN 0;
  972.         }
  973.     YY_BREAK
  974. case 14:
  975. #line 211 "scan_commons.l"
  976. case 15:
  977. YY_RULE_SETUP
  978. #line 211 "scan_commons.l"
  979. {
  980.             get_common_contents(yytext);
  981.             BEGIN 0;
  982.         }
  983.     YY_BREAK
  984. case 16:
  985. #line 216 "scan_commons.l"
  986. case 17:
  987. YY_RULE_SETUP
  988. #line 216 "scan_commons.l"
  989. {
  990.             get_common_contents(yytext);
  991.             BEGIN 0;
  992.         }
  993.     YY_BREAK
  994. case 18:
  995. YY_RULE_SETUP
  996. #line 220 "scan_commons.l"
  997. BEGIN(INITIAL);
  998.     YY_BREAK
  999. case YY_STATE_EOF(INITIAL):
  1000. case YY_STATE_EOF(GETBLOCK):
  1001. #line 221 "scan_commons.l"
  1002. {
  1003.         yyterminate();
  1004.         }
  1005.     YY_BREAK
  1006. case 19:
  1007. YY_RULE_SETUP
  1008. #line 224 "scan_commons.l"
  1009. ECHO;
  1010.     YY_BREAK
  1011. #line 1013 "lex.yy.c"
  1012.  
  1013.     case YY_END_OF_BUFFER:
  1014.         {
  1015.         /* Amount of text matched not including the EOB char. */
  1016.         int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
  1017.  
  1018.         /* Undo the effects of YY_DO_BEFORE_ACTION. */
  1019.         *yy_cp = yy_hold_char;
  1020.  
  1021.         if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
  1022.             {
  1023.             /* We're scanning a new file or input source.  It's
  1024.              * possible that this happened because the user
  1025.              * just pointed yyin at a new source and called
  1026.              * yylex().  If so, then we have to assure
  1027.              * consistency between yy_current_buffer and our
  1028.              * globals.  Here is the right place to do so, because
  1029.              * this is the first action (other than possibly a
  1030.              * back-up) that will match for the new input source.
  1031.              */
  1032.             yy_n_chars = yy_current_buffer->yy_n_chars;
  1033.             yy_current_buffer->yy_input_file = yyin;
  1034.             yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
  1035.             }
  1036.  
  1037.         /* Note that here we test for yy_c_buf_p "<=" to the position
  1038.          * of the first EOB in the buffer, since yy_c_buf_p will
  1039.          * already have been incremented past the NUL character
  1040.          * (since all states make transitions on EOB to the
  1041.          * end-of-buffer state).  Contrast this with the test
  1042.          * in input().
  1043.          */
  1044.         if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1045.             { /* This was really a NUL. */
  1046.             yy_state_type yy_next_state;
  1047.  
  1048.             yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
  1049.  
  1050.             yy_current_state = yy_get_previous_state();
  1051.  
  1052.             /* Okay, we're now positioned to make the NUL
  1053.              * transition.  We couldn't have
  1054.              * yy_get_previous_state() go ahead and do it
  1055.              * for us because it doesn't know how to deal
  1056.              * with the possibility of jamming (and we don't
  1057.              * want to build jamming into it because then it
  1058.              * will run more slowly).
  1059.              */
  1060.  
  1061.             yy_next_state = yy_try_NUL_trans( yy_current_state );
  1062.  
  1063.             yy_bp = yytext_ptr + YY_MORE_ADJ;
  1064.  
  1065.             if ( yy_next_state )
  1066.                 {
  1067.                 /* Consume the NUL. */
  1068.                 yy_cp = ++yy_c_buf_p;
  1069.                 yy_current_state = yy_next_state;
  1070.                 goto yy_match;
  1071.                 }
  1072.  
  1073.             else
  1074.                 {
  1075.                 yy_cp = yy_c_buf_p;
  1076.                 goto yy_find_action;
  1077.                 }
  1078.             }
  1079.  
  1080.         else switch ( yy_get_next_buffer() )
  1081.             {
  1082.             case EOB_ACT_END_OF_FILE:
  1083.                 {
  1084.                 yy_did_buffer_switch_on_eof = 0;
  1085.  
  1086.                 if ( yywrap() )
  1087.                     {
  1088.                     /* Note: because we've taken care in
  1089.                      * yy_get_next_buffer() to have set up
  1090.                      * yytext, we can now set up
  1091.                      * yy_c_buf_p so that if some total
  1092.                      * hoser (like flex itself) wants to
  1093.                      * call the scanner after we return the
  1094.                      * YY_NULL, it'll still work - another
  1095.                      * YY_NULL will get returned.
  1096.                      */
  1097.                     yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
  1098.  
  1099.                     yy_act = YY_STATE_EOF(YY_START);
  1100.                     goto do_action;
  1101.                     }
  1102.  
  1103.                 else
  1104.                     {
  1105.                     if ( ! yy_did_buffer_switch_on_eof )
  1106.                         YY_NEW_FILE;
  1107.                     }
  1108.                 break;
  1109.                 }
  1110.  
  1111.             case EOB_ACT_CONTINUE_SCAN:
  1112.                 yy_c_buf_p =
  1113.                     yytext_ptr + yy_amount_of_matched_text;
  1114.  
  1115.                 yy_current_state = yy_get_previous_state();
  1116.  
  1117.                 yy_cp = yy_c_buf_p;
  1118.                 yy_bp = yytext_ptr + YY_MORE_ADJ;
  1119.                 goto yy_match;
  1120.  
  1121.             case EOB_ACT_LAST_MATCH:
  1122.                 yy_c_buf_p =
  1123.                 &yy_current_buffer->yy_ch_buf[yy_n_chars];
  1124.  
  1125.                 yy_current_state = yy_get_previous_state();
  1126.  
  1127.                 yy_cp = yy_c_buf_p;
  1128.                 yy_bp = yytext_ptr + YY_MORE_ADJ;
  1129.                 goto yy_find_action;
  1130.             }
  1131.         break;
  1132.         }
  1133.  
  1134.     default:
  1135.         YY_FATAL_ERROR(
  1136.             "fatal flex scanner internal error--no action found" );
  1137.     } /* end of action switch */
  1138.         } /* end of scanning one token */
  1139.     } /* end of yylex */
  1140.  
  1141.  
  1142. /* yy_get_next_buffer - try to read in a new buffer
  1143.  *
  1144.  * Returns a code representing an action:
  1145.  *    EOB_ACT_LAST_MATCH -
  1146.  *    EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  1147.  *    EOB_ACT_END_OF_FILE - end of file
  1148.  */
  1149.  
  1150. static int yy_get_next_buffer()
  1151.     {
  1152.     register char *dest = yy_current_buffer->yy_ch_buf;
  1153.     register char *source = yytext_ptr;
  1154.     register int number_to_move, i;
  1155.     int ret_val;
  1156.  
  1157.     if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  1158.         YY_FATAL_ERROR(
  1159.         "fatal flex scanner internal error--end of buffer missed" );
  1160.  
  1161.     if ( yy_current_buffer->yy_fill_buffer == 0 )
  1162.         { /* Don't try to fill the buffer, so this is an EOF. */
  1163.         if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
  1164.             {
  1165.             /* We matched a singled characater, the EOB, so
  1166.              * treat this as a final EOF.
  1167.              */
  1168.             return EOB_ACT_END_OF_FILE;
  1169.             }
  1170.  
  1171.         else
  1172.             {
  1173.             /* We matched some text prior to the EOB, first
  1174.              * process it.
  1175.              */
  1176.             return EOB_ACT_LAST_MATCH;
  1177.             }
  1178.         }
  1179.  
  1180.     /* Try to read more data. */
  1181.  
  1182.     /* First move last chars to start of buffer. */
  1183.     number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
  1184.  
  1185.     for ( i = 0; i < number_to_move; ++i )
  1186.         *(dest++) = *(source++);
  1187.  
  1188.     if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
  1189.         /* don't do the read, it's not guaranteed to return an EOF,
  1190.          * just force an EOF
  1191.          */
  1192.         yy_n_chars = 0;
  1193.  
  1194.     else
  1195.         {
  1196.         int num_to_read =
  1197.             yy_current_buffer->yy_buf_size - number_to_move - 1;
  1198.  
  1199.         while ( num_to_read <= 0 )
  1200.             { /* Not enough room in the buffer - grow it. */
  1201. #ifdef YY_USES_REJECT
  1202.             YY_FATAL_ERROR(
  1203. "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
  1204. #else
  1205.  
  1206.             /* just a shorter name for the current buffer */
  1207.             YY_BUFFER_STATE b = yy_current_buffer;
  1208.  
  1209.             int yy_c_buf_p_offset =
  1210.                 (int) (yy_c_buf_p - b->yy_ch_buf);
  1211.  
  1212.             if ( b->yy_is_our_buffer )
  1213.                 {
  1214.                 int new_size = b->yy_buf_size * 2;
  1215.  
  1216.                 if ( new_size <= 0 )
  1217.                     b->yy_buf_size += b->yy_buf_size / 8;
  1218.                 else
  1219.                     b->yy_buf_size *= 2;
  1220.  
  1221.                 b->yy_ch_buf = (char *)
  1222.                     /* Include room in for 2 EOB chars. */
  1223.                     yy_flex_realloc( (void *) b->yy_ch_buf,
  1224.                              b->yy_buf_size + 2 );
  1225.                 }
  1226.             else
  1227.                 /* Can't grow it, we don't own it. */
  1228.                 b->yy_ch_buf = 0;
  1229.  
  1230.             if ( ! b->yy_ch_buf )
  1231.                 YY_FATAL_ERROR(
  1232.                 "fatal error - scanner input buffer overflow" );
  1233.  
  1234.             yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
  1235.  
  1236.             num_to_read = yy_current_buffer->yy_buf_size -
  1237.                         number_to_move - 1;
  1238. #endif
  1239.             }
  1240.  
  1241.         if ( num_to_read > YY_READ_BUF_SIZE )
  1242.             num_to_read = YY_READ_BUF_SIZE;
  1243.  
  1244.         /* Read in more data. */
  1245.         YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  1246.             yy_n_chars, num_to_read );
  1247.         }
  1248.  
  1249.     if ( yy_n_chars == 0 )
  1250.         {
  1251.         if ( number_to_move == YY_MORE_ADJ )
  1252.             {
  1253.             ret_val = EOB_ACT_END_OF_FILE;
  1254.             yyrestart( yyin );
  1255.             }
  1256.  
  1257.         else
  1258.             {
  1259.             ret_val = EOB_ACT_LAST_MATCH;
  1260.             yy_current_buffer->yy_buffer_status =
  1261.                 YY_BUFFER_EOF_PENDING;
  1262.             }
  1263.         }
  1264.  
  1265.     else
  1266.         ret_val = EOB_ACT_CONTINUE_SCAN;
  1267.  
  1268.     yy_n_chars += number_to_move;
  1269.     yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  1270.     yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  1271.  
  1272.     yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
  1273.  
  1274.     return ret_val;
  1275.     }
  1276.  
  1277.  
  1278. /* yy_get_previous_state - get the state just before the EOB char was reached */
  1279.  
  1280. static yy_state_type yy_get_previous_state()
  1281.     {
  1282.     register yy_state_type yy_current_state;
  1283.     register char *yy_cp;
  1284.  
  1285.     yy_current_state = yy_start;
  1286.     yy_current_state += YY_AT_BOL();
  1287.     yy_state_ptr = yy_state_buf;
  1288.     *yy_state_ptr++ = yy_current_state;
  1289.  
  1290.     for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  1291.         {
  1292.         register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
  1293.         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1294.             {
  1295.             yy_current_state = (int) yy_def[yy_current_state];
  1296.             if ( yy_current_state >= 176 )
  1297.                 yy_c = yy_meta[(unsigned int) yy_c];
  1298.             }
  1299.         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  1300.         *yy_state_ptr++ = yy_current_state;
  1301.         }
  1302.  
  1303.     return yy_current_state;
  1304.     }
  1305.  
  1306.  
  1307. /* yy_try_NUL_trans - try to make a transition on the NUL character
  1308.  *
  1309.  * synopsis
  1310.  *    next_state = yy_try_NUL_trans( current_state );
  1311.  */
  1312.  
  1313. #ifdef YY_USE_PROTOS
  1314. static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
  1315. #else
  1316. static yy_state_type yy_try_NUL_trans( yy_current_state )
  1317. yy_state_type yy_current_state;
  1318. #endif
  1319.     {
  1320.     register int yy_is_jam;
  1321.  
  1322.     register YY_CHAR yy_c = 1;
  1323.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1324.         {
  1325.         yy_current_state = (int) yy_def[yy_current_state];
  1326.         if ( yy_current_state >= 176 )
  1327.             yy_c = yy_meta[(unsigned int) yy_c];
  1328.         }
  1329.     yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  1330.     *yy_state_ptr++ = yy_current_state;
  1331.     yy_is_jam = (yy_current_state == 175);
  1332.  
  1333.     return yy_is_jam ? 0 : yy_current_state;
  1334.     }
  1335.  
  1336.  
  1337. #ifndef YY_NO_UNPUT
  1338. #ifdef YY_USE_PROTOS
  1339. static void yyunput( int c, register char *yy_bp )
  1340. #else
  1341. static void yyunput( c, yy_bp )
  1342. int c;
  1343. register char *yy_bp;
  1344. #endif
  1345.     {
  1346.     register char *yy_cp = yy_c_buf_p;
  1347.  
  1348.     /* undo effects of setting up yytext */
  1349.     *yy_cp = yy_hold_char;
  1350.  
  1351.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  1352.         { /* need to shift things up to make room */
  1353.         /* +2 for EOB chars. */
  1354.         register int number_to_move = yy_n_chars + 2;
  1355.         register char *dest = &yy_current_buffer->yy_ch_buf[
  1356.                     yy_current_buffer->yy_buf_size + 2];
  1357.         register char *source =
  1358.                 &yy_current_buffer->yy_ch_buf[number_to_move];
  1359.  
  1360.         while ( source > yy_current_buffer->yy_ch_buf )
  1361.             *--dest = *--source;
  1362.  
  1363.         yy_cp += (int) (dest - source);
  1364.         yy_bp += (int) (dest - source);
  1365.         yy_n_chars = yy_current_buffer->yy_buf_size;
  1366.  
  1367.         if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  1368.             YY_FATAL_ERROR( "flex scanner push-back overflow" );
  1369.         }
  1370.  
  1371.     *--yy_cp = (char) c;
  1372.  
  1373.     if ( c == '\n' )
  1374.         --yylineno;
  1375.  
  1376.     yytext_ptr = yy_bp;
  1377.     yy_hold_char = *yy_cp;
  1378.     yy_c_buf_p = yy_cp;
  1379.     }
  1380. #endif    /* ifndef YY_NO_UNPUT */
  1381.  
  1382.  
  1383. #ifdef __cplusplus
  1384. static int yyinput()
  1385. #else
  1386. static int input()
  1387. #endif
  1388.     {
  1389.     int c;
  1390.  
  1391.     *yy_c_buf_p = yy_hold_char;
  1392.  
  1393.     if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  1394.         {
  1395.         /* yy_c_buf_p now points to the character we want to return.
  1396.          * If this occurs *before* the EOB characters, then it's a
  1397.          * valid NUL; if not, then we've hit the end of the buffer.
  1398.          */
  1399.         if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1400.             /* This was really a NUL. */
  1401.             *yy_c_buf_p = '\0';
  1402.  
  1403.         else
  1404.             { /* need more input */
  1405.             yytext_ptr = yy_c_buf_p;
  1406.             ++yy_c_buf_p;
  1407.  
  1408.             switch ( yy_get_next_buffer() )
  1409.                 {
  1410.                 case EOB_ACT_END_OF_FILE:
  1411.                     {
  1412.                     if ( yywrap() )
  1413.                         {
  1414.                         yy_c_buf_p =
  1415.                         yytext_ptr + YY_MORE_ADJ;
  1416.                         return EOF;
  1417.                         }
  1418.  
  1419.                     if ( ! yy_did_buffer_switch_on_eof )
  1420.                         YY_NEW_FILE;
  1421. #ifdef __cplusplus
  1422.                     return yyinput();
  1423. #else
  1424.                     return input();
  1425. #endif
  1426.                     }
  1427.  
  1428.                 case EOB_ACT_CONTINUE_SCAN:
  1429.                     yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
  1430.                     break;
  1431.  
  1432.                 case EOB_ACT_LAST_MATCH:
  1433. #ifdef __cplusplus
  1434.                     YY_FATAL_ERROR(
  1435.                     "unexpected last match in yyinput()" );
  1436. #else
  1437.                     YY_FATAL_ERROR(
  1438.                     "unexpected last match in input()" );
  1439. #endif
  1440.                 }
  1441.             }
  1442.         }
  1443.  
  1444.     c = *(unsigned char *) yy_c_buf_p;    /* cast for 8-bit char's */
  1445.     *yy_c_buf_p = '\0';    /* preserve yytext */
  1446.     yy_hold_char = *++yy_c_buf_p;
  1447.  
  1448.     yy_current_buffer->yy_at_bol = (c == '\n');
  1449.     if ( yy_current_buffer->yy_at_bol )
  1450.         ++yylineno;
  1451.  
  1452.     return c;
  1453.     }
  1454.  
  1455.  
  1456. #ifdef YY_USE_PROTOS
  1457. void yyrestart( FILE *input_file )
  1458. #else
  1459. void yyrestart( input_file )
  1460. FILE *input_file;
  1461. #endif
  1462.     {
  1463.     if ( ! yy_current_buffer )
  1464.         yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  1465.  
  1466.     yy_init_buffer( yy_current_buffer, input_file );
  1467.     yy_load_buffer_state();
  1468.     }
  1469.  
  1470.  
  1471. #ifdef YY_USE_PROTOS
  1472. void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  1473. #else
  1474. void yy_switch_to_buffer( new_buffer )
  1475. YY_BUFFER_STATE new_buffer;
  1476. #endif
  1477.     {
  1478.     if ( yy_current_buffer == new_buffer )
  1479.         return;
  1480.  
  1481.     if ( yy_current_buffer )
  1482.         {
  1483.         /* Flush out information for old buffer. */
  1484.         *yy_c_buf_p = yy_hold_char;
  1485.         yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  1486.         yy_current_buffer->yy_n_chars = yy_n_chars;
  1487.         }
  1488.  
  1489.     yy_current_buffer = new_buffer;
  1490.     yy_load_buffer_state();
  1491.  
  1492.     /* We don't actually know whether we did this switch during
  1493.      * EOF (yywrap()) processing, but the only time this flag
  1494.      * is looked at is after yywrap() is called, so it's safe
  1495.      * to go ahead and always set it.
  1496.      */
  1497.     yy_did_buffer_switch_on_eof = 1;
  1498.     }
  1499.  
  1500.  
  1501. #ifdef YY_USE_PROTOS
  1502. void yy_load_buffer_state( void )
  1503. #else
  1504. void yy_load_buffer_state()
  1505. #endif
  1506.     {
  1507.     yy_n_chars = yy_current_buffer->yy_n_chars;
  1508.     yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  1509.     yyin = yy_current_buffer->yy_input_file;
  1510.     yy_hold_char = *yy_c_buf_p;
  1511.     }
  1512.  
  1513.  
  1514. #ifdef YY_USE_PROTOS
  1515. YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  1516. #else
  1517. YY_BUFFER_STATE yy_create_buffer( file, size )
  1518. FILE *file;
  1519. int size;
  1520. #endif
  1521.     {
  1522.     YY_BUFFER_STATE b;
  1523.  
  1524.     b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
  1525.     if ( ! b )
  1526.         YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1527.  
  1528.     b->yy_buf_size = size;
  1529.  
  1530.     /* yy_ch_buf has to be 2 characters longer than the size given because
  1531.      * we need to put in 2 end-of-buffer characters.
  1532.      */
  1533.     b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
  1534.     if ( ! b->yy_ch_buf )
  1535.         YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1536.  
  1537.     b->yy_is_our_buffer = 1;
  1538.  
  1539.     yy_init_buffer( b, file );
  1540.  
  1541.     return b;
  1542.     }
  1543.  
  1544.  
  1545. #ifdef YY_USE_PROTOS
  1546. void yy_delete_buffer( YY_BUFFER_STATE b )
  1547. #else
  1548. void yy_delete_buffer( b )
  1549. YY_BUFFER_STATE b;
  1550. #endif
  1551.     {
  1552.     if ( ! b )
  1553.         return;
  1554.  
  1555.     if ( b == yy_current_buffer )
  1556.         yy_current_buffer = (YY_BUFFER_STATE) 0;
  1557.  
  1558.     if ( b->yy_is_our_buffer )
  1559.         yy_flex_free( (void *) b->yy_ch_buf );
  1560.  
  1561.     yy_flex_free( (void *) b );
  1562.     }
  1563.  
  1564.  
  1565. #ifndef YY_ALWAYS_INTERACTIVE
  1566. #ifndef YY_NEVER_INTERACTIVE
  1567. extern int isatty YY_PROTO(( int ));
  1568. #endif
  1569. #endif
  1570.  
  1571. #ifdef YY_USE_PROTOS
  1572. void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
  1573. #else
  1574. void yy_init_buffer( b, file )
  1575. YY_BUFFER_STATE b;
  1576. FILE *file;
  1577. #endif
  1578.  
  1579.  
  1580.     {
  1581.     yy_flush_buffer( b );
  1582.  
  1583.     b->yy_input_file = file;
  1584.     b->yy_fill_buffer = 1;
  1585.  
  1586. #if YY_ALWAYS_INTERACTIVE
  1587.     b->yy_is_interactive = 1;
  1588. #else
  1589. #if YY_NEVER_INTERACTIVE
  1590.     b->yy_is_interactive = 0;
  1591. #else
  1592.     b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
  1593. #endif
  1594. #endif
  1595.     }
  1596.  
  1597.  
  1598. #ifdef YY_USE_PROTOS
  1599. void yy_flush_buffer( YY_BUFFER_STATE b )
  1600. #else
  1601. void yy_flush_buffer( b )
  1602. YY_BUFFER_STATE b;
  1603. #endif
  1604.  
  1605.     {
  1606.     b->yy_n_chars = 0;
  1607.  
  1608.     /* We always need two end-of-buffer characters.  The first causes
  1609.      * a transition to the end-of-buffer state.  The second causes
  1610.      * a jam in that state.
  1611.      */
  1612.     b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
  1613.     b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  1614.  
  1615.     b->yy_buf_pos = &b->yy_ch_buf[0];
  1616.  
  1617.     b->yy_at_bol = 1;
  1618.     b->yy_buffer_status = YY_BUFFER_NEW;
  1619.  
  1620.     if ( b == yy_current_buffer )
  1621.         yy_load_buffer_state();
  1622.     }
  1623.  
  1624.  
  1625. #ifndef YY_NO_SCAN_BUFFER
  1626. #ifdef YY_USE_PROTOS
  1627. YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
  1628. #else
  1629. YY_BUFFER_STATE yy_scan_buffer( base, size )
  1630. char *base;
  1631. yy_size_t size;
  1632. #endif
  1633.     {
  1634.     YY_BUFFER_STATE b;
  1635.  
  1636.     if ( size < 2 ||
  1637.          base[size-2] != YY_END_OF_BUFFER_CHAR ||
  1638.          base[size-1] != YY_END_OF_BUFFER_CHAR )
  1639.         /* They forgot to leave room for the EOB's. */
  1640.         return 0;
  1641.  
  1642.     b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
  1643.     if ( ! b )
  1644.         YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
  1645.  
  1646.     b->yy_buf_size = size - 2;    /* "- 2" to take care of EOB's */
  1647.     b->yy_buf_pos = b->yy_ch_buf = base;
  1648.     b->yy_is_our_buffer = 0;
  1649.     b->yy_input_file = 0;
  1650.     b->yy_n_chars = b->yy_buf_size;
  1651.     b->yy_is_interactive = 0;
  1652.     b->yy_at_bol = 1;
  1653.     b->yy_fill_buffer = 0;
  1654.     b->yy_buffer_status = YY_BUFFER_NEW;
  1655.  
  1656.     yy_switch_to_buffer( b );
  1657.  
  1658.     return b;
  1659.     }
  1660. #endif
  1661.  
  1662.  
  1663. #ifndef YY_NO_SCAN_STRING
  1664. #ifdef YY_USE_PROTOS
  1665. YY_BUFFER_STATE yy_scan_string( yyconst char *str )
  1666. #else
  1667. YY_BUFFER_STATE yy_scan_string( str )
  1668. yyconst char *str;
  1669. #endif
  1670.     {
  1671.     int len;
  1672.     for ( len = 0; str[len]; ++len )
  1673.         ;
  1674.  
  1675.     return yy_scan_bytes( str, len );
  1676.     }
  1677. #endif
  1678.  
  1679.  
  1680. #ifndef YY_NO_SCAN_BYTES
  1681. #ifdef YY_USE_PROTOS
  1682. YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
  1683. #else
  1684. YY_BUFFER_STATE yy_scan_bytes( bytes, len )
  1685. yyconst char *bytes;
  1686. int len;
  1687. #endif
  1688.     {
  1689.     YY_BUFFER_STATE b;
  1690.     char *buf;
  1691.     yy_size_t n;
  1692.     int i;
  1693.  
  1694.     /* Get memory for full buffer, including space for trailing EOB's. */
  1695.     n = len + 2;
  1696.     buf = (char *) yy_flex_alloc( n );
  1697.     if ( ! buf )
  1698.         YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
  1699.  
  1700.     for ( i = 0; i < len; ++i )
  1701.         buf[i] = bytes[i];
  1702.  
  1703.     buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
  1704.  
  1705.     b = yy_scan_buffer( buf, n );
  1706.     if ( ! b )
  1707.         YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
  1708.  
  1709.     /* It's okay to grow etc. this buffer, and we should throw it
  1710.      * away when we're done.
  1711.      */
  1712.     b->yy_is_our_buffer = 1;
  1713.  
  1714.     return b;
  1715.     }
  1716. #endif
  1717.  
  1718.  
  1719. #ifndef YY_NO_PUSH_STATE
  1720. #ifdef YY_USE_PROTOS
  1721. static void yy_push_state( int new_state )
  1722. #else
  1723. static void yy_push_state( new_state )
  1724. int new_state;
  1725. #endif
  1726.     {
  1727.     if ( yy_start_stack_ptr >= yy_start_stack_depth )
  1728.         {
  1729.         yy_size_t new_size;
  1730.  
  1731.         yy_start_stack_depth += YY_START_STACK_INCR;
  1732.         new_size = yy_start_stack_depth * sizeof( int );
  1733.  
  1734.         if ( ! yy_start_stack )
  1735.             yy_start_stack = (int *) yy_flex_alloc( new_size );
  1736.  
  1737.         else
  1738.             yy_start_stack = (int *) yy_flex_realloc(
  1739.                     (void *) yy_start_stack, new_size );
  1740.  
  1741.         if ( ! yy_start_stack )
  1742.             YY_FATAL_ERROR(
  1743.             "out of memory expanding start-condition stack" );
  1744.         }
  1745.  
  1746.     yy_start_stack[yy_start_stack_ptr++] = YY_START;
  1747.  
  1748.     BEGIN(new_state);
  1749.     }
  1750. #endif
  1751.  
  1752.  
  1753. #ifndef YY_NO_POP_STATE
  1754. static void yy_pop_state()
  1755.     {
  1756.     if ( --yy_start_stack_ptr < 0 )
  1757.         YY_FATAL_ERROR( "start-condition stack underflow" );
  1758.  
  1759.     BEGIN(yy_start_stack[yy_start_stack_ptr]);
  1760.     }
  1761. #endif
  1762.  
  1763.  
  1764. #ifndef YY_NO_TOP_STATE
  1765. static int yy_top_state()
  1766.     {
  1767.     return yy_start_stack[yy_start_stack_ptr - 1];
  1768.     }
  1769. #endif
  1770.  
  1771. #ifndef YY_EXIT_FAILURE
  1772. #define YY_EXIT_FAILURE 2
  1773. #endif
  1774.  
  1775. #ifdef YY_USE_PROTOS
  1776. static void yy_fatal_error( yyconst char msg[] )
  1777. #else
  1778. static void yy_fatal_error( msg )
  1779. char msg[];
  1780. #endif
  1781.     {
  1782.     (void) fprintf( stderr, "%s\n", msg );
  1783.     exit( YY_EXIT_FAILURE );
  1784.     }
  1785.  
  1786.  
  1787.  
  1788. /* Redefine yyless() so it works in section 3 code. */
  1789.  
  1790. #undef yyless
  1791. #define yyless(n) \
  1792.     do \
  1793.         { \
  1794.         /* Undo effects of setting up yytext. */ \
  1795.         yytext[yyleng] = yy_hold_char; \
  1796.         yy_c_buf_p = yytext + n - YY_MORE_ADJ; \
  1797.         yy_hold_char = *yy_c_buf_p; \
  1798.         *yy_c_buf_p = '\0'; \
  1799.         yyleng = n; \
  1800.         } \
  1801.     while ( 0 )
  1802.  
  1803.  
  1804. /* Internal utility routines. */
  1805.  
  1806. #ifndef yytext_ptr
  1807. #ifdef YY_USE_PROTOS
  1808. static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
  1809. #else
  1810. static void yy_flex_strncpy( s1, s2, n )
  1811. char *s1;
  1812. yyconst char *s2;
  1813. int n;
  1814. #endif
  1815.     {
  1816.     register int i;
  1817.     for ( i = 0; i < n; ++i )
  1818.         s1[i] = s2[i];
  1819.     }
  1820. #endif
  1821.  
  1822.  
  1823. #ifdef YY_USE_PROTOS
  1824. static void *yy_flex_alloc( yy_size_t size )
  1825. #else
  1826. static void *yy_flex_alloc( size )
  1827. yy_size_t size;
  1828. #endif
  1829.     {
  1830.     return (void *) malloc( size );
  1831.     }
  1832.  
  1833. #ifdef YY_USE_PROTOS
  1834. static void *yy_flex_realloc( void *ptr, yy_size_t size )
  1835. #else
  1836. static void *yy_flex_realloc( ptr, size )
  1837. void *ptr;
  1838. yy_size_t size;
  1839. #endif
  1840.     {
  1841.     /* The cast to (char *) in the following accommodates both
  1842.      * implementations that use char* generic pointers, and those
  1843.      * that use void* generic pointers.  It works with the latter
  1844.      * because both ANSI C and C++ allow castless assignment from
  1845.      * any pointer type to void*, and deal with argument conversions
  1846.      * as though doing an assignment.
  1847.      */
  1848.     return (void *) realloc( (char *) ptr, size );
  1849.     }
  1850.  
  1851. #ifdef YY_USE_PROTOS
  1852. static void yy_flex_free( void *ptr )
  1853. #else
  1854. static void yy_flex_free( ptr )
  1855. void *ptr;
  1856. #endif
  1857.     {
  1858.     free( ptr );
  1859.     }
  1860.  
  1861. #if YY_MAIN
  1862. int main()
  1863.     {
  1864.     yylex();
  1865.     return 0;
  1866.     }
  1867. #endif
  1868. #line 224 "scan_commons.l"
  1869.  
  1870.  
  1871. /****
  1872. * macro used in the signal catcher routine below.
  1873. * aborts the scanner if yyin is still open and, if needed,
  1874. * closes the current database file.
  1875. ****/
  1876. #define SHUTUP(text,exitnum)    { \
  1877.     fprintf(stderr, "\n%s: %s\n", progname, text); \
  1878.     if(yyin) \
  1879.     { \
  1880.         fprintf(stderr, "Stopping scanner\n"); \
  1881.         YY_FLUSH_BUFFER; \
  1882.         fclose(yyin); fclose(yyout); \
  1883.     } \
  1884.     if(db_file) \
  1885.     { \
  1886.         fprintf(stderr, "Syncing and closing database\n");\
  1887.         gdbm_close(db_file); db_file = NULL; \
  1888.     } \
  1889.     fprintf(stderr, "Terminated with signal %s\n", #exitnum); \
  1890.     fprintf(stderr, "Total files scanned: %i\n", curr_file_num); \
  1891.     if(dump_core) abort(); \
  1892.     exit(exitnum+20); \
  1893.     }
  1894.  
  1895. /****
  1896. * Exit function for internal flex errors. This function will
  1897. * close the database file (if left open)
  1898. ****/
  1899. void
  1900. scanner_fail(void)
  1901. {
  1902. #if 0
  1903.     if(db_file)
  1904.     {
  1905.         gdbm_close(db_file);
  1906.         db_file = NULL;
  1907.     }
  1908.     fclose(yyin);
  1909.     fclose(yyout);
  1910. #endif
  1911. }
  1912. /****
  1913. * Signal handler for a nice and clean exit 
  1914. ****/
  1915. static RETSIGTYPE
  1916. sig_handler(int signum)
  1917. {
  1918.     switch(signum)
  1919.     {
  1920. #ifdef SIGBUS    /* SIGBUS is not defined on all systems */
  1921.         case SIGBUS:
  1922.             SHUTUP("Aaaiieee, a bus error!", SIGBUS);
  1923. #endif /* SIGBUS */
  1924.         case SIGSEGV:
  1925.             SHUTUP("Ooops, a segmentation violation.", SIGSEGV);
  1926. #ifdef SIGALRM    /* same for SIGALRM */
  1927.         case SIGALRM:
  1928.             SHUTUP("Aborted.", SIGALRM);
  1929. #endif
  1930.         case SIGUSR1:
  1931.             SHUTUP("Memory allocation error.", SIGUSR1);
  1932. #ifdef SIGQUIT    /* same for SIGQUIT */
  1933.         case SIGQUIT:
  1934.             SHUTUP("Interrupted.", SIGQUIT);
  1935. #endif
  1936.         case SIGINT:
  1937.             SHUTUP("Interrupted.", SIGINT);
  1938.         default:
  1939.             SHUTUP("What did _you_ do?  Stopping.", signum);
  1940.     }
  1941. }
  1942.  
  1943. /*****
  1944. * replace an existing entry in the current database with the data contained
  1945. * in key. Otherwise create a new entry in the database.
  1946. *****/
  1947. static void replace_item(datum key)
  1948. {
  1949.     if(gdbm_exists(db_file, key))
  1950.     {
  1951.         datum prev;
  1952.  
  1953.         prev = gdbm_fetch(db_file, key);
  1954.         /*
  1955.         * If the stringcompare matches the current file, it's already 
  1956.         * here so we don't want to update it again. 
  1957.         */
  1958.         if(strstr(prev.dptr, content.dptr))
  1959.         {
  1960.             num_common_rejected++;
  1961.             return;
  1962.         }
  1963.         /*
  1964.         * Resize the returned item so it will contain the next also 
  1965.         * but separated by a comma 
  1966.         */
  1967.         prev.dsize += content.dsize + 2;
  1968.         checked_realloc(prev.dptr, prev.dsize, char);
  1969.  
  1970.         /* update data */
  1971.         strcat(prev.dptr, ",");
  1972.         strcat(prev.dptr, content.dptr);
  1973.  
  1974.         /* store the new data */
  1975.         gdbm_store(db_file, key, prev, GDBM_REPLACE);
  1976.  
  1977.         free(prev.dptr);
  1978.         num_common_accepted++;
  1979.         num_common_stored++;
  1980.         num_common_replaced++;
  1981.         return;
  1982.     }    /* fall through */
  1983.     insert_item(key);
  1984. }
  1985.  
  1986. /*****
  1987. * Add a new entry to the current database
  1988. *****/
  1989. static void insert_item(datum key)
  1990. {
  1991.     if(gdbm_store(db_file, key, content, GDBM_INSERT))
  1992.     {
  1993.         if(!verbose)
  1994.             printf("already have %s, rejected.\n", key.dptr);
  1995.         num_common_rejected++;
  1996.         return;
  1997.     }    /* fall through */
  1998.     num_common_accepted++;
  1999.     num_common_stored++;
  2000. }
  2001.  
  2002. /*****
  2003. * retrieve all commons found in text
  2004. *****/
  2005. static void
  2006. get_common_contents(char *text)
  2007. {
  2008.     char *chPtr, *block;
  2009.     int i;
  2010.     datum key;
  2011.  
  2012.     /* allocate scratch memory */
  2013.     checked_malloc(block, strlen(text)+1, char);
  2014.     /* 
  2015.     * must copy, text is a ptr into a buffer of the scanner. 
  2016.     * Modifying this block will cause unpredictable results 
  2017.     */
  2018.     strcpy(block, text);
  2019.     /* make all text upcase */
  2020.     upcase(block);
  2021.  
  2022.     /* 
  2023.     * forget blocks with FUNCTION in them, scanner picked up the
  2024.     * wrong line.
  2025.     */
  2026.     if(strstr(block, "FUNCTION"))
  2027.         return;
  2028.  
  2029.     /* scan the block for commons. scan_block returns 0 on error. */
  2030.     if((num_warnings = scan_block(block, yylineno)) != -1)
  2031.     {
  2032.         /* store the commons returned */
  2033.         for(i=0, chPtr = strtok(block, ","); chPtr != NULL; 
  2034.             chPtr = strtok(NULL, ","), i++)
  2035.         {
  2036.             key.dptr = chPtr;
  2037.             key.dsize = strlen(chPtr)+1;
  2038.             /*
  2039.             * gdbm_proto_func is a ptr to the actual function used. 
  2040.             * It's real value depends on the -a command line option 
  2041.             */
  2042.             gdbm_proto_func(key); 
  2043.             num_common_total++; 
  2044.         }
  2045.     }
  2046.     else
  2047.         num_errors++;
  2048.     /* if we got warnings, display in what file they are found */
  2049.     if(num_warnings)
  2050.         fprintf(stderr, "File: %s%s\n", curr_path, curr_file);
  2051.     free(block);
  2052. }
  2053.  
  2054. /*****
  2055. * Command line handling
  2056. *****/
  2057. int set_global_option(char *arg)
  2058.     switch(arg[0])
  2059.     {
  2060.         case 'a' :    /* add instead of reject commons */
  2061.             printf("adding instead of rejecting duplicate "
  2062.                 "commons\n");
  2063.             replace = GDBM_REPLACE;
  2064.             gdbm_proto_func = replace_item;
  2065.             break;
  2066.         case 'c' :    /* dump core on errors */
  2067.             dump_core = 1;
  2068.             break;
  2069.         case 'f' :    /* use filenames instead of full paths */
  2070.             full_names = 0 ;
  2071.             break;
  2072.         case 'h' :    /* help requested */
  2073.             printf(usage, progname); 
  2074.             exit(2); 
  2075. #ifdef __MSDOS__
  2076.         case 'm' :    /* show memory usage under msdos */
  2077.             need_mem_info_for_msdos = 1;
  2078.             break;
  2079. #endif
  2080.         case 'q' :     /* be really quiet */
  2081.             quiet = 1; 
  2082.             verbose = 0; 
  2083.             break; 
  2084.         case 'r' :    /* re-organize database */
  2085.             reorganize = 1;
  2086.             break;
  2087.         case 's' :    /* fast store. No update after each add */
  2088.             fast = 0;
  2089.             break;
  2090.         case 't' :    /* don't install signal handlers */
  2091.             no_signal = 1;
  2092.             break;
  2093.         case 'v' :     /* be verbose */
  2094.             verbose = 1; 
  2095.             break; 
  2096.         case 'E' :    /* an extension specification */
  2097.             SCAN_ARG("-E");
  2098.             if(num_extensions == MAXEXTS)
  2099.             {
  2100.                 fprintf(stderr, "Capacity exceeded, more than "
  2101.                     "%i extensions given on command "
  2102.                     "line.\n", MAXEXTS);
  2103.                 fprintf(stderr, "Ignoring extension %s\n", 
  2104.                     arg+1);
  2105.             }
  2106.             else
  2107.             {
  2108.                 checked_malloc(ext_table[num_extensions], 
  2109.                     strlen(arg+1)+1,char);
  2110.                 strcpy(ext_table[num_extensions++], arg+1); 
  2111. #ifdef __MSDOS__     /* dos returns uppercase when building a filelist */
  2112.                 upcase(ext_table[num_extensions-1]);
  2113. #endif
  2114.             }
  2115.             return(1); 
  2116.         case 'I' :    /* a directory specification */
  2117.             SCAN_ARG("-I");
  2118.             if(num_dirs_to_visit == MAXDIRS)
  2119.             {
  2120.                 fprintf(stderr, "Capacity exceeded, more than "
  2121.                     "%i directories given on command "
  2122.                     "line.\n", MAXDIRS);
  2123.                 fprintf(stderr, "Ignoring directory %s\n", 
  2124.                     arg+1);
  2125.             }
  2126.             else
  2127.             {
  2128.                 checked_malloc(dirs_to_visit[num_dirs_to_visit],
  2129.                     strlen(arg+1)+1, char);
  2130.                 strcpy(dirs_to_visit[num_dirs_to_visit++], 
  2131.                     arg+1); 
  2132.             }
  2133.             return(1); 
  2134.         case 'd' :    /* name of database to create/update */
  2135.             SCAN_ARG("-d");
  2136.             outfile = arg + 1;
  2137.             return(1); 
  2138.         case 'x' :    /* ignore file specification */
  2139.             SCAN_ARG("-x");
  2140.             if(num_ignore == MAXIGNORE)
  2141.             {
  2142.                 fprintf(stderr, "Capacity exceeded, more than "
  2143.                     "%i ignores given on command line.\n", 
  2144.                     MAXIGNORE);
  2145.                 fprintf(stderr, "Ignoring option -x%s\n", 
  2146.                     arg+1);
  2147.             }
  2148.             else
  2149.             {
  2150.                 checked_malloc(ignore_list[num_ignore], 
  2151.                     strlen(arg+1)+1, char);
  2152.                 strcpy(ignore_list[num_ignore++], arg+1);
  2153. #ifdef __MSDOS__ /* dos returns uppercase when building a filelist */
  2154.                 upcase(ignore_list[num_ignore-1]);
  2155. #endif
  2156.             }
  2157.             return(1);
  2158.         case '-' :    /* secondary options */
  2159.             if(!strcmp("help", arg+1))    /* help wanted */
  2160.             {
  2161.                 printf(usage, progname); 
  2162.                 exit(2); 
  2163.             }
  2164.             if(!strcmp("version", arg+1))    /* version number */
  2165.             {
  2166.                 print_version_id(progname, VERSION, "$Revision: 1.9 $");
  2167.                 exit(2);
  2168.             }    /* fall through */
  2169.         default:
  2170.             fprintf(stderr,"unknown option -%s\n", arg);
  2171.             exit(3);
  2172.     }
  2173.     return(0); 
  2174. }
  2175.  
  2176. /*****
  2177. * Return 0 if the file given is to be ignored, something else otherwise
  2178. *****/
  2179. static inline int 
  2180. ignore_this_file(char *file)
  2181. {
  2182.     register int i;
  2183.     char *ret_val = NULL;
  2184.     for(i = 0 ; i < num_ignore &&
  2185.         (ret_val = strstr(file, ignore_list[i])) == NULL; i++)
  2186.             /* do nothing */ ;
  2187.     if(ret_val != NULL)
  2188.     {
  2189.         if(!quiet)
  2190.             printf("Ignoring file %s\n", file);
  2191.         ign_file_num++;
  2192.         return(0);
  2193.     }
  2194.     return(1);
  2195. }
  2196.  
  2197. /*****
  2198. * main for scan_commons
  2199. *****/
  2200. int main (int argc, char **argv)
  2201.     FILE *file;
  2202.     int i, narg;
  2203.     char *arg;
  2204.     char fullname[MAXPATHLEN];
  2205.  
  2206.     get_filename_part(argv[0], progname);
  2207.  
  2208.     if(argc == 1)
  2209.     {
  2210.         printf(usage, progname);
  2211.         exit(2);
  2212.     }
  2213.  
  2214.     /*
  2215.     * Command line handling. Set default switches.
  2216.     */
  2217.     full_names = 1;
  2218.     replace = GDBM_INSERT;
  2219.     fast = GDBM_FAST;
  2220.     /* default action is to insert a common if it does not yet exist */
  2221.     gdbm_proto_func = insert_item;
  2222.  
  2223.     /* scan the entire command line for any options */
  2224.     arg = argv[narg = 1];
  2225.     while ( narg < argc && arg[0] == '-' )
  2226.     {
  2227.         if (arg[0] == '-')
  2228.         {
  2229.             int num_opts = strlen(arg) ;
  2230.             for(i = 1 ; i < num_opts ; i++ )
  2231.             if(set_global_option(++arg))
  2232.                 break;
  2233.         }
  2234.         arg = argv[++narg];
  2235.     }
  2236.     /*
  2237.     * Try to get a database name from the environment specification if no
  2238.     * database is given on the command line
  2239.     */
  2240.     if(outfile == NULL)
  2241.         outfile = get_database_location(COMMON_LOCATION);
  2242.     if(outfile == NULL)
  2243.     {
  2244.         fprintf(stderr, "%s: no database found/specified\n", progname);
  2245.         exit(5);
  2246.     }
  2247.  
  2248.     /* attach signal handlers if not in debug mode. */
  2249.     if(!no_signal)
  2250.         ATTACH_SIGNALS;
  2251.  
  2252.     /* see if we have a dir spec or files on the command line */
  2253.     if(num_dirs_to_visit == 0 && narg == argc && reorganize == 0 )
  2254.     {
  2255.         fprintf(stderr,"%s: no files given.\n", progname);
  2256.         exit(4);
  2257.     }
  2258.  
  2259.     /* report initial settings if we have to be verbose */
  2260.     if(verbose)
  2261.     {
  2262.         if(num_dirs_to_visit != 0)
  2263.         {
  2264.             printf("List of directories to visit:\n");
  2265.             for(i = 0 ; i < num_dirs_to_visit; i++)
  2266.                 printf("%s\n", dirs_to_visit[i]);
  2267.         }
  2268.         if(num_extensions != 0)
  2269.         {
  2270.             printf("List of extensions to use:\n");
  2271.             for(i = 0 ; i < num_extensions; i++)
  2272.                 printf("%s ", ext_table[i]);
  2273.             printf("\n");
  2274.         }
  2275.         if(num_ignore != 0)
  2276.         {
  2277.             printf("List of files to ignore:\n");
  2278.             for(i = 0 ; i < num_ignore; i++)
  2279.                 printf("%s\n", ignore_list[i]);
  2280.         }
  2281.         if(num_dirs_to_visit != 0)
  2282.             printf("Scanning directories\n");
  2283.         fflush(stdout);
  2284.     }
  2285.  
  2286.     /* go create a list of all files in the directories given (if any) */
  2287.     for(i = 0 ; i < num_dirs_to_visit; i++)
  2288.     {
  2289.         if(verbose)
  2290.             printf("%s\n", dirs_to_visit[i]); 
  2291.         build_file_list(&file_list, &num_files, dirs_to_visit[i],
  2292.             ext_table, num_extensions); 
  2293.     }
  2294.  
  2295.     /* add files given on the command line to the list of files to visit */
  2296.     if(narg != argc)
  2297.     {
  2298.         for(i = narg ; i < argc ; i++)
  2299.         {
  2300.             checked_realloc(file_list, num_files+1, char*);
  2301.             checked_malloc(file_list[num_files], strlen(argv[i])+1,
  2302.                 char);
  2303.             sprintf(file_list[num_files++], "%s", argv[i]); 
  2304.         }
  2305.         if(verbose && argc-narg !=0)
  2306.             printf("%i files given on command line.", argc - narg); 
  2307.     }
  2308.  
  2309.     /* give the list of files to scan when we are being verbose */
  2310.     if(verbose)
  2311.     {
  2312.         printf("List of files to scan:\n");
  2313.         for(i = 0 ; i < num_files; i++)
  2314.             printf("%s\n", file_list[i]);
  2315.     }
  2316.  
  2317.     /* show number of files to scan */
  2318.     if(!quiet)
  2319.     {
  2320.         printf("Total Files to scan: %i\n", num_files); 
  2321.         printf("Database to create/update: %s\n", outfile);
  2322.     }
  2323.     fflush(stdout);
  2324.  
  2325.     /* open the database file for storage. Set to fast mode if requested */
  2326.     db_file = gdbm_open(outfile, 256, GDBM_WRCREAT | fast, DBM_PERM, NULL);
  2327.     if(db_file == NULL)
  2328.     {
  2329.         fprintf(stderr, "gdbm error: %s\n", gdbm_strerror(gdbm_errno));
  2330.         perror(outfile);
  2331.         exit(6);
  2332.     }
  2333.  
  2334.     /* write some administrative data to the database */
  2335.     write_commondb_header(db_file, outfile);
  2336.     for(i = 0 ; i < num_dirs_to_visit; i++)
  2337.         write_commondb_dirinfo(db_file, dirs_to_visit[i]);
  2338.  
  2339.     /* purge non-matching chars to /dev/null */
  2340.     yyout = fopen(YYOUT_DEVICE, "w+");
  2341.  
  2342.     num_files--;
  2343.  
  2344.     /* register exit function if the scanner fails */
  2345.     atexit(scanner_fail);
  2346.  
  2347.     /* loop through all files in the filelist */
  2348.     for(i = 0; i <= num_files; i++)
  2349.     {
  2350.         /* Check to see if we are to ignore this file */
  2351.         if((num_ignore == 0 ? 1 : ignore_this_file(file_list[i])))
  2352.         {
  2353.             file = fopen(file_list[i], "r");
  2354.             if(!file)
  2355.             {
  2356.                 perror(file_list[i]); 
  2357.                 continue;
  2358.             }
  2359.             num_common_total = num_common_rejected = 0;
  2360.             num_common_accepted = 0;
  2361.             num_common_replaced = num_common_stored = 0;
  2362.             num_errors = num_warnings = 0;
  2363.  
  2364.             /* get the complete path to this file and store it */
  2365.             ParseFilename(file_list[i], curr_file, curr_path);
  2366.             if(full_names)
  2367.                 sprintf(fullname, "%s%s", curr_path, curr_file);
  2368.             else
  2369.                 sprintf(fullname, "%s", curr_file);
  2370.  
  2371.             /* data belonging to each common found in this file */
  2372.             content.dptr = fullname;
  2373.             content.dsize = strlen(fullname)+1;
  2374.             yyin = file;  
  2375.             if(!quiet) 
  2376.                 printf("\nScanning %s\n", file_list[i]);
  2377.             rewind(yyin);
  2378.             /* go scan the file */
  2379.             yylex();
  2380.             YY_FLUSH_BUFFER;    /* clear scanner buffer */ 
  2381.             fclose(yyin);        /* close the input file */
  2382.             if(verbose)         /* report if wanted */
  2383.             { 
  2384.                 printf("\n---- Stats for file %s (%i/%i)\n", 
  2385.                     file_list[i], i+1, num_files+1);
  2386.                 printf("commons found      : %i\n", 
  2387.                     num_common_total);
  2388.                 printf("duplicate commons  : %i\n", 
  2389.                     num_common_replaced);
  2390.                 printf("commons rejected   : %i\n", 
  2391.                     num_common_rejected);
  2392.                 printf("commons accepted   : %i\n", 
  2393.                     num_common_accepted);
  2394.                 printf("commons stored     : %i\n", 
  2395.                     num_common_stored);
  2396.                 printf("Scan warnings      : %i\n", 
  2397.                     num_warnings);
  2398.                 printf("Scan errors        : %i\n", 
  2399.                     num_errors);
  2400.             }
  2401.             /* flush messages to stdout */
  2402.             fflush(stdout);
  2403.             num_total += num_common_total;
  2404.             num_total_replaced += num_common_replaced;
  2405.             num_total_rejected += num_common_rejected;
  2406.             num_total_accepted += num_common_accepted;
  2407.             num_total_stored   += num_common_stored;
  2408.             curr_file_num++;
  2409.         }
  2410.     }
  2411.     /* close /dev/null */
  2412.     fclose(yyout);
  2413.  
  2414.     /* report some statistics */
  2415.     if(!quiet)
  2416.     {
  2417.         printf("\n--- Total Statistics ---\n");
  2418.         printf("Directories visited: %i\n", num_dirs_to_visit);
  2419.         printf("Files searched     : %i\n", num_files+1);
  2420.         printf("Files ignored      : %i\n\n", ign_file_num);
  2421.         printf("commons found      : %i\n", num_total);
  2422.         printf("duplicate commons  : %i\n", num_total_replaced);
  2423.         printf("commons rejected   : %i\n", num_total_rejected);
  2424.         printf("commons accepted   : %i\n", num_total_accepted);
  2425.         printf("commons stored     : %i\n", num_total_stored);
  2426.         printf("\n------------------------\n");
  2427.     }
  2428.  
  2429.     /* write some more administrative data */
  2430.     write_commondb_update_info(db_file, num_total - num_total_rejected );
  2431.  
  2432.     if(reorganize)
  2433.     {
  2434.         if(!quiet)
  2435.             printf("Re-organizing database\n");
  2436.         if(gdbm_reorganize(db_file))
  2437.         {
  2438.             fprintf(stderr, "gdbm error: %s\n",
  2439.                 gdbm_strerror(gdbm_errno));
  2440.             perror(outfile);
  2441.         }
  2442.     }
  2443.     gdbm_close(db_file);    /* close the database */
  2444.     db_file = NULL;
  2445.  
  2446. #ifdef __MSDOS__
  2447.     if(need_mem_info_for_msdos)
  2448.     {
  2449.         printf("\n------------------\n");
  2450.         printf("MSDOS Memory Usage\n\n");
  2451.         printf("Heap size is %u bytes\n", _heaplen);
  2452.         printf("Stack size is %u\ bytesn", _stklen);
  2453.         dir_mem = sizeof(dirs_to_visit);
  2454.         for(i = 0 ; i < num_dirs_to_visit; i++)
  2455.             dir_mem += strlen(dirs_to_visit[i]);
  2456.         printf("Memory used by dir list: %lu bytes\n", dir_mem);
  2457.         ext_mem = sizeof(ext_table);
  2458.         for(i = 0 ; i < num_extensions; i++)
  2459.             ext_mem += strlen(ext_table[i]);
  2460.         printf("Memory used by ext list: %lu bytes\n", ext_mem);
  2461.         ign_mem = sizeof(ignore_list);
  2462.         for(i = 0 ; i < num_ignore; i++)
  2463.             ign_mem += strlen(ignore_list[i]);
  2464.         printf("Memory used by ignore list: %lu bytes\n", ign_mem);
  2465.         file_mem = sizeof(file_list);
  2466.         for(i = 0 ; i < num_files; i++)
  2467.             file_mem += strlen(file_list[i]);
  2468.          printf("Memory used by file list: %lu bytes\n", file_mem);
  2469.  
  2470.         printf("Total memory used: %lu bytes\n",
  2471.             dir_mem + ext_mem + ign_mem + file_mem);
  2472.     }
  2473. #endif
  2474.     return(0);
  2475. }
  2476.