home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mdepsrc.zip / main.c < prev    next >
C/C++ Source or Header  |  1996-12-10  |  16KB  |  732 lines

  1. /* $XConsortium: main.c,v 1.84 94/11/30 16:10:44 kaleb Exp $ */
  2. /* $XFree86: xc/config/makedepend/main.c,v 3.3 1995/01/28 15:41:03 dawes Exp $ */
  3. /*
  4.  
  5. Copyright (c) 1993, 1994  X Consortium
  6.  
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13.  
  14. The above copyright notice and this permission notice shall be included in
  15. all copies or substantial portions of the Software.
  16.  
  17. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  20. X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  21. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23.  
  24. Except as contained in this notice, the name of the X Consortium shall not be
  25. used in advertising or otherwise to promote the sale, use or other dealings
  26. in this Software without prior written authorization from the X Consortium.
  27.  
  28. */
  29.  
  30. #include "def.h"
  31. #ifdef hpux
  32. #define sigvec sigvector
  33. #endif /* hpux */
  34.  
  35. #ifdef X_POSIX_C_SOURCE
  36. #define _POSIX_C_SOURCE X_POSIX_C_SOURCE
  37. #include <signal.h>
  38. #undef _POSIX_C_SOURCE
  39. #else
  40. #if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
  41. #include <signal.h>
  42. #else
  43. #define _POSIX_SOURCE
  44. #include <signal.h>
  45. #undef _POSIX_SOURCE
  46. #endif
  47. #endif
  48.  
  49. #if NeedVarargsPrototypes
  50. #include <stdarg.h>
  51. #endif
  52.  
  53. #ifdef MINIX
  54. #define USE_CHMOD    1
  55. #endif
  56.  
  57. #ifdef DEBUG
  58. int    _debugmask;
  59. #endif
  60.  
  61. char *ProgramName;
  62.  
  63. char    *directives[] = {
  64.     "if",
  65.     "ifdef",
  66.     "ifndef",
  67.     "else",
  68.     "endif",
  69.     "define",
  70.     "undef",
  71.     "include",
  72.     "line",
  73.     "pragma",
  74.     "error",
  75.     "ident",
  76.     "sccs",
  77.     "elif",
  78.     "eject",
  79.     NULL
  80. };
  81.  
  82. #define MAKEDEPEND
  83. #include "imakemdep.h"    /* from config sources */
  84. #undef MAKEDEPEND
  85.  
  86. struct    inclist inclist[ MAXFILES ],
  87.         *inclistp = inclist,
  88.         maininclist;
  89.  
  90. char    *filelist[ MAXFILES ];
  91. char    *includedirs[ MAXDIRS + 1 ];
  92. char    *notdotdot[ MAXDIRS ];
  93. char    *objprefix = "";
  94. char    *objsuffix = ".obj"; /* OBJSUFFIX;  */
  95. char    *startat = "# DO NOT DELETE";
  96. int    width = 78;
  97. boolean    append = FALSE;
  98. boolean    printed = FALSE;
  99. boolean    verbose = FALSE;
  100. boolean    show_where_not = FALSE;
  101. boolean warn_multiple = FALSE;    /* Warn on multiple includes of same file */
  102.  
  103. static
  104. #ifdef SIGNALRETURNSINT
  105. int
  106. #else
  107. void
  108. #endif
  109. catch (sig)
  110.     int sig;
  111. {
  112.     fflush (stdout);
  113.     fatalerr ("got signal %d\n", sig);
  114. }
  115.  
  116. #if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32) || defined(__EMX__) || defined(__OS2__)
  117. #define USGISH
  118. #endif
  119.  
  120. #ifndef USGISH
  121. #ifndef _POSIX_SOURCE
  122. #define sigaction sigvec
  123. #define sa_handler sv_handler
  124. #define sa_mask sv_mask
  125. #define sa_flags sv_flags
  126. #endif
  127. struct sigaction sig_act;
  128. #endif /* USGISH */
  129.  
  130. main(argc, argv)
  131.     int    argc;
  132.     char    **argv;
  133. {
  134.     register char    **fp = filelist;
  135.     register char    **incp = includedirs;
  136.     register char    *p;
  137.     register struct inclist    *ip;
  138.     char    *makefile = NULL;
  139.     struct filepointer    *filecontent;
  140.     struct symtab *psymp = predefs;
  141.     char *endmarker = NULL;
  142.     char *defincdir = NULL;
  143.  
  144.     ProgramName = argv[0];
  145.  
  146.     while (psymp->s_name)
  147.     {
  148.         define2(psymp->s_name, psymp->s_value, &maininclist);
  149.         psymp++;
  150.     }
  151.     if (argc == 2 && argv[1][0] == '@') {
  152.         struct stat ast;
  153.         int afd;
  154.         char *args;
  155.         char **nargv;
  156.         int nargc;
  157.         char quotechar = '\0';
  158.  
  159.         nargc = 1;
  160.         if ((afd = open(argv[1]+1, O_RDONLY)) < 0)
  161.         fatalerr("cannot open \"%s\"\n", argv[1]+1);
  162.         fstat(afd, &ast);
  163.         args = (char *)malloc(ast.st_size + 1);
  164.         if ((ast.st_size = read(afd, args, ast.st_size)) < 0)
  165.         fatalerr("failed to read %s\n", argv[1]+1);
  166.         args[ast.st_size] = '\0';
  167.         close(afd);
  168.         for (p = args; *p; p++) {
  169.         if (quotechar) {
  170.             if (quotechar == '\\' ||
  171.             (*p == quotechar && p[-1] != '\\'))
  172.             quotechar = '\0';
  173.             continue;
  174.         }
  175.         switch (*p) {
  176.         case '\\':
  177.         case '"':
  178.         case '\'':
  179.             quotechar = *p;
  180.             break;
  181.         case ' ':
  182.         case '\n':
  183.             *p = '\0';
  184.             if (p > args && p[-1])
  185.             nargc++;
  186.             break;
  187.         }
  188.         }
  189.         if (p[-1])
  190.         nargc++;
  191.         nargv = (char **)malloc(nargc * sizeof(char *));
  192.         nargv[0] = argv[0];
  193.         argc = 1;
  194.         for (p = args; argc < nargc; p += strlen(p) + 1)
  195.         if (*p) nargv[argc++] = p;
  196.         argv = nargv;
  197.     }
  198.     for(argc--, argv++; argc; argc--, argv++) {
  199.             /* if looking for endmarker then check before parsing */
  200.         if (endmarker && strcmp (endmarker, *argv) == 0) {
  201.             endmarker = NULL;
  202.             continue;
  203.         }
  204.         if (**argv != '-') {
  205.             /* treat +thing as an option for C++ */
  206.             if (endmarker && **argv == '+')
  207.                 continue;
  208.             *fp++ = argv[0];
  209.             continue;
  210.         }
  211.         switch(argv[0][1]) {
  212.         case '-':
  213.             endmarker = &argv[0][2];
  214.             if (endmarker[0] == '\0') endmarker = "--";
  215.             break;
  216.         case 'D':
  217.             if (argv[0][2] == '\0') {
  218.                 argv++;
  219.                 argc--;
  220.             }
  221.             for (p=argv[0] + 2; *p ; p++)
  222.                 if (*p == '=') {
  223.                     *p = ' ';
  224.                     break;
  225.                 }
  226.             define(argv[0] + 2, &maininclist);
  227.             break;
  228.         case 'i':
  229.             {
  230.                 char* delim;
  231.                 char* envinclude;
  232.                 char* prevdir;
  233.                 if (endmarker) break;
  234.                 if (argv[0][2] == '\0') {
  235.                     argv++;
  236.                     argc--;
  237.                     envinclude = getenv(argv[0]);
  238.                 } else    envinclude = getenv(argv[0]+2);
  239.                 if (!envinclude)    break;
  240.                 prevdir = envinclude;
  241.                 delim = (char*)strchr(envinclude, ';');
  242.                 while(delim)
  243.                 {
  244.                     if (incp >= includedirs + MAXDIRS)    fatalerr("Too many Include directories.\n");
  245.                     *delim = '\0';
  246.                     delim++;
  247.                     *incp++ = prevdir;
  248.                     prevdir = delim;
  249.                     delim = (char*)strchr(delim, ';');
  250.                 }
  251.             }
  252.             break;
  253.         case 'I':
  254.             if (incp >= includedirs + MAXDIRS)
  255.                 fatalerr("Too many -I flags.\n");
  256.             *incp++ = argv[0]+2;
  257.             if (**(incp-1) == '\0') {
  258.                 *(incp-1) = *(++argv);
  259.                 argc--;
  260.             }
  261.             break;
  262.         case 'Y':
  263.             defincdir = argv[0]+2;
  264.             break;
  265.         /* do not use if endmarker processing */
  266.         case 'a':
  267.             if (endmarker) break;
  268.             append = TRUE;
  269.             break;
  270.         case 'w':
  271.             if (endmarker) break;
  272.             if (argv[0][2] == '\0') {
  273.                 argv++;
  274.                 argc--;
  275.                 width = atoi(argv[0]);
  276.             } else
  277.                 width = atoi(argv[0]+2);
  278.             break;
  279.         case 'o':
  280.             if (endmarker) break;
  281.             if (argv[0][2] == '\0') {
  282.                 argv++;
  283.                 argc--;
  284.                 objsuffix = argv[0];
  285.             } else
  286.                 objsuffix = argv[0]+2;
  287.             break;
  288.         case 'p':
  289.             if (endmarker) break;
  290.             if (argv[0][2] == '\0') {
  291.                 argv++;
  292.                 argc--;
  293.                 objprefix = argv[0];
  294.             } else
  295.                 objprefix = argv[0]+2;
  296.             break;
  297.         case 'v':
  298.             if (endmarker) break;
  299.             verbose = TRUE;
  300. #ifdef DEBUG
  301.             if (argv[0][2])
  302.                 _debugmask = atoi(argv[0]+2);
  303. #endif
  304.             break;
  305.         case 's':
  306.             if (endmarker) break;
  307.             startat = argv[0]+2;
  308.             if (*startat == '\0') {
  309.                 startat = *(++argv);
  310.                 argc--;
  311.             }
  312.             if (*startat != '#')
  313.                 fatalerr("-s flag's value should start %s\n",
  314.                     "with '#'.");
  315.             break;
  316.         case 'f':
  317.             if (endmarker) break;
  318.             makefile = argv[0]+2;
  319.             if (*makefile == '\0') {
  320.                 makefile = *(++argv);
  321.                 argc--;
  322.             }
  323.             break;
  324.         case 'm':
  325.             warn_multiple = TRUE;
  326.             break;
  327.             
  328.         /* Ignore -O, -g so we can just pass ${CFLAGS} to
  329.            makedepend
  330.          */
  331.         case 'O':
  332.         case 'g':
  333.             break;
  334.         default:
  335.             if (endmarker) break;
  336.     /*        fatalerr("unknown opt = %s\n", argv[0]); */
  337.             warning("ignoring option %s\n", argv[0]);
  338.         }
  339.     }
  340.     if (!defincdir) {
  341. #ifdef PREINCDIR
  342.         if (incp >= includedirs + MAXDIRS)
  343.         fatalerr("Too many -I flags.\n");
  344.         *incp++ = PREINCDIR;
  345. #endif
  346. #ifdef INCLUDEDIR
  347.         if (incp >= includedirs + MAXDIRS)
  348.         fatalerr("Too many -I flags.\n");
  349.         *incp++ = INCLUDEDIR;
  350. #endif
  351. #ifdef POSTINCDIR
  352.         if (incp >= includedirs + MAXDIRS)
  353.         fatalerr("Too many -I flags.\n");
  354.         *incp++ = POSTINCDIR;
  355. #endif
  356.     } else if (*defincdir) {
  357.         if (incp >= includedirs + MAXDIRS)
  358.         fatalerr("Too many -I flags.\n");
  359.         *incp++ = defincdir;
  360.     }
  361.  
  362.     redirect(startat, makefile);
  363.  
  364.     /*
  365.      * catch signals.
  366.      */
  367. #ifdef USGISH
  368. /*  should really reset SIGINT to SIG_IGN if it was.  */
  369. #ifdef SIGHUP
  370.     signal (SIGHUP, catch);
  371. #endif
  372.     signal (SIGINT, catch);
  373. #ifdef SIGQUIT
  374.     signal (SIGQUIT, catch);
  375. #endif
  376.     signal (SIGILL, catch);
  377. #ifdef SIGBUS
  378.     signal (SIGBUS, catch);
  379. #endif
  380.     signal (SIGSEGV, catch);
  381. #ifdef SIGSYS
  382.     signal (SIGSYS, catch);
  383. #endif
  384. #else
  385.     sig_act.sa_handler = catch;
  386. #ifdef _POSIX_SOURCE
  387.     sigemptyset(&sig_act.sa_mask);
  388.     sigaddset(&sig_act.sa_mask, SIGINT);
  389.     sigaddset(&sig_act.sa_mask, SIGQUIT);
  390. #ifdef SIGBUS
  391.     sigaddset(&sig_act.sa_mask, SIGBUS);
  392. #endif
  393.     sigaddset(&sig_act.sa_mask, SIGILL);
  394.     sigaddset(&sig_act.sa_mask, SIGSEGV);
  395.     sigaddset(&sig_act.sa_mask, SIGHUP);
  396.     sigaddset(&sig_act.sa_mask, SIGPIPE);
  397. #ifdef SIGSYS
  398.     sigaddset(&sig_act.sa_mask, SIGSYS);
  399. #endif
  400. #else
  401.     sig_act.sa_mask = ((1<<(SIGINT -1))
  402.                |(1<<(SIGQUIT-1))
  403. #ifdef SIGBUS
  404.                |(1<<(SIGBUS-1))
  405. #endif
  406.                |(1<<(SIGILL-1))
  407.                |(1<<(SIGSEGV-1))
  408.                |(1<<(SIGHUP-1))
  409.                |(1<<(SIGPIPE-1))
  410. #ifdef SIGSYS
  411.                |(1<<(SIGSYS-1))
  412. #endif
  413.                );
  414. #endif /* _POSIX_SOURCE */
  415.     sig_act.sa_flags = 0;
  416.     sigaction(SIGHUP, &sig_act, (struct sigaction *)0);
  417.     sigaction(SIGINT, &sig_act, (struct sigaction *)0);
  418.     sigaction(SIGQUIT, &sig_act, (struct sigaction *)0);
  419.     sigaction(SIGILL, &sig_act, (struct sigaction *)0);
  420. #ifdef SIGBUS
  421.     sigaction(SIGBUS, &sig_act, (struct sigaction *)0);
  422. #endif
  423.     sigaction(SIGSEGV, &sig_act, (struct sigaction *)0);
  424. #ifdef SIGSYS
  425.     sigaction(SIGSYS, &sig_act, (struct sigaction *)0);
  426. #endif
  427. #endif /* USGISH */
  428.  
  429.     /*
  430.      * now peruse through the list of files.
  431.      */
  432.     for(fp=filelist; *fp; fp++) {
  433.         filecontent = getfile(*fp);
  434.         ip = newinclude(*fp, (char *)NULL);
  435.  
  436.         find_includes(filecontent, ip, ip, 0, FALSE);
  437.         freefile(filecontent);
  438.         recursive_pr_include(ip, ip->i_file, base_name(*fp));
  439.         inc_clean();
  440.     }
  441.     if (printed)
  442.         printf("\n");
  443.     exit(0);
  444. }
  445.  
  446. struct filepointer *getfile(file)
  447.     char    *file;
  448. {
  449.     register int    fd;
  450.     struct filepointer    *content;
  451.     struct stat    st;
  452.  
  453.     content = (struct filepointer *)malloc(sizeof(struct filepointer));
  454.     if ((fd = open(file, O_RDONLY)) < 0) {
  455.         warning("cannot open \"%s\"\n", file);
  456.         content->f_p = content->f_base = content->f_end = (char *)malloc(1);
  457.         *content->f_p = '\0';
  458.         return(content);
  459.     }
  460.     fstat(fd, &st);
  461.     content->f_base = (char *)malloc(st.st_size+1);
  462.     if (content->f_base == NULL)
  463.         fatalerr("cannot allocate mem\n");
  464.     if ((st.st_size = read(fd, content->f_base, st.st_size)) < 0)
  465.         fatalerr("failed to read %s\n", file);
  466.     close(fd);
  467.     content->f_len = st.st_size+1;
  468.     content->f_p = content->f_base;
  469.     content->f_end = content->f_base + st.st_size;
  470.     *content->f_end = '\0';
  471.     content->f_line = 0;
  472.     return(content);
  473. }
  474.  
  475. freefile(fp)
  476.     struct filepointer    *fp;
  477. {
  478.     free(fp->f_base);
  479.     free(fp);
  480. }
  481.  
  482. char *copy(str)
  483.     register char    *str;
  484. {
  485.     register char    *p = (char *)malloc(strlen(str) + 1);
  486.  
  487.     strcpy(p, str);
  488.     return(p);
  489. }
  490.  
  491. match(str, list)
  492.     register char    *str, **list;
  493. {
  494.     register int    i;
  495.  
  496.     for (i=0; *list; i++, list++)
  497.         if (strcmp(str, *list) == 0)
  498.             return(i);
  499.     return(-1);
  500. }
  501.  
  502. /*
  503.  * Get the next line.  We only return lines beginning with '#' since that
  504.  * is all this program is ever interested in.
  505.  */
  506. char *getline(filep)
  507.     register struct filepointer    *filep;
  508. {
  509.     register char    *p,    /* walking pointer */
  510.             *eof,    /* end of file pointer */
  511.             *bol;    /* beginning of line pointer */
  512.     register    lineno;    /* line number */
  513.  
  514.     p = filep->f_p;
  515.     eof = filep->f_end;
  516.     if (p >= eof)
  517.         return((char *)NULL);
  518.     lineno = filep->f_line;
  519.  
  520.     for(bol = p--; ++p < eof; ) {
  521.         if (*p == '/' && *(p+1) == '*') { /* consume comments */
  522.             *p++ = ' ', *p++ = ' ';
  523.             while (*p) {
  524.                 if (*p == '*' && *(p+1) == '/') {
  525.                     *p++ = ' ', *p = ' ';
  526.                     break;
  527.                 }
  528.                 else if (*p == '\n')
  529.                     lineno++;
  530.                 *p++ = ' ';
  531.             }
  532.             continue;
  533.         }
  534. #ifdef WIN32
  535.         else if (*p == '/' && *(p+1) == '/') { /* consume comments */
  536.             *p++ = ' ', *p++ = ' ';
  537.             while (*p && *p != '\n')
  538.                 *p++ = ' ';
  539.             lineno++;
  540.             continue;
  541.         }
  542. #endif
  543.         else if (*p == '\\') {
  544.             if (*(p+1) == '\n') {
  545.                 *p = ' ';
  546.                 *(p+1) = ' ';
  547.                 lineno++;
  548.             }
  549.         }
  550.         else if (*p == '\n') {
  551.             lineno++;
  552.             if (*bol == '#') {
  553.                 register char *cp;
  554.  
  555.                 *p++ = '\0';
  556.                 /* punt lines with just # (yacc generated) */
  557.                 for (cp = bol+1; 
  558.                      *cp && (*cp == ' ' || *cp == '\t'); cp++);
  559.                 if (*cp) goto done;
  560.             }
  561.             bol = p+1;
  562.         }
  563.     }
  564.     if (*bol != '#')
  565.         bol = NULL;
  566. done:
  567.     filep->f_p = p;
  568.     filep->f_line = lineno;
  569.     return(bol);
  570. }
  571.  
  572. /*
  573.  * Strip the file name down to what we want to see in the Makefile.
  574.  * It will have objprefix and objsuffix around it.
  575.  */
  576. char *base_name(file)
  577.     register char    *file;
  578. {
  579.     register char    *p;
  580.  
  581.     file = copy(file);
  582.     for(p=file+strlen(file); p>file && *p != '.'; p--) ;
  583.  
  584.     if (*p == '.')
  585.         *p = '\0';
  586.     return(file);
  587. }
  588.  
  589. #if defined(USG) && !defined(CRAY) && !defined(SVR4) && !defined(__EMX__)
  590. int rename (from, to)
  591.     char *from, *to;
  592. {
  593.     (void) unlink (to);
  594.     if (link (from, to) == 0) {
  595.     unlink (from);
  596.     return 0;
  597.     } else {
  598.     return -1;
  599.     }
  600. }
  601. #endif /* USGISH */
  602.  
  603. redirect(line, makefile)
  604.     char    *line,
  605.         *makefile;
  606. {
  607.     struct stat    st;
  608.     FILE    *fdin, *fdout;
  609.     char    backup[ BUFSIZ ],
  610.         buf[ BUFSIZ ];
  611.     boolean    found = FALSE;
  612.     int    len;
  613.  
  614.     /*
  615.      * if makefile is "-" then let it pour onto stdout.
  616.      */
  617.     if (makefile && *makefile == '-' && *(makefile+1) == '\0')
  618.         return;
  619.  
  620.     /*
  621.      * use a default makefile is not specified.
  622.      */
  623.     if (!makefile) {
  624.         if (stat("Makefile", &st) == 0)
  625.             makefile = "Makefile";
  626.         else if (stat("makefile", &st) == 0)
  627.             makefile = "makefile";
  628.         else
  629.             fatalerr("[mM]akefile is not present\n");
  630.     }
  631.     else
  632.         stat(makefile, &st);
  633.     if ((fdin = fopen(makefile, "r")) == NULL)
  634.         fatalerr("cannot open \"%s\"\n", makefile);
  635.     sprintf(backup, "%s.bak", makefile);
  636.     unlink(backup);
  637. #if defined(WIN32) || defined(__EMX__) || defined(__OS2__)
  638.     fclose(fdin);
  639. #endif
  640.     if (rename(makefile, backup) < 0)
  641.         fatalerr("cannot rename %s to %s\n", makefile, backup);
  642. #if defined(WIN32) || defined(__EMX__) || defined(__OS2__)
  643.     if ((fdin = fopen(backup, "r")) == NULL)
  644.         fatalerr("cannot open \"%s\"\n", backup);
  645. #endif
  646.     if ((fdout = freopen(makefile, "w", stdout)) == NULL)
  647.         fatalerr("cannot open \"%s\"\n", backup);
  648.     len = strlen(line);
  649.     while (!found && fgets(buf, BUFSIZ, fdin)) {
  650.         if (*buf == '#' && strncmp(line, buf, len) == 0)
  651.             found = TRUE;
  652.         fputs(buf, fdout);
  653.     }
  654.     if (!found) {
  655.         if (verbose)
  656.         warning("Adding new delimiting line \"%s\" and dependencies...\n",
  657.             line);
  658.         puts(line); /* same as fputs(fdout); but with newline */
  659.     } else if (append) {
  660.         while (fgets(buf, BUFSIZ, fdin)) {
  661.         fputs(buf, fdout);
  662.         }
  663.     }
  664.     fflush(fdout);
  665. #if defined(USGISH) || defined(_SEQUENT_) || defined(USE_CHMOD)
  666.     chmod(makefile, st.st_mode);
  667. #else
  668.         fchmod(fileno(fdout), st.st_mode);
  669. #endif /* USGISH */
  670. }
  671.  
  672. #if NeedVarargsPrototypes
  673. fatalerr(char *msg, ...)
  674. #else
  675. /*VARARGS*/
  676. fatalerr(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
  677.     char *msg;
  678. #endif
  679. {
  680. #if NeedVarargsPrototypes
  681.     va_list args;
  682. #endif
  683.     fprintf(stderr, "%s: error:  ", ProgramName);
  684. #if NeedVarargsPrototypes
  685.     va_start(args, msg);
  686.     vfprintf(stderr, msg, args);
  687.     va_end(args);
  688. #else
  689.     fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
  690. #endif
  691.     exit (1);
  692. }
  693.  
  694. #if NeedVarargsPrototypes
  695. warning(char *msg, ...)
  696. #else
  697. /*VARARGS0*/
  698. warning(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
  699.     char *msg;
  700. #endif
  701. {
  702. #if NeedVarargsPrototypes
  703.     va_list args;
  704. #endif
  705.     fprintf(stderr, "%s: warning:  ", ProgramName);
  706. #if NeedVarargsPrototypes
  707.     va_start(args, msg);
  708.     vfprintf(stderr, msg, args);
  709.     va_end(args);
  710. #else
  711.     fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
  712. #endif
  713. }
  714.  
  715. #if NeedVarargsPrototypes
  716. warning1(char *msg, ...)
  717. #else
  718. /*VARARGS0*/
  719. warning1(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
  720.     char *msg;
  721. #endif
  722. {
  723. #if NeedVarargsPrototypes
  724.     va_list args;
  725.     va_start(args, msg);
  726.     vfprintf(stderr, msg, args);
  727.     va_end(args);
  728. #else
  729.     fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
  730. #endif
  731. }
  732.