Unified · Split
| @@ -70,7 +70,7 @@ typedef struct { · 69 unmodified lines | |||
| 70 | 70 | ||
| 71 | typedef struct { | 71 | typedef struct { |
| 72 | int verbose; | 72 | int verbose; |
| 73 | const char *last_message; | 73 | char *last_message; |
| 74 | Jbig2Severity severity; | 74 | Jbig2Severity severity; |
| 75 | char *type; | 75 | char *type; |
| 76 | long repeats; | 76 | long repeats; |
| @@ -402,9 +402,15 @@ error_callback(void *error_callback_data, const char *message, Jbig2Severity sev · 325 unmodified lines | |||
| 402 | break; | 402 | break; |
| 403 | } | 403 | } |
| 404 | 404 | ||
| 405 | if (state->last_message == NULL || (state->last_message != NULL && strcmp(message, state->last_message) && state->severity == severity && state->type == type)) { | 405 | if (state->last_message != NULL && !strcmp(message, state->last_message) && state->severity == severity && state->type == type) { |
| 406 | if (state->repeats > 1) | 406 | state->repeats++; |
| 407 | { | 407 | if (state->repeats % 1000000 == 0) { |
| 408 | ret = fprintf(stderr, "jbig2dec %s last message repeated %ld times so far\n", state->type, state->repeats); | ||
| 409 | if (ret < 0) | ||
| 410 | goto printerror; | ||
| 411 | } | ||
| 412 | } else { | ||
| 413 | if (state->repeats > 1) { | ||
| 408 | ret = fprintf(stderr, "jbig2dec %s last message repeated %ld times\n", state->type, state->repeats); | 414 | ret = fprintf(stderr, "jbig2dec %s last message repeated %ld times\n", state->type, state->repeats); |
| 409 | if (ret < 0) | 415 | if (ret < 0) |
| 410 | goto printerror; | 416 | goto printerror; |
| @@ -417,16 +423,19 @@ error_callback(void *error_callback_data, const char *message, Jbig2Severity sev · 6 unmodified lines | |||
| 417 | if (ret < 0) | 423 | if (ret < 0) |
| 418 | goto printerror; | 424 | goto printerror; |
| 419 | 425 | ||
| 420 | state->last_message = message; | 426 | state->repeats = 0; |
| 421 | state->severity = severity; | 427 | state->severity = severity; |
| 422 | state->type = type; | 428 | state->type = type; |
| 423 | state->repeats = 0; | 429 | free(state->last_message); |
| 424 | } else if (state->last_message != NULL) { | 430 | state->last_message = NULL; |
| 425 | state->repeats++; | 431 | |
| 426 | if (state->repeats % 1000000 == 0) { | 432 | if (message) { |
| 427 | ret = fprintf(stderr, "jbig2dec %s last message repeated %ld times so far\n", state->type, state->repeats); | 433 | state->last_message = strdup(message); |
| 428 | if (ret < 0) | 434 | if (state->last_message == NULL) { |
| 429 | goto printerror; | 435 | ret = fprintf(stderr, "jbig2dec WARNING could not duplicate message\n"); |
| 436 | if (ret < 0) | ||
| 437 | goto printerror; | ||
| 438 | } | ||
| 430 | } | 439 | } |
| 431 | } | 440 | } |
| 432 | 441 | ||
| @@ -434,8 +443,9 @@ error_callback(void *error_callback_data, const char *message, Jbig2Severity sev · 1 unmodified line | |||
| 434 | 443 | ||
| 435 | printerror: | 444 | printerror: |
| 436 | fprintf(stderr, "jbig2dec WARNING could not print message\n"); | 445 | fprintf(stderr, "jbig2dec WARNING could not print message\n"); |
| 437 | state->last_message = NULL; | ||
| 438 | state->repeats = 0; | 446 | state->repeats = 0; |
| 447 | free(state->last_message); | ||
| 448 | state->last_message = NULL; | ||
| 439 | } | 449 | } |
| 440 | 450 | ||
| 441 | static void | 451 | static void |
| @@ -559,6 +569,12 @@ main(int argc, char **argv) · 117 unmodified lines | |||
| 559 | 569 | ||
| 560 | filearg = parse_options(argc, argv, ¶ms); | 570 | filearg = parse_options(argc, argv, ¶ms); |
| 561 | 571 | ||
| 572 | error_callback_state.verbose = params.verbose; | ||
| 573 | error_callback_state.severity = JBIG2_SEVERITY_DEBUG; | ||
| 574 | error_callback_state.type = NULL; | ||
| 575 | error_callback_state.last_message = NULL; | ||
| 576 | error_callback_state.repeats = 0; | ||
| 577 | |||
| 562 | if (params.hash) | 578 | if (params.hash) |
| 563 | hash_init(¶ms); | 579 | hash_init(¶ms); |
| 564 | 580 | ||
| @@ -604,10 +620,6 @@ main(int argc, char **argv) · 39 unmodified lines | |||
| 604 | goto cleanup; | 620 | goto cleanup; |
| 605 | } | 621 | } |
| 606 | 622 | ||
| 607 | error_callback_state.verbose = params.verbose; | ||
| 608 | error_callback_state.last_message = NULL; | ||
| 609 | error_callback_state.repeats = 0; | ||
| 610 | |||
| 611 | if (params.memory_limit == 0) | 623 | if (params.memory_limit == 0) |
| 612 | allocator = NULL; | 624 | allocator = NULL; |
| 613 | else | 625 | else |
| @@ -759,6 +771,8 @@ cleanup: · 145 unmodified lines | |||
| 759 | jbig2_ctx_free(ctx); | 771 | jbig2_ctx_free(ctx); |
| 760 | if (params.output_filename) | 772 | if (params.output_filename) |
| 761 | free(params.output_filename); | 773 | free(params.output_filename); |
| 774 | if (error_callback_state.last_message) | ||
| 775 | free(error_callback_state.last_message); | ||
| 762 | if (params.hash) | 776 | if (params.hash) |
| 763 | hash_free(¶ms); | 777 | hash_free(¶ms); |
| 764 | 778 | ||