main(int argc, char **argv) { FILE *fp; int i; progname = argv[0]; for (i = 1; i < argc && argv[i][0] == '-' && argv[i][1] != 0; i++) if (!strcmp(argv[i], "-noquote")) showquotes = 0; else errormsg(Error, "%s: unknown option %s\n", progname, argv[i]); nwindex = new_recognizer(ALPHANUM, SYMBOLS); if (i == argc) { #line 75 "finduses.nw" { FILE *tmp = tmpfile(); char *line; if (tmp == NULL) #line 155 "finduses.nw" errormsg(Fatal, "%s: couldn't open temporary file\n", progname); #line 78 "finduses.nw" while ((line = getline_noweb(stdin)) != NULL) { if (fputs(line, tmp) == EOF) #line 157 "finduses.nw" errormsg(Fatal, "%s: error writing temporary file\n", progname); #line 80 "finduses.nw" if (is_index(line, "defn")) { if (line[strlen(line)-1] == '\n') line[strlen(line)-1] = 0; add_ident(nwindex, line+1+5+1+4+1); } else if (is_index(line, "localdefn")) { if (line[strlen(line)-1] == '\n') line[strlen(line)-1] = 0; add_ident(nwindex, line+1+5+1+9+1); } else if (is_keyword(line, "fatal")) { exit(1); } } rewind(tmp); stop_adding(nwindex); add_use_markers(tmp, stdout); } #line 46 "finduses.nw" } else { #line 56 "finduses.nw" for (; i < argc; i++) if ((fp=fopen(argv[i],"r"))==NULL) errormsg(Error, "%s: couldn't open file %s\n", progname, argv[i]); else { read_ids(fp); fclose(fp); } #line 48 "finduses.nw" stop_adding(nwindex); add_use_markers(stdin, stdout); } nowebexit(NULL); return errorlevel; /* slay warning */ }
void errormsg(enum errorlevel level, char *s,...) { va_list args; /* see K&R, page 174 */ va_start(args,s); #line 81 "errors.nw" if (level > errorlevel) errorlevel = level; vfprintf(stderr, s, args); fprintf(stderr,"\n"); #line 64 "errors.nw" va_end(args); if (level >= Fatal) nowebexit(s); }
main(int argc, char **argv) { int i; tabsize = 0; /* default for nt is not to use tabs */ progname = argv[0]; finalstage = 1; #line 46 "mnt.nw" read_defs(stdin); apply_each_module(remove_final_newline); #line 36 "mnt.nw" for (i=1; i<argc; i++) switch (*argv[i]) { case '-': #line 152 "mnt.nw" switch (*++argv[i]) { case 'a': if (strcmp(argv[i], "all")) errormsg(Warning, "Ignoring unknown option -%s", argv[i]); else { #line 49 "mnt.nw" apply_each_module(add_uses_to_usecounts); apply_each_module(emit_if_unused_and_conforming); #line 156 "mnt.nw" } break; case 't': /* set tab size or turn off */ if (isdigit(argv[i][1])) tabsize = atoi(argv[i]+1); else if (argv[i][1]==0) tabsize = 0; /* no tabs */ else errormsg(Error, "%s: ill-formed option %s\n", argv[0], argv[i]); break; case 'L': /* have a #line number format */ locformat = argv[i] + 1; if (!*locformat) locformat = Clocformat; break; default: errormsg(Warning, "Ignoring unknown option -%s", argv[i]); } #line 38 "mnt.nw" break; default: emitfile(argv[i]); break; } nowebexit(NULL); return errorlevel; /* slay warning */ }
void errorat(char *filename, int lineno, enum errorlevel level, char *s, ...) { va_list args; /* see K&R, page 174 */ va_start(args,s); fprintf(stderr, "%s:%d: ", filename, lineno); #line 81 "errors.nw" if (level > errorlevel) errorlevel = level; vfprintf(stderr, s, args); fprintf(stderr,"\n"); #line 76 "errors.nw" va_end(args); if (level >= Fatal) nowebexit(s); }