Showing the changes to src/core/chuck_errmsg.cpp (1 of 37 files). Show all
Unified · Split
| @@ -51,7 +51,8 @@ t_CKBOOL anyErrors= FALSE; · 50 unmodified lines | ||
| 51 | 51 | // local global |
| 52 | 52 | static const char * fileName = ""; |
| 53 | 53 | static int lineNum = 1; |
| 54 | −static char g_buffer[1024] = ""; | |
| 54 | +#define CK_ERR_BUF_LENGTH 1024 | |
| 55 | +static char g_buffer[CK_ERR_BUF_LENGTH] = ""; | |
| 55 | 56 | static const size_t LASTERROR_SIZE = 1024; |
| 56 | 57 | static char g_lasterror[LASTERROR_SIZE] = "[chuck]: (no error)"; |
| 57 | 58 | static size_t g_lasterrorIndex = strlen(g_lasterror); |
| @@ -367,7 +368,7 @@ static const char * g_str[] = { · 309 unmodified lines | ||
| 367 | 368 | |
| 368 | 369 | |
| 369 | 370 | // intList |
| 370 | −typedef struct intList {int i; struct intList *rest;} *IntList; | |
| 371 | +typedef struct intList {t_CKINT i; struct intList *rest;} *IntList; | |
| 371 | 372 | static IntList linePos=NULL; |
| 372 | 373 | |
| 373 | 374 | |
| @@ -387,7 +388,7 @@ static int lastErrorCat(const char * str) · 13 unmodified lines | ||
| 387 | 388 | |
| 388 | 389 | |
| 389 | 390 | // constructor |
| 390 | −static IntList intList( int i, IntList rest ) | |
| 391 | +static IntList intList( t_CKINT i, IntList rest ) | |
| 391 | 392 | { |
| 392 | 393 | IntList l = (IntList)checked_malloc(sizeof *l); |
| 393 | 394 | l->i=i; l->rest=rest; |
| @@ -431,7 +432,7 @@ void EM_reset_msg() · 37 unmodified lines | ||
| 431 | 432 | } |
| 432 | 433 | |
| 433 | 434 | // [%s]:line(%d).char(%d): |
| 434 | −void EM_error( int pos, const char * message, ... ) | |
| 435 | +void EM_error( t_CKINT pos, const char * message, ... ) | |
| 435 | 436 | { |
| 436 | 437 | va_list ap; |
| 437 | 438 | IntList lines = linePos; |
| @@ -448,12 +449,12 @@ void EM_error( int pos, const char * message, ... ) · 10 unmodified lines | ||
| 448 | 449 | if( g_lasterror[0] != '\0' ) lastErrorCat( "\n" ); |
| 449 | 450 | |
| 450 | 451 | CK_FPRINTF_STDERR( "[%s]:", *fileName ? mini(fileName) : "chuck" ); |
| 451 | − sprintf( g_buffer, "[%s]:", *fileName ? mini(fileName) : "chuck" ); | |
| 452 | + snprintf( g_buffer, CK_ERR_BUF_LENGTH, "[%s]:", *fileName ? mini(fileName) : "chuck" ); | |
| 452 | 453 | lastErrorCat( g_buffer ); |
| 453 | 454 | if(lines) |
| 454 | 455 | { |
| 455 | 456 | CK_FPRINTF_STDERR( "line(%d).char(%d):", num, pos-lines->i ); |
| 456 | − sprintf( g_buffer, "line(%d).char(%d):", num, pos-lines->i ); | |
| 457 | + snprintf( g_buffer, CK_ERR_BUF_LENGTH, "line(%d).char(%d):", num, (int)(pos-lines->i) ); | |
| 457 | 458 | lastErrorCat( g_buffer ); |
| 458 | 459 | } |
| 459 | 460 | CK_FPRINTF_STDERR( " " ); |
| @@ -464,7 +465,7 @@ void EM_error( int pos, const char * message, ... ) · 4 unmodified lines | ||
| 464 | 465 | va_end(ap); |
| 465 | 466 | |
| 466 | 467 | va_start(ap, message); |
| 467 | − vsprintf( g_buffer, message, ap ); | |
| 468 | + vsnprintf( g_buffer, CK_ERR_BUF_LENGTH, message, ap ); | |
| 468 | 469 | va_end(ap); |
| 469 | 470 | |
| 470 | 471 | CK_FPRINTF_STDERR( "\n"); |
| @@ -474,7 +475,7 @@ void EM_error( int pos, const char * message, ... ) · 3 unmodified lines | ||
| 474 | 475 | |
| 475 | 476 | |
| 476 | 477 | // [%s]:line(%d): |
| 477 | −void EM_error2( int line, const char * message, ... ) | |
| 478 | +void EM_error2( t_CKINT line, const char * message, ... ) | |
| 478 | 479 | { |
| 479 | 480 | va_list ap; |
| 480 | 481 | |
| @@ -484,12 +485,12 @@ void EM_error2( int line, const char * message, ... ) · 3 unmodified lines | ||
| 484 | 485 | if( g_lasterror[0] != '\0' ) lastErrorCat( "\n" ); |
| 485 | 486 | |
| 486 | 487 | CK_FPRINTF_STDERR( "[%s]:", *fileName ? mini(fileName) : "chuck" ); |
| 487 | − sprintf( g_buffer, "[%s]:", *fileName ? mini(fileName) : "chuck" ); | |
| 488 | + snprintf( g_buffer, CK_ERR_BUF_LENGTH, "[%s]:", *fileName ? mini(fileName) : "chuck" ); | |
| 488 | 489 | lastErrorCat( g_buffer ); |
| 489 | 490 | if(line) |
| 490 | 491 | { |
| 491 | − CK_FPRINTF_STDERR( "line(%d):", line ); | |
| 492 | − sprintf( g_buffer, "line(%d):", line ); | |
| 492 | + CK_FPRINTF_STDERR( "line(%d):", (int)line ); | |
| 493 | + snprintf( g_buffer, CK_ERR_BUF_LENGTH, "line(%d):", (int)line ); | |
| 493 | 494 | lastErrorCat( g_buffer ); |
| 494 | 495 | } |
| 495 | 496 | CK_FPRINTF_STDERR( " " ); |
| @@ -500,7 +501,7 @@ void EM_error2( int line, const char * message, ... ) · 4 unmodified lines | ||
| 500 | 501 | va_end( ap ); |
| 501 | 502 | |
| 502 | 503 | va_start( ap, message ); |
| 503 | − vsprintf( g_buffer, message, ap ); | |
| 504 | + vsnprintf( g_buffer, CK_ERR_BUF_LENGTH, message, ap ); | |
| 504 | 505 | va_end( ap ); |
| 505 | 506 | |
| 506 | 507 | lastErrorCat( g_buffer ); |
| @@ -510,7 +511,7 @@ void EM_error2( int line, const char * message, ... ) · 3 unmodified lines | ||
| 510 | 511 | |
| 511 | 512 | |
| 512 | 513 | // [%s]:line(%d): |
| 513 | −void EM_error2b( int line, const char * message, ... ) | |
| 514 | +void EM_error2b( t_CKINT line, const char * message, ... ) | |
| 514 | 515 | { |
| 515 | 516 | va_list ap; |
| 516 | 517 | |
| @@ -520,12 +521,12 @@ void EM_error2b( int line, const char * message, ... ) · 3 unmodified lines | ||
| 520 | 521 | if( g_lasterror[0] != '\0' ) lastErrorCat( "\n" ); |
| 521 | 522 | |
| 522 | 523 | CK_FPRINTF_STDERR( "[%s]:", *fileName ? mini(fileName) : "chuck" ); |
| 523 | − sprintf( g_buffer, "[%s]:", *fileName ? mini(fileName) : "chuck" ); | |
| 524 | + snprintf( g_buffer, CK_ERR_BUF_LENGTH, "[%s]:", *fileName ? mini(fileName) : "chuck" ); | |
| 524 | 525 | lastErrorCat( g_buffer ); |
| 525 | 526 | if(line) |
| 526 | 527 | { |
| 527 | − CK_FPRINTF_STDERR( "line(%d):", line ); | |
| 528 | − sprintf( g_buffer, "line(%d):", line ); | |
| 528 | + CK_FPRINTF_STDERR( "line(%d):", (int)line ); | |
| 529 | + snprintf( g_buffer, CK_ERR_BUF_LENGTH, "line(%d):", (int)line ); | |
| 529 | 530 | lastErrorCat( g_buffer ); |
| 530 | 531 | } |
| 531 | 532 | CK_FPRINTF_STDERR( " " ); |
| @@ -536,7 +537,7 @@ void EM_error2b( int line, const char * message, ... ) · 4 unmodified lines | ||
| 536 | 537 | va_end( ap ); |
| 537 | 538 | |
| 538 | 539 | va_start( ap, message ); |
| 539 | − vsprintf( g_buffer, message, ap ); | |
| 540 | + vsnprintf( g_buffer, CK_ERR_BUF_LENGTH, message, ap ); | |
| 540 | 541 | va_end( ap ); |
| 541 | 542 | |
| 542 | 543 | lastErrorCat( g_buffer ); |
| @@ -561,7 +562,7 @@ void EM_error3( const char * message, ... ) · 18 unmodified lines | ||
| 561 | 562 | va_end( ap ); |
| 562 | 563 | |
| 563 | 564 | va_start( ap, message ); |
| 564 | − vsprintf( g_buffer, message, ap ); | |
| 565 | + vsnprintf( g_buffer, CK_ERR_BUF_LENGTH, message, ap ); | |
| 565 | 566 | va_end( ap ); |
| 566 | 567 | |
| 567 | 568 | lastErrorCat( g_buffer ); |