diff options
author | Simon Cozens <simon@netthink.co.uk> | 2001-05-12 18:58:41 +0100 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-05-25 12:24:45 +0000 |
commit | ac7cd81aae231be8bd5734f1506e627995fef570 (patch) | |
tree | 1afabad86fa3c13ab376d2b27373051baf9ff235 /pp.c | |
parent | e66fb0c202c476a67c63915139a2545b39101339 (diff) | |
download | perl-ac7cd81aae231be8bd5734f1506e627995fef570.tar.gz |
Based on
Subject: [PATCH pp.c] Wrapping pack("C",256)
Message-ID: <20010512175841.A6132@netthink.co.uk>
p4raw-id: //depot/perl@10209
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -5465,9 +5465,26 @@ PP(pp_pack) case 'c': while (len-- > 0) { fromstr = NEXTFROM; - aint = SvIV(fromstr); - achar = aint; - sv_catpvn(cat, &achar, sizeof(char)); + switch (datumtype) { + case 'C': + aint = SvIV(fromstr); + if ((aint < 0 || aint > 255) && + ckWARN(WARN_PACK)) + Perl_warner(aTHX_ WARN_PACK, + "Character in \"C\" format wrapped"); + achar = aint & 255; + sv_catpvn(cat, &achar, sizeof(char)); + break; + case 'c': + aint = SvIV(fromstr); + if ((aint < -128 || aint > 127) && + ckWARN(WARN_PACK)) + Perl_warner(aTHX_ WARN_PACK, + "Character in \"c\" format wrapped"); + achar = aint & 255; + sv_catpvn(cat, &achar, sizeof(char)); + break; + } } break; case 'U': |