main.c 16 KB

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