static Errorclass lint2(void) { char *file; char *line; char **nwordv; /* * Look for type 2 lint errors * * %.7s used( %s(%d) ), but not defined * %.7s defined( %s(%d) ), but never used * %.7s declared( %s(%d) ), but never used or defined * * bufp defined( "./metric.h"(10) ), but never used */ if (cur_wordc < 5) return (C_UNKNOWN); if (lastchar(cur_wordv[2]) == '(' /* ')' */ && strcmp(cur_wordv[4], "),") == 0) { language = INLINT; if (persperdexplode(cur_wordv[3], &line, &file)) { nwordv = wordvsplice(2, cur_wordc, cur_wordv+1); nwordv[0] = file; nwordv[1] = line; cur_wordc = cur_wordc + 2; cur_wordv = nwordv - 1; /* 1 based */ return (C_TRUE); } } return (C_UNKNOWN); } /* end of lint 2*/
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 */
/* * Do the error message from the Richie C Compiler for the PDP11, * which has this source: * * if (filename[0]) * fprintf(stderr, "%s:", filename); * fprintf(stderr, "%d: ", line); * * This also handles errors with column numbers, as in * * foo.c:534:12: missing ';' * */ Errorclass richieccom(void) { char *cp; char **nwordv; char *file; char *colon; if (lastchar(wordv[1]) == ':') { cp = colon = wordv[1] + strlen(wordv[1]) - 1; while (isdigit(*--cp)) continue; // If there are two numbers, we want the first if (*cp == ':' && isdigit(cp[-1])) { colon = cp; while (isdigit(*--cp)) continue; } if (*cp == ':') { *colon = '\0'; /* last : */ *cp = '\0'; /* first : */ file = wordv[1]; nwordv = wordvsplice(1, wordc, wordv+1); nwordv[0] = file; nwordv[1] = cp + 1; wordc += 1; wordv = nwordv - 1; language = INCC; currentfilename = wordv[1]; return (C_TRUE); } } return (C_UNKNOWN); }
static Errorclass lint1(void) { char *line1 = NULL, *line2 = NULL; char *file1 = NULL, *file2 = NULL; char **nwordv1, **nwordv2; /* * Now, attempt a match for the various errors that lint * can complain about. * * Look first for type 1 lint errors */ if (cur_wordc > 1 && strcmp(cur_wordv[cur_wordc-1], "::") == 0) { /* * %.7s, arg. %d used inconsistently %s(%d) :: %s(%d) * %.7s value used inconsistently %s(%d) :: %s(%d) * %.7s multiply declared %s(%d) :: %s(%d) * %.7s value declared inconsistently %s(%d) :: %s(%d) * %.7s function value type must be declared before use %s(%d) :: %s(%d) */ language = INLINT; if (cur_wordc > 2 && persperdexplode(cur_wordv[cur_wordc], &line2, &file2) && persperdexplode(cur_wordv[cur_wordc-2], &line1, &file1)) { nwordv1 = wordvsplice(2, cur_wordc, cur_wordv+1); nwordv2 = wordvsplice(2, cur_wordc, cur_wordv+1); nwordv1[0] = file1; nwordv1[1] = line1; erroradd(cur_wordc+2, nwordv1, C_TRUE, C_DUPL); /* takes 0 based*/ nwordv2[0] = file2; nwordv2[1] = line2; cur_wordc = cur_wordc + 2; cur_wordv = nwordv2 - 1; /* 1 based */ return (C_TRUE); } } if (file2) free(file2); if (file1) free(file1); if (line2) free(line2); if (line1) free(line1); return (C_UNKNOWN); } /* end of lint 1*/
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; }
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); }