GETARGS.C 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* Parse command line arguments for bison,
  2. Copyright (C) 1984, 1986, 1989 Free Software Foundation, Inc.
  3. This file is part of Bison, the GNU Compiler Compiler.
  4. Bison is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 1, or (at your option)
  7. any later version.
  8. Bison is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with Bison; see the file COPYING. If not, write to
  14. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  15. #include <stdio.h>
  16. #include "system.h"
  17. #include "files.h"
  18. int verboseflag;
  19. int definesflag;
  20. int debugflag;
  21. int nolinesflag;
  22. extern int fixed_outfiles;/* JF */
  23. extern int getopt();
  24. extern void fatal();
  25. void
  26. getargs(argc, argv)
  27. int argc;
  28. char *argv[];
  29. {
  30. register int c;
  31. char *p = argv[0];
  32. char *lastcomponent;
  33. extern int optind;
  34. extern char *optarg;
  35. verboseflag = 0;
  36. definesflag = 0;
  37. debugflag = 0;
  38. fixed_outfiles = 0;
  39. #if 0 /* Let's avoid dependence on what name invoked with.
  40. The file `yacc' can be a shell script that runs `bison -y'. */
  41. /* See if the program was invoked as "yacc". */
  42. lastcomponent = p;
  43. while (*p)
  44. {
  45. if (*p == '/')
  46. lastcomponent = p + 1;
  47. p++;
  48. }
  49. if (! strcmp (lastcomponent, "yacc"))
  50. /* If so, pretend we have "-y" as argument. */
  51. fixed_outfiles = 1;
  52. #endif
  53. while ((c = getopt (argc, argv, "yvdlto:")) != EOF)
  54. switch (c)
  55. {
  56. case 'y':
  57. fixed_outfiles = 1;
  58. break;
  59. case 'v':
  60. if(optind && argv[optind] && !strcmp(argv[optind],"-version")) {
  61. extern char *version_string;
  62. printf("%s",version_string);
  63. while(getopt(argc,argv,"ersion")!='n')
  64. ;
  65. } else
  66. verboseflag = 1;
  67. break;
  68. case 'd':
  69. definesflag = 1;
  70. break;
  71. case 'l':
  72. nolinesflag = 1;
  73. break;
  74. case 't':
  75. debugflag = 1;
  76. break;
  77. case 'o':
  78. spec_outfile = optarg;
  79. }
  80. if (optind == argc)
  81. fatal("grammar file not specified");
  82. else
  83. infile = argv[optind];
  84. if (optind < argc - 1)
  85. fprintf(stderr, "bison: warning: extra arguments ignored\n");
  86. }