#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
# ifdef EBCDIC
# else
# endif
{
return UNI_TO_NATIVE(uv);
}
# if !defined(PERL_IMPLICIT_CONTEXT)
# define utf8_to_uvchr Perl_utf8_to_uvchr
# else
# endif
#endif /* PERL_VERSION <= 6 */
/* Changes in 5.7 series mean that now IOK is only set if scalar is
precisely integer but in 5.6 and earlier we need to do a more
complex test */
#if PERL_VERSION <= 6
#define DD_is_integer(sv) (SvIOK(sv) && (SvIsUV(val) ? SvUV(sv) == SvNV(sv) : SvIV(sv) == SvNV(sv)))
#else
#endif
/* does a string need to be protected? */
static I32
needs_quote(register char *s)
{
TOP:
if (s[0] == ':') {
if (*++s) {
if (*s++ != ':')
return 1;
}
else
return 1;
}
if (isIDFIRST(*s)) {
while (*++s)
if (!isALNUM(*s)) {
if (*s == ':')
goto TOP;
else
return 1;
}
}
else
return 1;
return 0;
}
/* count the number of "'"s and "\"s in string */
static I32
{
while (slen > 0) {
if (*s == '\'' || *s == '\\')
++ret;
++s;
--slen;
}
return ret;
}
/* returns number of chars added to escape "'"s and "\"s in s */
/* slen number of characters in s will be escaped */
/* destination must be long enough for additional chars */
static I32
{
while (slen > 0) {
switch (*s) {
case '\'':
case '\\':
*d = '\\';
++d; ++ret;
default:
*d = *s;
++d; ++s; --slen;
break;
}
}
return ret;
}
static I32
{
/* Could count 128-255 and 256+ in two variables, if we want to
be like &qquote and make a distinction. */
/* STRLEN topbit_grow = 0; bytes needed to represent chars 128-255 */
STRLEN backslashes = 0;
STRLEN single_quotes = 0;
/* this will need EBCDICification */
if (k > 127) {
/* 4: \x{} then count the number of hex digits. */
#if UVSIZE == 4
8 /* We may allocate a bit more than the minimum here. */
#else
#endif
);
} else if (k == '\\') {
backslashes++;
} else if (k == '\'') {
} else if (k == '"' || k == '$' || k == '@') {
} else {
normal++;
}
}
if (grow) {
/* We have something needing hex. 3 is ""\0 */
*r++ = '"';
if (k == '"' || k == '\\' || k == '$' || k == '@') {
*r++ = '\\';
*r++ = (char)k;
}
else if (k < 0x80)
*r++ = (char)k;
else {
/* The return value of sprintf() is unportable.
* In modern systems it returns (int) the number of characters,
* but in older systems it might return (char*) the original
* buffer, or it might even be (void). The easiest portable
* thing to do is probably use sprintf() in void context and
* then strlen(buffer) for the length. The more proper way
* would of course be to figure out the prototype of sprintf.
* --jhi */
r += strlen(r);
}
}
*r++ = '"';
} else {
/* Single quotes. */
+ qq_escapables + normal);
*r++ = '\'';
char k = *s;
if (k == '\'' || k == '\\')
*r++ = '\\';
*r++ = k;
}
*r++ = '\'';
}
*r = '\0';
j = r - rstart;
return j;
}
/* append a repeated string to an SV */
static SV *
{
else
if (n > 0) {
if (len == 1) {
start[n] = '\0';
while (n > 0)
}
else
while (n > 0) {
--n;
}
}
return sv;
}
/*
* This ought to be split into smaller functions. (it is one long function since
* it exactly parallels the perl version, which was one long thing for
* efficiency raisins.) Ugggh!
*/
static I32
{
char tmpbuf[128];
U32 i;
char *iname;
if (!val)
return 0;
if (SvGMAGICAL(val))
{
else if (i)
if (i)
(void)sv_2mortal(val);
}
else
/* if it has a name, we need to either look it up, or keep a tab
* on it so we know when we hit it later
*/
if (namelen) {
{
{
else
}
else {
}
else {
}
}
else
}
return 1;
}
else {
return 0;
}
}
else { /* store our name and continue */
}
}
else
(void)SvREFCNT_inc(val);
}
}
while (slash) {
}
return 1;
}
/* If purity is not set and maxdepth is set, then check depth:
* if we have reached maximum depth, return the string
* representation of the thing we are currently examining
* at this depth (i.e., 'Foo=ARRAY(0xdeadbeef)').
*/
return 1;
}
if (realpack) { /* we have a blessed ref */
if (indent >= 2) {
}
}
(*levelp)++;
if (realpack) { /* blessed */
} /* plain */
else {
}
}
}
/* allowing for a 24 char wide array index */
if (name[0] == '@') {
iname[0] = '$';
}
else {
/* omit "->" in $foo{bar}->[0], but not in ${$foo}->[0] */
/*if (namelen > 0
&& name[namelen-1] != ']' && name[namelen-1] != '}'
&& (namelen < 4 || (name[1] != '{' && name[2] != '{')))*/
if ((namelen > 0
|| (namelen > 4
{
}
}
}
if (svp)
else
elem = &PL_sv_undef;
if (indent >= 3) {
}
}
if (ixmax >= 0) {
}
if (name[0] == '@')
else
}
char *key;
if (name[0] == '%') {
}
else {
/* omit "->" in $foo[0]->{bar}, but not in ${$foo}->{bar} */
if ((namelen > 0
|| (namelen > 4
{
}
}
}
if (sortkeys) {
#if PERL_VERSION < 8
#else
}
# ifdef USE_LOCALE_NUMERIC
# else
# endif
#endif
}
if (i) {
}
if (! keys)
warn("Sortkeys subroutine did not return ARRAYREF\n");
}
if (keys)
}
else
/* foreach (keys %hash) */
for (i = 0; 1; i++) {
char *nkey;
char *nkey_buffer = NULL;
break;
if (i)
if (sortkeys) {
char *key;
}
else {
}
/* old logic was first to check utf8 flag, and if utf8 always
call esc_q_utf8. This caused test to break under -Mutf8,
because there even strings like 'c' have utf8 flag on.
Hence with quotekeys == 0 the XS code would still '' quote
them based on flags, whereas the perl code would not,
based on regexps.
The perl code is correct.
needs_quote() decides that anything that isn't a valid
perl identifier needs to be quoted, hence only correctly
formed strings with no characters outside [A-Za-z0-9_:]
won't need quoting. None of those characters are used in
the byte encoding of utf8, so anything with utf8
encoded characters in will need quoting. Hence strings
with utf8 encoded characters in will end up inside do_utf8
just like before, but now strings with utf8 flag set but
only ascii characters will end up in the unquoted section.
There should also be less tests for the (probably currently)
more common doesn't need quoting case.
The code is also smaller (22044 vs 22260) because I've been
able to pull the common logic out to both sides. */
if (do_utf8) {
}
else {
nkey = nkey_buffer;
nkey[0] = '\'';
if (nticks)
else
}
}
else {
}
if (indent >= 2) {
char *extra;
}
else
if (indent >= 2)
}
if (i) {
}
if (name[0] == '%')
else
}
if (purity)
warn("Encountered CODE ref, using dummy placeholder");
}
else {
}
if (realpack) { /* free blessed allocs */
if (indent >= 2) {
}
}
}
(*levelp)--;
}
else {
STRLEN i;
if (namelen) {
{
{
return 1;
}
}
else if (val != &PL_sv_undef) {
}
}
if (DD_is_integer(val)) {
else
/* Need to check to see if this is a string such as " 0".
I'm assuming from sprintf isn't going to clash with utf8.
Is this valid on EBCDIC? */
goto integer_came_from_string;
}
if (len > 10) {
/* Looks like we're on a 64 bit system. Make it a string so that
if a 32 bit system reads the number it will cope better. */
} else
}
++c; --i; /* just get the name */
c += 4;
i -= 4;
}
if (needs_quote(c)) {
r[0] = '*'; r[1] = '{'; r[2] = '\'';
i += esc_q(r+3, c, i);
i += 3;
r[i++] = '\''; r[i++] = '}';
r[i] = '\0';
}
else {
i++;
}
if (purity) {
SV *e;
I32 j;
for (j=0; j<3; j++) {
if (!e)
continue;
if (j == 0 && !SvOK(e))
continue;
{
e = newRV_inc(e);
if (indent >= 2)
sortkeys);
SvREFCNT_dec(e);
}
}
}
}
}
else {
else {
r[0] = '\'';
i += esc_q(r+1, c, i);
++i;
r[i++] = '\'';
r[i] = '\0';
}
}
}
if (idlen) {
if (deepcopy)
}
}
return 1;
}
#
#
void
Data_Dumper_Dumpxs(href, ...)
PROTOTYPE: $;$$
{
char tmpbuf[1024];
if (items < 2)
croak("Usage: Data::Dumper::Dumpxs(PACKAGE, VAL_ARY_REF, [NAME_ARY_REF])");
if (items >= 3)
if (i)
if (i)
(void)sv_2mortal(href);
}
name = sv_newmortal();
indent = 2;
quotekeys = 1;
#if 0 /* useqq currently unused */
#endif
{
/* flag to use qsortsv() for sorting hash keys */
}
}
if (todumpav)
else
imax = -1;
for (i = 0; i <= imax; ++i) {
else
val = &PL_sv_undef;
else
case SVt_PVAV:
break;
case SVt_PVHV:
break;
case SVt_PVCV:
break;
default:
break;
}
}
else
}
}
else {
}
if (indent >= 2) {
}
else
if (indent >= 2)
}
if (postlen >= 0) {
I32 i;
for (i = 0; i <= postlen; ++i) {
if (i < postlen) {
}
}
}
}
if (i < imax) /* not the last time thro ? */
}
}
}
else
croak("Call to new() method failed to return HASH ref");
}