1 /* Copyright (c) 2008-2009 H.Merijn Brand. All rights reserved.
2 * This program is free software; you can redistribute it and/or
3 * modify it under the same terms as Perl itself.
12 #define NEED_pv_pretty
13 #define NEED_pv_escape
14 #define NEED_my_snprintf
27 if (pipe (err)) return (NULL);
32 if (dup (err[1]) == 2)
33 Perl_sv_dump (aTHX_ sv);
36 err[1] = dup (err[2]);
39 Perl_sv_setpvn (aTHX_ dd, "", 0);
40 while ((n = read (err[0], buf, 128)) > 0)
42 /* perl 5.8.0 did not export Perl_sv_catpvn */
43 Perl_sv_catpvn_flags (aTHX_ dd, buf, n, SV_GMAGIC);
45 Perl_sv_catpvn (aTHX_ dd, buf, n);
50 MODULE = Data::Peek PACKAGE = Data::Peek
58 ST (0) = newSVpv ("Your perl did not export Perl_sv_peek ()", 0);
68 ST (0) = newSVpv (Perl_sv_peek (aTHX_ items ? ST (0) : DEFSV), 0);
78 SV *sv = items ? ST (0) : DEFSV;
79 SV *dsp = newSVpv ("", 0);
80 if (SvPOK (sv) || SvPOKp (sv))
81 Perl_pv_pretty (aTHX_ dsp, SvPVX (sv), SvCUR (sv), 0,
83 (PERL_PV_PRETTY_DUMP | PERL_PV_ESCAPE_UNI_DETECT));
89 triplevar (pv, iv, nv)
96 SV *tv = newSVpvs ("");
97 SvUPGRADE (tv, SVt_PVNV);
99 if (SvPOK (pv) || SvPOKp (pv)) {
100 sv_setpvn (tv, SvPVX (pv), SvCUR (pv));
101 if (SvUTF8 (pv)) SvUTF8_on (tv);
104 sv_setpvn (tv, NULL, 0);
106 if (SvNOK (nv) || SvNOKp (nv)) {
107 SvNV_set (tv, SvNV (nv));
111 if (SvIOK (iv) || SvIOKp (iv)) {
112 SvIV_set (tv, SvIV (iv));
126 if (items > 1 && SvGMAGICAL (sv) && SvTRUE (ST (1)))
129 if (SvPOK (sv) || SvPOKp (sv)) {
130 SV *xv = newSVpv (SvPVX (sv), 0);
131 if (SvUTF8 (sv)) SvUTF8_on (xv);
135 PUSHs (&PL_sv_undef);
137 if (SvIOK (sv) || SvIOKp (sv))
140 PUSHs (&PL_sv_undef);
142 if (SvNOK (sv) || SvNOKp (sv))
145 PUSHs (&PL_sv_undef);
148 SV *xv = newSVsv (SvRV (sv));
152 PUSHs (&PL_sv_undef);
154 mPUSHi (SvMAGICAL (sv) >> 21);
163 SV *dd = _DDump (sv);
173 #if PERL_VERSION >= 8
176 DDump_IO (io, sv, level)
182 Perl_do_sv_dump (aTHX_ 0, io, sv, 1, level, 1, 0);