static Errorclass mod2(void) { /* * for decwrl modula2 compiler (powell) */ if (cur_wordc < 5) return (C_UNKNOWN); if ((strcmp(cur_wordv[1], "!!!") == 0 /* early version */ || strcmp(cur_wordv[1], "File") == 0) /* later version */ && lastchar(cur_wordv[2]) == ',' /* file name */ && strcmp(cur_wordv[3], "line") == 0 && isdigit((unsigned char)firstchar(cur_wordv[4])) /* line number */ && lastchar(cur_wordv[4]) == ':' /* line number */ ) { clob_last(cur_wordv[2], '\0'); /* drop last , on file name */ clob_last(cur_wordv[4], '\0'); /* drop last : on line number */ cur_wordv[3] = cur_wordv[2]; /* file name on top of "line" */ cur_wordv += 2; cur_wordc -= 2; currentfilename = cur_wordv[1]; language = INMOD2; return (C_TRUE); } return (C_UNKNOWN); }
Errorclass sunf77(void) { /* * Finally attempt a Sun f77 error message match: * Examples: * "bar.f", line 237: Error: no label on format statement * "test.f", line 7: ANSI extension: Hollerith constant * "dir/foo.h", line 1: Warning: missing END statement */ if ((firstchar(wordv[1]) == '"') && (lastchar(wordv[1]) == ',') && (next_lastchar(wordv[1]) == '"') && (strcmp(wordv[2], "line") == 0) && (isdigit(firstchar(wordv[3]))) && (lastchar(wordv[3]) == ':') && ((strcmp(wordv[4], "Error:") == 0) || (strcmp(wordv[4], "Warning:") == 0) || ((strcmp(wordv[4], "ANSI") == 0) && (strcmp(wordv[5], "extension:") == 0)))) { clob_last(wordv[1], '\0'); /* drop last , */ clob_last(wordv[1], '\0'); /* drop last " */ wordv[1]++; /* drop first " */ clob_last(wordv[3], '\0'); /* drop : on line number */ wordv[2] = wordv[1]; /* overwrite "line" */ wordv++; /* compensate */ wordc--; currentfilename = wordv[1]; language = INSUNF77; return (C_TRUE); } return (C_UNKNOWN); } /* end of Sun f77 */
static Errorclass troff(void) { /* * troff source error message, from eqn, bib, tbl... * Just like pcc ccom, except uses `' */ if (cur_wordc < 4) return (C_UNKNOWN); if (firstchar(cur_wordv[1]) == '`' && lastchar(cur_wordv[1]) == ',' && next_lastchar(cur_wordv[1]) == '\'' && strcmp(cur_wordv[2], "line") == 0 && isdigit((unsigned char)firstchar(cur_wordv[3])) && lastchar(cur_wordv[3]) == ':') { clob_last(cur_wordv[1], '\0'); /* drop last , */ clob_last(cur_wordv[1], '\0'); /* drop last " */ cur_wordv[1]++; /* drop first " */ clob_last(cur_wordv[3], '\0'); /* drop : on line number */ cur_wordv[2] = cur_wordv[1]; /* overwrite "line" */ cur_wordv++; /*compensate*/ currentfilename = cur_wordv[1]; language = INTROFF; return (C_TRUE); } return (C_UNKNOWN); }
static Errorclass pccccom(void) { /* * Now attempt a ccom error message match: * Examples: * "morsesend.c", line 237: operands of & have incompatible types * "test.c", line 7: warning: old-fashioned initialization: use = * "subdir.d/foo2.h", line 1: illegal initialization */ if (cur_wordc < 4) return (C_UNKNOWN); if (firstchar(cur_wordv[1]) == '"' && lastchar(cur_wordv[1]) == ',' && next_lastchar(cur_wordv[1]) == '"' && strcmp(cur_wordv[2], "line") == 0 && isdigit((unsigned char)firstchar(cur_wordv[3])) && lastchar(cur_wordv[3]) == ':') { clob_last(cur_wordv[1], '\0'); /* drop last , */ clob_last(cur_wordv[1], '\0'); /* drop last " */ cur_wordv[1]++; /* drop first " */ clob_last(cur_wordv[3], '\0'); /* drop : on line number */ cur_wordv[2] = cur_wordv[1]; /* overwrite "line" */ cur_wordv++; /*compensate*/ cur_wordc--; currentfilename = cur_wordv[1]; language = INCC; return (C_TRUE); } return (C_UNKNOWN); } /* end of ccom */
Errorclass troff(void) { /* * troff source error message, from eqn, bib, tbl... * Just like pcc ccom, except uses `' */ if ((firstchar(wordv[1]) == '`') && (lastchar(wordv[1]) == ',') && (next_lastchar(wordv[1]) == '\'') && (strcmp(wordv[2], "line") == 0) && (isdigit(firstchar(wordv[3]))) && (lastchar(wordv[3]) == ':')) { clob_last(wordv[1], '\0'); /* drop last , */ clob_last(wordv[1], '\0'); /* drop last " */ wordv[1]++; /* drop first " */ clob_last(wordv[3], '\0'); /* drop : on line number */ wordv[2] = wordv[1]; /* overwrite "line" */ wordv++; /* compensate */ currentfilename = wordv[1]; language = INTROFF; return (C_TRUE); } return (C_UNKNOWN); }
Errorclass ri(void) { /* * Match an error message produced by ri; here is the * procedure yanked from the distributed version of ri * April 24, 1980. * * serror(str, x1, x2, x3) * char str[]; * char *x1, *x2, *x3; * { * extern int yylineno; * * putc('"', stdout); * fputs(srcfile, stdout); * putc('"', stdout); * fprintf(stdout, " %d: ", yylineno); * fprintf(stdout, str, x1, x2, x3); * fprintf(stdout, "\n"); * synerrs++; * } */ if ((firstchar(wordv[1]) == '"') && (lastchar(wordv[1]) == '"') && (lastchar(wordv[2]) == ':') && (isdigit(firstchar(wordv[2])))) { clob_last(wordv[1], '\0'); /* drop the last " */ wordv[1]++; /* skip over the first " */ clob_last(wordv[2], '\0'); language = INRI; return (C_TRUE); } return (C_UNKNOWN); }
static Errorclass lint0(void) { char **nwordv; char *line, *file; /* * Attempt a match for the new lint style normal compiler * error messages, of the form * * printf("%s(%d): %s\n", filename, linenumber, message); */ if (cur_wordc < 2) return (C_UNKNOWN); if (lastchar(cur_wordv[1]) == ':' && next_lastchar(cur_wordv[1]) == ')') { clob_last(cur_wordv[1], '\0'); /* colon */ if (persperdexplode(cur_wordv[1], &line, &file)) { nwordv = wordvsplice(1, cur_wordc, cur_wordv+1); nwordv[0] = file; /* file name */ nwordv[1] = line; /* line number */ cur_wordc += 1; cur_wordv = nwordv - 1; language = INLINT; return (C_TRUE); } cur_wordv[1][strlen(cur_wordv[1])] = ':'; } return (C_UNKNOWN); }
static Errorclass richieccom(void) { char *cp; char **nwordv; char *file; if (cur_wordc < 2) return (C_UNKNOWN); if (lastchar(cur_wordv[1]) == ':') { cp = cur_wordv[1] + strlen(cur_wordv[1]) - 1; while (isdigit((unsigned char)*--cp)) continue; if (*cp == ':') { clob_last(cur_wordv[1], '\0'); /* last : */ *cp = '\0'; /* first : */ file = cur_wordv[1]; nwordv = wordvsplice(1, cur_wordc, cur_wordv+1); nwordv[0] = file; nwordv[1] = cp + 1; cur_wordc += 1; cur_wordv = nwordv - 1; language = INCC; currentfilename = cur_wordv[1]; return (C_TRUE); } } return (C_UNKNOWN); }
Errorclass f77(void) { char **nwordv; /* * look for f77 errors: * Error messages from /usr/src/cmd/f77/error.c, with * these printf formats: * * Compiler error line %d of %s: %s * Error on line %d of %s: %s * Warning on line %d of %s: %s * Error. No assembly. */ if (wordc == 3 && wordvcmp(wordv+1, 3, F77_no_ass) == 0) { wordc = 0; return (C_SYNC); } if (wordc < 6) return (C_UNKNOWN); if ((lastchar(wordv[6]) == ':') && ((wordvcmp(wordv+1, 3, F77_fatal) == 0) || (wordvcmp(wordv+1, 3, F77_error) == 0) || (wordvcmp(wordv+1, 3, F77_warning) == 0))) { language = INF77; nwordv = wordvsplice(2, wordc, wordv+1); nwordv[0] = wordv[6]; clob_last(nwordv[0], '\0'); nwordv[1] = wordv[4]; wordc += 2; wordv = nwordv - 1; /* 1 based */ return (C_TRUE); } return (C_UNKNOWN); } /* end of f77 */
Errorclass cpp(void) { /* * Now attempt a cpp error message match * Examples: * ./morse.h: 23: undefined control * morsesend.c: 229: MAGNIBBL: argument mismatch * morsesend.c: 237: MAGNIBBL: argument mismatch * test1.c: 6: undefined control */ if ((language != INLD) && /* loader errors have almost same fmt */ (lastchar(wordv[1]) == ':') && (isdigit(firstchar(wordv[2]))) && (lastchar(wordv[2]) == ':')) { language = INCPP; clob_last(wordv[1], '\0'); clob_last(wordv[2], '\0'); return (C_TRUE); } return (C_UNKNOWN); } /*end of cpp*/
Errorclass mod2(void) { /* * for decwrl modula2 compiler (powell) */ if (((strcmp(wordv[1], "!!!") == 0) || /* early version */ (strcmp(wordv[1], "File") == 0)) && /* later version */ (lastchar(wordv[2]) == ',') && /* file name */ (strcmp(wordv[3], "line") == 0) && (isdigit(firstchar(wordv[4]))) && /* line number */ (lastchar(wordv[4]) == ':')) { /* line number */ clob_last(wordv[2], '\0'); /* drop last , on file name */ clob_last(wordv[4], '\0'); /* drop last : on line number */ wordv[3] = wordv[2]; /* file name on top of "line" */ wordv += 2; wordc -= 2; currentfilename = wordv[1]; language = INMOD2; return (C_TRUE); } return (C_UNKNOWN); }
static Errorclass gcc45ccom(void) { char *cp, *ccp; char **nwordv; char *file; if (cur_wordc < 2) return C_UNKNOWN; if (lastchar(cur_wordv[1]) != ':') return C_UNKNOWN; cp = cur_wordv[1] + strlen(cur_wordv[1]) - 1; while (isdigit((unsigned char)*--cp)) continue; if (*cp != ':') return C_UNKNOWN; ccp = cp; while (isdigit((unsigned char)*--cp)) continue; if (*cp != ':') return C_UNKNOWN; clob_last(cur_wordv[1], '\0'); /* last : */ *ccp = '\0'; /* middle : */ *cp = '\0'; /* first : */ file = cur_wordv[1]; #ifdef notyet #define EHEAD 2 #else #define EHEAD 1 /* Nothing to do with column info yet */ #endif nwordv = wordvsplice(EHEAD, cur_wordc, cur_wordv + 1); nwordv[0] = file; nwordv[1] = cp + 1; #ifdef notyet nwordv[2] = ccp + 1; #endif cur_wordc += 1; cur_wordv = nwordv - 1; language = INCC; currentfilename = cur_wordv[1]; return C_TRUE; }
/* * Tell if the error text is to be ignored. * The error must have been canonicalized, with * the file name the zeroth entry in the errorv, * and the linenumber the second. * Return the new categorization of the error class. */ Errorclass discardit(Eptr errorp) { int language; int i; Errorclass errorclass = errorp->error_e_class; switch (errorclass) { case C_SYNC: case C_NONSPEC: case C_UNKNOWN: return (errorclass); default: break; } if (errorp->error_lgtext < 2) { return (C_NONSPEC); } language = errorp->error_language; if (language == INLINT) { if (errorclass != C_NONSPEC) { /* no file */ for (i = 0; lint_libs[i] != 0; i++) { if (strcmp(errorp->error_text[0], lint_libs[i]) == 0) { return (C_DISCARD); } } } /* * check if the argument to the error message * is to be ignored */ if (ispunct(lastchar(errorp->error_text[2]))) clob_last(errorp->error_text[2], '\0'); if (search_ignore( errorp->error_text[errorclass == C_NONSPEC ? 0 : 2]) >= 0) { return (C_NULLED); } } return (errorclass); }
Errorclass pi(void) { char **nwordv; nwordv = NULL; if (cur_wordc < 2) return (C_UNKNOWN); if (strlen(cur_wordv[1]) == 1 && ( cur_wordv[1][0] == 'e' || cur_wordv[1][0] == 'E') && piptr(cur_wordv[2]) ) { boolean longpiptr = 0; /* * We have recognized a first pass error of the form: * letter ------^---- message * * turn into an error message of the form: * * file line 'pascal errortype' letter \n |---- message * or of the form: * file line letter |---- message * when there are strlen("(*[pi]") or more * preceding '-' on the error pointer. * * Where the | is intended to be a down arrow, so that * the pi error messages can be inserted above the * line in error, instead of below. (All of the other * languages put their messages before the source line, * instead of after it as does pi.) * * where the pointer to the error has been truncated * by 6 characters to account for the fact that * the pointer points into a tab preceded input line. */ language = INPI; (void)substitute(cur_wordv[2], '^', '|'); longpiptr = position(cur_wordv[2],'|') > (6+8); nwordv = wordvsplice(longpiptr ? 2 : 4, cur_wordc, cur_wordv+1); nwordv[0] = strdup(currentfilename); nwordv[1] = strdup(c_linenumber); if (!longpiptr) { nwordv[2] = Strdup("pascal errortype"); /* XXX leaked */ nwordv[3] = cur_wordv[1]; nwordv[4] = strdup("%%%\n"); if (strlen(nwordv[5]) > (8-2)) /* this is the pointer */ nwordv[5] += (8-2); /* bump over 6 characters */ } cur_wordv = nwordv - 1; /* convert to 1 based */ cur_wordc += longpiptr ? 2 : 4; return (C_TRUE); } if (cur_wordc >= 4 && strlen(cur_wordv[1]) == 1 && (*cur_wordv[1] == 'E' || *cur_wordv[1] == 'w' || *cur_wordv[1] == 'e') && alldigits(cur_wordv[2]) && strlen(cur_wordv[3]) == 1 && cur_wordv[3][0] == '-' ) { /* * Message of the form: letter linenumber - message * Turn into form: filename linenumber letter - message */ language = INPI; nwordv = wordvsplice(1, cur_wordc, cur_wordv + 1); nwordv[0] = strdup(currentfilename); nwordv[1] = cur_wordv[2]; nwordv[2] = cur_wordv[1]; c_linenumber = cur_wordv[2]; cur_wordc += 1; cur_wordv = nwordv - 1; return (C_TRUE); } if (cur_wordc >= 3 && strlen(cur_wordv[1]) == 1 && (*cur_wordv[1] == 'E' || *cur_wordv[1] == 'w' || *cur_wordv[1] == 'e') && strlen(cur_wordv[2]) == 1 && cur_wordv[2][0] == '-' ) { /* * Message of the form: letter - message * * This happens only when we are traversing the tree * during the second pass of pi, and discover semantic * errors. * * We have already (presumably) saved the header message * and can now construct a nulled error message for the * current file. * * Turns into a message of the form: * filename (header) letter - message * * First, see if it is a message referring to more than * one line number. Only of the form: * %s undefined on line%s * %s improperly used on line%s */ boolean undefined = 0; int wordindex; language = INPI; if ((undefined = (wordvcmp(cur_wordv+2, 3, pi_und1) == 0)) || (undefined = (wordvcmp(cur_wordv+2, 3, pi_und2) == 0)) || wordvcmp(cur_wordv+2, 4, pi_imp1) == 0 || wordvcmp(cur_wordv+2, 4, pi_imp2) == 0 ) { for (wordindex = undefined ? 5 : 6; wordindex <= cur_wordc; wordindex++) { if (nwordv) { free(nwordv[0]); free(nwordv); } nwordv = wordvsplice(2, undefined ? 2 : 3, cur_wordv+1); nwordv[0] = strdup(currentfilename); nwordv[1] = cur_wordv[wordindex]; if (wordindex != cur_wordc) erroradd(undefined ? 4 : 5, nwordv, C_TRUE, C_UNKNOWN); } cur_wordc = undefined ? 4 : 5; cur_wordv = nwordv - 1; return (C_TRUE); } nwordv = wordvsplice(1+3, cur_wordc, cur_wordv+1); nwordv[0] = strdup(currentfilename); nwordv[1] = strdup(c_header[0]); nwordv[2] = strdup(c_header[1]); nwordv[3] = strdup(c_header[2]); cur_wordv = nwordv - 1; cur_wordc += 1 + 3; return (C_THISFILE); } if (strcmp(cur_wordv[1], "...") == 0 && c_linenumber && currentfilename != default_currentfilename) { /* * have a continuation error message * of the form: ... message * Turn into form : filename linenumber message */ language = INPI; nwordv = wordvsplice(1, cur_wordc, cur_wordv+1); nwordv[0] = strdup(currentfilename); nwordv[1] = strdup(c_linenumber); cur_wordv = nwordv - 1; cur_wordc += 1; return (C_TRUE); } if (cur_wordc == 6 && lastchar(cur_wordv[6]) == ':' && isdateformat(5, cur_wordv + 1) ) { /* * Have message that tells us we have changed files */ language = INPI; currentfilename = strdup(cur_wordv[6]); clob_last(currentfilename, '\0'); return (C_SYNC); } if (cur_wordc == 3 && strcmp(cur_wordv[1], "In") == 0 && lastchar(cur_wordv[3]) == ':' && instringset(cur_wordv[2], Piroutines) ) { language = INPI; c_header = wordvsplice(0, cur_wordc, cur_wordv+1); return (C_SYNC); } /* * now, check for just the line number followed by the text */ if (alldigits(cur_wordv[1])) { language = INPI; c_linenumber = cur_wordv[1]; return (C_IGNORE); } /* * Attempt to match messages refering to a line number * * Multiply defined label in case, lines %d and %d * Goto %s from line %d is into a structured statement * End matched %s on line %d * Inserted keyword end matching %s on line %d */ multiple = structured = 0; if ( (cur_wordc == 6 && wordvcmp(cur_wordv+1, 2, pi_Endmatched) == 0) || (cur_wordc == 8 && wordvcmp(cur_wordv+1, 4, pi_Inserted) == 0) || (multiple = (cur_wordc == 9 && wordvcmp(cur_wordv+1,6, pi_multiple) == 0)) || (structured = (cur_wordc == 10 && wordvcmp(cur_wordv+6,5, pi_structured) == 0)) ) { language = INPI; nwordv = wordvsplice(2, cur_wordc, cur_wordv+1); nwordv[0] = strdup(currentfilename); nwordv[1] = structured ? cur_wordv [5] : cur_wordv[cur_wordc]; cur_wordc += 2; cur_wordv = nwordv - 1; if (!multiple) return (C_TRUE); erroradd(cur_wordc, nwordv, C_TRUE, C_UNKNOWN); nwordv = wordvsplice(0, cur_wordc, nwordv); nwordv[1] = cur_wordv[cur_wordc - 2]; return (C_TRUE); } return (C_UNKNOWN); }