The R Project SVN R

Rev

Rev 86508 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 86508 Rev 87891
Line 71... Line 71...
71
    char decchar; /* = '.' */    /* This only gets compared to chars */
71
    char decchar; /* = '.' */    /* This only gets compared to chars */
72
    char *quoteset; /* = NULL */
72
    char *quoteset; /* = NULL */
73
    int comchar; /* = NO_COMCHAR */
73
    int comchar; /* = NO_COMCHAR */
74
    int ttyflag; /* = 0 */
74
    int ttyflag; /* = 0 */
75
    Rconnection con; /* = NULL */
75
    Rconnection con; /* = NULL */
76
    Rboolean wasopen; /* = FALSE */
76
    bool wasopen; /* = false */
77
    Rboolean escapes; /* = FALSE */
77
    bool escapes; /* = false */
78
    int save; /* = 0; */
78
    int save; /* = 0; */
79
    Rboolean isLatin1; /* = FALSE */
79
    bool isLatin1; /* = false */
80
    Rboolean isUTF8; /* = FALSE */
80
    bool isUTF8; /* = false */
81
    Rboolean atStart;
81
    bool atStart;
82
    Rboolean embedWarn;
82
    bool embedWarn;
83
    Rboolean skipNul;
83
    bool skipNul;
84
    char convbuf[100];
84
    char convbuf[100];
85
} LocalData;
85
} LocalData;
86
 
86
 
87
static SEXP insertString(char *str, LocalData *l)
87
static SEXP insertString(char *str, LocalData *l)
88
{
88
{
Line 90... Line 90...
90
    if (l->con->UTF8out || l->isUTF8) enc = CE_UTF8;
90
    if (l->con->UTF8out || l->isUTF8) enc = CE_UTF8;
91
    else if (l->isLatin1) enc = CE_LATIN1;
91
    else if (l->isLatin1) enc = CE_LATIN1;
92
    return mkCharCE(str, enc);
92
    return mkCharCE(str, enc);
93
}
93
}
94
 
94
 
95
static R_INLINE Rboolean Rspace(unsigned int c)
95
static R_INLINE bool Rspace(unsigned int c)
96
{
96
{
97
    if (c == ' ' || c == '\t' || c == '\n' || c == '\r') return TRUE;
97
    if (c == ' ' || c == '\t' || c == '\n' || c == '\r') return true;
98
#ifdef Win32
98
#ifdef Win32
99
    /* 0xa0 is NBSP in all 8-bit Windows locales */
99
    /* 0xa0 is NBSP in all 8-bit Windows locales */
100
    if(!mbcslocale && c == 0xa0) return TRUE;
100
    if(!mbcslocale && c == 0xa0) return true;
101
#else
101
#else
102
     /* 0xa0 is NBSP in Latin-1 */
102
     /* 0xa0 is NBSP in Latin-1 */
103
    if(known_to_be_latin1 && c == 0xa0) return TRUE;
103
    if(known_to_be_latin1 && c == 0xa0) return true;
104
#endif
104
#endif
105
    return FALSE;
105
    return false;
106
}
106
}
107
 
107
 
108
 
108
 
109
/* used by readline() and menu() */
109
/* used by readline() and menu() */
110
static int ConsoleGetchar(void)
110
static int ConsoleGetchar(void)
Line 159... Line 159...
159
    if (errno == ERANGE) res = NA_INTEGER;
159
    if (errno == ERANGE) res = NA_INTEGER;
160
    return (int) res;
160
    return (int) res;
161
}
161
}
162
 
162
 
163
static double
163
static double
164
Strtod (const char *nptr, char **endptr, Rboolean NA, LocalData *d)
164
Strtod (const char *nptr, char **endptr, bool NA, LocalData *d)
165
{
165
{
166
    return R_strtod4(nptr, endptr, d->decchar, NA);
166
    return R_strtod4(nptr, endptr, d->decchar, NA);
167
}
167
}
168
 
168
 
169
static Rcomplex
169
static Rcomplex
170
strtoc(const char *nptr, char **endptr, Rboolean NA, LocalData *d)
170
strtoc(const char *nptr, char **endptr, bool NA, LocalData *d)
171
{
171
{
172
    Rcomplex z;
172
    Rcomplex z;
173
    double x, y;
173
    double x, y;
174
    char *s, *endp;
174
    char *s, *endp;
175
 
175
 
Line 221... Line 221...
221
	if(d->skipNul) {
221
	if(d->skipNul) {
222
	    do {
222
	    do {
223
		c = (d->ttyflag) ? ConsoleGetcharWithPushBack(d->con) :
223
		c = (d->ttyflag) ? ConsoleGetcharWithPushBack(d->con) :
224
		    Rconn_fgetc(d->con);
224
		    Rconn_fgetc(d->con);
225
	    } while(c == 0);
225
	    } while(c == 0);
226
	} else d->embedWarn = TRUE;
226
	} else d->embedWarn = true;
227
    }
227
    }
