From: Gerard Goossen Date: Sun, 25 Mar 2007 13:36:31 +0000 (+0200) Subject: move the logic of combining '_' and '#' with the previous logic X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fb2b694ac153e3b2b3f9e40df708ecd1973cbf38;p=p5sagit%2Fp5-mst-13.2.git move the logic of combining '_' and '#' with the previous logic from Nomad.pm to dump.c. So they are already combined in the XML dump. Subject: [PATCH] mad: combine whitespace keys '_' '#' in dump.c instead of Nomad.pm Message-Id: <20070508170341.GH17043@ostwald> p4raw-id: //depot/perl@31207 --- diff --git a/dump.c b/dump.c index fd6af40..f6366f7 100644 --- a/dump.c +++ b/dump.c @@ -2822,6 +2822,7 @@ Perl_do_op_xmldump(pTHX_ I32 level, PerlIO *file, const OP *o) } if (PL_madskills && o->op_madprop) { + char prevkey = '\0'; SV *tmpsv = newSVpvn("", 0); MADPROP* mp = o->op_madprop; sv_utf8_upgrade(tmpsv); @@ -2836,6 +2837,10 @@ Perl_do_op_xmldump(pTHX_ I32 level, PerlIO *file, const OP *o) sv_setpvn(tmpsv,"\"",1); if (tmp) sv_catxmlpvn(tmpsv, &tmp, 1, 0); + if ((tmp == '_') || (tmp == '#')) /* '_' '#' whitespace belong to the previous token. */ + sv_catxmlpvn(tmpsv, &prevkey, 1, 0); + else + prevkey = tmp; sv_catpv(tmpsv, "\""); switch (mp->mad_type) { case MAD_NULL: diff --git a/mad/Nomad.pm b/mad/Nomad.pm index 49659a8..e425467 100755 --- a/mad/Nomad.pm +++ b/mad/Nomad.pm @@ -519,13 +519,8 @@ sub hash { for my $kid (@{$$self{Kids}}) { my ($k,$v) = $kid->pair($self, @_); $firstthing ||= $k; - if ($k =~ /^[_#]$/) { # rekey whitespace according to preceding entry - $k .= $lastthing; # (which is actually the token the whitespace is before) - } - else { - $k .= 'x' while exists $hash{$k}; - $lastthing = $k; - } + $k .= 'x' while exists $hash{$k}; + $lastthing = $k; $hash{$k} = $v; } $hash{FIRST} = $firstthing;