Compare commits
5 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d01b831aa | ||
|
|
0d2e791e82 | ||
|
|
71fe947ff5 | ||
|
|
beb2a595f1 | ||
|
|
0fbc3c0c84 |
3 changed files with 42 additions and 16 deletions
|
|
@ -80,7 +80,7 @@ std::cout << \"1s is \"<< std::chrono::duration_cast<std::chrono::milliseconds>(
|
|||
set( TEST_NULLPTR "
|
||||
#include <cstddef>
|
||||
std::nullptr_t f() {return nullptr;}
|
||||
int main() {return !!f();}
|
||||
int main() {return !(f() == f());}
|
||||
" )
|
||||
cmake_push_check_state()
|
||||
if( UNIX )
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ void ErrorDescriptor::PrependToUserMsg( const char * msg ) {
|
|||
}
|
||||
|
||||
void ErrorDescriptor::AppendToUserMsg( const char c ) {
|
||||
_userMsg.append( &c );
|
||||
_userMsg.push_back( c );
|
||||
}
|
||||
|
||||
void ErrorDescriptor::AppendToUserMsg( const char * msg ) {
|
||||
|
|
@ -147,7 +147,7 @@ void ErrorDescriptor::PrependToDetailMsg( const char * msg ) {
|
|||
}
|
||||
|
||||
void ErrorDescriptor::AppendToDetailMsg( const char c ) {
|
||||
_detailMsg.append( &c );
|
||||
_detailMsg.push_back( c );
|
||||
}
|
||||
|
||||
void ErrorDescriptor::AppendToDetailMsg( const char * msg ) {
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@
|
|||
#include "express/info.h"
|
||||
#include "express/linklist.h"
|
||||
|
||||
#if defined( _WIN32 ) || defined ( __WIN32__ )
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
bool __ERROR_buffer_errors = false;
|
||||
const char * current_filename = "stdin";
|
||||
|
|
@ -112,6 +115,7 @@ static struct heap_element {
|
|||
static int ERROR_with_lines = 0; /**< number of warnings & errors that have occurred with a line number */
|
||||
static char * ERROR_string;
|
||||
static char * ERROR_string_base;
|
||||
static char * ERROR_string_end;
|
||||
|
||||
static bool ERROR_unsafe = false;
|
||||
static jmp_buf ERROR_safe_env;
|
||||
|
|
@ -119,6 +123,34 @@ static jmp_buf ERROR_safe_env;
|
|||
|
||||
#define error_file stderr /**< message buffer file */
|
||||
|
||||
static int ERROR_vprintf( const char *format, va_list ap ) {
|
||||
int result = snprintf( ERROR_string, ERROR_string_end - ERROR_string, format, ap );
|
||||
if(result < 0) {
|
||||
ERROR_string = ERROR_string_end;
|
||||
} else if(result > (ERROR_string_end - ERROR_string)) {
|
||||
ERROR_string = ERROR_string_end;
|
||||
} else {
|
||||
ERROR_string = ERROR_string + result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int ERROR_printf( const char *format, ... ) {
|
||||
int result;
|
||||
va_list ap;
|
||||
va_start( ap, format );
|
||||
result = ERROR_vprintf( format, ap );
|
||||
va_end( ap );
|
||||
return result;
|
||||
}
|
||||
|
||||
static void ERROR_nexterror() {
|
||||
if( ERROR_string == ERROR_string_end ) {
|
||||
return;
|
||||
}
|
||||
ERROR_string++;
|
||||
}
|
||||
|
||||
/** Initialize the Error module */
|
||||
void ERRORinitialize( void ) {
|
||||
ERROR_subordinate_failed =
|
||||
|
|
@ -127,6 +159,7 @@ void ERRORinitialize( void ) {
|
|||
ERRORcreate( "%s, expecting %s in %s %s", SEVERITY_EXIT );
|
||||
|
||||
ERROR_string_base = ( char * )sc_malloc( ERROR_MAX_SPACE );
|
||||
ERROR_string_end = ERROR_string_base + ERROR_MAX_SPACE;
|
||||
ERROR_start_message_buffer();
|
||||
|
||||
|
||||
|
|
@ -377,20 +410,14 @@ va_dcl {
|
|||
heap[child].msg = ERROR_string;
|
||||
|
||||
if( what->severity >= SEVERITY_ERROR ) {
|
||||
sprintf( ERROR_string, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, what->serial );
|
||||
ERROR_string += strlen( ERROR_string );
|
||||
vsprintf( ERROR_string, what->message, args );
|
||||
ERROR_string += strlen( ERROR_string );
|
||||
*ERROR_string++ = '\n';
|
||||
*ERROR_string++ = '\0';
|
||||
ERROR_printf( "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, what->serial );
|
||||
ERROR_vprintf( what->message, args );
|
||||
ERROR_nexterror();
|
||||
ERRORoccurred = true;
|
||||
} else {
|
||||
sprintf( ERROR_string, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial );
|
||||
ERROR_string += strlen( ERROR_string );
|
||||
vsprintf( ERROR_string, what->message, args );
|
||||
ERROR_string += strlen( ERROR_string );
|
||||
*ERROR_string++ = '\n';
|
||||
*ERROR_string++ = '\0';
|
||||
ERROR_printf( "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial );
|
||||
ERROR_vprintf( what->message, args );
|
||||
ERROR_nexterror();
|
||||
}
|
||||
if( what->severity >= SEVERITY_EXIT ||
|
||||
ERROR_string + ERROR_MAX_STRLEN > ERROR_string_base + ERROR_MAX_SPACE ||
|
||||
|
|
@ -410,7 +437,6 @@ va_dcl {
|
|||
ERRORoccurred = true;
|
||||
} else {
|
||||
fprintf( error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial );
|
||||
ERROR_string += strlen( ERROR_string ) + 1;
|
||||
vfprintf( error_file, what->message, args );
|
||||
fprintf( error_file, "\n" );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue