diff options
| author | Mattias EngdegÄrd | 2019-06-28 10:14:32 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2019-06-28 13:27:10 +0200 |
| commit | 821725580720f9974b87189fe950435818a17e39 (patch) | |
| tree | 0a157ca619464b1c15f0557c3a9fc59b6a7c3609 /src | |
| parent | a7682bce3cfc7661acf6f395c0558f2202b4d78d (diff) | |
| download | emacs-821725580720f9974b87189fe950435818a17e39.tar.gz emacs-821725580720f9974b87189fe950435818a17e39.zip | |
Consistently use stderr for debug output in regexp code
* src/regex-emacs.c (DEBUG_PRINT, print_fastmap, print_compiled_pattern)
(print_double_string, regex_compile): Print to stderr instead of stdout.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex-emacs.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/regex-emacs.c b/src/regex-emacs.c index 4cb17037c26..47ee6647482 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c | |||
| @@ -441,7 +441,8 @@ extract_number_and_incr (re_char **source) | |||
| 441 | static int regex_emacs_debug = -100000; | 441 | static int regex_emacs_debug = -100000; |
| 442 | 442 | ||
| 443 | # define DEBUG_STATEMENT(e) e | 443 | # define DEBUG_STATEMENT(e) e |
| 444 | # define DEBUG_PRINT(...) if (regex_emacs_debug > 0) printf (__VA_ARGS__) | 444 | # define DEBUG_PRINT(...) \ |
| 445 | if (regex_emacs_debug > 0) fprintf (stderr, __VA_ARGS__) | ||
| 445 | # define DEBUG_COMPILES_ARGUMENTS | 446 | # define DEBUG_COMPILES_ARGUMENTS |
| 446 | # define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ | 447 | # define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ |
| 447 | if (regex_emacs_debug > 0) print_partial_compiled_pattern (s, e) | 448 | if (regex_emacs_debug > 0) print_partial_compiled_pattern (s, e) |
| @@ -462,7 +463,7 @@ print_fastmap (char *fastmap) | |||
| 462 | if (fastmap[i++]) | 463 | if (fastmap[i++]) |
| 463 | { | 464 | { |
| 464 | was_a_range = false; | 465 | was_a_range = false; |
| 465 | putchar (i - 1); | 466 | fputc (i - 1, stderr); |
| 466 | while (i < (1 << BYTEWIDTH) && fastmap[i]) | 467 | while (i < (1 << BYTEWIDTH) && fastmap[i]) |
| 467 | { | 468 | { |
| 468 | was_a_range = true; | 469 | was_a_range = true; |
| @@ -470,12 +471,12 @@ print_fastmap (char *fastmap) | |||
| 470 | } | 471 | } |
| 471 | if (was_a_range) | 472 | if (was_a_range) |
| 472 | { | 473 | { |
| 473 | printf ("-"); | 474 | fprintf (stderr, "-"); |
| 474 | putchar (i - 1); | 475 | fputc (i - 1, stderr); |
| 475 | } | 476 | } |
| 476 | } | 477 | } |
| 477 | } | 478 | } |
| 478 | putchar ('\n'); | 479 | fputc ('\n', stderr); |
| 479 | } | 480 | } |
| 480 | 481 | ||
| 481 | 482 | ||
| @@ -733,19 +734,19 @@ print_compiled_pattern (struct re_pattern_buffer *bufp) | |||
| 733 | re_char *buffer = bufp->buffer; | 734 | re_char *buffer = bufp->buffer; |
| 734 | 735 | ||
| 735 | print_partial_compiled_pattern (buffer, buffer + bufp->used); | 736 | print_partial_compiled_pattern (buffer, buffer + bufp->used); |
| 736 | printf ("%tu bytes used/%tu bytes allocated.\n", | 737 | fprintf (stderr, "%tu bytes used/%tu bytes allocated.\n", |
| 737 | bufp->used, bufp->allocated); | 738 | bufp->used, bufp->allocated); |
| 738 | 739 | ||
| 739 | if (bufp->fastmap_accurate && bufp->fastmap) | 740 | if (bufp->fastmap_accurate && bufp->fastmap) |
| 740 | { | 741 | { |
| 741 | printf ("fastmap: "); | 742 | fprintf (stderr, "fastmap: "); |
| 742 | print_fastmap (bufp->fastmap); | 743 | print_fastmap (bufp->fastmap); |
| 743 | } | 744 | } |
| 744 | 745 | ||
| 745 | printf ("re_nsub: %tu\t", bufp->re_nsub); | 746 | fprintf (stderr, "re_nsub: %tu\t", bufp->re_nsub); |
| 746 | printf ("regs_alloc: %d\t", bufp->regs_allocated); | 747 | fprintf (stderr, "regs_alloc: %d\t", bufp->regs_allocated); |
| 747 | printf ("can_be_null: %d\t", bufp->can_be_null); | 748 | fprintf (stderr, "can_be_null: %d\t", bufp->can_be_null); |
| 748 | fflush (stdout); | 749 | fflush (stderr); |
| 749 | /* Perhaps we should print the translate table? */ | 750 | /* Perhaps we should print the translate table? */ |
| 750 | } | 751 | } |
| 751 | 752 | ||
| @@ -755,16 +756,16 @@ print_double_string (re_char *where, re_char *string1, ptrdiff_t size1, | |||
| 755 | re_char *string2, ptrdiff_t size2) | 756 | re_char *string2, ptrdiff_t size2) |
| 756 | { | 757 | { |
| 757 | if (where == NULL) | 758 | if (where == NULL) |
| 758 | printf ("(null)"); | 759 | fprintf (stderr, "(null)"); |
| 759 | else | 760 | else |
| 760 | { | 761 | { |
| 761 | if (FIRST_STRING_P (where)) | 762 | if (FIRST_STRING_P (where)) |
| 762 | { | 763 | { |
| 763 | fwrite_unlocked (where, 1, string1 + size1 - where, stdout); | 764 | fwrite_unlocked (where, 1, string1 + size1 - where, stderr); |
| 764 | where = string2; | 765 | where = string2; |
| 765 | } | 766 | } |
| 766 | 767 | ||
| 767 | fwrite_unlocked (where, 1, string2 + size2 - where, stdout); | 768 | fwrite_unlocked (where, 1, string2 + size2 - where, stderr); |
| 768 | } | 769 | } |
| 769 | } | 770 | } |
| 770 | 771 | ||
| @@ -1734,8 +1735,8 @@ regex_compile (re_char *pattern, ptrdiff_t size, | |||
| 1734 | if (regex_emacs_debug > 0) | 1735 | if (regex_emacs_debug > 0) |
| 1735 | { | 1736 | { |
| 1736 | for (ptrdiff_t debug_count = 0; debug_count < size; debug_count++) | 1737 | for (ptrdiff_t debug_count = 0; debug_count < size; debug_count++) |
| 1737 | putchar (pattern[debug_count]); | 1738 | fputc (pattern[debug_count], stderr); |
| 1738 | putchar ('\n'); | 1739 | fputc ('\n', stderr); |
| 1739 | } | 1740 | } |
| 1740 | #endif | 1741 | #endif |
| 1741 | 1742 | ||