diff options
| author | Paul Eggert | 2019-07-01 21:42:58 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-07-01 21:44:02 -0700 |
| commit | b35f378d6e7d52393f1afc32a6f9880b9240af91 (patch) | |
| tree | 6da055bb2ab8464cc183df2f9b07670797a93377 /src | |
| parent | 1a2c896aedc4a615b3c6102624326891a0481461 (diff) | |
| download | emacs-b35f378d6e7d52393f1afc32a6f9880b9240af91.tar.gz emacs-b35f378d6e7d52393f1afc32a6f9880b9240af91.zip | |
Fix regex-emacs debug format glitches
These patches affect behavior only if REGEX_EMACS_DEBUG.
* src/regex-emacs.c (debug_putchar): Use unsigned for %x.
(print_compiled_pattern, ENSURE_FAIL_STACK, PUSH_FAILURE_POINT)
(POP_FAILURE_POINT): Use %td for ptrdiff_t.
(print_compiled_pattern, regex_compile, re_match_2_internal):
Put newlines at ends of lines, not at starts of next lines.
Omit white space at line ends.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex-emacs.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/regex-emacs.c b/src/regex-emacs.c index 5887eaa30c7..ac9f91dacbc 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c | |||
| @@ -455,7 +455,10 @@ debug_putchar (int c) | |||
| 455 | if (c >= 32 && c <= 126) | 455 | if (c >= 32 && c <= 126) |
| 456 | fputc (c, stderr); | 456 | fputc (c, stderr); |
| 457 | else | 457 | else |
| 458 | fprintf (stderr, "{%02x}", c); | 458 | { |
| 459 | unsigned int uc = c; | ||
| 460 | fprintf (stderr, "{%02x}", uc); | ||
| 461 | } | ||
| 459 | } | 462 | } |
| 460 | 463 | ||
| 461 | /* Print the fastmap in human-readable form. */ | 464 | /* Print the fastmap in human-readable form. */ |
| @@ -743,7 +746,7 @@ print_compiled_pattern (struct re_pattern_buffer *bufp) | |||
| 743 | re_char *buffer = bufp->buffer; | 746 | re_char *buffer = bufp->buffer; |
| 744 | 747 | ||
| 745 | print_partial_compiled_pattern (buffer, buffer + bufp->used); | 748 | print_partial_compiled_pattern (buffer, buffer + bufp->used); |
| 746 | fprintf (stderr, "%tu bytes used/%tu bytes allocated.\n", | 749 | fprintf (stderr, "%td bytes used/%td bytes allocated.\n", |
| 747 | bufp->used, bufp->allocated); | 750 | bufp->used, bufp->allocated); |
| 748 | 751 | ||
| 749 | if (bufp->fastmap_accurate && bufp->fastmap) | 752 | if (bufp->fastmap_accurate && bufp->fastmap) |
| @@ -752,9 +755,9 @@ print_compiled_pattern (struct re_pattern_buffer *bufp) | |||
| 752 | print_fastmap (bufp->fastmap); | 755 | print_fastmap (bufp->fastmap); |
| 753 | } | 756 | } |
| 754 | 757 | ||
| 755 | fprintf (stderr, "re_nsub: %tu\t", bufp->re_nsub); | 758 | fprintf (stderr, "re_nsub: %td\t", bufp->re_nsub); |
| 756 | fprintf (stderr, "regs_alloc: %d\t", bufp->regs_allocated); | 759 | fprintf (stderr, "regs_alloc: %d\t", bufp->regs_allocated); |
| 757 | fprintf (stderr, "can_be_null: %d\t", bufp->can_be_null); | 760 | fprintf (stderr, "can_be_null: %d\n", bufp->can_be_null); |
| 758 | fflush (stderr); | 761 | fflush (stderr); |
| 759 | /* Perhaps we should print the translate table? */ | 762 | /* Perhaps we should print the translate table? */ |
| 760 | } | 763 | } |
| @@ -968,8 +971,8 @@ typedef struct | |||
| 968 | while (REMAINING_AVAIL_SLOTS <= space) { \ | 971 | while (REMAINING_AVAIL_SLOTS <= space) { \ |
| 969 | if (!GROW_FAIL_STACK (fail_stack)) \ | 972 | if (!GROW_FAIL_STACK (fail_stack)) \ |
| 970 | return -2; \ | 973 | return -2; \ |
| 971 | DEBUG_PRINT ("\n Doubled stack; size now: %tu\n", fail_stack.size); \ | 974 | DEBUG_PRINT ("\n Doubled stack; size now: %td\n", fail_stack.size); \ |
| 972 | DEBUG_PRINT (" slots available: %tu\n", REMAINING_AVAIL_SLOTS);\ | 975 | DEBUG_PRINT (" slots available: %td\n", REMAINING_AVAIL_SLOTS);\ |
| 973 | } | 976 | } |
| 974 | 977 | ||
| 975 | /* Push register NUM onto the stack. */ | 978 | /* Push register NUM onto the stack. */ |
| @@ -1058,14 +1061,14 @@ do { \ | |||
| 1058 | char *destination; \ | 1061 | char *destination; \ |
| 1059 | DEBUG_STATEMENT (nfailure_points_pushed++); \ | 1062 | DEBUG_STATEMENT (nfailure_points_pushed++); \ |
| 1060 | DEBUG_PRINT ("\nPUSH_FAILURE_POINT:\n"); \ | 1063 | DEBUG_PRINT ("\nPUSH_FAILURE_POINT:\n"); \ |
| 1061 | DEBUG_PRINT (" Before push, next avail: %tu\n", fail_stack.avail); \ | 1064 | DEBUG_PRINT (" Before push, next avail: %td\n", fail_stack.avail); \ |
| 1062 | DEBUG_PRINT (" size: %tu\n", fail_stack.size); \ | 1065 | DEBUG_PRINT (" size: %td\n", fail_stack.size); \ |
| 1063 | \ | 1066 | \ |
| 1064 | ENSURE_FAIL_STACK (NUM_NONREG_ITEMS); \ | 1067 | ENSURE_FAIL_STACK (NUM_NONREG_ITEMS); \ |
| 1065 | \ | 1068 | \ |
| 1066 | DEBUG_PRINT ("\n"); \ | 1069 | DEBUG_PRINT ("\n"); \ |
| 1067 | \ | 1070 | \ |
| 1068 | DEBUG_PRINT (" Push frame index: %tu\n", fail_stack.frame); \ | 1071 | DEBUG_PRINT (" Push frame index: %td\n", fail_stack.frame); \ |
| 1069 | PUSH_FAILURE_INT (fail_stack.frame); \ | 1072 | PUSH_FAILURE_INT (fail_stack.frame); \ |
| 1070 | \ | 1073 | \ |
| 1071 | DEBUG_PRINT (" Push string %p: \"", string_place); \ | 1074 | DEBUG_PRINT (" Push string %p: \"", string_place); \ |
| @@ -1107,8 +1110,8 @@ do { \ | |||
| 1107 | \ | 1110 | \ |
| 1108 | /* Remove failure points and point to how many regs pushed. */ \ | 1111 | /* Remove failure points and point to how many regs pushed. */ \ |
| 1109 | DEBUG_PRINT ("POP_FAILURE_POINT:\n"); \ | 1112 | DEBUG_PRINT ("POP_FAILURE_POINT:\n"); \ |
| 1110 | DEBUG_PRINT (" Before pop, next avail: %tu\n", fail_stack.avail); \ | 1113 | DEBUG_PRINT (" Before pop, next avail: %td\n", fail_stack.avail); \ |
| 1111 | DEBUG_PRINT (" size: %tu\n", fail_stack.size); \ | 1114 | DEBUG_PRINT (" size: %td\n", fail_stack.size); \ |
| 1112 | \ | 1115 | \ |
| 1113 | /* Pop the saved registers. */ \ | 1116 | /* Pop the saved registers. */ \ |
| 1114 | while (fail_stack.frame < fail_stack.avail) \ | 1117 | while (fail_stack.frame < fail_stack.avail) \ |
| @@ -1127,7 +1130,7 @@ do { \ | |||
| 1127 | DEBUG_PRINT ("\"\n"); \ | 1130 | DEBUG_PRINT ("\"\n"); \ |
| 1128 | \ | 1131 | \ |
| 1129 | fail_stack.frame = POP_FAILURE_INT (); \ | 1132 | fail_stack.frame = POP_FAILURE_INT (); \ |
| 1130 | DEBUG_PRINT (" Popping frame index: %zu\n", fail_stack.frame); \ | 1133 | DEBUG_PRINT (" Popping frame index: %td\n", fail_stack.frame); \ |
| 1131 | \ | 1134 | \ |
| 1132 | eassert (fail_stack.avail >= 0); \ | 1135 | eassert (fail_stack.avail >= 0); \ |
| 1133 | eassert (fail_stack.frame <= fail_stack.avail); \ | 1136 | eassert (fail_stack.frame <= fail_stack.avail); \ |
| @@ -2650,7 +2653,7 @@ regex_compile (re_char *pattern, ptrdiff_t size, | |||
| 2650 | if (regex_emacs_debug > 0) | 2653 | if (regex_emacs_debug > 0) |
| 2651 | { | 2654 | { |
| 2652 | re_compile_fastmap (bufp); | 2655 | re_compile_fastmap (bufp); |
| 2653 | DEBUG_PRINT ("\nCompiled pattern: \n"); | 2656 | DEBUG_PRINT ("\nCompiled pattern:\n"); |
| 2654 | print_compiled_pattern (bufp); | 2657 | print_compiled_pattern (bufp); |
| 2655 | } | 2658 | } |
| 2656 | regex_emacs_debug--; | 2659 | regex_emacs_debug--; |
| @@ -3941,7 +3944,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, | |||
| 3941 | ptrdiff_t num_regs_pushed = 0; | 3944 | ptrdiff_t num_regs_pushed = 0; |
| 3942 | #endif | 3945 | #endif |
| 3943 | 3946 | ||
| 3944 | DEBUG_PRINT ("\n\nEntering re_match_2.\n"); | 3947 | DEBUG_PRINT ("\nEntering re_match_2.\n"); |
| 3945 | 3948 | ||
| 3946 | REGEX_USE_SAFE_ALLOCA; | 3949 | REGEX_USE_SAFE_ALLOCA; |
| 3947 | 3950 | ||