228
    return c;
228
    return c;
229
}
229
}
230
 
230
 
231
static R_INLINE void unscanchar(int c, LocalData *d)
231
static R_INLINE void unscanchar(int c, LocalData *d)
Line 245... Line 245...
245
    } else
245
    } else
246
	next = scanchar_raw(d);
246
	next = scanchar_raw(d);
247
    return next;
247
    return next;
248
}
248
}
249
 
249
 
250
static int scanchar(Rboolean inQuote, LocalData *d)
250
static int scanchar(bool inQuote, LocalData *d)
251
{
251
{
252
    int next;
252
    int next;
253
    if (d->save) {
253
    if (d->save) {
254
	next = d->save;
254
	next = d->save;
255
	d->save = 0;
255
	d->save = 0;
Line 338... Line 338...
338
 
338
 
339
   bch is used to distinguish \r, \n and EOF from more input available.
339
   bch is used to distinguish \r, \n and EOF from more input available.
340
*/
340
*/
341
    char *bufp;
341
    char *bufp;
342
    int c, quote, filled, nbuf = MAXELTSIZE, m, mm = 0;
342
    int c, quote, filled, nbuf = MAXELTSIZE, m, mm = 0;
343
    Rboolean dbcslocale = (R_MB_CUR_MAX == 2) && !d->isUTF8 && !d->isLatin1;
343
    bool dbcslocale = (R_MB_CUR_MAX == 2) && !d->isUTF8 && !d->isLatin1;
344
 
344
 
345
    m = 0;
345
    m = 0;
346
    filled = 1;
346
    filled = 1;
347
    if (d->sepchar == 0) {
347
    if (d->sepchar == 0) {
348
	/* skip all space or tabs: only look at lead bytes here */
348
	/* skip all space or tabs: only look at lead bytes here */
349
	strip = 0; /* documented to be ignored in this case */
349
	strip = 0; /* documented to be ignored in this case */
350
	while ((c = scanchar(FALSE, d)) == ' ' || c == '\t') ;
350
	while ((c = scanchar(false, d)) == ' ' || c == '\t') ;
351
	if (c == '\n' || c == '\r' || c == R_EOF) {
351
	if (c == '\n' || c == '\r' || c == R_EOF) {
352
	    filled = c;
352
	    filled = c;
353
	    goto donefill;
353
	    goto donefill;
354
	}
354
	}
355
	if ((type == STRSXP || type == NILSXP) && strchr(d->quoteset, c)) {
355
	if ((type == STRSXP || type == NILSXP) && strchr(d->quoteset, c)) {
356
	    quote = c;
356
	    quote = c;
357
	    while ((c = scanchar(TRUE, d)) != R_EOF && c != quote) {
357
	    while ((c = scanchar(true, d)) != R_EOF && c != quote) {
358
		if (m >= nbuf - 3) {
358
		if (m >= nbuf - 3) {
359
		    nbuf *= 2;
359
		    nbuf *= 2;
360
		    R_AllocStringBuffer(nbuf, buffer);
360
		    R_AllocStringBuffer(nbuf, buffer);
361
		}
361
		}
362
		if (c == '\\') {
362
		if (c == '\\') {
363
		    /* If this is an embedded quote, unquote it, but
363
		    /* If this is an embedded quote, unquote it, but
364
		       otherwise keep backslashes */
364
		       otherwise keep backslashes */
365
		    c = scanchar(TRUE, d);
365
		    c = scanchar(true, d);
366
		    if (c == R_EOF) break;
366
		    if (c == R_EOF) break;
367
		    if(c != quote) buffer->data[m++] = '\\';
367
		    if(c != quote) buffer->data[m++] = '\\';
368
		}
368
		}
369
		buffer->data[m++] = (char) c;
369
		buffer->data[m++] = (char) c;
370
		if(dbcslocale && btowc(c) == WEOF)
370
		if(dbcslocale && btowc(c) == WEOF)
371
		    buffer->data[m++] = (char) scanchar2(d);
371
		    buffer->data[m++] = (char) scanchar2(d);
372
	    }
372
	    }
373
	    if (c == R_EOF)
373
	    if (c == R_EOF)
374
		warning(_("EOF within quoted string"));
374
		warning(_("EOF within quoted string"));
375
	    c = scanchar(FALSE, d);
375
	    c = scanchar(false, d);
376
	    mm = m;
376
	    mm = m;
377
	}
377
	}
378
	else { /* not a quoted char string */
378
	else { /* not a quoted char string */
379
	    do {
379
	    do {
380
		if (m >= nbuf - 3) {
380
		if (m >= nbuf - 3) {
Line 382... Line 382...
382
		    R_AllocStringBuffer(nbuf, buffer);
382
		    R_AllocStringBuffer(nbuf, buffer);
383
		}
383
		}
384
		buffer->data[m++] = (char) c;
384
		buffer->data[m++] = (char) c;
385
		if(dbcslocale && btowc(c) == WEOF)
385
		if(dbcslocale && btowc(c) == WEOF)
386
		    buffer->data[m++] = (char) scanchar2(d);
386
		    buffer->data[m++] = (char) scanchar2(d);
387
		c = scanchar(FALSE, d);
387
		c = scanchar(false, d);
388
	    } while (!Rspace(c) && c != R_EOF);
388
	    } while (!Rspace(c) && c != R_EOF);
389
	}
389
	}
390
	/* skip all space or tabs: only look at lead bytes here */
390
	/* skip all space or tabs: only look at lead bytes here */
391
	while (c == ' ' || c == '\t') c = scanchar(FALSE, d);
391
	while (c == ' ' || c == '\t') c = scanchar(false, d);
392
	if (c == '\n' || c == '\r' || c == R_EOF)
392
	if (c == '\n' || c == '\r' || c == R_EOF)
393
	    filled = c;
393
	    filled = c;
394
	else
394
	else
395
	    unscanchar(c, d);
395
	    unscanchar(c, d);
396
    }
396
    }
397
    else { /* have separator */
397
    else { /* have separator */
398
	while ((c = scanchar(FALSE, d)) != d->sepchar &&
398
	while ((c = scanchar(false, d)) != d->sepchar &&
399
	       c != '\n' && c != '\r' && c != R_EOF)
399
	       c != '\n' && c != '\r' && c != R_EOF)
400
	    {
400
	    {
401
		/* eat white space */
401
		/* eat white space */
402
		if (type != STRSXP)
402
		if (type != STRSXP)
403
		    while (c == ' ' || c == '\t')
403
		    while (c == ' ' || c == '\t')
404
			if ((c = scanchar(FALSE, d)) == d->sepchar
404
			if ((c = scanchar(false, d)) == d->sepchar
405
			    || c == '\n' || c == '\r' || c == R_EOF) {
405
			    || c == '\n' || c == '\r' || c == R_EOF) {
406
			    filled = c;
406
			    filled = c;
407
			    goto donefill;
407
			    goto donefill;
408
			}
408
			}
409
		/* CSV style quoted string handling */
409
		/* CSV style quoted string handling */
410
		if ((type == STRSXP || type == NILSXP)
410
		if ((type == STRSXP || type == NILSXP)
411
		    && c != 0 && strchr(d->quoteset, c)) {
411
		    && c != 0 && strchr(d->quoteset, c)) {
412
		    quote = c;
412
		    quote = c;
413
		inquote:
413
		inquote:
414
		    while ((c = scanchar(TRUE, d)) != R_EOF && c != quote) {
414
		    while ((c = scanchar(true, d)) != R_EOF && c != quote) {
415
			if (m >= nbuf - 3) {
415
			if (m >= nbuf - 3) {
416
			    nbuf *= 2;
416
			    nbuf *= 2;
417
			    R_AllocStringBuffer(nbuf, buffer);
417
			    R_AllocStringBuffer(nbuf, buffer);
418
			}
418
			}
419
			buffer->data[m++] = (char) c;
419
			buffer->data[m++] = (char) c;
420
			if(dbcslocale && btowc(c) == WEOF)
420
			if(dbcslocale && btowc(c) == WEOF)
421
			    buffer->data[m++] = (char) scanchar2(d);
421
			    buffer->data[m++] = (char) scanchar2(d);
422
		    }
422
		    }
423
		    if (c == R_EOF)
423
		    if (c == R_EOF)
424
			warning(_("EOF within quoted string"));
424
			warning(_("EOF within quoted string"));
425
		    c = scanchar(TRUE, d); /* only peek at lead byte
425
		    c = scanchar(true, d); /* only peek at lead byte
426
					      unless ASCII */
426
					      unless ASCII */
427
		    if (c == quote) {
427
		    if (c == quote) {
428
			if (m >= nbuf - 3) {
428
			if (m >= nbuf - 3) {
429
			    nbuf *= 2;
429
			    nbuf *= 2;
430
			    R_AllocStringBuffer(nbuf, buffer);
430
			    R_AllocStringBuffer(nbuf, buffer);
Line 464... Line 464...
464
    *bufp = '\0';
464
    *bufp = '\0';
465
    /* Remove UTF-8 BOM */
465
    /* Remove UTF-8 BOM */
466
    if(d->atStart && utf8locale &&
466
    if(d->atStart && utf8locale &&
467
       !strncmp(buffer->data, "\xef\xbb\xbf", 3))
467
       !strncmp(buffer->data, "\xef\xbb\xbf", 3))
468
	memmove(buffer->data, buffer->data+3, strlen(buffer->data) + 1);
468
	memmove(buffer->data, buffer->data+3, strlen(buffer->data) + 1);
469
    d->atStart = FALSE;
469
    d->atStart = false;
470
    *bch = filled;
470
    *bch = filled;
471
    return buffer->data;
471
    return buffer->data;
472
}
472
}
473
 
473
 
474
/* If mode = 0 use for numeric fields where "" is NA
474
/* If mode = 0 use for numeric fields where "" is NA
Line 486... Line 486...
486
 
486
 
487
NORET static R_INLINE void expected(char *what, char *got, LocalData *d)
487
NORET static R_INLINE void expected(char *what, char *got, LocalData *d)
488
{
488
{
489
    int c;
489
    int c;
490
    if (d->ttyflag) { /* This is safe in a MBCS */
490
    if (d->ttyflag) { /* This is safe in a MBCS */
491
	while ((c = scanchar(FALSE, d)) != R_EOF && c != '\n')
491
	while ((c = scanchar(false, d)) != R_EOF && c != '\n')
492
	    ;
492
	    ;
493
    }
493
    }
494
    error(_("scan() expected '%s', got '%s'"), what, got);
494
    error(_("scan() expected '%s', got '%s'"), what, got);
495
}
495
}
496
 
496
 
Line 520... Line 520...
520
	break;
520
	break;
521
    case REALSXP:
521
    case REALSXP:
522
	if (isNAstring(buffer, 0, d))
522
	if (isNAstring(buffer, 0, d))
523
	    REAL(ans)[i] = NA_REAL;
523
	    REAL(ans)[i] = NA_REAL;
524
	else {
524
	else {
525
	    REAL(ans)[i] = Strtod(buffer, &endp, FALSE, d);
525
	    REAL(ans)[i] = Strtod(buffer, &endp, false, d);
526
	    if (!isBlankString(endp))
526
	    if (!isBlankString(endp))
527
		expected("a real", buffer, d);
527
		expected("a real", buffer, d);
528
	}
528
	}
529
	break;
529
	break;
530
    case CPLXSXP:
530
    case CPLXSXP:
531
	if (isNAstring(buffer, 0, d))
531
	if (isNAstring(buffer, 0, d))
532
	    COMPLEX(ans)[i].r = COMPLEX(ans)[i].i = NA_REAL;
532
	    COMPLEX(ans)[i].r = COMPLEX(ans)[i].i = NA_REAL;
533
	else {
533
	else {
534
	    COMPLEX(ans)[i] = strtoc(buffer, &endp, FALSE, d);
534
	    COMPLEX(ans)[i] = strtoc(buffer, &endp, false, d);
535
	    if (!isBlankString(endp))
535
	    if (!isBlankString(endp))
536
		expected("a complex", buffer, d);
536
		expected("a complex", buffer, d);
537
	}
537
	}
538
	break;
538
	break;
539
    case STRSXP:
539
    case STRSXP:
Line 616... Line 616...
616
	else {
616
	else {
617
	    extractItem(buffer, ans, n, d);
617
	    extractItem(buffer, ans, n, d);
618
	    ic--;
618
	    ic--;
619
	    if (++n == maxitems) {
619
	    if (++n == maxitems) {
620
		if (d->ttyflag && bch != '\n') { /* MBCS-safe */
620
		if (d->ttyflag && bch != '\n') { /* MBCS-safe */
621
		    while ((c = scanchar(FALSE, d)) != '\n')
621
		    while ((c = scanchar(false, d)) != '\n')
622
			;
622
			;
623
		}
623
		}
624
		break;
624
		break;
625
	    }
625
	    }
626
	}
626
	}
627
	if (flush && (bch != '\n') && (bch != R_EOF)) { /* MBCS-safe */
627
	if (flush && (bch != '\n') && (bch != R_EOF)) { /* MBCS-safe */
628
	    while ((c = scanchar(FALSE, d)) != '\n' && (c != R_EOF));
628
	    while ((c = scanchar(false, d)) != '\n' && (c != R_EOF));
629
	    bch = c;
629
	    bch = c;
630
	}
630
	}
631
    }
631
    }
632
    if (!d->quiet)
632
    if (!d->quiet)
633
	REprintf("Read %lld item%s\n", (long long) n, (n == 1) ? "" : "s");
633
	REprintf("Read %lld item%s\n", (long long) n, (n == 1) ? "" : "s");
Line 717... Line 717...
717
    if (d->ttyflag)
717
    if (d->ttyflag)
718
	snprintf(ConsolePrompt, CONSOLE_PROMPT_SIZE, "1: ");
718
	snprintf(ConsolePrompt, CONSOLE_PROMPT_SIZE, "1: ");
719
 
719
 
720
    // we checked its type in do_scan
720
    // we checked its type in do_scan
721
    int *lstrip = LOGICAL(stripwhite);
721
    int *lstrip = LOGICAL(stripwhite);
722
    Rboolean vec_strip = (xlength(stripwhite) == xlength(what));
722
    bool vec_strip = (xlength(stripwhite) == xlength(what));
723
    strip = lstrip[0];
723
    strip = lstrip[0];
724
 
724
 
725
    ic = 999;
725
    ic = 999;
726
    for (;;) {
726
    for (;;) {
727
	if(!ic) {
727
	if(!ic) {
Line 788... Line 788...
788
	    if (colsread == nc) {
788
	    if (colsread == nc) {
789
		n++;
789
		n++;
790
		ii = 0;
790
		ii = 0;
791
		colsread = 0;
791
		colsread = 0;
792
		if (flush && (bch != '\n') && (bch != R_EOF)) { /* MBCS-safe */
792
		if (flush && (bch != '\n') && (bch != R_EOF)) { /* MBCS-safe */
793
		    while ((c = scanchar(FALSE, d)) != '\n' && c != R_EOF);
793
		    while ((c = scanchar(false, d)) != '\n' && c != R_EOF);
794
		    bch = c;
794
		    bch = c;
795
		}
795
		}
796
	    }
796
	    }
797
	}
797
	}
798
    }
798
    }
Line 853... Line 853...
853
    SEXP ans, file, sep, what, stripwhite, dec, quotes, comstr;
853
    SEXP ans, file, sep, what, stripwhite, dec, quotes, comstr;
854
    int c, flush, fill, blskip, multiline, escapes, skipNul;
854
    int c, flush, fill, blskip, multiline, escapes, skipNul;
855
    R_xlen_t nmax, nlines, nskip;
855
    R_xlen_t nmax, nlines, nskip;
856
    const char *p, *encoding;
856
    const char *p, *encoding;
857
    RCNTXT cntxt;
857
    RCNTXT cntxt;
858
    LocalData data = {NULL, 0, 0, '.', NULL, NO_COMCHAR, 0, NULL, FALSE,
858
    LocalData data = {NULL, 0, 0, '.', NULL, NO_COMCHAR, 0, NULL, false,
859
		      FALSE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, {FALSE}};
859
		      false, 0, false, false, false, false, false, {false}};
860
    data.NAstrings = R_NilValue;
860
    data.NAstrings = R_NilValue;
861
 
861
 
862
    checkArity(op, args);
862
    checkArity(op, args);
863
 
863
 
864
    file = CAR(args);		   args = CDR(args);
864
    file = CAR(args);		   args = CDR(args);
Line 879... Line 879...
879
    comstr = CAR(args);            args = CDR(args);
879
    comstr = CAR(args);            args = CDR(args);
880
    escapes = asLogical(CAR(args));args = CDR(args);
880
    escapes = asLogical(CAR(args));args = CDR(args);
881
    if(!isString(CAR(args)) || LENGTH(CAR(args)) != 1)
881
    if(!isString(CAR(args)) || LENGTH(CAR(args)) != 1)
882
	error(_("invalid '%s' argument"), "encoding");
882
	error(_("invalid '%s' argument"), "encoding");
883
    encoding = CHAR(STRING_ELT(CAR(args), 0)); args = CDR(args); /* ASCII */
883
    encoding = CHAR(STRING_ELT(CAR(args), 0)); args = CDR(args); /* ASCII */
884
    if(streql(encoding, "latin1")) data.isLatin1 = TRUE;
884
    if(streql(encoding, "latin1")) data.isLatin1 = true;
885
    if(streql(encoding, "UTF-8"))  data.isUTF8 = TRUE;
885
    if(streql(encoding, "UTF-8"))  data.isUTF8 = true;
886
    skipNul = asLogical(CAR(args));
886
    skipNul = asLogical(CAR(args));
887
 
887
 
888
    if (data.quiet == NA_LOGICAL)		data.quiet = 0;
888
    if (data.quiet == NA_LOGICAL)		data.quiet = 0;
889
    if (blskip == NA_LOGICAL)			blskip = 1;
889
    if (blskip == NA_LOGICAL)			blskip = 1;
890
    if (multiline == NA_LOGICAL)		multiline = 1;
890
    if (multiline == NA_LOGICAL)		multiline = 1;
Line 954... Line 954...
954
    data.skipNul = skipNul != 0;
954
    data.skipNul = skipNul != 0;
955
 
955
 
956
    int ii = asInteger(file);
956
    int ii = asInteger(file);
957
    data.con = getConnection(ii);
957
    data.con = getConnection(ii);
958
    if(ii == 0) {
958
    if(ii == 0) {
959
	data.atStart = FALSE;
959
	data.atStart = false;
960
	data.ttyflag = 1;
960
	data.ttyflag = 1;
961
    } else {
961
    } else {
962
	data.atStart = (nskip == 0);
962
	data.atStart = (nskip == 0);
963
	data.ttyflag = 0;
963
	data.ttyflag = 0;
964
	data.wasopen = data.con->isopen;
964
	data.wasopen = data.con->isopen;
965
	if(!data.wasopen) {
965
	if(!data.wasopen) {
966
	    data.con->UTF8out = TRUE;  /* a request */
966
	    data.con->UTF8out = true;  /* a request */
967
	    strcpy(data.con->mode, "r");
967
	    strcpy(data.con->mode, "r");
968
	    if(!data.con->open(data.con))
968
	    if(!data.con->open(data.con))
969
		error(_("cannot open the connection"));
969
		error(_("cannot open the connection"));
970
	    if(!data.con->canread) {
970
	    if(!data.con->canread) {
971
		data.con->close(data.con);
971
		data.con->close(data.con);
Line 975... Line 975...
975
	    if(!data.con->canread)
975
	    if(!data.con->canread)
976
		error(_("cannot read from this connection"));
976
		error(_("cannot read from this connection"));
977
	}
977
	}
978
	for(R_xlen_t i = 0, j = 10000; i < nskip; i++) { /* MBCS-safe */
978
	for(R_xlen_t i = 0, j = 10000; i < nskip; i++) { /* MBCS-safe */
979
	    for(;;) {
979
	    for(;;) {
980
		c = scanchar(FALSE, &data);
980
		c = scanchar(false, &data);
981
		if (!j--) {
981
		if (!j--) {
982
		    R_CheckUserInterrupt();
982
		    R_CheckUserInterrupt();
983
		    j = 10000;
983
		    j = 10000;
984
		}
984
		}
985
		if (c == '\n' || c == R_EOF)
985
		if (c == '\n' || c == R_EOF)
Line 1015... Line 1015...
1015
    /* we might have a character that was unscanchar-ed.
1015
    /* we might have a character that was unscanchar-ed.
1016
       So pushback if possible */
1016
       So pushback if possible */
1017
    if (data.save && !data.ttyflag && data.wasopen) {
1017
    if (data.save && !data.ttyflag && data.wasopen) {
1018
	char line[2] = " ";
1018
	char line[2] = " ";
1019
	line[0] = (char) data.save;
1019
	line[0] = (char) data.save;
1020
	con_pushback(data.con, FALSE, line);
1020
	con_pushback(data.con, false, line);
1021
    }
1021
    }
1022
    if (!data.ttyflag && !data.wasopen)
1022
    if (!data.ttyflag && !data.wasopen)
1023
	data.con->close(data.con);
1023
	data.con->close(data.con);
1024
    if (data.quoteset[0]) free(data.quoteset);
1024
    if (data.quoteset[0]) free(data.quoteset);
1025
    if (!skipNul && data.embedWarn)
1025
    if (!skipNul && data.embedWarn)