first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / core / tools / dependency_tool / makedep.cpp
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 #ifdef __WIN32__
31   #pragma warning(disable : 4996)
32 #endif
33
34 #include "def.h"
35
36 #ifdef _MSC_VER
37 #include <io.h>
38 #else
39 #include <unistd.h>
40 #endif
41 #include <stdio.h>
42 #include <string.h>
43
44 #ifdef hpux
45 #define sigvec sigvector
46 #endif /* hpux */
47
48 #ifdef X_POSIX_C_SOURCE
49 #define _POSIX_C_SOURCE X_POSIX_C_SOURCE
50 #include <signal.h>
51 #undef _POSIX_C_SOURCE
52 #else
53 #if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
54 #include <signal.h>
55 #else
56 #define _POSIX_SOURCE
57 #include <signal.h>
58 #undef _POSIX_SOURCE
59 #endif
60 #endif
61
62 #if NeedVarargsPrototypes
63 #include <stdarg.h>
64 #endif
65
66 #ifdef MINIX
67 #define USE_CHMOD  1
68 #endif
69
70 #ifdef DEBUG
71 int  _debugmask;
72 #endif
73
74 char *ProgramName;
75
76 const char  *directives[] = {
77   "if",
78   "ifdef",
79   "ifndef",
80   "else",
81   "endif",
82   "define",
83   "undef",
84   "include",
85   "line",
86   "pragma",
87   "error",
88   "ident",
89   "sccs",
90   "elif",
91   "eject",
92   "import",
93   NULL
94 };
95
96 #define MAKEDEPEND
97 #include "imakemdep.h"  /* from config sources */
98 #undef MAKEDEPEND
99
100 struct  inclist inc_list[ MAXFILES ], *inclistp = inc_list, maininclist;
101
102 char  *filelist[ MAXFILES ];
103 char  *includedirs[ MAXDIRS + 1 ];
104 char  *excludedirs[ MAXDIRS + 1 ];
105 char  *notdotdot[ MAXDIRS ];
106 char  *objprefix = (char *)"";
107 char  *objsuffix = (char *)".obj"; /* OBJSUFFIX;  */
108 char  *startat = (char *)"# DO NOT DELETE";
109 int  width = 78;
110 bool  append = false;
111 bool  printed = false;
112 bool  verbose = false;
113 bool  show_where_not = false;
114 bool warn_multiple = false;  /* Warn on multiple includes of same file */
115
116 static
117 #ifdef SIGNALRETURNSINT
118 int
119 #else
120 void
121 #endif
122 c_catch(int sig)
123 {
124   fflush (stdout);
125   fatalerr ((char *)"got signal %d\n", sig);
126 }
127
128 #if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32) || defined(__EMX__) || defined(__OS2__)
129 #define USGISH
130 #endif
131
132 #ifndef USGISH
133 #ifndef _POSIX_SOURCE
134 #define sigaction sigvec
135 #define sa_handler sv_handler
136 #define sa_mask sv_mask
137 #define sa_flags sv_flags
138 #endif
139 struct sigaction sig_act;
140 #endif /* USGISH */
141
142 /* fatty boombalatty, and wrong idea here.
143
144 // adds any subdirectories under dirname into the list of
145 // include directories, so we can get a whole hierarchies set of
146 // include files.
147 void add_subdirs(char *dirname, char ** &incp)
148 {
149   directory dir(dirname);
150   string_array subdirs = dir.directories();
151   for (int i = 0; i < subdirs.length(); i++) {
152     istring curr = istring(dirname) + "/" + subdirs[i];
153     // add the current subdirectory.
154     if (incp >= includedirs + MAXDIRS)
155       fatalerr("Too many -I flags.\n");
156     *incp++ = strdup(curr.s());
157 printf((istring("added ") + curr + "\n").s());
158     add_subdirs(curr.s(), incp);
159   }
160 }
161 */
162
163 int main(int argc, char  **argv)
164 {
165   register char  **fp = filelist;
166   register char  **incp = includedirs;
167   register char  **excp = excludedirs;
168   register char  *p;
169   register struct inclist  *ip;
170   char  *makefile = NULL;
171   struct filepointer  *filecontent;
172   struct symtab *psymp = predefs;
173   char *endmarker = NULL;
174   char *defincdir = NULL;
175
176   ProgramName = argv[0];
177
178   while (psymp->s_name)
179   {
180       define2(psymp->s_name, psymp->s_value, &maininclist);
181       psymp++;
182   }
183   if (argc == 2 && argv[1][0] == '@') {
184       struct stat ast;
185       int afd;
186       char *args;
187       char **nargv;
188       int nargc;
189       char quotechar = '\0';
190
191       nargc = 1;
192       if ((afd = open(argv[1]+1, O_RDONLY)) < 0)
193     fatalerr("cannot open \"%s\"\n", argv[1]+1);
194       fstat(afd, &ast);
195       args = (char *)malloc(ast.st_size + 2);
196       if ((ast.st_size = read(afd, args, ast.st_size)) < 0)
197     fatalerr("failed to read %s\n", argv[1]+1);
198       args[ast.st_size] = '\n';
199       args[ast.st_size + 1] = '\0';
200       close(afd);
201       for (p = args; *p; p++) {
202     if (quotechar) {
203         if (quotechar == '\\' ||
204       (*p == quotechar && p[-1] != '\\'))
205       quotechar = '\0';
206         continue;
207     }
208     switch (*p) {
209     case '\\':
210     case '"':
211     case '\'':
212         quotechar = *p;
213         break;
214     case ' ':
215     case '\n':
216         *p = '\0';
217         if (p > args && p[-1])
218       nargc++;
219         break;
220     }
221       }
222       if (p[-1])
223     nargc++;
224       nargv = (char **)malloc(nargc * sizeof(char *));
225       nargv[0] = argv[0];
226       argc = 1;
227       for (p = args; argc < nargc; p += strlen(p) + 1)
228     if (*p) nargv[argc++] = p;
229       argv = nargv;
230   }
231   for(argc--, argv++; argc; argc--, argv++) {
232         /* if looking for endmarker then check before parsing */
233     if (endmarker && strcmp (endmarker, *argv) == 0) {
234         endmarker = NULL;
235         continue;
236     }
237     if (**argv != '-') {
238       /* treat +thing as an option for C++ */
239       if (endmarker && **argv == '+')
240         continue;
241       *fp++ = argv[0];
242       continue;
243     }
244     switch(argv[0][1]) {
245     case '-':
246       endmarker = &argv[0][2];
247       if (endmarker[0] == '\0') endmarker = (char *)"--";
248       break;
249     case 'D':
250       if (argv[0][2] == '\0') {
251         argv++;
252         argc--;
253       }
254       for (p=argv[0] + 2; *p ; p++)
255         if (*p == '=') {
256           *p = ' ';
257           break;
258         }
259       define(argv[0] + 2, &maininclist);
260       break;
261     case 'i':
262       {
263         char* delim;
264         char* envinclude;
265         char* prevdir;
266         if (endmarker) break;
267         if (argv[0][2] == '\0') {
268           argv++;
269           argc--;
270           envinclude = getenv(argv[0]);
271         } else  envinclude = getenv(argv[0]+2);
272         if (!envinclude)  break;
273         prevdir = envinclude;
274         delim = (char*)strchr(envinclude, ';');
275         while(delim)
276         {
277           if (incp >= includedirs + MAXDIRS)  fatalerr("Too many Include directories.\n");
278           *delim = '\0';
279           delim++;
280           *incp++ = prevdir;
281           prevdir = delim;
282           delim = (char*)strchr(delim, ';');
283         }
284       }
285       break;
286     case 'X':
287 //fprintf(stderr, "adding Xclude %s\n", argv[0]+2);
288       // add a directory to the exclusions list.
289       if (excp >= excludedirs + MAXDIRS)
290           fatalerr("Too many -X flags.\n");
291       *excp++ = argv[0]+2;
292       if (**(excp-1) == '\0') {
293         // fix the prior entry, but don't incremement yet; we'll do that
294         // on the include list instead.
295         *(excp-1) = *(argv + 1);
296       }
297       if (incp >= includedirs + MAXDIRS)
298           fatalerr("Too many -I flags via -X.\n");
299       *incp++ = argv[0]+2;
300       if (**(incp-1) == '\0') {
301         *(incp-1) = *(++argv);
302         argc--;
303       }
304       break;
305     case 'I':
306       if (incp >= includedirs + MAXDIRS)
307           fatalerr("Too many -I flags.\n");
308       *incp++ = argv[0]+2;
309       if (**(incp-1) == '\0') {
310         *(incp-1) = *(++argv);
311         argc--;
312       }
313 ///      add_subdirs(*(incp-1), incp);
314       break;
315     case 'Y':
316       defincdir = argv[0]+2;
317       break;
318     /* do not use if endmarker processing */
319     case 'a':
320       if (endmarker) break;
321       append = true;
322       break;
323     case 'w':
324       if (endmarker) break;
325       if (argv[0][2] == '\0') {
326         argv++;
327         argc--;
328         width = atoi(argv[0]);
329       } else
330         width = atoi(argv[0]+2);
331       break;
332     case 'o':
333       if (endmarker) break;
334       if (argv[0][2] == '\0') {
335         argv++;
336         argc--;
337         objsuffix = argv[0];
338       } else
339         objsuffix = argv[0]+2;
340       break;
341     case 'p':
342       if (endmarker) break;
343       if (argv[0][2] == '\0') {
344         argv++;
345         argc--;
346         objprefix = argv[0];
347       } else
348         objprefix = argv[0]+2;
349       break;
350     case 'v':
351       if (endmarker) break;
352       verbose = true;
353 #ifdef DEBUG
354       if (argv[0][2])
355         _debugmask = atoi(argv[0]+2);
356 #endif
357       break;
358     case 's':
359       if (endmarker) break;
360       startat = argv[0]+2;
361       if (*startat == '\0') {
362         startat = *(++argv);
363         argc--;
364       }
365       if (*startat != '#')
366         fatalerr("-s flag's value should start %s\n",
367           "with '#'.");
368       break;
369     case 'f':
370       if (endmarker) break;
371       makefile = argv[0]+2;
372       if (*makefile == '\0') {
373         makefile = *(++argv);
374         argc--;
375       }
376       break;
377     case 'm':
378       warn_multiple = true;
379       break;
380       
381     /* Ignore -O, -g so we can just pass ${CFLAGS} to
382        makedepend
383      */
384     case 'O':
385     case 'g':
386       break;
387     default:
388       if (endmarker) break;
389   /*    fatalerr("unknown opt = %s\n", argv[0]); */
390       warning("ignoring option %s\n", argv[0]);
391     }
392   }
393
394   if (!defincdir) {
395 #ifdef PREINCDIR
396       if (incp >= includedirs + MAXDIRS)
397     fatalerr("Too many -I flags.\n");
398       *incp++ = PREINCDIR;
399 #endif
400 #ifdef INCLUDEDIR
401       if (incp >= includedirs + MAXDIRS)
402     fatalerr("Too many -I flags.\n");
403       *incp++ = INCLUDEDIR;
404 #endif
405 #ifdef POSTINCDIR
406       if (incp >= includedirs + MAXDIRS)
407     fatalerr("Too many -I flags.\n");
408       *incp++ = POSTINCDIR;
409 #endif
410   } else if (*defincdir) {
411       if (incp >= includedirs + MAXDIRS)
412     fatalerr("Too many -I flags.\n");
413       *incp++ = defincdir;
414   }
415
416   redirect(startat, makefile);
417
418   /*
419    * c_catch signals.
420    */
421 #ifdef USGISH
422 /*  should really reset SIGINT to SIG_IGN if it was.  */
423 #ifdef SIGHUP
424   signal (SIGHUP, c_catch);
425 #endif
426   signal (SIGINT, c_catch);
427 #ifdef SIGQUIT
428   signal (SIGQUIT, c_catch);
429 #endif
430   signal (SIGILL, c_catch);
431 #ifdef SIGBUS
432   signal (SIGBUS, c_catch);
433 #endif
434   signal (SIGSEGV, c_catch);
435 #ifdef SIGSYS
436   signal (SIGSYS, c_catch);
437 #endif
438 #else
439   sig_act.sa_handler = c_catch;
440 #ifdef _POSIX_SOURCE
441   sigemptyset(&sig_act.sa_mask);
442   sigaddset(&sig_act.sa_mask, SIGINT);
443   sigaddset(&sig_act.sa_mask, SIGQUIT);
444 #ifdef SIGBUS
445   sigaddset(&sig_act.sa_mask, SIGBUS);
446 #endif
447   sigaddset(&sig_act.sa_mask, SIGILL);
448   sigaddset(&sig_act.sa_mask, SIGSEGV);
449   sigaddset(&sig_act.sa_mask, SIGHUP);
450   sigaddset(&sig_act.sa_mask, SIGPIPE);
451 #ifdef SIGSYS
452   sigaddset(&sig_act.sa_mask, SIGSYS);
453 #endif
454 #else
455   sig_act.sa_mask = ((1<<(SIGINT -1))
456          |(1<<(SIGQUIT-1))
457 #ifdef SIGBUS
458          |(1<<(SIGBUS-1))
459 #endif
460          |(1<<(SIGILL-1))
461          |(1<<(SIGSEGV-1))
462          |(1<<(SIGHUP-1))
463          |(1<<(SIGPIPE-1))
464 #ifdef SIGSYS
465          |(1<<(SIGSYS-1))
466 #endif
467          );
468 #endif /* _POSIX_SOURCE */
469   sig_act.sa_flags = 0;
470   sigaction(SIGHUP, &sig_act, (struct sigaction *)0);
471   sigaction(SIGINT, &sig_act, (struct sigaction *)0);
472   sigaction(SIGQUIT, &sig_act, (struct sigaction *)0);
473   sigaction(SIGILL, &sig_act, (struct sigaction *)0);
474 #ifdef SIGBUS
475   sigaction(SIGBUS, &sig_act, (struct sigaction *)0);
476 #endif
477   sigaction(SIGSEGV, &sig_act, (struct sigaction *)0);
478 #ifdef SIGSYS
479   sigaction(SIGSYS, &sig_act, (struct sigaction *)0);
480 #endif
481 #endif /* USGISH */
482
483   /*
484    * now peruse through the list of files.
485    */
486   for(fp=filelist; *fp; fp++) {
487     filecontent = getfile(*fp);
488     ip = newinclude(*fp, (char *)NULL);
489
490     find_includes(filecontent, ip, ip, 0, false);
491     freefile(filecontent);
492     recursive_pr_include(ip, ip->i_file, base_name(*fp));
493     inc_clean();
494   }
495   if (printed)
496     printf("\n");
497
498   return 0;
499 }
500
501 struct filepointer *getfile(char  *file)
502 {
503   register int  fd;
504   struct filepointer  *content;
505   struct stat  st;
506
507   content = (struct filepointer *)malloc(sizeof(struct filepointer));
508   content->f_name = strdup(file);
509   if ((fd = open(file, O_RDONLY)) < 0) {
510     warning("cannot open \"%s\"\n", file);
511     content->f_p = content->f_base = content->f_end = (char *)malloc(1);
512     *content->f_p = '\0';
513     return(content);
514   }
515   fstat(fd, &st);
516   content->f_base = (char *)malloc(st.st_size+1);
517   if (content->f_base == NULL)
518     fatalerr("cannot allocate mem\n");
519   if ((st.st_size = read(fd, content->f_base, st.st_size)) < 0)
520     fatalerr("failed to read %s\n", file);
521   close(fd);
522   content->f_len = st.st_size+1;
523   content->f_p = content->f_base;
524   content->f_end = content->f_base + st.st_size;
525   *content->f_end = '\0';
526   content->f_line = 0;
527   return(content);
528 }
529
530 void freefile(struct filepointer  *fp)
531 {
532   free(fp->f_name);
533   free(fp->f_base);
534   free(fp);
535 }
536
537 char *copy(register char  *str)
538 {
539   register char  *p = (char *)malloc(strlen(str) + 1);
540
541   strcpy(p, str);
542   return(p);
543 }
544
545 int match(register const char *str, register const char **list)
546 {
547   register int  i;
548
549   for (i=0; *list; i++, list++)
550     if (strcmp(str, *list) == 0)
551       return i;
552   return -1;
553 }
554
555 /*
556  * Get the next line.  We only return lines beginning with '#' since that
557  * is all this program is ever interested in.
558  */
559 char *getline(register struct filepointer  *filep)
560 {
561   register char  *p,  /* walking pointer */
562       *eof,  /* end of file pointer */
563       *bol;  /* beginning of line pointer */
564   register  int lineno;  /* line number */
565
566   eof = filep->f_end;
567 ////  if (p >= eof) return NULL;
568   lineno = filep->f_line;
569   bol = filep->f_p;
570
571   // p is always pointing at the "beginning of a line" when we start this loop.
572   // this means that we must start considering the stuff on that line as
573   // being a useful thing to look at.
574   for (p = filep->f_p; p < eof; p++) {
575 if (bol > p) fatalerr("somehow bol got ahead of p.");
576     if (*p == '/' && *(p+1) == '*') {
577       /* consume C-style comments */
578       *p++ = ' '; *p++ = ' ';  // skip the two we've already seen.
579       while (p < eof) {
580         if (*p == '*' && *(p+1) == '/') {
581           *p++ = ' '; *p = ' ';
582             // skip one of these last two, let the loop skip the next.
583           break;
584         } else if (*p == '\n') lineno++;
585         p++;  // skip the current character.
586       }
587       continue;
588     } else if (*p == '/' && *(p+1) == '/') {
589       /* consume C++-style comments */
590       *p++ = ' '; *p++ = ' ';  // skip the comment characters.
591       while (p < eof && (*p != '\n') ) *p++ = ' ';
592         // we scan until we get to the end of line.
593 ///no count, since we'll see it again.      lineno++;
594       p--;  // skip back to just before \n.
595       continue;  // let the loop skip past the eol that we saw.
596     } else if (*p == '\\') {
597       // handle an escape character.
598       if (*(p+1) == '\n') {
599         // we modify the stream so we consider the line correctly.
600         *p = ' ';
601         *(p+1) = ' ';
602         lineno++;
603       }
604     } else if (*p == '\n') {
605       // we've finally reached the end of the line.
606       lineno++;
607       *p = '\0';  // set the end of line to be a end of string now.
608       if (bol < p) {
609         // it's not at the same position as the end of line, so it's worth
610         // considering.
611         while ( (bol < p) && ((*bol == ' ') || (*bol == '\t')) ) bol++;
612 ////fprintf(stderr, "%s: %s\n", filep->f_name, bol);
613 ////fflush(stderr);
614         if (*bol == '#') {
615           register char *cp;
616           /* punt lines with just # (yacc generated) */
617           for (cp = bol+1; *cp && (*cp == ' ' || *cp == '\t'); cp++) {}
618           if (*cp) { p++; goto done; }
619         }
620       }
621       // this is a failure now.  we reset the beginning of line.
622       bol = p+1;
623     }
624   }
625   if (*bol != '#') bol = NULL;
626 done:
627   filep->f_p = p;
628   filep->f_line = lineno;
629   return bol;
630 }
631
632 /*
633  * Strip the file name down to what we want to see in the Makefile.
634  * It will have objprefix and objsuffix around it.
635  */
636 char *base_name(register char  *file)
637 {
638   register char  *p;
639
640   file = copy(file);
641   for(p=file+strlen(file); p>file && *p != '.'; p--) ;
642
643   if (*p == '.')
644     *p = '\0';
645   return(file);
646 }
647
648 #if defined(USG) && !defined(CRAY) && !defined(SVR4) && !defined(__EMX__)
649 int rename(char *from, char *to)
650 {
651     (void) unlink (to);
652     if (link (from, to) == 0) {
653   unlink (from);
654   return 0;
655     } else {
656   return -1;
657     }
658 }
659 #endif /* USGISH */
660
661 void redirect(char  *line, char  *makefile)
662 {
663   struct stat  st;
664   FILE  *fdin, *fdout;
665   char  backup[ BUFSIZ ],
666     buf[ BUFSIZ ];
667   bool  found = false;
668   int  len;
669
670   /*
671    * if makefile is "-" then let it pour onto stdout.
672    */
673   if (makefile && *makefile == '-' && *(makefile+1) == '\0')
674     return;
675
676   /*
677    * use a default makefile is not specified.
678    */
679   if (!makefile) {
680     if (stat("Makefile", &st) == 0)
681       makefile = (char *)"Makefile";
682     else if (stat("makefile", &st) == 0)
683       makefile = (char *)"makefile";
684     else
685       fatalerr("[mM]akefile is not present\n");
686   }
687   else
688       stat(makefile, &st);
689   if ((fdin = fopen(makefile, "r")) == NULL)
690     fatalerr("cannot open \"%s\"\n", makefile);
691   sprintf(backup, "%s.bak", makefile);
692   unlink(backup);
693 #if defined(WIN32) || defined(__EMX__) || defined(__OS2__)
694   fclose(fdin);
695 #endif
696   if (rename(makefile, backup) < 0)
697     fatalerr("cannot rename %s to %s\n", makefile, backup);
698 #if defined(WIN32) || defined(__EMX__) || defined(__OS2__)
699   if ((fdin = fopen(backup, "r")) == NULL)
700     fatalerr("cannot open \"%s\"\n", backup);
701 #endif
702   if ((fdout = freopen(makefile, "w", stdout)) == NULL)
703     fatalerr("cannot open \"%s\"\n", backup);
704   len = int(strlen(line));
705   while (!found && fgets(buf, BUFSIZ, fdin)) {
706     if (*buf == '#' && strncmp(line, buf, len) == 0)
707       found = true;
708     fputs(buf, fdout);
709   }
710   if (!found) {
711     if (verbose)
712     warning("Adding new delimiting line \"%s\" and dependencies...\n",
713       line);
714     puts(line); /* same as fputs(fdout); but with newline */
715   } else if (append) {
716       while (fgets(buf, BUFSIZ, fdin)) {
717     fputs(buf, fdout);
718       }
719   }
720   fflush(fdout);
721 #if defined(USGISH) || defined(_SEQUENT_) || defined(USE_CHMOD)
722   chmod(makefile, st.st_mode);
723 #else
724         fchmod(fileno(fdout), st.st_mode);
725 #endif /* USGISH */
726 }
727
728 #if NeedVarargsPrototypes
729 void fatalerr(const char *msg, ...)
730 #else
731 /*VARARGS*/
732 void fatalerr(char *msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
733 #endif
734 {
735 #if NeedVarargsPrototypes
736   va_list args;
737 #endif
738   fprintf(stderr, "%s: error:  ", ProgramName);
739 #if NeedVarargsPrototypes
740   va_start(args, msg);
741   vfprintf(stderr, msg, args);
742   va_end(args);
743 #else
744   fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
745 #endif
746   exit (1);
747 }
748
749 #if NeedVarargsPrototypes
750 void warning(const char *msg, ...)
751 #else
752 /*VARARGS0*/
753 void warning(const char *msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
754 #endif
755 {
756 #if NeedVarargsPrototypes
757   va_list args;
758 #endif
759   fprintf(stderr, "%s: warning:  ", ProgramName);
760 #if NeedVarargsPrototypes
761   va_start(args, msg);
762   vfprintf(stderr, msg, args);
763   va_end(args);
764 #else
765   fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
766 #endif
767 }
768
769 #if NeedVarargsPrototypes
770 void warning1(const char *msg, ...)
771 #else
772 /*VARARGS0*/
773 void warning1(const char *msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
774 #endif
775 {
776 #if NeedVarargsPrototypes
777   va_list args;
778   va_start(args, msg);
779   vfprintf(stderr, msg, args);
780   va_end(args);
781 #else
782   fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
783 #endif
784 }
785