diff options
author | Slaven Rezic <slaven@rezic.de> | 1998-08-01 15:38:03 +0200 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-08-02 06:56:37 +0000 |
commit | 6c1ab3c2c17f75c79d85b1f973965af56233f51c (patch) | |
tree | 7a7c8f09a6d1f1c440693efef85bf186b0e92fd5 /ext | |
parent | 1e66bd8391da19cb804ff0fbe538706d2b0fc7fa (diff) | |
download | perl-6c1ab3c2c17f75c79d85b1f973965af56233f51c.tar.gz |
fix quoting of keys with embedded nulls
Message-Id: <199808011138.NAA05189@mail.cs.tu-berlin.de>
Subject: Data::Dumper 2.09, patch
p4raw-id: //depot/maint-5.005/perl@1706
Diffstat (limited to 'ext')
-rw-r--r-- | ext/Data/Dumper/Dumper.xs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ext/Data/Dumper/Dumper.xs b/ext/Data/Dumper/Dumper.xs index 6add52fe0f..d8012eec5b 100644 --- a/ext/Data/Dumper/Dumper.xs +++ b/ext/Data/Dumper/Dumper.xs @@ -5,7 +5,7 @@ static SV *freezer; static SV *toaster; -static I32 num_q _((char *s)); +static I32 num_q _((char *s, STRLEN slen)); static I32 esc_q _((char *dest, char *src, STRLEN slen)); static SV *sv_x _((SV *sv, char *str, STRLEN len, I32 n)); static I32 DD_dump _((SV *val, char *name, STRLEN namelen, SV *retval, @@ -42,14 +42,15 @@ TOP: /* count the number of "'"s and "\"s in string */ static I32 -num_q(register char *s) +num_q(register char *s, register STRLEN slen) { register I32 ret = 0; - - while (*s) { + + while (slen > 0) { if (*s == '\'' || *s == '\\') ++ret; ++s; + --slen; } return ret; } @@ -380,7 +381,7 @@ DD_dump(SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv, hval = hv_iterval((HV*)ival, entry); if (quotekeys || needs_quote(key)) { - nticks = num_q(key); + nticks = num_q(key, klen); New(0, nkey, klen+nticks+3, char); nkey[0] = '\''; if (nticks) |