Skip to content

Commit

Permalink
Merge pull request #14 from khwilliamson/mime
Browse files Browse the repository at this point in the history
MIME-Base64: Rmv EBCDIC-dependent code
  • Loading branch information
mbeijen authored Jan 9, 2025
2 parents e28a691 + f4ed665 commit 7ba8c20
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 279 deletions.
10 changes: 1 addition & 9 deletions Base64.xs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ static const unsigned char index_64[256] = {
# define SvPVbyte SvPV
#endif

#ifndef isXDIGIT
# define isXDIGIT isxdigit
#endif

#ifndef NATIVE_TO_ASCII
# define NATIVE_TO_ASCII(ch) (ch)
#endif
Expand Down Expand Up @@ -301,11 +297,7 @@ decoded_base64_length(sv)

MODULE = MIME::Base64 PACKAGE = MIME::QuotedPrint

#ifdef EBCDIC
#define qp_isplain(c) ((c) == '\t' || ((!isprint(c) && (c) != '=')))
#else
#define qp_isplain(c) ((c) == '\t' || (((c) >= ' ' && (c) <= '~') && (c) != '='))
#endif
#define qp_isplain(c) ((c) == '\t' || (isPRINT(c) && (c) != '='))

SV*
encode_qp(sv,...)
Expand Down
6 changes: 4 additions & 2 deletions t/base64.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ BEGIN {
if (ord('A') == 0x41) {
*ASCII = sub { return $_[0] };
}
else {
else { # Translating to ASCII has the effect of showing that this test file
# verifies that arbitrary binary input acts the same on both
# platforms.
require Encode;
*ASCII = sub { Encode::encode('ascii',$_[0]) };
*ASCII = sub { return Encode::encode('ascii',$_[0]); };
}
}

Expand Down
7 changes: 4 additions & 3 deletions t/base64url.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

use strict;
use warnings;
use Test qw(plan ok);
use Test qw(plan ok skip);

use MIME::Base64 qw(encode_base64url decode_base64url);

my @tests;

while (<DATA>) {
next if /^#/;
chomp;
Expand All @@ -18,8 +19,8 @@ plan tests => 2 * @tests;
for (@tests) {
my($name, $input, $output) = @$_;
print "# $name\n";
ok(decode_base64url($input), $output);
ok(encode_base64url($output), $input);
skip(ord("A") != 65 ? "ASCII-centric test" : 0, decode_base64url($input), $output);
skip(ord("A") != 65 ? "ASCII-centric test" : 0, encode_base64url($output), $input);
}

__END__
Expand Down
Loading

0 comments on commit 7ba8c20

Please sign in to comment.