static R_INLINE int scanchar_raw(LocalData *d) { int c = (d->ttyflag) ? ConsoleGetcharWithPushBack(d->con) : Rconn_fgetc(d->con); if(c == 0) { if(d->skipNul) { do { c = (d->ttyflag) ? ConsoleGetcharWithPushBack(d->con) : Rconn_fgetc(d->con); } while(c == 0); } else d->embedWarn = TRUE; } return c; }
/* Use R_alloc as this might get interrupted */ static char *Rconn_getline2(Rconnection con) { int c, bufsize = MAXELTSIZE, nbuf = -1; char *buf; buf = R_alloc(bufsize, sizeof(char)); while((c = Rconn_fgetc(con)) != R_EOF) { if(nbuf+2 >= bufsize) { // allow for terminator below bufsize *= 2; char *buf2 = R_alloc(bufsize, sizeof(char)); memcpy(buf2, buf, nbuf); buf = buf2; } if(c != '\n'){ buf[++nbuf] = (char) c; } else { buf[++nbuf] = '\0'; break; } } /* Make sure it is null-terminated even if file did not end with * newline. */ if(nbuf >= 0 && buf[nbuf]) buf[++nbuf] = '\0'; return (nbuf == -1) ? NULL: buf; }
static R_INLINE int scanchar_raw(LocalData *d) { return (d->ttyflag) ? ConsoleGetcharWithPushBack(d->con) : Rconn_fgetc(d->con); }