The R Project SVN R

Rev

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

Rev 52152 Rev 52666
Line 970... Line 970...
970
	    last = TRUE;
970
	    last = TRUE;
971
	    break;
971
	    break;
972
	default:
972
	default:
973
	    last = FALSE;
973
	    last = FALSE;
974
	}
974
	}
-
 
975
    if (!last) line_len = max(line_len, nc);  /* the unterminated last might be the longest */
975
    n = max(cnt_n, cnt_r) + (last ? 0 : 1);
976
    n = max(cnt_n, cnt_r) + (last ? 0 : 1);
976
    if (cnt_n == 0 && cnt_r > 0) eol = '\r';
977
    if (cnt_n == 0 && cnt_r > 0) eol = '\r';
977
    if (cnt_r == cnt_n) CRLF = TRUE;
978
    if (cnt_r == cnt_n) CRLF = TRUE;
978
    /* over-allocate a line buffer */
979
    /* over-allocate a line buffer */
979
    line = R_chk_calloc(1+(line_len ? line_len :nc), 1);
980
    line = R_chk_calloc(1+line_len, 1);
980
    PROTECT(ans = allocVector(STRSXP, n));
981
    PROTECT(ans = allocVector(STRSXP, n));
981
    for(p = s, q = line, nl = 0; *p; p++) {
982
    for(p = s, q = line, nl = 0; *p; p++) {
982
	if (*p == eol) {
983
	if (*p == eol) {
983
	    *q = '\0';
984
	    *q = '\0';
984
	    SET_STRING_ELT(ans, nl++, mkCharCE(line, ienc));
985
	    SET_STRING_ELT(ans, nl++, mkCharCE(line, ienc));