getargs.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Parse command line arguments for bison,
  2. Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
  3. BISON is distributed in the hope that it will be useful, but WITHOUT ANY
  4. WARRANTY. No author or distributor accepts responsibility to anyone
  5. for the consequences of using it or for whether it serves any
  6. particular purpose or works at all, unless he says so in writing.
  7. Refer to the BISON General Public License for full details.
  8. Everyone is granted permission to copy, modify and redistribute BISON,
  9. but only under the conditions described in the BISON General Public
  10. License. A copy of this license is supposed to have been given to you
  11. along with BISON so you can know your rights and responsibilities. It
  12. should be in a file named COPYING. Among other things, the copyright
  13. notice and this notice must be preserved on all copies.
  14. In other words, you are welcome to use, share and improve this program.
  15. You are forbidden to forbid anyone else to use, share and improve
  16. what you give them. Help stamp out software-hoarding! */
  17. #include <stdio.h>
  18. #include "files.h"
  19. int verboseflag;
  20. int definesflag;
  21. extern int fixed_outfiles;/* JF */
  22. getargs(argc, argv)
  23. int argc;
  24. char *argv[];
  25. {
  26. register int i;
  27. register char *cp;
  28. register int duplicates;
  29. verboseflag = 0;
  30. definesflag = 0;
  31. duplicates = 0;
  32. i = 1;
  33. while (i < argc && *argv[i] == '-')
  34. {
  35. cp = argv[i] + 1;
  36. while (*cp)
  37. {
  38. switch (*cp)
  39. {
  40. case 'y':/* JF this case */
  41. case 'Y':
  42. if(fixed_outfiles)
  43. duplicates = 1;
  44. else
  45. fixed_outfiles = 1;
  46. break;
  47. case 'v':
  48. case 'V':
  49. if (verboseflag)
  50. duplicates = 1;
  51. else
  52. verboseflag = 1;
  53. break;
  54. case 'd':
  55. case 'D':
  56. if (definesflag)
  57. duplicates = 1;
  58. else
  59. definesflag = 1;
  60. break;
  61. default:
  62. fatals("illegal option: %s", argv[i]);
  63. }
  64. cp++;
  65. }
  66. i++;
  67. }
  68. if (duplicates)
  69. fprintf(stderr, "warning: repeated arguments ignored");
  70. if (i == argc)
  71. fatal("grammar file not specified");
  72. else
  73. infile = argv[i];
  74. if (i < argc - 1)
  75. fprintf(stderr, "warning: extra arguments ignored");
  76. }