/* * Eat all of the lines in the input file, attempting to categorize * them by their various flavors */ void eaterrors(int *r_errorc, Eptr **r_errorv) { Errorclass errorclass = C_SYNC; char *line; const char *inbuffer; size_t inbuflen; for (;;) { if ((inbuffer = fgetln(errorfile, &inbuflen)) == NULL) break; line = Calloc(inbuflen + 1, sizeof(char)); memcpy(line, inbuffer, inbuflen); line[inbuflen] = '\0'; wordvbuild(line, &cur_wordc, &cur_wordv); /* * for convenience, convert cur_wordv to be 1 based, instead * of 0 based. */ cur_wordv -= 1; if (cur_wordc > 0 && ((( errorclass = onelong() ) != C_UNKNOWN) || (( errorclass = cpp() ) != C_UNKNOWN) || (( errorclass = gcc45ccom() ) != C_UNKNOWN) || (( errorclass = pccccom() ) != C_UNKNOWN) || (( errorclass = richieccom() ) != C_UNKNOWN) || (( errorclass = lint0() ) != C_UNKNOWN) || (( errorclass = lint1() ) != C_UNKNOWN) || (( errorclass = lint2() ) != C_UNKNOWN) || (( errorclass = lint3() ) != C_UNKNOWN) || (( errorclass = make() ) != C_UNKNOWN) || (( errorclass = f77() ) != C_UNKNOWN) || ((errorclass = pi() ) != C_UNKNOWN) || (( errorclass = ri() )!= C_UNKNOWN) || (( errorclass = mod2() )!= C_UNKNOWN) || (( errorclass = troff() )!= C_UNKNOWN)) ) ; else errorclass = catchall(); if (cur_wordc) erroradd(cur_wordc, cur_wordv+1, errorclass, C_UNKNOWN); } #ifdef FULLDEBUG printf("%d errorentrys\n", nerrors); #endif arrayify(r_errorc, r_errorv, er_head); }
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*/
void eaterrors(int *r_errorc, Eptr **r_errorv) { Errorclass errorclass = C_SYNC; for (;;) { if (fgets(inbuffer, BUFSIZ, errorfile) == NULL) break; wordvbuild(inbuffer, &wordc, &wordv); /* * for convenience, convert wordv to be 1 based, instead * of 0 based. */ wordv -= 1; /* * check for sunf77 errors has to be done before * pccccom to be able to distingush between the two */ if ((wordc > 0) && (((errorclass = onelong()) != C_UNKNOWN) || ((errorclass = cpp()) != C_UNKNOWN) || ((errorclass = sunf77()) != C_UNKNOWN) || ((errorclass = pccccom()) != C_UNKNOWN) || ((errorclass = richieccom()) != C_UNKNOWN) || ((errorclass = lint0()) != C_UNKNOWN) || ((errorclass = lint1()) != C_UNKNOWN) || ((errorclass = lint2()) != C_UNKNOWN) || ((errorclass = lint3()) != C_UNKNOWN) || ((errorclass = make()) != C_UNKNOWN) || ((errorclass = f77()) != C_UNKNOWN) || ((errorclass = pi()) != C_UNKNOWN) || ((errorclass = ri()) != C_UNKNOWN) || ((errorclass = troff()) != C_UNKNOWN) || ((errorclass = mod2()) != C_UNKNOWN) || ((errorclass = troff()) != C_UNKNOWN))) { /* EMPTY */ } else { errorclass = catchall(); } if (wordc) erroradd(wordc, wordv+1, errorclass, C_UNKNOWN); } #ifdef FULLDEBUG printf("%d errorentrys\n", nerrors); #endif arrayify(r_errorc, r_errorv, er_head); }
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); }