The R Project SVN R

Rev

Rev 77340 | Rev 77541 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 77340 Rev 77341
Line 494... Line 494...
494
{
494
{
495
    int c;
495
    int c;
496
    Rboolean checkBOM = FALSE, checkBOM8 = FALSE;
496
    Rboolean checkBOM = FALSE, checkBOM8 = FALSE;
497
 
497
 
498
    if(con->inconv) {
498
    if(con->inconv) {
499
	if(con->navail <= 0) {
499
	while(con->navail <= 0) {
-
 
500
	    /* Probably in all cases there will be at most one iteration
-
 
501
	       of the loop. It could iterate multiple times only if the input
-
 
502
	       encoding could have \r or \n as a part of a multi-byte coded
-
 
503
	       character.
-
 
504
	    */
500
	    unsigned int i, inew = 0;
505
	    unsigned int i, inew = 0;
501
	    char *p, *ob;
506
	    char *p, *ob;
502
	    const char *ib;
507
	    const char *ib;
503
	    size_t inb, onb, res;
508
	    size_t inb, onb, res;
504
 
509
 
Line 519... Line 524...
519
		    c = con->fgetc_internal(con);
524
		    c = con->fgetc_internal(con);
520
		if(c == R_EOF){ con->EOF_signalled = TRUE; break; }
525
		if(c == R_EOF){ con->EOF_signalled = TRUE; break; }
521
		*p++ = (char) c;
526
		*p++ = (char) c;
522
		con->inavail++;
527
		con->inavail++;
523
		inew++;
528
		inew++;
-
 
529
		if(!con->buff && (c == '\n' || c == '\r'))
-
 
530
		    /* Possibly a line separator: better stop filling in the
-
 
531
		       encoding conversion buffer if not buffering the input
-
 
532
		       anyway, as not to confuse interactive applications
-
 
533
		       (PR17634).
-
 
534
		    */
-
 
535
		    break;
524
	    }
536
	    }
525
	    if(inew == 0) return R_EOF;
537
	    if(inew == 0) return R_EOF;
526
	    if(checkBOM && con->inavail >= 2 &&
538
	    if(checkBOM && con->inavail >= 2 &&
527
	       ((int)con->iconvbuff[0] & 0xff) == 255 &&
539
	       ((int)con->iconvbuff[0] & 0xff) == 255 &&
528
	       ((int)con->iconvbuff[1] & 0xff) == 254) {
540
	       ((int)con->iconvbuff[1] & 0xff) == 254) {