summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-07-23 10:48:20 -0600
committerKarl Williamson <public@khwilliamson.com>2013-08-01 13:01:42 -0600
commitad3f05adb1975f100a1e610eaa5eb43099c3063d (patch)
tree96e569759c3c1ce62c0d9d9492620f97593085eb /regcomp.c
parent41c407bcf550c4e19a5b20e9ac26ad65a405d4e2 (diff)
downloadperl-ad3f05adb1975f100a1e610eaa5eb43099c3063d.tar.gz
Extend sv_dump() to dump SVt_INVLIST
This changes the previously unused _invlist_dump() function to be called from sv_dump() to dump inversion list scalars. The format for regular SVt_PVs doesn't give human-friendly output for these. Since these lists are currently not visible outside the Perl core, the format is documented only in comments in the function itself.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/regcomp.c b/regcomp.c
index 32830544f6..eac30510e5 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -8293,40 +8293,54 @@ Perl__invlist_contents(pTHX_ SV* const invlist)
}
#endif
-#ifdef PERL_ARGS_ASSERT__INVLIST_DUMP
void
-Perl__invlist_dump(pTHX_ SV* const invlist, const char * const header)
+Perl__invlist_dump(pTHX_ PerlIO *file, I32 level, const char * const indent, SV* const invlist)
{
- /* Dumps out the ranges in an inversion list. The string 'header'
- * if present is output on a line before the first range */
+ /* Designed to be called only by do_sv_dump(). Dumps out the ranges of the
+ * inversion list 'invlist' to 'file' at 'level' Each line is prefixed by
+ * the string 'indent'. The output looks like this:
+ [0] 0x000A .. 0x000D
+ [2] 0x0085
+ [4] 0x2028 .. 0x2029
+ [6] 0x3104 .. INFINITY
+ * This means that the first range of code points matched by the list are
+ * 0xA through 0xD; the second range contains only the single code point
+ * 0x85, etc. An inversion list is an array of UVs. Two array elements
+ * are used to define each range (except if the final range extends to
+ * infinity, only a single element is needed). The array index of the
+ * first element for the corresponding range is given in brackets. */
UV start, end;
+ STRLEN count = 0;
PERL_ARGS_ASSERT__INVLIST_DUMP;
- if (header && strlen(header)) {
- PerlIO_printf(Perl_debug_log, "%s\n", header);
- }
if (invlist_is_iterating(invlist)) {
- PerlIO_printf(Perl_debug_log, "Can't dump because is in middle of iterating\n");
+ Perl_dump_indent(aTHX_ level, file,
+ "%sCan't dump inversion list because is in middle of iterating\n",
+ indent);
return;
}
invlist_iterinit(invlist);
while (invlist_iternext(invlist, &start, &end)) {
if (end == UV_MAX) {
- PerlIO_printf(Perl_debug_log, "0x%04"UVXf" .. INFINITY\n", start);
+ Perl_dump_indent(aTHX_ level, file,
+ "%s[%d] 0x%04"UVXf" .. INFINITY\n",
+ indent, count, start);
}
else if (end != start) {
- PerlIO_printf(Perl_debug_log, "0x%04"UVXf" .. 0x%04"UVXf"\n",
- start, end);
+ Perl_dump_indent(aTHX_ level, file,
+ "%s[%d] 0x%04"UVXf" .. 0x%04"UVXf"\n",
+ indent, count, start, end);
}
else {
- PerlIO_printf(Perl_debug_log, "0x%04"UVXf"\n", start);
+ Perl_dump_indent(aTHX_ level, file, "%s[%d] 0x%04"UVXf"\n",
+ indent, count, start);
}
+ count += 2;
}
}
-#endif
#ifdef PERL_ARGS_ASSERT__INVLISTEQ
bool