local void convert(stream instr, stream outstr) { char line[MAX_LINELEN]; /* input linelength */ int i, nlines, noutv; string *outv; /* pointer to vector of strings to write */ char *cp, *seps=", \t"; /* column separators */ nlines=0; /* count lines read so far */ for (;;) { if (get_line(instr, line) < 0) /* EOF */ return; dprintf(3,"LINE: (%s)\n",line); if (iscomment(line)) continue; nlines++; tab2space(line); /* work around a Gipsy (?) problem */ outv = burststring(line,seps); noutv = xstrlen(outv,sizeof(string)) - 1; if (noutv < maxcol) error("Too few columns in input file (%d < %d)",noutv,maxcol); if (Qall) nkeep = noutv; for (i=0; i<nkeep; i++) { if (keep[i] == 0) fprintf(outstr,"%d",nlines); else fprintf(outstr,"%s",outv[keep[i]-1]); if (i < nkeep-1) fprintf(outstr,"%c",colsep); } if (colsep != 'n') fprintf(outstr,"\n"); /* end of line */ } }
void operator()(Range& rng, UserState& out) { std::string filename(boost::begin(rng), boost::end(rng)); std::ifstream ifs(filename.c_str()); assert( ifs.good() ); std::string text; std::getline(ifs, text, '\0'); tab2space(text, 4); if (!match< cpp_to_xhtml::start >(text, out)) { assert(false); } }