The R Project SVN R

Rev

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

Rev 8801 Rev 8892
Line 101... Line 101...
101
 
101
 
102
 
102
 
103
void onsigusr2()
103
void onsigusr2()
104
{
104
{
105
    inError = 1;
105
    inError = 1;
106
    
106
 
107
    if( R_CollectWarnings ) {
107
    if( R_CollectWarnings ) {
108
	inError = 2;
108
	inError = 2;
109
	REprintf("In addition: ");
109
	REprintf("In addition: ");
110
	PrintWarnings();
110
	PrintWarnings();
111
	inError = 1;
111
	inError = 1;
112
    }
112
    }
113
    
113
 
114
    
114
 
115
    if (R_Inputfile != NULL)
115
    if (R_Inputfile != NULL)
116
	fclose(R_Inputfile);
116
	fclose(R_Inputfile);
117
    R_ResetConsole();
117
    R_ResetConsole();
118
    R_FlushConsole();
118
    R_FlushConsole();
119
    R_ClearerrConsole();
119
    R_ClearerrConsole();
Line 265... Line 265...
265
{
265
{
266
    char *p, *dcall;
266
    char *p, *dcall;
267
 
267
 
268
    va_list(ap);
268
    va_list(ap);
269
 
269
 
270
    if ( inError ) {
270
    if (inError) {
271
	if( inError == 3 )
271
	if(inError == 3)
272
	    REprintf("Error during wrapup \n");
272
	    REprintf("Error during wrapup \n");
273
	jump_now();
273
	jump_now();
274
    }
274
    }
275
 
275
 
276
    if(call != R_NilValue ) {
276
    if(call != R_NilValue) {
277
	inError = 1;
277
	inError = 1;
278
	dcall = CHAR(STRING(deparse1(call, 0))[0]);
278
	dcall = CHAR(STRING(deparse1(call, 0))[0]);
279
	sprintf(errbuf, "Error in %s : ", dcall);
279
	sprintf(errbuf, "Error in %s : ", dcall);
280
	if (strlen(dcall) > LONGCALL) strcat(errbuf, "\n	");
280
	if (strlen(dcall) > LONGCALL) strcat(errbuf, "\n	");/* <- TAB */
281
    }
281
    }
282
    else
282
    else
283
	sprintf(errbuf, "Error: ");
283
	sprintf(errbuf, "Error: ");
284
 
284
 
285
    p = errbuf + strlen(errbuf);
285
    p = errbuf + strlen(errbuf);
Line 297... Line 297...
297
    SEXP res;
297
    SEXP res;
298
 
298
 
299
    checkArity(op, args);
299
    checkArity(op, args);
300
    PROTECT(res = allocVector(STRSXP, 1));
300
    PROTECT(res = allocVector(STRSXP, 1));
301
    STRING(res)[0] = mkChar(errbuf);
301
    STRING(res)[0] = mkChar(errbuf);
302
    UNPROTECT(1);    
302
    UNPROTECT(1);
303
    return res;
303
    return res;
304
}
304
}
305
 
305
 
306
void error(const char *format, ...)
306
void error(const char *format, ...)
307
{
307
{
Line 435... Line 435...
435
#endif
435
#endif
436
 
436
 
437
void do_stop(SEXP call, SEXP op, SEXP args, SEXP rho)
437
void do_stop(SEXP call, SEXP op, SEXP args, SEXP rho)
438
{
438
{
439
    RCNTXT *cptr;
439
    RCNTXT *cptr;
-
 
440
    SEXP c_call;
-
 
441
 
-
 
442
    if(asLogical(CAR(args))) {/* find context -> "Error in ..:" */
-
 
443
	cptr = R_GlobalContext->nextcontext;
-
 
444
	while ( !(cptr->callflag & CTXT_FUNCTION) && cptr->nextcontext != NULL)
-
 
445
	    cptr = cptr->nextcontext;
-
 
446
	c_call = cptr->call;
-
 
447
    }
-
 
448
    else
-
 
449
	c_call = R_NilValue;
440
 
450
 
441
    cptr = R_GlobalContext->nextcontext;
-
 
442
    while ( !(cptr->callflag & CTXT_FUNCTION) && cptr->nextcontext != NULL)
-
 
443
	cptr = cptr->nextcontext;
451
    args = CDR(args);
444
 
452
 
445
    if (CAR(args) != R_NilValue) {
453
    if (CAR(args) != R_NilValue) { /* message */
446
      CAR(args) = coerceVector(CAR(args), STRSXP);
454
      CAR(args) = coerceVector(CAR(args), STRSXP);
447
      if(!isValidString(CAR(args)))
455
      if(!isValidString(CAR(args)))
448
	  errorcall(cptr->call, " [invalid string in stop(.)]");
456
	  errorcall(c_call, " [invalid string in stop(.)]");
449
      errorcall(cptr->call, "%s", CHAR(STRING(CAR(args))[0]));
457
      errorcall(c_call, "%s", CHAR(STRING(CAR(args))[0]));
450
    }
458
    }
451
    else
459
    else
452
      errorcall(cptr->call, "");
460
      errorcall(c_call, "");
453
    /*NOTREACHED*/
-
 
454
}
461
}
455
 
462
 
456
SEXP do_warning(SEXP call, SEXP op, SEXP args, SEXP rho)
463
SEXP do_warning(SEXP call, SEXP op, SEXP args, SEXP rho)
457
{
464
{
458
    RCNTXT *cptr;
465
    RCNTXT *cptr;