/* Last edited on 2007-08-16 00:05:42 by stolfi */ /* See the authorship and copyright notice at the end of this file. */ /* Changes: */ #include #include #include #include #include /* INTERNAL PROTOTYPES */ /* PROCEDURES */ void ParseFreeVector(byte *L, long W, double *v, long N, char *fName, long R) { long i; byte *eb = L; long nb = W; char fmt[10]; for (i=0; i 0) && (((*eb) == ' ') || ((*eb) == '\011'))) { eb++; nb--; } if (nb <= 0) { LineError("too few elements", fName, R); } /* Find next blank, tab, comma or end-of-buffer: */ ef = eb; nf = nb; while ((nf > 0) && ((*ef) != ',') && ((*ef) != ' ') && ((*ef) != '\011')) { ef++; nf--; } sprintf(fmt, "%%%ldlf", nb-nf); /* Parse element: */ v[i] = ParseNum(eb, nb-nf, fmt, R, i); /* Skip it: */ eb = ef; nb = nf; /* skip comma, if any: */ if ((nb > 0) && ((*eb) == ',')) { eb++; nb--; } } } void ParseFixedVector(byte *L, long W, int wd, double *v, long N, char *fName, long R) { long i; byte *eb = L; long nb = W; char fmt[10]; sprintf(fmt, "%%%ldlf", wd); for (i=0; i= curA) { if (curN >= MAX_LINE_LENGTH) { LineError("line too long", "", R); } else { long newA = (curA == 0 ? 256 : 2*curA); byte *newL = (byte *)Alloc(newA*sizeof(byte)); long i; for (i=0; i 0) free(curL); curA = newA; curL = newL; } } curL[curN] = c; curN++; c = fgetc(stdin); if (c == EOF) { Error("missing NL at end of input file"); } } (*L) = curL; (*A) = curA; (*N) = curN; return(FALSE); } char* CopyItem(byte *L, long N) { byte *S = (char*)(Alloc(N*sizeof(byte))); long i; for (i=0; i