The R Project SVN R

Rev

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

Rev 63481 Rev 64828
Line 1... Line 1...
1
/*
1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  Copyright (C) 1995--2013  The R Core Team.
3
 *  Copyright (C) 1995--2014  The R Core Team.
4
 *
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
6
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
8
 *  (at your option) any later version.
Line 52... Line 52...
52
*/
52
*/
53
static int inError = 0;
53
static int inError = 0;
54
static int inWarning = 0;
54
static int inWarning = 0;
55
static int inPrintWarnings = 0;
55
static int inPrintWarnings = 0;
56
static int immediateWarning = 0;
56
static int immediateWarning = 0;
-
 
57
static int noBreakWarning = 0;
57
 
58
 
58
static void try_jump_to_restart(void);
59
static void try_jump_to_restart(void);
59
// The next is crucial to the use of NORET attributes.
60
// The next is crucial to the use of NORET attributes.
60
static void NORET
61
static void NORET
61
jump_to_top_ex(Rboolean, Rboolean, Rboolean, Rboolean, Rboolean);
62
jump_to_top_ex(Rboolean, Rboolean, Rboolean, Rboolean, Rboolean);
Line 354... Line 355...
354
	Rvsnprintf(buf, min(BUFSIZE, R_WarnLength+1), format, ap);
355
	Rvsnprintf(buf, min(BUFSIZE, R_WarnLength+1), format, ap);
355
	if(R_WarnLength < BUFSIZE - 20 && strlen(buf) == R_WarnLength)
356
	if(R_WarnLength < BUFSIZE - 20 && strlen(buf) == R_WarnLength)
356
	    strcat(buf, " [... truncated]");
357
	    strcat(buf, " [... truncated]");
357
	if(dcall[0] == '\0')
358
	if(dcall[0] == '\0')
358
	    REprintf(_("Warning: %s\n"), buf);
359
	    REprintf(_("Warning: %s\n"), buf);
359
	else if(mbcslocale &&
360
	else if(noBreakWarning || 
360
		18 + wd(dcall) + wd(buf) <= LONGWARN)
361
		(mbcslocale && 18 + wd(dcall) + wd(buf) <= LONGWARN) ||
361
	    REprintf(_("Warning in %s : %s\n"), dcall, buf);
-
 
362
	else if(18+strlen(dcall)+strlen(buf) <= LONGWARN)
362
		(!mbcslocale && 18+strlen(dcall)+strlen(buf) <= LONGWARN) )
363
	    REprintf(_("Warning in %s : %s\n"), dcall, buf);
363
	    REprintf(_("Warning in %s : %s\n"), dcall, buf);
364
	else
364
	else
365
	    REprintf(_("Warning in %s :\n  %s\n"), dcall, buf);
365
	    REprintf(_("Warning in %s :\n  %s\n"), dcall, buf);
366
	if(R_ShowWarnCalls && call != R_NilValue) {
366
	if(R_ShowWarnCalls && call != R_NilValue) {
367
	    tr = R_ConciseTraceback(call, 0);
367
	    tr = R_ConciseTraceback(call, 0);
Line 1149... Line 1149...
1149
    if(asLogical(CAR(args))) { /* immediate = TRUE */
1149
    if(asLogical(CAR(args))) { /* immediate = TRUE */
1150
	immediateWarning = 1;
1150
	immediateWarning = 1;
1151
    } else
1151
    } else
1152
	immediateWarning = 0;
1152
	immediateWarning = 0;
1153
    args = CDR(args);
1153
    args = CDR(args);
-
 
1154
    if(asLogical(CAR(args))) { /* noBreak = TRUE */
-
 
1155
	noBreakWarning = 1;
-
 
1156
    } else
-
 
1157
	noBreakWarning = 0;
-
 
1158
    args = CDR(args);
1154
    if (CAR(args) != R_NilValue) {
1159
    if (CAR(args) != R_NilValue) {
1155
	SETCAR(args, coerceVector(CAR(args), STRSXP));
1160
	SETCAR(args, coerceVector(CAR(args), STRSXP));
1156
	if(!isValidString(CAR(args)))
1161
	if(!isValidString(CAR(args)))
1157
	    warningcall(c_call, _(" [invalid string in warning(.)]"));
1162
	    warningcall(c_call, _(" [invalid string in warning(.)]"));
1158
	else
1163
	else
1159
	    warningcall(c_call, "%s", translateChar(STRING_ELT(CAR(args), 0)));
1164
	    warningcall(c_call, "%s", translateChar(STRING_ELT(CAR(args), 0)));
1160
    }
1165
    }
1161
    else
1166
    else
1162
	warningcall(c_call, "");
1167
	warningcall(c_call, "");
1163
    immediateWarning = 0; /* reset to internal calls */
1168
    immediateWarning = 0; /* reset to internal calls */
-
 
1169
    noBreakWarning = 0;
1164
 
1170
 
1165
    return CAR(args);
1171
    return CAR(args);
1166
}
1172
}
1167
 
1173
 
1168
/* Error recovery for incorrect argument count error. */
1174
/* Error recovery for incorrect argument count error. */