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); }
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 */
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); }
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); }
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 */
/* * Go to the end of the current paragraph. */ int gotoeop(int f, int n) { MARK odot; int was_at_bol; int was_on_empty; int fc; n = need_a_count(f, n, 1); fc = firstchar(DOT.l); was_on_empty = is_empty_line(DOT); was_at_bol = ((fc >= 0 && DOT.o <= fc) || fc < 0); odot = DOT; while (n) { if (findpat(TRUE, 1, b_val_rexp(curbp, VAL_PARAGRAPHS)->reg, FORWARD) != TRUE) { DOT = curbp->b_line; } else if (is_empty_line(DOT)) { /* special case -- if we found an empty line. */ /* either as the very next line, or at the end of our search */ if ((was_on_empty && lback(DOT.l) == odot.l) || (n > 0 && llength(lback(DOT.l)) == 0)) { /* then we haven't really found what we wanted. keep going */ skipblanksf(); continue; } } n--; } if (doingopcmd) { /* if we're now at the beginning of a line and we can back up, do so to avoid eating the newline and leading whitespace */ fc = firstchar(DOT.l); if (((fc >= 0 && DOT.o <= fc) || fc < 0) && !is_first_line(DOT, curbp) && !sameline(DOT, odot)) { backchar(TRUE, DOT.o + 1); } /* if we started at the start of line, eat the whole line */ if (!sameline(DOT, odot) && was_at_bol) regionshape = rgn_FULLLINE; } return TRUE; }
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); }
/* * Go to the beginning of the current paragraph. */ int gotobop(int f, int n) { MARK odot; int was_on_empty; int fc; n = need_a_count(f, n, 1); was_on_empty = is_empty_line(DOT); odot = DOT; fc = firstchar(DOT.l); if (doingopcmd && ((fc >= 0 && DOT.o <= fc) || fc < 0) && !is_first_line(DOT, curbp)) { backchar(TRUE, DOT.o + 1); pre_op_dot = DOT; } while (n) { if (findpat(TRUE, 1, b_val_rexp(curbp, VAL_PARAGRAPHS)->reg, REVERSE) != TRUE) { (void) gotobob(f, n); } else if (is_empty_line(DOT)) { /* special case -- if we found an empty line, and it's adjacent to where we started, skip all adjacent empty lines, and try again */ if ((was_on_empty && lforw(DOT.l) == odot.l) || (n > 0 && llength(lforw(DOT.l)) == 0)) { /* then we haven't really found what we wanted. keep going */ skipblanksb(); continue; } } n--; } if (doingopcmd) { fc = firstchar(DOT.l); if (!sameline(DOT, odot) && (pre_op_dot.o > lastchar(pre_op_dot.l)) && ((fc >= 0 && DOT.o <= fc) || fc < 0)) { regionshape = rgn_FULLLINE; } } return TRUE; }
char *fchar(char *str,char *delim,int wordno) { char *s; if ((s=firstchar(str,delim,wordno))==NULL) return str+strlen(str); else return s; }
/* ARGSUSED */ int firstnonwhite(int f GCC_UNUSED, int n GCC_UNUSED) { DOT.o = firstchar(DOT.l); if (DOT.o < w_left_margin(curwp)) { if (llength(DOT.l) <= w_left_margin(curwp)) DOT.o = w_left_margin(curwp); else DOT.o = llength(DOT.l) - 1; } return TRUE; }
/* push a deleted line onto the undo stack. */ void toss_to_undo(LINE *lp) { LINE *next; LINE *prev; int fc; TRACE2((T_CALLED "toss_to_undo(%p)\n", lp)); if (needundocleanup) preundocleanup(); pushline(lp, BACKSTK(curbp)); next = lforw(lp); /* need to save a dot -- either the next line or the previous one */ if (next == buf_head(curbp)) { prev = lback(lp); FORWDOT(curbp).l = prev; fc = firstchar(prev); if (fc < 0) /* all white */ FORWDOT(curbp).o = llength(prev) - 1; else FORWDOT(curbp).o = fc; } else { FORWDOT(curbp).l = next; fc = firstchar(next); if (fc < 0) /* all white */ FORWDOT(curbp).o = b_left_margin(curbp); else FORWDOT(curbp).o = fc; } dumpuline(lp); return2Void(); }
TBool CAgentTest::CompareLines(const TDesC8& aLine1, const TDesC8& aLine2) { _LIT8(Krev,"REV"); TBool ret=!aLine1.Compare(aLine2); if (!ret) { TBufC8<2> firstchar(aLine1.Left(2)); if(!firstchar.Compare(Krev())) { return ETrue; } } return ret; }
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 int getfence( int ch, /* fence type to match against */ int sdir) /* direction to scan if we're not on a fence to begin with */ { MARK oldpos; /* original pointer */ register int ofence = 0; /* open fence */ int s, i; int key = CPP_UNKNOWN; char *C_fences, *ptr; int fch; /* save the original cursor position */ oldpos = DOT; /* ch may have been passed, if being used internally */ if (!ch) { if ((i = firstchar(DOT.l)) < 0) /* offset of first nonblank */ return FALSE; /* line is entirely blank */ if (DOT.o <= i && (ch = lgetc(DOT.l,i)) == '#') { if (llength(DOT.l) < i+3) return FALSE; } else if ((ch = char_at(DOT)) == '/' || ch == '*') { /* EMPTY */; } else if (sdir == FORWARD) { /* get the current character */ if (oldpos.o < llength(oldpos.l)) { do { ch = char_at(oldpos); } while(!is_user_fence(ch, (int *)0) && ++oldpos.o < llength(oldpos.l)); } if (is_at_end_of_line(oldpos)) { return FALSE; } } else { /* get the current character */ if (oldpos.o >= 0) { do { ch = char_at(oldpos); } while(!is_user_fence(ch, (int *)0) && --oldpos.o >= 0); } if (oldpos.o < 0) { return FALSE; } } /* we've at least found a fence -- move us that far */ DOT.o = oldpos.o; } fch = ch; /* is it a "special" fence char? */ C_fences = "/*#"; ptr = strchr(C_fences, ch); if (!ptr) { ofence = is_user_fence(ch, &sdir); if (ofence) fch = PAIRED_FENCE_CH; } /* setup proper matching fence */ switch (fch) { case PAIRED_FENCE_CH: /* NOTHING */ break; case '#': if ((i = firstchar(DOT.l)) < 0) return FALSE; /* line is entirely blank */ if ((i = nextchar(DOT.l, i+1)) >= 0 && ((key = cpp_keyword(DOT.l, i)) != CPP_UNKNOWN)) break; return FALSE; case '*': ch = '/'; if (NextCharIs('/')) { sdir = REVERSE; forwchar(TRUE,1); break; } else if (PrevCharIs('/')) { sdir = FORWARD; backchar(TRUE,1); if (doingopcmd) pre_op_dot = DOT; break; } return FALSE; case '/': if (NextCharIs('*')) { sdir = FORWARD; break; } else if (PrevCharIs('*')) { sdir = REVERSE; break; } /* FALL THROUGH */ default: return(FALSE); } /* ops are inclusive of the endpoint */ if (doingopcmd && sdir == REVERSE) { forwchar(TRUE,1); pre_op_dot = DOT; backchar(TRUE,1); } if (key != CPP_UNKNOWN) { /* we're searching for a cpp keyword */ s = cpp_fence(sdir, key); } else if (ch == '/') { s = comment_fence(sdir); } else { s = simple_fence(sdir, ch, ofence); } if (s == TRUE) return TRUE; /* restore the current position */ DOT = oldpos; return(FALSE); }
static int cpp_fence( int sdir, int key) { int count = 1; int i, j, this; /* patch: this should come from arguments */ if (key == CPP_ENDIF) sdir = REVERSE; else sdir = FORWARD; /* set up for scan */ if (sdir == REVERSE) DOT.l = lback(DOT.l); else DOT.l = lforw(DOT.l); while (count > 0 && !is_header_line(DOT, curbp)) { if ((i = firstchar(DOT.l)) >= 0 && lgetc(DOT.l,i) == '#' && (j = nextchar(DOT.l, i+1)) >= 0 && ((this = cpp_keyword(DOT.l, j)) != CPP_UNKNOWN)) { int done = FALSE; switch (this) { case CPP_IF: if (sdir == FORWARD) { count++; } else { done = ((count-- == 1) && (key != this)); if (done) count = 0; } break; case CPP_ELIF: case CPP_ELSE: done = ((sdir == FORWARD) && (count == 1)); if (done) count = 0; break; case CPP_ENDIF: if (sdir == FORWARD) { done = (--count == 0); } else { count++; } } if ((count <= 0) || done) { DOT.o = i; break; } } if (sdir == REVERSE) DOT.l = lback(DOT.l); else DOT.l = lforw(DOT.l); if (is_header_line(DOT,curbp) || interrupted()) return FALSE; } if (count == 0) { curwp->w_flag |= WFMOVE; if (doingopcmd) regionshape = FULLLINE; return TRUE; } return FALSE; }
word MaxReadLog(struct _proto *pro, word doing_ul) { FILE *log; #define LOGLEN 255 char fname[PATHLEN]; char line[LOGLEN]; word gotfile=FALSE; char tempname[PATHLEN]; FENTRY fent; /* Handle the "%" translation characters */ Parse_Outside_Cmd(pro->log, fname); if ((log=fopen(fname, fopen_read))==NULL) { cant_open(fname); return FALSE; } while (fgets(line, LOGLEN, log)) { char *ulstr, *dlstr, *got, *desc; word ul; word fn; /* Find the positions of the upload and download strings */ dlstr=strstr(line, pro->dlkey); ulstr=strstr(line, pro->ulkey); if (ulstr==NULL && dlstr==NULL) continue; if (pro->flag & P_BI) { /* Use whichever token comes FIRST in the log line, since we might * * see either. */ ul=(ulstr && (dlstr==NULL || ulstr < dlstr)); got=(ul ? ulstr : dlstr); } else { /* Otherwise, just get the one that was requested */ ul=doing_ul; got=(ul ? ulstr : dlstr); if (!got) continue; } /* Now copy the filename, based on the word# we're supposed to get. */ getword(got, fname, ctl_delim, pro->fnamword+1); /* Skip it if we didn't get anything */ if (*fname=='\0') continue; /* Now figure out if we requested this file or not... */ for (fn=0; GetFileEntry(fn, &fent); fn++) if (eqstri(No_Path(fent.szName), No_Path(fname))) break; if (fn==FileEntries()) memset(&fent, 0, sizeof fent); /* Grab the description, if any */ desc=pro->descword ? firstchar(got, ctl_delim, pro->descword) : NULL; if (desc) fent.szDesc=desc; /* If we're doing an upload, strip the path specification */ if (ul) { strcpy(tempname, No_Path(fname)); fent.szName=tempname; /* Now figure out the fully-qualified path/name of the file so * that we can get the correct size. */ sprintf(fname, ss, FAS(fah, uppath), fent.szName); } else { fent.szName=fname; } /* Now get the size of this file */ fent.ulSize = fsize(fent.szName); if (ul) { logit(log_ul, *pro->desc, FAS(fah, uppath), fent.szName); fent.fFlags |= FFLAG_GOT; } else { fent.fFlags |= FFLAG_SENT; } UpdFileEntry(fn, &fent); gotfile=TRUE; } fclose(log); /* If the transfer was successful, delete both the .CTL and .LOG files */ if (gotfile) { Parse_Outside_Cmd(pro->log, fname); unlink(fname); Parse_Outside_Cmd(pro->ctl, fname); unlink(fname); } return gotfile; }