The R Project SVN R

Rev

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

Rev 6206 Rev 6217
Line 236... Line 236...
236
 
236
 
237
void jump_to_toplevel()
237
void jump_to_toplevel()
238
{
238
{
239
    RCNTXT *c;
239
    RCNTXT *c;
240
    SEXP s, t;
240
    SEXP s, t;
-
 
241
    int haveHandler;
241
    int nback = 0;
242
    int nback = 0;
242
 
243
 
243
    inError = 1;
244
    inError = 1;
244
 
245
 
245
    if( R_CollectWarnings ) {
246
    if( R_CollectWarnings ) {
Line 249... Line 250...
249
	inError = 1;
250
	inError = 1;
250
    }
251
    }
251
 
252
 
252
    /*now see if options("error") is set */
253
    /*now see if options("error") is set */
253
    s = GetOption(install("error"), R_NilValue);
254
    s = GetOption(install("error"), R_NilValue);
254
    if( s != R_NilValue ) {
255
    haveHandler = ( s != R_NilValue );
-
 
256
    if (haveHandler) {
255
	if( !isLanguage(s) &&  ! isExpression(s) )  /* shouldn't happen */
257
	if( !isLanguage(s) &&  ! isExpression(s) )  /* shouldn't happen */
256
	    REprintf("invalid option \"error\"\n");
258
	    REprintf("invalid option \"error\"\n");
257
	else {
259
	else {
258
	    c = R_GlobalContext;
260
	    c = R_GlobalContext;
259
	    while ( !(c->callflag & CTXT_FUNCTION) && c->callflag )
261
	    while ( !(c->callflag & CTXT_FUNCTION) && c->callflag )
260
		c = c->nextcontext;
262
		c = c->nextcontext;
261
	    inError = 3;
263
	    inError = 3;
-
 
264
	    if (isLanguage(s))
262
	    eval(s, c->cloenv);
265
		eval(s, c->cloenv);
-
 
266
	    else /* expression */
-
 
267
            {
-
 
268
		int i, n = LENGTH(s);
-
 
269
		for (i = 0 ; i < n ; i++)
-
 
270
		    eval(VECTOR(s)[i], c->cloenv);
-
 
271
	    }
263
	    inError = 1;
272
	    inError = 1;
264
	}
273
	}
265
    }
274
    }
266
    else if ( !R_Interactive )
-
 
267
	R_CleanUp(SA_NOSAVE);
-
 
268
 
275
 
269
    if (R_Inputfile != NULL)
276
    if (R_Inputfile != NULL)
270
	fclose(R_Inputfile);
277
	fclose(R_Inputfile);
271
    R_ResetConsole();
278
    R_ResetConsole();
272
    R_FlushConsole();
279
    R_FlushConsole();
Line 283... Line 290...
283
	if (c->callflag == CTXT_RESTART) {
290
	if (c->callflag == CTXT_RESTART) {
284
		inError=0;
291
		inError=0;
285
		findcontext(CTXT_RESTART, c->cloenv, R_DollarSymbol);
292
		findcontext(CTXT_RESTART, c->cloenv, R_DollarSymbol);
286
	}
293
	}
287
    }
294
    }
-
 
295
    if ( !R_Interactive && !haveHandler && inError )
-
 
296
	R_CleanUp(SA_NOSAVE);
-
 
297
 
288
    if (R_Sinkfile) R_Outputfile = R_Sinkfile;
298
    if (R_Sinkfile) R_Outputfile = R_Sinkfile;
289
    else R_Outputfile = R_Consolefile;
299
    else R_Outputfile = R_Consolefile;
290
    PROTECT(s = allocList(nback));
300
    PROTECT(s = allocList(nback));
291
    t = s;
301
    t = s;
292
    for (c = R_GlobalContext ; c ; c = c->nextcontext)
302
    for (c = R_GlobalContext ; c ; c = c->nextcontext)