Annotation of mandoc/main.c, Revision 1.36
1.36 ! kristaps 1: /* $Id: main.c,v 1.35 2009/07/06 09:21:24 kristaps Exp $ */
1.1 kristaps 2: /*
1.26 kristaps 3: * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
1.1 kristaps 4: *
5: * Permission to use, copy, modify, and distribute this software for any
1.25 kristaps 6: * purpose with or without fee is hereby granted, provided that the above
7: * copyright notice and this permission notice appear in all copies.
1.1 kristaps 8: *
1.25 kristaps 9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1 kristaps 16: */
17: #include <sys/stat.h>
18:
19: #include <assert.h>
20: #include <err.h>
21: #include <fcntl.h>
22: #include <stdio.h>
23: #include <stdlib.h>
24: #include <string.h>
25: #include <unistd.h>
26:
27: #include "mdoc.h"
1.10 kristaps 28: #include "man.h"
1.1 kristaps 29:
1.16 kristaps 30: /* Account for FreeBSD and Linux in our declarations. */
31:
1.3 kristaps 32: #ifdef __linux__
33: extern int getsubopt(char **, char * const *, char **);
34: # ifndef __dead
35: # define __dead __attribute__((__noreturn__))
36: # endif
1.13 kristaps 37: #elif defined(__dead2)
1.10 kristaps 38: # ifndef __dead
39: # define __dead __dead2
40: # endif
1.3 kristaps 41: #endif
42:
1.22 kristaps 43: typedef int (*out_mdoc)(void *, const struct mdoc *);
44: typedef int (*out_man)(void *, const struct man *);
45: typedef void (*out_free)(void *);
46:
1.5 kristaps 47: struct buf {
48: char *buf;
49: size_t sz;
50: };
51:
1.19 kristaps 52: enum intt {
53: INTT_AUTO,
54: INTT_MDOC,
55: INTT_MAN
56: };
57:
58: enum outt {
59: OUTT_ASCII = 0,
60: OUTT_TREE,
61: OUTT_LINT
62: };
63:
1.5 kristaps 64: struct curparse {
1.22 kristaps 65: const char *file; /* Current parse. */
66: int fd; /* Current parse. */
1.5 kristaps 67: int wflags;
1.36 ! kristaps 68: #define WARN_WALL (1 << 0) /* All-warnings mask. */
1.1 kristaps 69: #define WARN_WERR (1 << 2) /* Warnings->errors. */
1.23 kristaps 70: int fflags;
71: #define IGN_SCOPE (1 << 0) /* Ignore scope errors. */
1.24 kristaps 72: #define NO_IGN_ESCAPE (1 << 1) /* Don't ignore bad escapes. */
73: #define NO_IGN_MACRO (1 << 2) /* Don't ignore bad macros. */
74: #define NO_IGN_CHARS (1 << 3) /* Don't ignore bad chars. */
1.29 kristaps 75: enum intt inttype; /* Input parsers... */
1.19 kristaps 76: struct man *man;
1.22 kristaps 77: struct man *lastman;
1.19 kristaps 78: struct mdoc *mdoc;
1.22 kristaps 79: struct mdoc *lastmdoc;
1.29 kristaps 80: enum outt outtype; /* Output devices... */
1.22 kristaps 81: out_mdoc outmdoc;
82: out_man outman;
83: out_free outfree;
84: void *outdata;
1.5 kristaps 85: };
1.1 kristaps 86:
87: extern void *ascii_alloc(void);
1.22 kristaps 88: extern int tree_mdoc(void *, const struct mdoc *);
89: extern int tree_man(void *, const struct man *);
90: extern int terminal_mdoc(void *, const struct mdoc *);
91: extern int terminal_man(void *, const struct man *);
1.1 kristaps 92: extern void terminal_free(void *);
93:
94: static int foptions(int *, char *);
95: static int toptions(enum outt *, char *);
1.10 kristaps 96: static int moptions(enum intt *, char *);
1.1 kristaps 97: static int woptions(int *, char *);
98: static int merr(void *, int, int, const char *);
1.14 kristaps 99: static int manwarn(void *, int, int, const char *);
1.35 kristaps 100: static int mdocwarn(void *, int, int, const char *);
1.19 kristaps 101: static int ffile(struct buf *, struct buf *,
102: const char *, struct curparse *);
1.5 kristaps 103: static int fdesc(struct buf *, struct buf *,
1.19 kristaps 104: struct curparse *);
1.22 kristaps 105: static int pset(const char *, int, struct curparse *,
1.19 kristaps 106: struct man **, struct mdoc **);
107: static struct man *man_init(struct curparse *);
108: static struct mdoc *mdoc_init(struct curparse *);
1.10 kristaps 109: __dead static void version(void);
110: __dead static void usage(void);
1.1 kristaps 111:
1.22 kristaps 112: extern char *__progname;
113:
1.1 kristaps 114:
115: int
116: main(int argc, char *argv[])
117: {
1.19 kristaps 118: int c, rc;
1.5 kristaps 119: struct buf ln, blk;
120: struct curparse curp;
1.1 kristaps 121:
1.5 kristaps 122: bzero(&curp, sizeof(struct curparse));
123:
1.19 kristaps 124: curp.inttype = INTT_AUTO;
1.22 kristaps 125: curp.outtype = OUTT_ASCII;
1.19 kristaps 126:
1.1 kristaps 127: /* LINTED */
1.10 kristaps 128: while (-1 != (c = getopt(argc, argv, "f:m:VW:T:")))
1.1 kristaps 129: switch (c) {
130: case ('f'):
1.19 kristaps 131: if ( ! foptions(&curp.fflags, optarg))
1.32 kristaps 132: return(EXIT_FAILURE);
1.1 kristaps 133: break;
1.10 kristaps 134: case ('m'):
1.19 kristaps 135: if ( ! moptions(&curp.inttype, optarg))
1.32 kristaps 136: return(EXIT_FAILURE);
1.10 kristaps 137: break;
1.1 kristaps 138: case ('T'):
1.22 kristaps 139: if ( ! toptions(&curp.outtype, optarg))
1.32 kristaps 140: return(EXIT_FAILURE);
1.1 kristaps 141: break;
142: case ('W'):
1.5 kristaps 143: if ( ! woptions(&curp.wflags, optarg))
1.32 kristaps 144: return(EXIT_FAILURE);
1.1 kristaps 145: break;
146: case ('V'):
147: version();
148: /* NOTREACHED */
149: default:
150: usage();
151: /* NOTREACHED */
152: }
153:
154: argc -= optind;
155: argv += optind;
156:
1.5 kristaps 157: bzero(&ln, sizeof(struct buf));
158: bzero(&blk, sizeof(struct buf));
1.1 kristaps 159:
1.22 kristaps 160: rc = 1;
1.1 kristaps 161:
1.30 kristaps 162: if (NULL == *argv) {
163: curp.file = "<stdin>";
164: curp.fd = STDIN_FILENO;
165: if ( ! fdesc(&blk, &ln, &curp))
1.22 kristaps 166: rc = 0;
1.30 kristaps 167: }
1.22 kristaps 168:
169: while (rc && *argv) {
170: if ( ! ffile(&blk, &ln, *argv, &curp))
171: rc = 0;
172: argv++;
173: if (*argv && rc) {
174: if (curp.lastman)
175: if ( ! man_reset(curp.lastman))
176: rc = 0;
177: if (curp.lastmdoc)
178: if ( ! mdoc_reset(curp.lastmdoc))
179: rc = 0;
180: curp.lastman = NULL;
181: curp.lastmdoc = NULL;
1.4 kristaps 182: }
1.1 kristaps 183: }
184:
1.5 kristaps 185: if (blk.buf)
186: free(blk.buf);
187: if (ln.buf)
188: free(ln.buf);
1.22 kristaps 189: if (curp.outfree)
190: (*curp.outfree)(curp.outdata);
1.19 kristaps 191: if (curp.mdoc)
192: mdoc_free(curp.mdoc);
193: if (curp.man)
194: man_free(curp.man);
1.1 kristaps 195:
196: return(rc ? EXIT_SUCCESS : EXIT_FAILURE);
197: }
198:
199:
200: __dead static void
201: version(void)
202: {
203:
204: (void)printf("%s %s\n", __progname, VERSION);
1.18 kristaps 205: exit(EXIT_SUCCESS);
1.1 kristaps 206: }
207:
208:
209: __dead static void
210: usage(void)
211: {
212:
1.12 kristaps 213: (void)fprintf(stderr, "usage: %s [-V] [-foption...] "
214: "[-mformat] [-Toutput] [-Werr...]\n",
215: __progname);
1.18 kristaps 216: exit(EXIT_FAILURE);
1.1 kristaps 217: }
218:
219:
1.19 kristaps 220: static struct man *
221: man_init(struct curparse *curp)
222: {
223: int pflags;
224: struct man *man;
225: struct man_cb mancb;
226:
227: mancb.man_err = merr;
228: mancb.man_warn = manwarn;
229:
1.30 kristaps 230: /* Defaults from mandoc.1. */
1.27 kristaps 231:
1.33 kristaps 232: pflags = MAN_IGN_MACRO | MAN_IGN_ESCAPE | MAN_IGN_CHARS;
1.27 kristaps 233:
1.20 kristaps 234: if (curp->fflags & NO_IGN_MACRO)
235: pflags &= ~MAN_IGN_MACRO;
1.31 kristaps 236: if (curp->fflags & NO_IGN_CHARS)
237: pflags &= ~MAN_IGN_CHARS;
1.33 kristaps 238: if (curp->fflags & NO_IGN_ESCAPE)
239: pflags &= ~MAN_IGN_ESCAPE;
1.19 kristaps 240:
241: if (NULL == (man = man_alloc(curp, pflags, &mancb)))
242: warnx("memory exhausted");
243:
244: return(man);
245: }
246:
247:
248: static struct mdoc *
249: mdoc_init(struct curparse *curp)
250: {
251: int pflags;
252: struct mdoc *mdoc;
253: struct mdoc_cb mdoccb;
254:
255: mdoccb.mdoc_err = merr;
256: mdoccb.mdoc_warn = mdocwarn;
257:
1.30 kristaps 258: /* Defaults from mandoc.1. */
1.27 kristaps 259:
1.24 kristaps 260: pflags = MDOC_IGN_MACRO | MDOC_IGN_ESCAPE | MDOC_IGN_CHARS;
1.19 kristaps 261:
262: if (curp->fflags & IGN_SCOPE)
263: pflags |= MDOC_IGN_SCOPE;
1.24 kristaps 264: if (curp->fflags & NO_IGN_ESCAPE)
265: pflags &= ~MDOC_IGN_ESCAPE;
266: if (curp->fflags & NO_IGN_MACRO)
267: pflags &= ~MDOC_IGN_MACRO;
268: if (curp->fflags & NO_IGN_CHARS)
269: pflags &= ~MDOC_IGN_CHARS;
1.19 kristaps 270:
271: if (NULL == (mdoc = mdoc_alloc(curp, pflags, &mdoccb)))
1.24 kristaps 272: warnx("memory exhausted");
1.19 kristaps 273:
274: return(mdoc);
275: }
276:
277:
278: static int
279: ffile(struct buf *blk, struct buf *ln,
280: const char *file, struct curparse *curp)
1.1 kristaps 281: {
1.19 kristaps 282: int c;
1.1 kristaps 283:
1.19 kristaps 284: curp->file = file;
285: if (-1 == (curp->fd = open(curp->file, O_RDONLY, 0))) {
286: warn("%s", curp->file);
1.1 kristaps 287: return(0);
288: }
289:
1.19 kristaps 290: c = fdesc(blk, ln, curp);
1.1 kristaps 291:
1.19 kristaps 292: if (-1 == close(curp->fd))
293: warn("%s", curp->file);
1.1 kristaps 294:
295: return(c);
296: }
297:
298:
299: static int
1.19 kristaps 300: fdesc(struct buf *blk, struct buf *ln, struct curparse *curp)
1.1 kristaps 301: {
302: size_t sz;
303: ssize_t ssz;
304: struct stat st;
1.29 kristaps 305: int j, i, pos, lnn, comment;
1.19 kristaps 306: struct man *man;
307: struct mdoc *mdoc;
1.10 kristaps 308:
1.19 kristaps 309: sz = BUFSIZ;
310: man = NULL;
311: mdoc = NULL;
1.1 kristaps 312:
313: /*
1.19 kristaps 314: * Two buffers: ln and buf. buf is the input buffer optimised
315: * here for each file's block size. ln is a line buffer. Both
1.1 kristaps 316: * growable, hence passed in by ptr-ptr.
317: */
318:
1.19 kristaps 319: if (-1 == fstat(curp->fd, &st))
1.32 kristaps 320: warn("%s", curp->file);
1.6 kristaps 321: else if ((size_t)st.st_blksize > sz)
322: sz = st.st_blksize;
1.1 kristaps 323:
1.5 kristaps 324: if (sz > blk->sz) {
325: blk->buf = realloc(blk->buf, sz);
1.19 kristaps 326: if (NULL == blk->buf) {
327: warn("realloc");
328: return(0);
329: }
1.5 kristaps 330: blk->sz = sz;
1.1 kristaps 331: }
332:
1.19 kristaps 333: /* Fill buf with file blocksize. */
1.1 kristaps 334:
1.29 kristaps 335: for (lnn = pos = comment = 0; ; ) {
1.19 kristaps 336: if (-1 == (ssz = read(curp->fd, blk->buf, sz))) {
337: warn("%s", curp->file);
1.1 kristaps 338: return(0);
339: } else if (0 == ssz)
340: break;
341:
1.19 kristaps 342: /* Parse the read block into partial or full lines. */
343:
1.1 kristaps 344: for (i = 0; i < (int)ssz; i++) {
1.5 kristaps 345: if (pos >= (int)ln->sz) {
346: ln->sz += 256; /* Step-size. */
347: ln->buf = realloc(ln->buf, ln->sz);
1.19 kristaps 348: if (NULL == ln->buf) {
349: warn("realloc");
350: return(0);
351: }
1.1 kristaps 352: }
353:
1.5 kristaps 354: if ('\n' != blk->buf[i]) {
1.29 kristaps 355: if (comment)
356: continue;
1.5 kristaps 357: ln->buf[pos++] = blk->buf[i];
1.29 kristaps 358:
359: /* Handle in-line `\"' comments. */
360:
361: if (1 == pos || '\"' != ln->buf[pos - 1])
362: continue;
363:
364: for (j = pos - 2; j >= 0; j--)
365: if ('\\' != ln->buf[j])
366: break;
367:
368: if ( ! ((pos - 2 - j) % 2))
369: continue;
370:
371: comment = 1;
372: pos -= 2;
1.1 kristaps 373: continue;
1.29 kristaps 374: }
1.1 kristaps 375:
1.29 kristaps 376: /* Handle escaped `\\n' newlines. */
1.1 kristaps 377:
1.29 kristaps 378: if (pos > 0 && 0 == comment &&
379: '\\' == ln->buf[pos - 1]) {
1.1 kristaps 380: for (j = pos - 1; j >= 0; j--)
1.5 kristaps 381: if ('\\' != ln->buf[j])
1.1 kristaps 382: break;
383: if ( ! ((pos - j) % 2)) {
384: pos--;
385: lnn++;
386: continue;
387: }
388: }
389:
1.5 kristaps 390: ln->buf[pos] = 0;
1.19 kristaps 391: lnn++;
1.29 kristaps 392:
393: /* If unset, assign parser in pset(). */
1.19 kristaps 394:
395: if ( ! (man || mdoc) && ! pset(ln->buf,
396: pos, curp, &man, &mdoc))
1.10 kristaps 397: return(0);
1.19 kristaps 398:
1.29 kristaps 399: pos = comment = 0;
1.19 kristaps 400:
1.30 kristaps 401: /* Pass down into parsers. */
402:
1.10 kristaps 403: if (man && ! man_parseln(man, lnn, ln->buf))
1.1 kristaps 404: return(0);
1.19 kristaps 405: if (mdoc && ! mdoc_parseln(mdoc, lnn, ln->buf))
406: return(0);
1.1 kristaps 407: }
408: }
409:
1.29 kristaps 410: /* NOTE a parser may not have been assigned, yet. */
1.19 kristaps 411:
1.22 kristaps 412: if ( ! (man || mdoc)) {
413: warnx("%s: not a manual", curp->file);
414: return(0);
415: }
416:
417: if (mdoc && ! mdoc_endparse(mdoc))
418: return(0);
419: if (man && ! man_endparse(man))
420: return(0);
1.19 kristaps 421:
1.29 kristaps 422: /* If unset, allocate output dev now (if applicable). */
1.22 kristaps 423:
424: if ( ! (curp->outman && curp->outmdoc)) {
425: switch (curp->outtype) {
426: case (OUTT_TREE):
427: curp->outman = tree_man;
428: curp->outmdoc = tree_mdoc;
429: break;
430: case (OUTT_LINT):
431: break;
432: default:
433: curp->outdata = ascii_alloc();
434: curp->outman = terminal_man;
435: curp->outmdoc = terminal_mdoc;
436: curp->outfree = terminal_free;
437: break;
438: }
439: }
440:
441: /* Execute the out device, if it exists. */
442:
443: if (man && curp->outman)
444: if ( ! (*curp->outman)(curp->outdata, man))
445: return(0);
446: if (mdoc && curp->outmdoc)
447: if ( ! (*curp->outmdoc)(curp->outdata, mdoc))
448: return(0);
449:
450: return(1);
1.19 kristaps 451: }
452:
453:
454: static int
1.22 kristaps 455: pset(const char *buf, int pos, struct curparse *curp,
1.19 kristaps 456: struct man **man, struct mdoc **mdoc)
457: {
1.29 kristaps 458: int i;
1.19 kristaps 459:
460: /*
461: * Try to intuit which kind of manual parser should be used. If
462: * passed in by command-line (-man, -mdoc), then use that
463: * explicitly. If passed as -mandoc, then try to guess from the
1.30 kristaps 464: * line: either skip dot-lines, use -mdoc when finding `.Dt', or
1.19 kristaps 465: * default to -man, which is more lenient.
466: */
467:
1.29 kristaps 468: if (buf[0] == '.') {
469: for (i = 1; buf[i]; i++)
470: if (' ' != buf[i] && '\t' != buf[i])
471: break;
472: if (0 == buf[i])
473: return(1);
474: }
1.10 kristaps 475:
1.19 kristaps 476: switch (curp->inttype) {
477: case (INTT_MDOC):
478: if (NULL == curp->mdoc)
479: curp->mdoc = mdoc_init(curp);
480: if (NULL == (*mdoc = curp->mdoc))
481: return(0);
1.22 kristaps 482: curp->lastmdoc = *mdoc;
1.19 kristaps 483: return(1);
484: case (INTT_MAN):
485: if (NULL == curp->man)
486: curp->man = man_init(curp);
487: if (NULL == (*man = curp->man))
488: return(0);
1.22 kristaps 489: curp->lastman = *man;
1.19 kristaps 490: return(1);
491: default:
492: break;
493: }
494:
495: if (pos >= 3 && 0 == memcmp(buf, ".Dd", 3)) {
496: if (NULL == curp->mdoc)
497: curp->mdoc = mdoc_init(curp);
498: if (NULL == (*mdoc = curp->mdoc))
499: return(0);
1.22 kristaps 500: curp->lastmdoc = *mdoc;
1.19 kristaps 501: return(1);
502: }
503:
504: if (NULL == curp->man)
505: curp->man = man_init(curp);
506: if (NULL == (*man = curp->man))
507: return(0);
1.22 kristaps 508: curp->lastman = *man;
1.19 kristaps 509: return(1);
1.10 kristaps 510: }
511:
512:
513: static int
514: moptions(enum intt *tflags, char *arg)
515: {
516:
1.17 kristaps 517: if (0 == strcmp(arg, "doc"))
1.10 kristaps 518: *tflags = INTT_MDOC;
1.19 kristaps 519: else if (0 == strcmp(arg, "andoc"))
520: *tflags = INTT_AUTO;
1.17 kristaps 521: else if (0 == strcmp(arg, "an"))
1.10 kristaps 522: *tflags = INTT_MAN;
523: else {
524: warnx("bad argument: -m%s", arg);
525: return(0);
526: }
527:
528: return(1);
1.1 kristaps 529: }
530:
531:
532: static int
533: toptions(enum outt *tflags, char *arg)
534: {
535:
536: if (0 == strcmp(arg, "ascii"))
537: *tflags = OUTT_ASCII;
538: else if (0 == strcmp(arg, "lint"))
539: *tflags = OUTT_LINT;
540: else if (0 == strcmp(arg, "tree"))
541: *tflags = OUTT_TREE;
542: else {
543: warnx("bad argument: -T%s", arg);
544: return(0);
545: }
546:
547: return(1);
548: }
549:
550:
551: static int
552: foptions(int *fflags, char *arg)
553: {
1.34 kristaps 554: char *v, *o;
1.24 kristaps 555: char *toks[6];
1.1 kristaps 556:
557: toks[0] = "ign-scope";
1.24 kristaps 558: toks[1] = "no-ign-escape";
559: toks[2] = "no-ign-macro";
560: toks[3] = "no-ign-chars";
561: toks[4] = "strict";
562: toks[5] = NULL;
1.1 kristaps 563:
1.34 kristaps 564: while (*arg) {
565: o = arg;
1.1 kristaps 566: switch (getsubopt(&arg, toks, &v)) {
567: case (0):
1.15 kristaps 568: *fflags |= IGN_SCOPE;
1.1 kristaps 569: break;
570: case (1):
1.24 kristaps 571: *fflags |= NO_IGN_ESCAPE;
1.1 kristaps 572: break;
573: case (2):
1.24 kristaps 574: *fflags |= NO_IGN_MACRO;
1.1 kristaps 575: break;
1.20 kristaps 576: case (3):
1.24 kristaps 577: *fflags |= NO_IGN_CHARS;
578: break;
579: case (4):
580: *fflags |= NO_IGN_ESCAPE |
581: NO_IGN_MACRO | NO_IGN_CHARS;
1.20 kristaps 582: break;
1.1 kristaps 583: default:
1.34 kristaps 584: warnx("bad argument: -f%s", o);
1.1 kristaps 585: return(0);
586: }
1.34 kristaps 587: }
1.1 kristaps 588:
589: return(1);
590: }
591:
592:
593: static int
594: woptions(int *wflags, char *arg)
595: {
1.34 kristaps 596: char *v, *o;
1.36 ! kristaps 597: char *toks[3];
1.1 kristaps 598:
599: toks[0] = "all";
1.36 ! kristaps 600: toks[1] = "error";
! 601: toks[2] = NULL;
1.1 kristaps 602:
1.34 kristaps 603: while (*arg) {
604: o = arg;
1.1 kristaps 605: switch (getsubopt(&arg, toks, &v)) {
606: case (0):
607: *wflags |= WARN_WALL;
608: break;
609: case (1):
610: *wflags |= WARN_WERR;
611: break;
612: default:
1.34 kristaps 613: warnx("bad argument: -W%s", o);
1.1 kristaps 614: return(0);
615: }
1.34 kristaps 616: }
1.1 kristaps 617:
618: return(1);
619: }
620:
621:
1.2 kristaps 622: /* ARGSUSED */
1.1 kristaps 623: static int
624: merr(void *arg, int line, int col, const char *msg)
625: {
1.5 kristaps 626: struct curparse *curp;
627:
628: curp = (struct curparse *)arg;
1.36 ! kristaps 629:
1.5 kristaps 630: warnx("%s:%d: error: %s (column %d)",
631: curp->file, line, msg, col);
1.27 kristaps 632:
1.1 kristaps 633: return(0);
634: }
635:
636:
637: static int
1.35 kristaps 638: mdocwarn(void *arg, int line, int col, const char *msg)
1.1 kristaps 639: {
1.5 kristaps 640: struct curparse *curp;
1.1 kristaps 641:
1.5 kristaps 642: curp = (struct curparse *)arg;
1.1 kristaps 643:
1.36 ! kristaps 644: if ( ! (curp->wflags & WARN_WALL))
! 645: return(1);
! 646:
! 647: warnx("%s:%d: syntax warning: %s (column %d)",
1.35 kristaps 648: curp->file, line, msg, col);
1.1 kristaps 649:
1.5 kristaps 650: if ( ! (curp->wflags & WARN_WERR))
1.1 kristaps 651: return(1);
1.27 kristaps 652:
1.30 kristaps 653: warnx("considering warnings as errors");
1.1 kristaps 654: return(0);
655: }
656:
657:
1.14 kristaps 658: static int
659: manwarn(void *arg, int line, int col, const char *msg)
660: {
661: struct curparse *curp;
662:
663: curp = (struct curparse *)arg;
664:
1.36 ! kristaps 665: if ( ! (curp->wflags & WARN_WALL))
1.14 kristaps 666: return(1);
667:
668: warnx("%s:%d: syntax warning: %s (column %d)",
669: curp->file, line, msg, col);
670:
671: if ( ! (curp->wflags & WARN_WERR))
672: return(1);
673:
1.30 kristaps 674: warnx("considering warnings as errors");
1.14 kristaps 675: return(0);
676: }
CVSweb