static void cont_xy_store(PLFLT xx, PLFLT yy) { if (cont3d) { PLINT pts = currline->npts; if (pts % LINE_ITEMS == 0) realloc_line(currline); currline->x[pts] = xx; currline->y[pts] = yy; currline->npts++; } else plP_drawor(xx, yy); }
static int read_line( FILE *fd, Line *line) { char buf[BUFSIZE], *p; int len; int quoted = 0; /* quoted by double quote? */ char *str; int cur; str = line->str; cur = line->cursize = 0; while ((p = fgets(buf, BUFSIZE, fd)) != NULL) { ++line->seq; zap_comment(p, "ed); /* remove comment line */ len = strlen(p); if (len == 0) { if (cur > 0) { break; } continue; } if (cur + len + 1 > line->maxsize) { /* need to reallocate buffer. */ if (! realloc_line(line, line->maxsize + BUFSIZE)) { return -1; /* realloc error. */ } str = line->str; } strncpy(str + cur, p, len); cur += len; str[cur] = '\0'; #ifdef __UNIXOS2__ /* Take out carriage returns under OS/2 */ if (cur>1) { if (str[cur-2] == '\r' && str[cur-1] == '\n') { str[cur-2] = '\n'; str[cur-1] = '\0'; cur--; } } #endif if (!quoted && cur > 1 && str[cur - 2] == SYM_BACKSLASH && (str[cur - 1] == SYM_NEWLINE || str[cur-1] == SYM_CR)) { /* the line is ended backslash followed by newline. need to concatinate the next line. */ cur -= 2; str[cur] = '\0'; } else if (len < BUFSIZE - 1 || buf[len - 1] == SYM_NEWLINE || buf[len - 1] == SYM_CR) { /* the line is shorter than BUFSIZE. */ break; } } if (quoted) { /* error. still in quoted state. */ return -1; } return line->cursize = cur; }