# define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \
if (regex_emacs_debug > 0) print_double_string (w, s1, sz1, s2, sz2)
+static void
+debug_putchar (int c)
+{
+ if (c >= 32 && c <= 126)
+ fputc (c, stderr);
+ else
+ fprintf (stderr, "{%02x}", c);
+}
/* Print the fastmap in human-readable form. */
if (fastmap[i++])
{
was_a_range = false;
- fputc (i - 1, stderr);
+ debug_putchar (i - 1);
while (i < (1 << BYTEWIDTH) && fastmap[i])
{
was_a_range = true;
if (was_a_range)
{
fprintf (stderr, "-");
- fputc (i - 1, stderr);
+ debug_putchar (i - 1);
}
}
}
fprintf (stderr, "/exactn/%d", mcnt);
do
{
- fprintf (stderr, "/%c", *p++);
+ fprintf (stderr, "/");
+ debug_putchar (*p++);
}
while (--mcnt);
break;
/* Have we broken a range? */
else if (last + 1 != c && in_range)
{
- fprintf (stderr, "%c", last);
+ debug_putchar (last);
in_range = false;
}
if (! in_range)
- fprintf (stderr, "%c", c);
+ debug_putchar (c);
last = c;
}
if (in_range)
- fprintf (stderr, "%c", last);
+ debug_putchar (last);
fprintf (stderr, "]");
fprintf (stderr, "(null)");
else
{
+ int i;
if (FIRST_STRING_P (where))
{
- fwrite_unlocked (where, 1, string1 + size1 - where, stderr);
+ for (i = 0; i < string1 + size1 - where; i++)
+ debug_putchar (where[i]);
where = string2;
}
- fwrite_unlocked (where, 1, string2 + size2 - where, stderr);
+ for (i = 0; i < string2 + size2 - where; i++)
+ debug_putchar (where[i]);
}
}
if (regex_emacs_debug > 0)
{
for (ptrdiff_t debug_count = 0; debug_count < size; debug_count++)
- fputc (pattern[debug_count], stderr);
+ debug_putchar (pattern[debug_count]);
fputc ('\n', stderr);
}
#endif
dend = end_match_1;
}
- DEBUG_PRINT ("The compiled pattern is: ");
+ DEBUG_PRINT ("The compiled pattern is:\n");
DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend);
DEBUG_PRINT ("The string to match is: \"");
DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2);