The R Project SVN R

Rev

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

Rev 60667 Rev 63200
Line 41... Line 41...
41
 
41
 
42
SEXP attribute_hidden do_readDCF(SEXP call, SEXP op, SEXP args, SEXP env)
42
SEXP attribute_hidden do_readDCF(SEXP call, SEXP op, SEXP args, SEXP env)
43
{
43
{
44
    int nwhat, nret, nc, nr, m, k, lastm, need;
44
    int nwhat, nret, nc, nr, m, k, lastm, need;
45
    Rboolean blank_skip, field_skip = FALSE;
45
    Rboolean blank_skip, field_skip = FALSE;
46
    int whatlen, dynwhat, buflen = 100;
46
    int whatlen, dynwhat, buflen = 8096; // was 100, but that re-alloced often
47
    char line[MAXELTSIZE], *buf;
47
    char line[MAXELTSIZE], *buf;
48
    regex_t blankline, contline, trailblank, regline, eblankline;
48
    regex_t blankline, contline, trailblank, regline, eblankline;
49
    regmatch_t regmatch[1];
49
    regmatch_t regmatch[1];
50
    SEXP file, what, what2, retval, retval2, dims, dimnames;
50
    SEXP file, what, what2, retval, retval2, dims, dimnames;
51
    Rconnection con = NULL;
51
    Rconnection con = NULL;
Line 213... Line 213...
213
			}
213
			}
214
			UNPROTECT_PTR(retval);
214
			UNPROTECT_PTR(retval);
215
			UNPROTECT_PTR(what);
215
			UNPROTECT_PTR(what);
216
			retval = retval2;
216
			retval = retval2;
217
			what = what2;
217
			what = what2;
218
			/* FIXME:
-
 
219
			   Why are we doing this?
-
 
220
			   We need to copy the matched beginning of the
-
 
221
			   line to buf, so shouldn't we need
218
			/* Make sure enough space was used */
222
			     regmatch[0].rm_eo
-
 
223
			   bytes?
-
 
224
			*/
-
 
225
			need = (int) strlen(line+regmatch[0].rm_eo);
219
			need = (int) (Rf_strchr(line, ':') - line + 1);
226
			if(buflen < need){
220
			if(buflen < need){
227
			    char *tmp = (char *) realloc(buf, need);
221
			    char *tmp = (char *) realloc(buf, need);
228
			    if(!tmp) {
222
			    if(!tmp) {
229
				free(buf);
223
				free(buf);
230
				error(_("could not allocate memory for 'read.dcf'"));
224
				error(_("could not allocate memory for 'read.dcf'"));