Annotation of GNUtools/bison/getargs.c, revision 1.1.1.1

1.1       root        1: /* Parse command line arguments for bison,
                      2:    Copyright (C) 1984, 1986, 1989 Free Software Foundation, Inc.
                      3: 
                      4: This file is part of Bison, the GNU Compiler Compiler.
                      5: 
                      6: Bison is free software; you can redistribute it and/or modify
                      7: it under the terms of the GNU General Public License as published by
                      8: the Free Software Foundation; either version 2, or (at your option)
                      9: any later version.
                     10: 
                     11: Bison is distributed in the hope that it will be useful,
                     12: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     14: GNU General Public License for more details.
                     15: 
                     16: You should have received a copy of the GNU General Public License
                     17: along with Bison; see the file COPYING.  If not, write to
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
                     20: 
                     21: #include <stdio.h>
                     22: #include "getopt.h"
                     23: #include "system.h"
                     24: #include "files.h"
                     25: 
                     26: int verboseflag;
                     27: int definesflag;
                     28: int debugflag;
                     29: int nolinesflag;
                     30: char *spec_name_prefix; /* for -p.  */
                     31: char *spec_file_prefix; /* for -b. */
                     32: extern int fixed_outfiles;/* for -y */
                     33: 
                     34: extern char *program_name;
                     35: extern char *version_string;
                     36: 
                     37: extern void fatal();
                     38: 
                     39: struct option longopts[] =
                     40: {
                     41:   {"debug", 0, &debugflag, 1},
                     42:   {"defines", 0, &definesflag, 1},
                     43:   {"file-prefix", 1, 0, 'b'},
                     44:   {"fixed-output-files", 0, &fixed_outfiles, 1},
                     45:   {"help", 0, 0, 'h'},
                     46:   {"name-prefix", 1, 0, 'a'},
                     47:   {"no-lines", 0, &nolinesflag, 1},
                     48:   {"output", 1, 0, 'o'},
                     49:   {"output-file", 1, 0, 'o'},
                     50:   {"verbose", 0, &verboseflag, 1},
                     51:   {"version", 0, 0, 'V'},
                     52:   {"yacc", 0, &fixed_outfiles, 1},
                     53:   {0, 0, 0, 0}
                     54: };
                     55: 
                     56: void
                     57: usage (stream)
                     58:      FILE *stream;
                     59: {
                     60:   fprintf (stream, "\
                     61: Usage: %s [-dhltvyV] [-b file-prefix] [-o outfile] [-p name-prefix]\n\
                     62:        [--debug] [--defines] [--fixed-output-files] [--no-lines]\n\
                     63:        [--verbose] [--version] [--help] [--yacc]\n\
                     64:        [--file-prefix=prefix] [--name-prefix=prefix]\n\
                     65:        [--output=outfile] grammar-file\n",
                     66:           program_name);
                     67: }
                     68: 
                     69: void
                     70: getargs(argc, argv)
                     71:      int argc;
                     72:      char *argv[];
                     73: {
                     74:   register int c;
                     75: 
                     76:   verboseflag = 0;
                     77:   definesflag = 0;
                     78:   debugflag = 0;
                     79:   fixed_outfiles = 0;
                     80: 
                     81:   while ((c = getopt_long (argc, argv, "yvdhltVo:b:p:", longopts, (int *)0))
                     82:         != EOF)
                     83:     {
                     84:       switch (c)
                     85:        {
                     86:        case 0:
                     87:          /* Certain long options cause getopt_long to return 0.  */
                     88:          break;
                     89: 
                     90:        case 'y':
                     91:          fixed_outfiles = 1;
                     92:          break;
                     93:          
                     94:        case 'h':
                     95:          usage (stdout);
                     96:          exit (0);
                     97: 
                     98:        case 'V':
                     99:          printf ("%s", version_string);
                    100:          exit (0);
                    101:          
                    102:        case 'v':
                    103:          verboseflag = 1;
                    104:          break;
                    105:          
                    106:        case 'd':
                    107:          definesflag = 1;
                    108:          break;
                    109:          
                    110:        case 'l':
                    111:          nolinesflag = 1;
                    112:          break;
                    113:          
                    114:        case 't':
                    115:          debugflag = 1;
                    116:          break;
                    117:          
                    118:        case 'o':
                    119:          spec_outfile = optarg;
                    120:          break;
                    121:          
                    122:        case 'b':
                    123:          spec_file_prefix = optarg;
                    124:          break;
                    125:          
                    126:        case 'p':
                    127:          spec_name_prefix = optarg;
                    128:          break;
                    129:          
                    130:        default:
                    131:          usage (stderr);
                    132:          exit (1);
                    133:        }
                    134:     }
                    135: 
                    136:   if (optind == argc)
                    137:     {
                    138:       fprintf(stderr, "%s: no grammar file given\n", program_name);
                    139:       exit(1);
                    140:     }
                    141:   if (optind < argc - 1)
                    142:     fprintf(stderr, "%s: warning: extra arguments ignored\n", program_name);
                    143: 
                    144:   infile = argv[optind];
                    145: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.