From 0b4417c63f524ab9a456c1c9a6b97dc9e7bd797c Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 17 Aug 2012 08:41:32 -0700 Subject: [PATCH 01/34] Add a failing test for #813 reported by @donaldxs --- t/library/mime_base64.t | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/t/library/mime_base64.t b/t/library/mime_base64.t index 940087a6ed..aaae645238 100644 --- a/t/library/mime_base64.t +++ b/t/library/mime_base64.t @@ -24,12 +24,13 @@ Test cases taken from base64.t of MIME::Base64. load_bytecode 'PGE/Util.pbc' load_language 'data_json' - .local pmc plan, is, ok - plan = get_hll_global [ 'Test'; 'More' ], 'plan' - is = get_hll_global [ 'Test'; 'More' ], 'is' - ok = get_hll_global [ 'Test'; 'More' ], 'ok' + .local pmc plan, is, ok, lives_ok + plan = get_hll_global [ 'Test'; 'More' ], 'plan' + is = get_hll_global [ 'Test'; 'More' ], 'is' + ok = get_hll_global [ 'Test'; 'More' ], 'ok' + lives_ok = get_hll_global [ 'Test'; 'More' ], 'lives_ok' - plan(550) + plan(551) .local pmc json json = compreg 'data_json' @@ -370,6 +371,16 @@ END_JSON goto dec_loop dec_loop_end: + lives_ok(<<'CODE', 'enc_sub with utf8 GH#813') +.sub foo + .local pmc enc_sub + enc_sub = get_global [ "MIME"; "Base64" ], 'encode_base64' + + .local string result_encode + result_encode = enc_sub(utf8:"\x{203e}") +.end +CODE + .end .sub test_encode @@ -408,6 +419,7 @@ END_JSON is( result_decode, plain, comment ) .end + =head1 AUTHOR Bernhard Schmalhofer and others. From 07d53a065905428d76f4f116acf57de30ff2c390 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 18 Aug 2012 09:39:43 -0700 Subject: [PATCH 02/34] Improve and refactor failing #813 enc_sub test --- t/library/mime_base64.t | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/t/library/mime_base64.t b/t/library/mime_base64.t index aaae645238..66a03fa1f9 100644 --- a/t/library/mime_base64.t +++ b/t/library/mime_base64.t @@ -28,7 +28,6 @@ Test cases taken from base64.t of MIME::Base64. plan = get_hll_global [ 'Test'; 'More' ], 'plan' is = get_hll_global [ 'Test'; 'More' ], 'is' ok = get_hll_global [ 'Test'; 'More' ], 'ok' - lives_ok = get_hll_global [ 'Test'; 'More' ], 'lives_ok' plan(551) @@ -371,7 +370,15 @@ END_JSON goto dec_loop dec_loop_end: - lives_ok(<<'CODE', 'enc_sub with utf8 GH#813') + gh813_base64_utf8() + +.end + +.sub gh813_base64_utf8 + .local pmc lives_ok + lives_ok = get_hll_global [ 'Test'; 'More' ], 'lives_ok' + + lives_ok(<<'CODE', 'enc_sub("\x{203e}") # Github issue #813') .sub foo .local pmc enc_sub enc_sub = get_global [ "MIME"; "Base64" ], 'encode_base64' From 61f7941b134a4c11bd7b1cfc1513aa8b30c81a32 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 24 Sep 2012 12:30:19 -0500 Subject: [PATCH 03/34] [GH #813 + #814] Fix MIME/Base64.pir for encoded strings Use bytebuffer representations of the encoded string, not the encoded ord value. Now the implementation is correct, but some encoded tests not. --- runtime/parrot/library/MIME/Base64.pir | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/runtime/parrot/library/MIME/Base64.pir b/runtime/parrot/library/MIME/Base64.pir index dd4567d6bd..a2524d3e88 100644 --- a/runtime/parrot/library/MIME/Base64.pir +++ b/runtime/parrot/library/MIME/Base64.pir @@ -94,13 +94,17 @@ then a warning is generated if perl is running under -w. .local int len, len_mod_3 len = length plain - len_mod_3 = len % 3 + .local pmc bb + bb = new ['ByteBuffer'], len + bb = plain + len = elements bb + len_mod_3 = len % 3 # Fill up with with null bytes if len_mod_3 == 0 goto END_1 - plain = concat plain, ascii:"\0" + push bb, 0 if len_mod_3 == 2 goto END_1 - plain = concat plain, ascii:"\0" + push bb, 0 END_1: base64 = '' @@ -118,11 +122,11 @@ then a warning is generated if perl is running under -w. # read 3*8 bits # TODO GH #813 and #814 unicode chars - eight_0 = ord plain, i + eight_0 = bb[i] inc i - eight_1 = ord plain, i + eight_1 = bb[i] inc i - eight_2 = ord plain, i + eight_2 = bb[i] inc i # d[i]>>2; From 2eeefe4a98d8ccdef5bbb1fba60a3577a81a5044 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 24 Sep 2012 13:21:06 -0500 Subject: [PATCH 04/34] Add special mime-base64 utf8 test and examples --- MANIFEST | 3 + examples/mime_base64/utf8_base64.pir | 22 ++++ examples/mime_base64/utf8_base64.pl | 17 ++++ t/library/mime_base64u.t | 144 +++++++++++++++++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 examples/mime_base64/utf8_base64.pir create mode 100644 examples/mime_base64/utf8_base64.pl create mode 100644 t/library/mime_base64u.t diff --git a/MANIFEST b/MANIFEST index a92e48a0c9..b735668dad 100644 --- a/MANIFEST +++ b/MANIFEST @@ -581,6 +581,8 @@ examples/library/getopt_demo.pir [examples] examples/library/md5sum.pir [examples] examples/library/ncurses_life.pir [examples] examples/library/pcre.pir [examples] +examples/mime_base64/utf8_base64.pir [examples] +examples/mime_base64/utf8_base64.pl [examples] examples/mops/README.pod [examples] examples/mops/mops.c [examples] examples/mops/mops.cs [examples] @@ -1708,6 +1710,7 @@ t/library/iter.t [test] t/library/lwp.t [test] t/library/md5.t [test] t/library/mime_base64.t [test] +t/library/mime_base64u.t [test] t/library/nciutils.t [test] t/library/osutils.t [test] t/library/p6object.t [test] diff --git a/examples/mime_base64/utf8_base64.pir b/examples/mime_base64/utf8_base64.pir new file mode 100644 index 0000000000..902c21aa7d --- /dev/null +++ b/examples/mime_base64/utf8_base64.pir @@ -0,0 +1,22 @@ +.sub main :main + load_bytecode 'MIME/Base64.pbc' + + .local pmc enc_sub + enc_sub = get_global [ "MIME"; "Base64" ], 'encode_base64' + + .local string result_encode + # GH 814 + result_encode = enc_sub(utf8:"\x{a2}") + say "encode: utf8:\"\\x{a2}\"" + say "expected: wqI=" + print "result: " + say result_encode + + # GH 813 + result_encode = enc_sub(utf8:"\x{203e}") + say "encode: utf8:\"\\x{203e}\"" + say "expected: 4oC+" + print "result: " + say result_encode + +.end diff --git a/examples/mime_base64/utf8_base64.pl b/examples/mime_base64/utf8_base64.pl new file mode 100644 index 0000000000..9145cf2ba6 --- /dev/null +++ b/examples/mime_base64/utf8_base64.pl @@ -0,0 +1,17 @@ +#! /usr/bin/perl +use strict; +use MIME::Base64 qw(encode_base64 decode_base64); +use Encode qw(encode); + +my $encoded = encode_base64(encode("UTF-8", "\x{a2}")); +print "encode: utf-8:\"\\x{a2}\" - ", encode("UTF-8", "\x{a2}"), "\n"; +print "expected: wqI=\n"; +print "result: $encoded\n"; +print "decode: ",decode_base64("wqI="),"\n\n"; # 302 242 + +my $encoded = encode_base64(encode("UTF-8", "\x{203e}")); +print "encode: utf-8:\"\\x{203e}\" -> ",encode("UTF-8", "\x{203e}"),"\n"; +print "expected: 4oC+\n"; +print "result: $encoded\n"; # 342 200 276 + +print "decode: ",decode_base64("4oC+"),"\n"; diff --git a/t/library/mime_base64u.t b/t/library/mime_base64u.t new file mode 100644 index 0000000000..71bdfdf60a --- /dev/null +++ b/t/library/mime_base64u.t @@ -0,0 +1,144 @@ +#!./parrot +# Copyright (C) 2006-2012, Parrot Foundation. + +=head1 NAME + +t/library/mime_base64u.t - test unicode [ 'MIME'; 'Base64' ] + +=head1 SYNOPSIS + + % prove t/library/mime_base64u.t + +=head1 DESCRIPTION + +Test utf8 encoded [ 'MIME'; 'Base64' ] + +=cut + +.sub test :main + load_bytecode 'Test/More.pbc' + load_bytecode 'MIME/Base64.pbc' + + .local pmc plan, is, ok + plan = get_hll_global [ 'Test'; 'More' ], 'plan' + is = get_hll_global [ 'Test'; 'More' ], 'is' + ok = get_hll_global [ 'Test'; 'More' ], 'ok' + + plan(5) + + .local pmc encode_decode_tests, decode_tests + encode_decode_tests = new 'FixedPMCArray', 2 + $P0 = new 'FixedStringArray', 2 + $P0[0] = utf8:"\x{a2}" + $P0[1] = "wqI=" + encode_decode_tests[0] = $P0 + $P0 = new 'FixedStringArray', 2 + $P0[0] = utf8:"\x{203e}" + $P0[1] = "4oC+" + encode_decode_tests[1] = $P0 + + decode_tests = new 'FixedPMCArray', 2 + $P0 = new 'FixedStringArray', 2 + $P0[0] = "YWE=" + $P0[1] = "aa" + decode_tests[0] = $P0 + $P0 = new 'FixedStringArray', 2 + $P0[0] = "YQ" + $P0[1] = "a" + decode_tests[1] = $P0 + + .local int count + count = 0 + .local pmc test_iterator, test_case + .local string plain, base64, comment, comment_count + + test_iterator = iter encode_decode_tests + enc_dec_loop: + unless test_iterator goto enc_dec_loop_end + test_case = shift test_iterator + plain = test_case[0] + base64 = test_case[1] + comment = 'encode' + comment_count = count + comment = concat comment, comment_count + comment = concat comment, " " + comment = concat comment, plain + test_encode( plain, base64, comment ) + comment = 'decode' + comment_count = count + comment = concat comment, comment_count + test_decode( plain, base64, comment ) + inc count + goto enc_dec_loop + enc_dec_loop_end: + + test_iterator = iter decode_tests + dec_loop: + unless test_iterator goto dec_loop_end + test_case = shift test_iterator + base64 = test_case[0] + plain = test_case[1] + comment = 'decode' + comment_count = count + comment = concat comment, comment_count + comment = concat comment, " " + comment = concat comment, plain + test_decode( plain, base64, comment ) + inc count + goto dec_loop + dec_loop_end: +.end + +.sub test_encode + .param string plain + .param string base64 + .param string comment + + .local pmc enc_sub + enc_sub = get_global [ "MIME"; "Base64" ], 'encode_base64' + + .local pmc is + is = get_hll_global [ 'Test'; 'More' ], 'is' + + .local string result_encode + result_encode = enc_sub( plain ) + is( result_encode, base64, comment ) +.end + + +.sub test_decode + .param string plain + .param string base64 + .param string comment + + .local pmc dec_sub + dec_sub = get_global [ "MIME"; "Base64" ], 'decode_base64' + + .local pmc eight_to_six + eight_to_six = get_global 'eight_to_six' + + .local pmc is + is = get_hll_global [ 'Test'; 'More' ], 'is' + + .local string decode, result_decode + .local string enc + $I0 = encoding plain + enc = encodingname $I0 + decode = dec_sub( base64 ) + result_decode = trans_encoding decode, $I0 + comment = concat comment, " <-" + comment = concat comment, enc + is( result_decode, plain, comment ) +.end + +=head1 AUTHOR + +Bernhard Schmalhofer and others. + +=cut + +# Local Variables: +# mode: pir +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4 ft=pir: From ee7d8a52c171a1c7c311a8fdfbdb1034ae8d3b1f Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 24 Sep 2012 13:24:40 -0500 Subject: [PATCH 05/34] t/library/mime_base64.t: decode result to same encoding --- t/library/mime_base64.t | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/t/library/mime_base64.t b/t/library/mime_base64.t index 66a03fa1f9..98be09abc6 100644 --- a/t/library/mime_base64.t +++ b/t/library/mime_base64.t @@ -421,8 +421,14 @@ CODE .local pmc is is = get_hll_global [ 'Test'; 'More' ], 'is' - .local string result_decode - result_decode = dec_sub( base64 ) + .local string decode, result_decode + .local string enc + $I0 = encoding plain + enc = encodingname $I0 + decode = dec_sub( base64 ) + result_decode = trans_encoding decode, $I0 + comment = concat comment, " <-" + comment = concat comment, enc is( result_decode, plain, comment ) .end From 92f4de40230b86a161af99afb03853cca119651c Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 24 Sep 2012 13:37:11 -0500 Subject: [PATCH 06/34] [codingstd] add code, pod and copyrights to new examples --- examples/mime_base64/utf8_base64.pir | 35 ++++++++++++++++++++++++++++ examples/mime_base64/utf8_base64.pl | 35 ++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/examples/mime_base64/utf8_base64.pir b/examples/mime_base64/utf8_base64.pir index 902c21aa7d..39fa284a8e 100644 --- a/examples/mime_base64/utf8_base64.pir +++ b/examples/mime_base64/utf8_base64.pir @@ -1,3 +1,22 @@ +#!./parrot +# Copyright (C) 2012, Parrot Foundation. + +=head1 NAME + +examples/mime_base64/utf_base64.pir - Conformant MIME::Base64 utf8 handling + +=head1 SYNOPSIS + + % ./parrot examples/mime_base64/utf_base64.pir + +=head1 DESCRIPTION + +Compare conformant coreutils C and F +against ours. +See L + +=cut + .sub main :main load_bytecode 'MIME/Base64.pbc' @@ -20,3 +39,19 @@ say result_encode .end + +=head1 AUTHOR + +ronaldxs + +=head1 SEE ALSO + +F, + +=cut + +# Local Variables: +# mode: pir +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4 ft=pir: diff --git a/examples/mime_base64/utf8_base64.pl b/examples/mime_base64/utf8_base64.pl index 9145cf2ba6..8243a183bc 100644 --- a/examples/mime_base64/utf8_base64.pl +++ b/examples/mime_base64/utf8_base64.pl @@ -1,4 +1,22 @@ #! /usr/bin/perl +# Copyright (C) 2012, Parrot Foundation. + +=head1 NAME + +examples/mime_base64/utf_base64.pl - Conformant MIME::Base64 utf8 handling + +=head1 SYNOPSIS + + % perl examples/mime_base64/utf_base64.pl + +=head1 DESCRIPTION + +Compare conformant coreutils C and F +against parrots. +See L + +=cut + use strict; use MIME::Base64 qw(encode_base64 decode_base64); use Encode qw(encode); @@ -15,3 +33,20 @@ print "result: $encoded\n"; # 342 200 276 print "decode: ",decode_base64("4oC+"),"\n"; + +=head1 AUTHOR + +ronaldxs + +=head1 SEE ALSO + +F, + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: From 9fdc9c0d619bab17f7f5c55c3fcff5df5ad1f1c6 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Thu, 27 Sep 2012 22:41:43 -0500 Subject: [PATCH 07/34] Add unicode tests to data_json. Document chr op --- src/ops/string.ops | 4 ++++ t/compilers/data_json/from_parrot.t | 17 +++++++++++------ t/compilers/data_json/to_parrot.t | 21 +++++++++++++++++++-- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/ops/string.ops b/src/ops/string.ops index 9920dad3a9..5871271f32 100644 --- a/src/ops/string.ops +++ b/src/ops/string.ops @@ -59,6 +59,10 @@ inline op ord(out INT, in STR, in INT) { The character specified by codepoint integer $2 is returned in string $1. +For characters > 0xff an utf8 encoded string is returned, +for characters between 0x7f and 0xff a latin1 encoded string is returned, +for characters below 0x7f an ascii encoded string. + =cut inline op chr(out STR, in INT) { diff --git a/t/compilers/data_json/from_parrot.t b/t/compilers/data_json/from_parrot.t index 92bef5917f..bacc1761c2 100644 --- a/t/compilers/data_json/from_parrot.t +++ b/t/compilers/data_json/from_parrot.t @@ -1,5 +1,5 @@ #!./parrot -# Copyright (C) 2001-2010, Parrot Foundation. +# Copyright (C) 2001-2012, Parrot Foundation. =head1 NAME @@ -13,11 +13,13 @@ t/compilers/data_json/from_parrot.t - test parrot to JSON conversion. Tests JSON->Parrot conversions. +Note: This uses the old JSON.pbc not the new data_json compiler. + =cut .sub main :main .include 'test_more.pir' - plan(39) + plan(40) load_bytecode 'JSON.pbc' test_create_json_of_an_empty_string() @@ -356,7 +358,7 @@ OUTPUT .end -# no. 24..27 +# no. 24..28 .sub test_create_json_of_string_pmcs .local pmc s @@ -373,10 +375,13 @@ OUTPUT is($S0, '"12345\"67890"', 'Create JSON of String PMCs') $S0 = _json( s, 1 ) is($S0, "\"12345\\\"67890\"\n", 'Create JSON of String PMCs') + s = utf16:"\x{0}\u203e Pl\x{e4}ne" + $S0 = _json( s, 0 ) + is($S0, '"\x{0}\u203e Pl\x{e4}ne"', 'Create JSON of String PMCs') .end -# no. 28..31 +# no. 29..32 .sub test_create_json_of_integer_pmcs .local pmc i @@ -396,7 +401,7 @@ OUTPUT .end -# no. 32..35 +# no. 33..36 .sub test_create_json_of_boolean_pmcs .local pmc b @@ -416,7 +421,7 @@ OUTPUT .end -# no. 36..39 +# no. 37..40 .sub test_create_json_of_null_and_undef .local pmc n null n diff --git a/t/compilers/data_json/to_parrot.t b/t/compilers/data_json/to_parrot.t index 34e7861200..f151adbbe1 100644 --- a/t/compilers/data_json/to_parrot.t +++ b/t/compilers/data_json/to_parrot.t @@ -1,12 +1,12 @@ #!perl -# Copyright (C) 2001-2008, Parrot Foundation. +# Copyright (C) 2001-2012, Parrot Foundation. use strict; use warnings; use lib qw( t . lib ../lib ../../lib ); use Test::More; -use Parrot::Test tests => 60; +use Parrot::Test tests => 61; =head1 NAME @@ -20,6 +20,8 @@ t/compilers/data_json/to_parrot.t - test JSON to parrot conversions Tests JSON->Parrot conversions. +Note: This uses the new data_json compiler. + =cut json_dump_is( <<'JSON', <<'OUT', 'empty string' ); @@ -677,6 +679,21 @@ JSON ] OUT +json_dump_is( <<'JSON', <<'OUT', 'unicode chars' ); +["\u0000","\u00e4","\u007f","\u0080","\u0100","\u203e","Pl\u00e4ne"] +JSON +"JSON" => ResizablePMCArray (size:7) [ + "\x{0}", + "\x{e4}", + "\x{7f}", + "\x{80}", + "\u0100", + "\u203e", + "Pl\x{e4}ne" +] +OUT + + # GH #570 Need many more tests, exercising all aspects of http://www.json.org/ sub json_dump_is { From 2cd9f8e5ccde8765411f8db957cf6f1ab7516da3 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 28 Sep 2012 08:25:17 -0700 Subject: [PATCH 08/34] [t] Update manifest to make manifest tests happy --- MANIFEST | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MANIFEST b/MANIFEST index b735668dad..39e676e712 100644 --- a/MANIFEST +++ b/MANIFEST @@ -119,9 +119,9 @@ compilers/tge/TGE/Rule.pir [tge] compilers/tge/TGE/Tree.pir [tge] compilers/tge/tgc.pir [tge] config/README.pod []doc -config/auto/arch.pm [] config/auto/alignof.pm [] config/auto/alignof/test_c.in [] +config/auto/arch.pm [] config/auto/attributes.pm [] config/auto/attributes/test_c.in [] config/auto/backtrace.pm [] @@ -518,6 +518,8 @@ examples/benchmarks/stress2.rb [examples] examples/benchmarks/stress3.pasm [examples] examples/benchmarks/stress_integers.pir [examples] examples/benchmarks/stress_strings.pir [examples] +examples/benchmarks/stress_strings1.pir [examples] +examples/benchmarks/stress_stringsu.pir [examples] examples/benchmarks/vpm.pir [examples] examples/benchmarks/vpm.pl [examples] examples/benchmarks/vpm.py [examples] From 261611a9eda118f0efe5a18148bca159e5564c23 Mon Sep 17 00:00:00 2001 From: Whiteknight Date: Fri, 28 Sep 2012 19:01:08 -0400 Subject: [PATCH 09/34] Undo a prospective fix from rurban++. We don't want to flush stdout every time we read from any filehandle. --- src/io/api.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/io/api.c b/src/io/api.c index bca0e93607..e220244054 100644 --- a/src/io/api.c +++ b/src/io/api.c @@ -958,9 +958,6 @@ Parrot_io_readline_s(PARROT_INTERP, ARGMOD(PMC *handle), ARGIN(STRING * terminat size_t max_delimiter_byte_size = 0; io_sync_buffers_for_read(interp, handle, vtable, read_buffer, write_buffer); - if (!write_buffer) - Parrot_io_flush(interp, _PIO_STDOUT(interp)); - io_verify_is_open_for(interp, handle, vtable, PIO_F_READ); if (read_buffer == NULL) From f56a79e2a9d00cb179cbbfc20d1c3c6efd48d96b Mon Sep 17 00:00:00 2001 From: Whiteknight Date: Fri, 28 Sep 2012 19:28:43 -0400 Subject: [PATCH 10/34] On second read through, it doesn't appear that the old IO system had a write buffer on stdout. Take that away in the new system to try and fix some rakudo issues reported by pmichaud++ --- src/io/api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/io/api.c b/src/io/api.c index e220244054..223dcabd2a 100644 --- a/src/io/api.c +++ b/src/io/api.c @@ -76,8 +76,8 @@ Parrot_io_init(PARROT_INTERP) os_handle = Parrot_io_internal_std_os_handle(interp, PIO_STDOUT_FILENO); handle = Parrot_io_fdopen_flags(interp, PMCNULL, os_handle, PIO_F_WRITE); - Parrot_io_buffer_add_to_handle(interp, handle, IO_PTR_IDX_WRITE_BUFFER, BUFFER_SIZE_ANY, - PIO_BF_LINEBUF); + /* Parrot_io_buffer_add_to_handle(interp, handle, IO_PTR_IDX_WRITE_BUFFER, BUFFER_SIZE_ANY, + PIO_BF_LINEBUF); */ _PIO_STDOUT(interp) = handle; os_handle = Parrot_io_internal_std_os_handle(interp, PIO_STDERR_FILENO); From 7aee78c844c7cecb208039495e29ba40062fcf02 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Sat, 29 Sep 2012 19:14:18 -0500 Subject: [PATCH 11/34] [tools] Support more gdb-pp.py encodings Also fix a python gdb strlen error. The number of char is needed, not the number of codepoints. --- tools/dev/gdb-pp.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/dev/gdb-pp.py b/tools/dev/gdb-pp.py index ae8df4c048..786b129587 100644 --- a/tools/dev/gdb-pp.py +++ b/tools/dev/gdb-pp.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011, Parrot Foundation. +# Copyright (C) 2011-2012, Parrot Foundation. from gdb.printing import PrettyPrinter, SubPrettyPrinter import gdb.types import gdb @@ -155,6 +155,13 @@ def _parrot_str_to_str(val): """ encoding = val['encoding'].dereference() encoding_name = encoding['name'].string() - length = val['strlen'] - + length = val['bufused'] + + # See http://docs.python.org/library/codecs.html#standard-encodings + if encoding_name == 'binary': + encoding_name='raw_unicode_escape' + if encoding_name == 'ucs2': + encoding_name='utf_16_le' + if encoding_name == 'ucs4': + encoding_name=='utf_32_le' return val['strstart'].string(encoding=encoding_name,length=length) From b5b7a3c396fa15b3318bb6ad3e8350dc465fd383 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Sun, 30 Sep 2012 14:24:02 -0500 Subject: [PATCH 12/34] Revise [tools] Support more gdb-pp.py encodings Use native endianness --- tools/dev/gdb-pp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/dev/gdb-pp.py b/tools/dev/gdb-pp.py index 786b129587..25682b7858 100644 --- a/tools/dev/gdb-pp.py +++ b/tools/dev/gdb-pp.py @@ -161,7 +161,7 @@ def _parrot_str_to_str(val): if encoding_name == 'binary': encoding_name='raw_unicode_escape' if encoding_name == 'ucs2': - encoding_name='utf_16_le' + encoding_name='utf_16' if encoding_name == 'ucs4': - encoding_name=='utf_32_le' + encoding_name=='utf_32' return val['strstart'].string(encoding=encoding_name,length=length) From 9511781b3daccf8b6343883848e11007c17b0a63 Mon Sep 17 00:00:00 2001 From: Bob Kuo Date: Sun, 30 Sep 2012 18:07:47 -0500 Subject: [PATCH 13/34] remove hard tabs --- config/auto/alignof.pm | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/config/auto/alignof.pm b/config/auto/alignof.pm index 7cf1ff2ce1..d144268e0c 100644 --- a/config/auto/alignof.pm +++ b/config/auto/alignof.pm @@ -34,11 +34,11 @@ sub runstep { # This step only needed for clang++ if (test_if_needed($conf)) { - # Can do compile-time ALIGNOF definitions via offsetof() - $conf->data->set( 'HAS_COMPILER_OFFSETOF_ALIGNOF' => 1 ); + # Can do compile-time ALIGNOF definitions via offsetof() + $conf->data->set( 'HAS_COMPILER_OFFSETOF_ALIGNOF' => 1 ); $conf->debug("DEBUG: auto::alignof is only needed for clang++\n"); $self->set_result('skipped'); - return 1; + return 1; } # Need pre-compiled PARROT_ALIGNOF_* definitions $conf->data->set( 'HAS_COMPILER_OFFSETOF_ALIGNOF' => 0 ); @@ -46,8 +46,8 @@ sub runstep { my %types = ( intval => $conf->data->get('iv'), floatval => $conf->data->get('nv'), - stringptr => 'STRING *', - pmcptr => 'PMC *', + stringptr => 'STRING *', + pmcptr => 'PMC *', char => 'char', short => 'short', int => 'int', @@ -59,14 +59,13 @@ sub runstep { float => 'float', double => 'double', longdouble => 'long double', - Parrot_Int1 => 'char', - Parrot_Int2 => 'short', - Parrot_Int4 => 'int', - Parrot_Int8 => 'long long', - charptr => 'char *', - voidptr => 'void *', - funcptr_t => 'funcptr_t', - + Parrot_Int1 => 'char', + Parrot_Int2 => 'short', + Parrot_Int4 => 'int', + Parrot_Int8 => 'long long', + charptr => 'char *', + voidptr => 'void *', + funcptr_t => 'funcptr_t', longlong => 'long long', ulonglong => 'unsigned long long', __float128 => '__float128', @@ -74,12 +73,12 @@ sub runstep { my $alignof = ''; for my $name (keys %types) { - my $type = $types{$name}; - my $value = test_alignof($conf, $name, $type); - $alignof .= ' '.$name; - if ($value) { - $conf->data->set( 'PARROT_ALIGNOF_'.$name => $value ); - } + my $type = $types{$name}; + my $value = test_alignof($conf, $name, $type); + $alignof .= ' '.$name; + if ($value) { + $conf->data->set( 'PARROT_ALIGNOF_'.$name => $value ); + } } $conf->data->set( 'alignof' => $alignof ); From 4bb6df6d8ccb6cb22971f659d96fd2142d3c3ae4 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 1 Oct 2012 10:28:28 -0500 Subject: [PATCH 14/34] [cage] fix auto::inline for g++ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add missing return type to function error: ISO C++ forbids declaration of ‘f’ with no type [-fpermissive] --- config/auto/inline/test1_c.in | 4 ++-- config/auto/inline/test2_c.in | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/auto/inline/test1_c.in b/config/auto/inline/test1_c.in index 9f53dcb2f5..6cbfdc9ecd 100644 --- a/config/auto/inline/test1_c.in +++ b/config/auto/inline/test1_c.in @@ -1,12 +1,12 @@ /* -Copyright (C) 2003-2009, Parrot Foundation. +Copyright (C) 2003-2012, Parrot Foundation. test to check if compiler supports inline */ #include -inline f(void) { +inline void f(void) { puts("inline"); } diff --git a/config/auto/inline/test2_c.in b/config/auto/inline/test2_c.in index 14c7cb4922..f3ac3ac3f9 100644 --- a/config/auto/inline/test2_c.in +++ b/config/auto/inline/test2_c.in @@ -1,12 +1,12 @@ /* -Copyright (C) 2003-2009, Parrot Foundation. +Copyright (C) 2003-2012, Parrot Foundation. test to check if compiler supports __inline */ #include -__inline f(void) { +__inline void f(void) { puts("__inline"); } From 20bc3dbdfae8a1189318453bfab8bc9247b42620 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 1 Oct 2012 10:30:33 -0500 Subject: [PATCH 15/34] [cage] Improve llvm detection Probe for llvm-config-3.0 llvm-config-2.9 llvm-config-2.8 which do exist on debian, where llvm-config does not exist. Print found version, like "yes, 3.0" as with gcc and other libs. If not requested, print "not requested" instead of "no" to give a hint, that --with-llvm is wanted. Add llvm and inline probes to ChangeLog --- ChangeLog | 2 ++ config/auto/llvm.pm | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d47190a14..d74c0d8586 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,8 @@ + Cleaned wrong UNUSED(arg) macros in all pmc's due to an improved pmc2c compiler, which SHIMs all UNUSED args. [GH #836] + Added clang++ support and a new auto::alignof Configure step. [GH #844] + + Fixed auto::inline for C++ compilers + + Improved auto::llvm - Branches + The threads branch is almost ready to be merged. Some remaining races have been fixed. There are only some remaining platforms errors on diff --git a/config/auto/llvm.pm b/config/auto/llvm.pm index f2a2bcf766..31c9cb4f59 100644 --- a/config/auto/llvm.pm +++ b/config/auto/llvm.pm @@ -36,6 +36,7 @@ sub runstep { my $verbose = $conf->options->get( 'verbose' ); unless ( $conf->options->get( 'with-llvm' ) ) { $self->_handle_result( $conf, 0 ); + $self->set_result('not requested'); print "LLVM not requested\n" if $verbose; return 1; } @@ -45,8 +46,15 @@ sub runstep { # runstep() with a value of 1. If a given probe does not rule out LLVM, # we will proceed onward. - my $llvm_bindir = capture_output( qw| llvm-config --bindir | ) || ''; - chomp $llvm_bindir; + my ($llvm_bindir, $llvm_config); + for my $bin (qw(llvm-config llvm-config-3.0 llvm-config-2.9 llvm-config-2.8)) { + $llvm_bindir = capture_output( $bin, "--bindir" ) || ''; + chomp $llvm_bindir; + if ( $llvm_bindir ) { + $llvm_config = $bin; + last; + } + } if (! $llvm_bindir ) { print "Unable to find directory for 'llvm-config' executable\n" if $verbose; @@ -69,7 +77,7 @@ sub runstep { } } - $self->_handle_result($conf, 1); + $self->_handle_result($conf, $rv); return 1; # Having gotten this far, we will take a simple C file, compile it into @@ -176,14 +184,14 @@ sub version_check { if ($verbose) { print "Found 'lli' version $version\n"; } - return 1; + return $version; } } else { print "Unable to extract version for LLVM component 'lli'\n" if $verbose; $self->_handle_result( $conf, 0 ); - return; + return 0; } } @@ -219,7 +227,7 @@ sub _handle_failure_to_assemble_assembly { sub _handle_result { my ($self, $conf, $result) = @_; if ( $result ) { - $self->set_result('yes'); + $self->set_result( "yes, ".$result ); $conf->data->set( has_llvm => 1 ); } else { From 8c85134f2e3c9f442d23c855cf2a285aaedb61d2 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 1 Oct 2012 10:52:24 -0500 Subject: [PATCH 16/34] [codingstd] hard tabs in config/auto/gcc.pm --- config/auto/gcc.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/auto/gcc.pm b/config/auto/gcc.pm index 0652509883..d3bc38abdd 100644 --- a/config/auto/gcc.pm +++ b/config/auto/gcc.pm @@ -96,7 +96,7 @@ sub _evaluate_gcc { # and set -x c++ for clang++ if ($clang and $gpp and index($cc, '-x c++') < 1) { - $conf->data->set('cc' => $cc.' -x c++'); + $conf->data->set('cc' => $cc.' -x c++'); } $conf->data->set( From 2918625bb45e54adcc929b96e6df3d6f78c2a0f2 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 1 Oct 2012 12:39:16 -0500 Subject: [PATCH 17/34] [tools] gdb-pp.py better string output for multi-byte Use errors=replace instead of strict. See http://docs.python.org/library/codecs.html#codec-base-classes Prepend encoding when not ascii and not latin1, add strlen and bufused fields. --- tools/dev/gdb-pp.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/dev/gdb-pp.py b/tools/dev/gdb-pp.py index 25682b7858..3369eeec77 100644 --- a/tools/dev/gdb-pp.py +++ b/tools/dev/gdb-pp.py @@ -155,6 +155,11 @@ def _parrot_str_to_str(val): """ encoding = val['encoding'].dereference() encoding_name = encoding['name'].string() + name = encoding_name + ':' + if name == 'ascii:': + name = '' + if name == 'iso-8859-1:': + name = '' length = val['bufused'] # See http://docs.python.org/library/codecs.html#standard-encodings @@ -164,4 +169,9 @@ def _parrot_str_to_str(val): encoding_name='utf_16' if encoding_name == 'ucs4': encoding_name=='utf_32' - return val['strstart'].string(encoding=encoding_name,length=length) + if name == '': + return val['strstart'].string(encoding=encoding_name,errors='replace',length=length) + else: + return '%s%s [%d/%d]' % \ + (name, val['strstart'].string(encoding=encoding_name,errors='replace',length=length), \ + val['strlen'], length) From 5a51d80d476b083c6d62c471fb6dd919b271d032 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 1 Oct 2012 12:47:37 -0500 Subject: [PATCH 18/34] Add gdb pretty-printing to ChangeLog --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index d74c0d8586..6641b4262b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,8 @@ - Documentation + Cleaned up removed parrot cmdline options -D/-O/-v from --help output and running.pod [GH #838] + - Tools + + Improved gdb pretty-printing for multi-byte strings - Tests - Community From c1c30c6009f50cf00f48731437e24e0c0d699eec Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 1 Oct 2012 17:29:54 -0500 Subject: [PATCH 19/34] [GH #813 #814] [codingstd] Improve new mime_base64 examples --- examples/mime_base64/utf8_base64.pir | 2 +- examples/mime_base64/utf8_base64.pl | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/examples/mime_base64/utf8_base64.pir b/examples/mime_base64/utf8_base64.pir index 39fa284a8e..c07f4e9205 100644 --- a/examples/mime_base64/utf8_base64.pir +++ b/examples/mime_base64/utf8_base64.pir @@ -37,7 +37,7 @@ See L say "expected: 4oC+" print "result: " say result_encode - + .end =head1 AUTHOR diff --git a/examples/mime_base64/utf8_base64.pl b/examples/mime_base64/utf8_base64.pl index 8243a183bc..f4e12d5c86 100644 --- a/examples/mime_base64/utf8_base64.pl +++ b/examples/mime_base64/utf8_base64.pl @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#! perl # Copyright (C) 2012, Parrot Foundation. =head1 NAME @@ -15,9 +15,12 @@ =head1 DESCRIPTION against parrots. See L +Note: Unicode stored as MIME::Base64 is inherently endian-dependent. + =cut use strict; +use warnings; use MIME::Base64 qw(encode_base64 decode_base64); use Encode qw(encode); @@ -31,12 +34,16 @@ =head1 DESCRIPTION print "encode: utf-8:\"\\x{203e}\" -> ",encode("UTF-8", "\x{203e}"),"\n"; print "expected: 4oC+\n"; print "result: $encoded\n"; # 342 200 276 - print "decode: ",decode_base64("4oC+"),"\n"; -=head1 AUTHOR +for ([qq(a2)],[qq(c2a2)],[qw(203e)],[qw(3e 20)],[qw(1000)],[qw(00c7)],[qw(00ff 0000)]){ + $s = pack "H*",@{$_}; + printf "0x%s\t=> %s", join("",@{$_}), encode_base64($s); +} + +=head1 AUTHORS -ronaldxs +ronaldxs, Reini Urban =head1 SEE ALSO From 072156a66f12c09b8c64f8cc1d22753afb38447c Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 1 Oct 2012 17:31:03 -0500 Subject: [PATCH 20/34] [GH #813 #814] Move new mime_base64 examples to examples/library/ --- MANIFEST | 4 ++-- examples/{mime_base64 => library}/utf8_base64.pir | 0 examples/{mime_base64 => library}/utf8_base64.pl | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename examples/{mime_base64 => library}/utf8_base64.pir (100%) rename examples/{mime_base64 => library}/utf8_base64.pl (100%) diff --git a/MANIFEST b/MANIFEST index 39e676e712..323f0d5363 100644 --- a/MANIFEST +++ b/MANIFEST @@ -583,8 +583,8 @@ examples/library/getopt_demo.pir [examples] examples/library/md5sum.pir [examples] examples/library/ncurses_life.pir [examples] examples/library/pcre.pir [examples] -examples/mime_base64/utf8_base64.pir [examples] -examples/mime_base64/utf8_base64.pl [examples] +examples/library/utf8_base64.pir [examples] +examples/library/utf8_base64.pl [examples] examples/mops/README.pod [examples] examples/mops/mops.c [examples] examples/mops/mops.cs [examples] diff --git a/examples/mime_base64/utf8_base64.pir b/examples/library/utf8_base64.pir similarity index 100% rename from examples/mime_base64/utf8_base64.pir rename to examples/library/utf8_base64.pir diff --git a/examples/mime_base64/utf8_base64.pl b/examples/library/utf8_base64.pl similarity index 100% rename from examples/mime_base64/utf8_base64.pl rename to examples/library/utf8_base64.pl From dc5d2846960872fdf7863aa11dc34f37b2c10a37 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Mon, 1 Oct 2012 18:27:30 -0500 Subject: [PATCH 21/34] [GH #813 + #814] Use Bytebuffer for MIME::Base64, add 2nd enc arg to decode_base64 Use bytebuffer representations of the encoded string, not the encoded ord value. Also fix the tests to match this conformant behaviour. The problem is now that base64 encoded files are endian dependent, and the multibyte tests need to be skipped on big-endian. --- runtime/parrot/library/MIME/Base64.pir | 90 ++++---- t/library/mime_base64.t | 300 +++++++++++++------------ t/library/mime_base64u.t | 176 ++++++++++++--- 3 files changed, 348 insertions(+), 218 deletions(-) diff --git a/runtime/parrot/library/MIME/Base64.pir b/runtime/parrot/library/MIME/Base64.pir index a2524d3e88..712f649a4b 100644 --- a/runtime/parrot/library/MIME/Base64.pir +++ b/runtime/parrot/library/MIME/Base64.pir @@ -25,19 +25,18 @@ is the string to encode. The returned encoded string is broken into lines of no more than 76 characters each. -=item C +Note: Unicode stored as MIME::Base64 is inherently endian-dependent. + +=item C Decode a base64 string by calling the decode_base64() function. -This function takes a single argument which is the string to decode -and returns the decoded data. +This function takes as first argument the string to decode, +as optional second argument the encoding string for the decoded data. +It returns the decoded data. Any character not part of the 65-character base64 subset is silently ignored. Characters occurring after a '=' padding character are never decoded. -If the length of the string to decode, after ignoring non-base64 chars, -is not a multiple of 4 or if padding occurs too early, -then a warning is generated if perl is running under -w. - =back =cut @@ -93,12 +92,13 @@ then a warning is generated if perl is running under -w. six_to_eight = get_global 'six_to_eight' .local int len, len_mod_3 - len = length plain .local pmc bb + # For unicode we cannot use chr/ord. This breaks endianness. + # GH 813 and #814 + len = bytelength plain bb = new ['ByteBuffer'], len bb = plain - len = elements bb len_mod_3 = len % 3 # Fill up with with null bytes if len_mod_3 == 0 goto END_1 @@ -121,7 +121,6 @@ then a warning is generated if perl is running under -w. if i >= len goto END_3 # read 3*8 bits - # TODO GH #813 and #814 unicode chars eight_0 = bb[i] inc i eight_1 = bb[i] @@ -183,32 +182,37 @@ then a warning is generated if perl is running under -w. .sub decode_base64 .param string base64 + .param string enc :optional + .param int has_enc :opt_flag - .local string plain, base64_cleaned + .local string result, base64_cleaned + .local int enc_num base64_cleaned = '' - plain = '' + if has_enc goto HAS_ENC + enc = 'ascii' + HAS_ENC: - .local pmc eight_to_six + .local pmc eight_to_six, bb eight_to_six = get_global 'eight_to_six' .local int i, len .local int tmp_int_1, tmp_int_2 - .local string s_tmp_1 # Get rid of non-base64 chars len = length base64 i = 0 - START_5: + START_5: + .local string s_tmp_1 if i >= len goto END_5 tmp_int_1 = ord base64, i - inc i - tmp_int_2 = eight_to_six[tmp_int_1] - if tmp_int_2 == -1 goto START_5 - s_tmp_1 = chr tmp_int_1 - base64_cleaned = concat base64_cleaned, s_tmp_1 + inc i + tmp_int_2 = eight_to_six[tmp_int_1] + if tmp_int_2 == -1 goto START_5 + s_tmp_1 = chr tmp_int_1 + base64_cleaned = concat base64_cleaned, s_tmp_1 goto START_5 - END_5: + END_5: .local int len_mod_4 len = length base64_cleaned len_mod_4 = len % 4 @@ -216,27 +220,27 @@ then a warning is generated if perl is running under -w. # make sure that there are dummy bits beyond base64_cleaned = concat base64_cleaned, ascii:"\0\0\0" + bb = new ['ByteBuffer'] .local int eight_0, eight_1, eight_2 .local int six_0, six_1, six_2, six_3 i = 0 - START_2: + START_2: if i >= len goto END_2 # read 4*6 bits tmp_int_1 = ord base64_cleaned, i - six_0 = eight_to_six[tmp_int_1] - inc i + six_0 = eight_to_six[tmp_int_1] + inc i tmp_int_1 = ord base64_cleaned, i - six_1 = eight_to_six[tmp_int_1] - inc i + six_1 = eight_to_six[tmp_int_1] + inc i tmp_int_1 = ord base64_cleaned, i - six_2 = eight_to_six[tmp_int_1] - inc i + six_2 = eight_to_six[tmp_int_1] + inc i tmp_int_1 = ord base64_cleaned, i - six_3 = eight_to_six[tmp_int_1] - inc i - + six_3 = eight_to_six[tmp_int_1] + inc i # (f64[t.charAt(i)]<<2) | (f64[t.charAt(i+1)]>>4) shl tmp_int_1, six_0, 2 @@ -256,25 +260,25 @@ then a warning is generated if perl is running under -w. # write 3*8 bits # output is larger than input - s_tmp_1 = chr eight_0 - plain = concat plain, s_tmp_1 - s_tmp_1 = chr eight_1 - plain = concat plain, s_tmp_1 - s_tmp_1 = chr eight_2 - plain = concat plain, s_tmp_1 - + push bb, eight_0 + push bb, eight_1 + push bb, eight_2 goto START_2 - END_2: + END_2: # cut padded '=' if len_mod_4 == 0 goto END_3 if len_mod_4 == 1 goto END_3 - plain = chopn plain, 1 + len = elements bb + dec len + bb = len if len_mod_4 == 3 goto END_3 - plain = chopn plain, 1 - END_3: + dec len + bb = len - .return( plain ) + END_3: + result = bb.'get_string'(enc) + .return( result ) .end =head1 SEE ALSO diff --git a/t/library/mime_base64.t b/t/library/mime_base64.t index 98be09abc6..026eac302b 100644 --- a/t/library/mime_base64.t +++ b/t/library/mime_base64.t @@ -37,7 +37,7 @@ Test cases taken from base64.t of MIME::Base64. .local pmc encode_decode_tests, decode_tests encode_decode_tests = json.'compile'( <<'END_JSON' ) [ ["Hello, World!\n","SGVsbG8sIFdvcmxkIQo="], - ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh\nYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ=="], ["\u0000","AA=="], ["\u0001","AQ=="], @@ -167,136 +167,136 @@ Test cases taken from base64.t of MIME::Base64. ["}","fQ=="], ["~","fg=="], ["\u007f","fw=="], - ["\u0080","gA=="], - ["\u0081","gQ=="], - ["\u0082","gg=="], - ["\u0083","gw=="], - ["\u0084","hA=="], - ["\u0085","hQ=="], - ["\u0086","hg=="], - ["\u0087","hw=="], - ["\u0088","iA=="], - ["\u0089","iQ=="], - ["\u008a","ig=="], - ["\u008b","iw=="], - ["\u008c","jA=="], - ["\u008d","jQ=="], - ["\u008e","jg=="], - ["\u008f","jw=="], - ["\u0090","kA=="], - ["\u0091","kQ=="], - ["\u0092","kg=="], - ["\u0093","kw=="], - ["\u0094","lA=="], - ["\u0095","lQ=="], - ["\u0096","lg=="], - ["\u0097","lw=="], - ["\u0098","mA=="], - ["\u0099","mQ=="], - ["\u009a","mg=="], - ["\u009b","mw=="], - ["\u009c","nA=="], - ["\u009d","nQ=="], - ["\u009e","ng=="], - ["\u009f","nw=="], - ["\u00a0","oA=="], - ["\u00a1","oQ=="], - ["\u00a2","og=="], - ["\u00a3","ow=="], - ["\u00a4","pA=="], - ["\u00a5","pQ=="], - ["\u00a6","pg=="], - ["\u00a7","pw=="], - ["\u00a8","qA=="], - ["\u00a9","qQ=="], - ["\u00aa","qg=="], - ["\u00ab","qw=="], - ["\u00ac","rA=="], - ["\u00ad","rQ=="], - ["\u00ae","rg=="], - ["\u00af","rw=="], - ["\u00b0","sA=="], - ["\u00b1","sQ=="], - ["\u00b2","sg=="], - ["\u00b3","sw=="], - ["\u00b4","tA=="], - ["\u00b5","tQ=="], - ["\u00b6","tg=="], - ["\u00b7","tw=="], - ["\u00b8","uA=="], - ["\u00b9","uQ=="], - ["\u00ba","ug=="], - ["\u00bb","uw=="], - ["\u00bc","vA=="], - ["\u00bd","vQ=="], - ["\u00be","vg=="], - ["\u00bf","vw=="], - ["\u00c0","wA=="], - ["\u00c1","wQ=="], - ["\u00c2","wg=="], - ["\u00c3","ww=="], - ["\u00c4","xA=="], - ["\u00c5","xQ=="], - ["\u00c6","xg=="], - ["\u00c7","xw=="], - ["\u00c8","yA=="], - ["\u00c9","yQ=="], - ["\u00ca","yg=="], - ["\u00cb","yw=="], - ["\u00cc","zA=="], - ["\u00cd","zQ=="], - ["\u00ce","zg=="], - ["\u00cf","zw=="], - ["\u00d0","0A=="], - ["\u00d1","0Q=="], - ["\u00d2","0g=="], - ["\u00d3","0w=="], - ["\u00d4","1A=="], - ["\u00d5","1Q=="], - ["\u00d6","1g=="], - ["\u00d7","1w=="], - ["\u00d8","2A=="], - ["\u00d9","2Q=="], - ["\u00da","2g=="], - ["\u00db","2w=="], - ["\u00dc","3A=="], - ["\u00dd","3Q=="], - ["\u00de","3g=="], - ["\u00df","3w=="], - ["\u00e0","4A=="], - ["\u00e1","4Q=="], - ["\u00e2","4g=="], - ["\u00e3","4w=="], - ["\u00e4","5A=="], - ["\u00e5","5Q=="], - ["\u00e6","5g=="], - ["\u00e7","5w=="], - ["\u00e8","6A=="], - ["\u00e9","6Q=="], - ["\u00ea","6g=="], - ["\u00eb","6w=="], - ["\u00ec","7A=="], - ["\u00ed","7Q=="], - ["\u00ee","7g=="], - ["\u00ef","7w=="], - ["\u00f0","8A=="], - ["\u00f1","8Q=="], - ["\u00f2","8g=="], - ["\u00f3","8w=="], - ["\u00f4","9A=="], - ["\u00f5","9Q=="], - ["\u00f6","9g=="], - ["\u00f7","9w=="], - ["\u00f8","+A=="], - ["\u00f9","+Q=="], - ["\u00fa","+g=="], - ["\u00fb","+w=="], - ["\u00fc","/A=="], - ["\u00fd","/Q=="], - ["\u00fe","/g=="], - ["\u00ff","/w=="], - ["\u0000\u00ff","AP8="], - ["\u00ff\u0000","/wA="], + ["\u0080","woA="], + ["\u0081","woE="], + ["\u0082","woI="], + ["\u0083","woM="], + ["\u0084","woQ="], + ["\u0085","woU="], + ["\u0086","woY="], + ["\u0087","woc="], + ["\u0088","wog="], + ["\u0089","wok="], + ["\u008a","woo="], + ["\u008b","wos="], + ["\u008c","wow="], + ["\u008d","wo0="], + ["\u008e","wo4="], + ["\u008f","wo8="], + ["\u0090","wpA="], + ["\u0091","wpE="], + ["\u0092","wpI="], + ["\u0093","wpM="], + ["\u0094","wpQ="], + ["\u0095","wpU="], + ["\u0096","wpY="], + ["\u0097","wpc="], + ["\u0098","wpg="], + ["\u0099","wpk="], + ["\u009a","wpo="], + ["\u009b","wps="], + ["\u009c","wpw="], + ["\u009d","wp0="], + ["\u009e","wp4="], + ["\u009f","wp8="], + ["\u00a0","wqA="], + ["\u00a1","wqE="], + ["\u00a2","wqI="], + ["\u00a3","wqM="], + ["\u00a4","wqQ="], + ["\u00a5","wqU="], + ["\u00a6","wqY="], + ["\u00a7","wqc="], + ["\u00a8","wqg="], + ["\u00a9","wqk="], + ["\u00aa","wqo="], + ["\u00ab","wqs="], + ["\u00ac","wqw="], + ["\u00ad","wq0="], + ["\u00ae","wq4="], + ["\u00af","wq8="], + ["\u00b0","wrA="], + ["\u00b1","wrE="], + ["\u00b2","wrI="], + ["\u00b3","wrM="], + ["\u00b4","wrQ="], + ["\u00b5","wrU="], + ["\u00b6","wrY="], + ["\u00b7","wrc="], + ["\u00b8","wrg="], + ["\u00b9","wrk="], + ["\u00ba","wro="], + ["\u00bb","wrs="], + ["\u00bc","wrw="], + ["\u00bd","wr0="], + ["\u00be","wr4="], + ["\u00bf","wr8="], + ["\u00c0","w4A="], + ["\u00c1","w4E="], + ["\u00c2","w4I="], + ["\u00c3","w4M="], + ["\u00c4","w4Q="], + ["\u00c5","w4U="], + ["\u00c6","w4Y="], + ["\u00c7","w4c="], + ["\u00c8","w4g="], + ["\u00c9","w4k="], + ["\u00ca","w4o="], + ["\u00cb","w4s="], + ["\u00cc","w4w="], + ["\u00cd","w40="], + ["\u00ce","w44="], + ["\u00cf","w48="], + ["\u00d0","w5A="], + ["\u00d1","w5E="], + ["\u00d2","w5I="], + ["\u00d3","w5M="], + ["\u00d4","w5Q="], + ["\u00d5","w5U="], + ["\u00d6","w5Y="], + ["\u00d7","w5c="], + ["\u00d8","w5g="], + ["\u00d9","w5k="], + ["\u00da","w5o="], + ["\u00db","w5s="], + ["\u00dc","w5w="], + ["\u00dd","w50="], + ["\u00de","w54="], + ["\u00df","w58="], + ["\u00e0","w6A="], + ["\u00e1","w6E="], + ["\u00e2","w6I="], + ["\u00e3","w6M="], + ["\u00e4","w6Q="], + ["\u00e5","w6U="], + ["\u00e6","w6Y="], + ["\u00e7","w6c="], + ["\u00e8","w6g="], + ["\u00e9","w6k="], + ["\u00ea","w6o="], + ["\u00eb","w6s="], + ["\u00ec","w6w="], + ["\u00ed","w60="], + ["\u00ee","w64="], + ["\u00ef","w68="], + ["\u00f0","w7A="], + ["\u00f1","w7E="], + ["\u00f2","w7I="], + ["\u00f3","w7M="], + ["\u00f4","w7Q="], + ["\u00f5","w7U="], + ["\u00f6","w7Y="], + ["\u00f7","w7c="], + ["\u00f8","w7g="], + ["\u00f9","w7k="], + ["\u00fa","w7o="], + ["\u00fb","w7s="], + ["\u00fc","w7w="], + ["\u00fd","w70="], + ["\u00fe","w74="], + ["\u00ff","w78="], + ["\u0000\u00ff","AMO/"], + ["\u00ff\u0000","w78A"], ["\u0000\u0000\u0000","AAAA"], ["",""], ["a","YQ=="], @@ -332,7 +332,7 @@ END_JSON .local int count count = 0 .local pmc test_iterator, test_case - .local string plain, base64, comment, comment_count + .local string plain, base64, comment, comment_count, enc, esc_plain encode_decode_tests = encode_decode_tests() test_iterator = iter encode_decode_tests @@ -343,9 +343,15 @@ END_JSON base64 = shift test_case comment = 'encode' comment_count = count + $I0 = encoding plain + enc = encodingname $I0 + esc_plain = escape plain comment = concat comment, comment_count - # comment = concat comment, " " - # comment = concat comment, plain + comment = concat comment, " " + comment = concat comment, enc + comment = concat comment, ":\"" + comment = concat comment, esc_plain + comment = concat comment, "\"" test_encode( plain, base64, comment ) comment = 'decode' comment_count = count @@ -415,27 +421,37 @@ CODE .local pmc dec_sub dec_sub = get_global [ "MIME"; "Base64" ], 'decode_base64' - .local pmc eight_to_six - eight_to_six = get_global 'eight_to_six' - .local pmc is is = get_hll_global [ 'Test'; 'More' ], 'is' .local string decode, result_decode - .local string enc + .local string enc, enc1 $I0 = encoding plain enc = encodingname $I0 - decode = dec_sub( base64 ) - result_decode = trans_encoding decode, $I0 + if $I0 > 2 goto DEC_ENC + # ascii, latin1 + decode = dec_sub( base64 ) + decode = trans_encoding decode, $I0 + goto DEC_2 + DEC_ENC: + decode = dec_sub( base64, enc ) + DEC_2: + $I1 = encoding decode + enc1 = encodingname $I1 + .local string plain_norm, result_norm + result_norm = compose decode + plain_norm = compose plain + comment = concat comment, " " + comment = concat comment, enc1 comment = concat comment, " <-" comment = concat comment, enc - is( result_decode, plain, comment ) + is( result_norm, plain_norm, comment ) .end =head1 AUTHOR -Bernhard Schmalhofer and others. +Bernhard Schmalhofer and Reini Urban. =cut diff --git a/t/library/mime_base64u.t b/t/library/mime_base64u.t index 71bdfdf60a..1e57d335ee 100644 --- a/t/library/mime_base64u.t +++ b/t/library/mime_base64u.t @@ -11,31 +11,76 @@ t/library/mime_base64u.t - test unicode [ 'MIME'; 'Base64' ] =head1 DESCRIPTION -Test utf8 encoded [ 'MIME'; 'Base64' ] +Test non-ascii encoded MIME::Base64, without JSON. + +perl -MMIME::Base64 -e'for ([qq(a2)],[qq(c2a2)],[qw(203e)],[qw(3e 20)],[qw(1000)],[qw(00c7)],[qw(00ff 0000)]) +{ $s=pack "H*",@{$_}; printf "0x%s\t=> %s",join("",@{$_}),encode_base64($s) }' =cut .sub test :main load_bytecode 'Test/More.pbc' - load_bytecode 'MIME/Base64.pbc' + load_bytecode 'MIME/Base64.pir' .local pmc plan, is, ok plan = get_hll_global [ 'Test'; 'More' ], 'plan' is = get_hll_global [ 'Test'; 'More' ], 'is' ok = get_hll_global [ 'Test'; 'More' ], 'ok' - plan(5) + plan(20) .local pmc encode_decode_tests, decode_tests - encode_decode_tests = new 'FixedPMCArray', 2 + .local int i, size + i = 0 + size = 9 + encode_decode_tests = new 'FixedPMCArray', size + $P0 = new 'FixedStringArray', 2 - $P0[0] = utf8:"\x{a2}" - $P0[1] = "wqI=" - encode_decode_tests[0] = $P0 + $P0[0] = binary:"\x3e\x20" # same as 0x203e bswapped + $P0[1] = "PiA=" + encode_decode_tests[i] = $P0 + inc i $P0 = new 'FixedStringArray', 2 - $P0[0] = utf8:"\x{203e}" + $P0[0] = ucs2:"\x{203e}" # OVERLINE ‾ 0x203e + # TODO on big endian we'll get ID4= + $P0[1] = "PiA=" + encode_decode_tests[i] = $P0 + inc i + $P0 = new 'FixedStringArray', 2 + $P0[0] = utf8:"\u203e" # OVERLINE ‾ 0xe280be in utf8 $P0[1] = "4oC+" - encode_decode_tests[1] = $P0 + encode_decode_tests[i] = $P0 + inc i + $P0 = new 'FixedStringArray', 2 + $P0[0] = iso-8859-1:"\x{a2}" # ¢ + $P0[1] = "og==" + encode_decode_tests[i] = $P0 + inc i + $P0 = new 'FixedStringArray', 2 + $P0[0] = utf8:"\x{a2}" # ¢ 0xc2a2 in utf8 + $P0[1] = "wqI=" + encode_decode_tests[i] = $P0 + inc i + $P0 = new 'FixedStringArray', 2 + $P0[0] = ucs2:"\x{0100}" # Ā 0xc480 in utf8 + $P0[1] = "AAE=" + encode_decode_tests[i] = $P0 + inc i + $P0 = new 'FixedStringArray', 2 + $P0[0] = utf8:"\u0100" # Ā + $P0[1] = "xIA=" + encode_decode_tests[i] = $P0 + inc i + $P0 = new 'FixedStringArray', 2 + $P0[0] = utf16:"\x{00c7}" # Ç + $P0[1] = "xwA=" + encode_decode_tests[i] = $P0 + inc i + $P0 = new 'FixedStringArray', 2 + $P0[0] = ucs2:"\x{00ff}\x{0000}" # "ÿ\0" + $P0[1] = "/wAAAA==" + encode_decode_tests[i] = $P0 + inc i decode_tests = new 'FixedPMCArray', 2 $P0 = new 'FixedStringArray', 2 @@ -46,11 +91,12 @@ Test utf8 encoded [ 'MIME'; 'Base64' ] $P0[0] = "YQ" $P0[1] = "a" decode_tests[1] = $P0 - - .local int count + + .local int count, enc_num, hex_cnt, bufused, len count = 0 .local pmc test_iterator, test_case - .local string plain, base64, comment, comment_count + .local string plain, base64, comment, comment_count, enc, esc_plain, hex_str + hex_str = '' test_iterator = iter encode_decode_tests enc_dec_loop: @@ -58,11 +104,20 @@ Test utf8 encoded [ 'MIME'; 'Base64' ] test_case = shift test_iterator plain = test_case[0] base64 = test_case[1] - comment = 'encode' - comment_count = count - comment = concat comment, comment_count - comment = concat comment, " " - comment = concat comment, plain + enc_num = encoding plain + enc = encodingname enc_num + esc_plain = escape plain + bufused = bytelength plain + len = length plain + hex_str = hex_chars( plain, enc ) + $P0 = new 'FixedPMCArray', 6 + $P0[0] = count + $P0[1] = enc + $P0[2] = esc_plain + $P0[3] = hex_str + $P0[4] = bufused + $P0[5] = len + comment = sprintf "encode%d %s:\"%s\" %s(size=%d,len=%d)", $P0 test_encode( plain, base64, comment ) comment = 'decode' comment_count = count @@ -78,17 +133,47 @@ Test utf8 encoded [ 'MIME'; 'Base64' ] test_case = shift test_iterator base64 = test_case[0] plain = test_case[1] - comment = 'decode' - comment_count = count - comment = concat comment, comment_count - comment = concat comment, " " - comment = concat comment, plain + $I0 = encoding plain + enc = encodingname $I0 + esc_plain = escape plain + $P0 = new 'ResizablePMCArray' + push $P0, comment_count + push $P0, enc + push $P0, esc_plain + push $P0, $I0 + comment = sprintf "decode%d %s:\"%s\"(enc=%d)", $P0 test_decode( plain, base64, comment ) inc count goto dec_loop dec_loop_end: .end +.sub hex_chars + .param string chars + .param string enc + + .local string s + .local pmc bb + .local int len + bb = new 'ByteBuffer' + s = clone chars + bb = s + s = bb.'get_string'(enc) + len = length s + $P0 = new 'FixedPMCArray', 2 + $I1 = 0 + $S0 = '' +loop_1: + $I0 = ord s, $I1 + $P0[0] = $S0 + $P0[1] = $I0 + $S0 = sprintf '%s\x%x', $P0 + inc $I1 + if $I1 < len goto loop_1 + ## $S0 = chopn $S0, 2 + .return ($S0) +.end + .sub test_encode .param string plain .param string base64 @@ -111,29 +196,54 @@ Test utf8 encoded [ 'MIME'; 'Base64' ] .param string base64 .param string comment + #.include "iglobals.pasm" + #.local pmc interp + #interp = getinterp + #.local pmc config + #config = interp[.IGLOBALS_CONFIG_HASH] .local pmc dec_sub dec_sub = get_global [ "MIME"; "Base64" ], 'decode_base64' - .local pmc eight_to_six - eight_to_six = get_global 'eight_to_six' - .local pmc is is = get_hll_global [ 'Test'; 'More' ], 'is' - .local string decode, result_decode - .local string enc + .local string decode, result_norm, plain_norm + .local string enc, enc1 $I0 = encoding plain enc = encodingname $I0 - decode = dec_sub( base64 ) - result_decode = trans_encoding decode, $I0 - comment = concat comment, " <-" - comment = concat comment, enc - is( result_decode, plain, comment ) + + decode = dec_sub( base64, enc ) + + $I1 = encoding decode + enc1 = encodingname $I1 + $P0 = new 'ResizablePMCArray' + push $P0, comment + push $P0, enc1 + push $P0, enc + push $P0, $I0 + comment = sprintf "%s %s<-%s(enc=%d)", $P0 + if enc == 'binary' goto HEX_C + .local int has_icu + #has_icu = config['has_icu'] + has_icu = 1 + if has_icu goto HAS_ICU + + is( decode, plain, comment ) + HAS_ICU: + result_norm = compose decode + plain_norm = compose plain + is( result_norm, plain_norm, comment ) + goto END + HEX_C: + $S0 = hex_chars(decode, enc1) + $S1 = hex_chars(plain, enc) + is( $S0, $S1, comment ) + END: .end =head1 AUTHOR -Bernhard Schmalhofer and others. +Reini Urban, Bernhard Schmalhofer and others. =cut From 220ab0a81deb3e445d9f67a4bf4d1bac2b9334ee Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Tue, 2 Oct 2012 09:43:28 -0500 Subject: [PATCH 22/34] Revised [GH #813 + #814] ChangeLog --- ChangeLog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6641b4262b..79b07f141b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,7 +22,10 @@ have been fixed. There are only some remaining platforms errors on darwin/x86. - Libraries - + Fixed Mime/Base64 encode_base64. Split long lines at 76 chars. [GH #826] + + Fixed Mime::Base64: Split long lines at 76 chars. [GH #826] + Support multi-byte codepoints. use now binary encoding, + encoded files are now endian specific [GH #813 + #814], + added 2nd optional encoding arg to decode_base64(). - Documentation + Cleaned up removed parrot cmdline options -D/-O/-v from --help output and running.pod [GH #838] From 8c05855049581de4d85bf4f93db67998a65d4f84 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Tue, 2 Oct 2012 11:06:05 -0500 Subject: [PATCH 23/34] [GH #813, #814] Fix tests for big-endian Also check for has_icu to check with composed unicode strings --- t/library/mime_base64.t | 33 +++++++++++++++++---- t/library/mime_base64u.t | 63 ++++++++++++++++++++++++++++++---------- 2 files changed, 76 insertions(+), 20 deletions(-) diff --git a/t/library/mime_base64.t b/t/library/mime_base64.t index 026eac302b..e01bae3690 100644 --- a/t/library/mime_base64.t +++ b/t/library/mime_base64.t @@ -418,12 +418,29 @@ CODE .param string base64 .param string comment + .include "iglobals.pasm" + .local pmc interp + interp = getinterp + .local pmc config + config = interp[.IGLOBALS_CONFIG_HASH] + .local int has_icu + has_icu = config['has_icu'] + .local int bigendian + bigendian = config['bigendian'] + .local pmc dec_sub dec_sub = get_global [ "MIME"; "Base64" ], 'decode_base64' - .local pmc is + .local pmc is, skip is = get_hll_global [ 'Test'; 'More' ], 'is' - + skip = get_hll_global [ 'Test'; 'More' ], 'skip' + + $S0 = 'AAAA' + ne base64, $S0, CONT_TEST + unless bigendian goto CONT_TEST + skip(1, 'multi-byte codepoint test in big-endian') + goto END + CONT_TEST: .local string decode, result_decode .local string enc, enc1 $I0 = encoding plain @@ -438,14 +455,20 @@ CODE DEC_2: $I1 = encoding decode enc1 = encodingname $I1 - .local string plain_norm, result_norm - result_norm = compose decode - plain_norm = compose plain comment = concat comment, " " comment = concat comment, enc1 comment = concat comment, " <-" comment = concat comment, enc + + .local string plain_norm, result_norm + if has_icu goto HAS_ICU + is( decode, plain, comment ) + goto END + HAS_ICU: + result_norm = compose decode + plain_norm = compose plain is( result_norm, plain_norm, comment ) + END: .end diff --git a/t/library/mime_base64u.t b/t/library/mime_base64u.t index 1e57d335ee..e1126e9e97 100644 --- a/t/library/mime_base64u.t +++ b/t/library/mime_base64u.t @@ -98,6 +98,33 @@ perl -MMIME::Base64 -e'for ([qq(a2)],[qq(c2a2)],[qw(203e)],[qw(3e 20)],[qw(1000) .local string plain, base64, comment, comment_count, enc, esc_plain, hex_str hex_str = '' + .include "iglobals.pasm" + .local pmc interp + interp = getinterp + .local pmc config + config = interp[.IGLOBALS_CONFIG_HASH] + .local int bigendian + bigendian = config['bigendian'] + + unless bigendian goto BE_INIT + .local pmc be_result + be_result = new 'FixedStringArray', size + test_iterator = iter encode_decode_tests + be_loop: + unless test_iterator goto be_loop_end + test_case = shift test_iterator + base64 = test_case[1] + be_result[count] = base64 + inc count + goto be_loop + be_loop_end: + be_result[1] = 'ID4=' + be_result[5] = 'AQA=' + be_result[7] = 'AMc=' + be_result[8] = 'AP8AAA==' + + BE_INIT: + count = 0 test_iterator = iter encode_decode_tests enc_dec_loop: unless test_iterator goto enc_dec_loop_end @@ -118,6 +145,10 @@ perl -MMIME::Base64 -e'for ([qq(a2)],[qq(c2a2)],[qw(203e)],[qw(3e 20)],[qw(1000) $P0[4] = bufused $P0[5] = len comment = sprintf "encode%d %s:\"%s\" %s(size=%d,len=%d)", $P0 + + unless bigendian goto BE_SWAP + base64 = be_result[count] + BE_SWAP: test_encode( plain, base64, comment ) comment = 'decode' comment_count = count @@ -196,11 +227,16 @@ loop_1: .param string base64 .param string comment - #.include "iglobals.pasm" - #.local pmc interp - #interp = getinterp - #.local pmc config - #config = interp[.IGLOBALS_CONFIG_HASH] + .include "iglobals.pasm" + .local pmc interp + interp = getinterp + .local pmc config + config = interp[.IGLOBALS_CONFIG_HASH] + .local int has_icu + has_icu = config['has_icu'] + .local int bigendian + bigendian = config['bigendian'] + .local pmc dec_sub dec_sub = get_global [ "MIME"; "Base64" ], 'decode_base64' @@ -223,17 +259,14 @@ loop_1: push $P0, $I0 comment = sprintf "%s %s<-%s(enc=%d)", $P0 if enc == 'binary' goto HEX_C - .local int has_icu - #has_icu = config['has_icu'] - has_icu = 1 - if has_icu goto HAS_ICU - - is( decode, plain, comment ) + if has_icu goto HAS_ICU + is( decode, plain, comment ) + goto END HAS_ICU: - result_norm = compose decode - plain_norm = compose plain - is( result_norm, plain_norm, comment ) - goto END + result_norm = compose decode + plain_norm = compose plain + is( result_norm, plain_norm, comment ) + goto END HEX_C: $S0 = hex_chars(decode, enc1) $S1 = hex_chars(plain, enc) From 87ac5cebd4610f1a53c27b6f0b7298a36e25f4a5 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Tue, 2 Oct 2012 11:28:35 -0500 Subject: [PATCH 24/34] Revised [GH #813 + #814] ChangeLog - titlecasing --- ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79b07f141b..3e9047d731 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,9 +23,9 @@ darwin/x86. - Libraries + Fixed Mime::Base64: Split long lines at 76 chars. [GH #826] - Support multi-byte codepoints. use now binary encoding, + Support multi-byte codepoints. Use binary encoding, encoded files are now endian specific [GH #813 + #814], - added 2nd optional encoding arg to decode_base64(). + Added 2nd optional encoding arg to decode_base64(). - Documentation + Cleaned up removed parrot cmdline options -D/-O/-v from --help output and running.pod [GH #838] From fedbe5e03c912b2ef32a5894051202b8a6ca21aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Vorla=CC=88nder?= Date: Wed, 3 Oct 2012 10:32:14 +0200 Subject: [PATCH 25/34] Fix a bug that causes parrot to fail on platforms where size_t is an unsigned type. Signed-off-by: Reini Urban --- src/hash.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hash.c b/src/hash.c index e9ed11fcff..02c3e89927 100644 --- a/src/hash.c +++ b/src/hash.c @@ -850,7 +850,8 @@ expand_hash(PARROT_INTERP, ARGMOD(Hash *hash)) const UINTVAL old_size = hash->mask + 1; const UINTVAL new_size = old_size << 1; /* Double. Right-shift is 2x */ const UINTVAL new_mask = new_size - 1; - size_t offset, i; + size_t i; + ptrdiff_t offset; /* allocate some less buckets From 29ec1b05e56a2befed0036382637a90928ac0c8f Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Wed, 3 Oct 2012 09:35:18 -0500 Subject: [PATCH 26/34] [GH #854] ChangeLog line --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 3e9047d731..bd8bf77f4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ bytes from every installed executable. [GH #824] + Parrot_get_cpu_type returns now "unknown" for all unknown cpu types. On non-windows it returned before 4.9.0 a null string. [GH #846] + + Fixed src/hash.c for platforms where size_t is unsigned (e.g. vms) [GH #854] - Build + Improved warnings for clang. [GH #843] + Cleaned wrong UNUSED(arg) macros in all pmc's due to an improved From 48a9db23543419806669238988f87bdb518e7664 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Wed, 3 Oct 2012 10:19:49 -0500 Subject: [PATCH 27/34] [GH #855] utf8 comparison problem --- t/library/mime_base64.t | 3 +++ 1 file changed, 3 insertions(+) diff --git a/t/library/mime_base64.t b/t/library/mime_base64.t index e01bae3690..ef9c98c23f 100644 --- a/t/library/mime_base64.t +++ b/t/library/mime_base64.t @@ -437,6 +437,9 @@ CODE $S0 = 'AAAA' ne base64, $S0, CONT_TEST + ## Note: also fails on solaris little-endian + skip(1, '\0\0\0 fails to compare for unknown reasons GH #855') + goto END unless bigendian goto CONT_TEST skip(1, 'multi-byte codepoint test in big-endian') goto END From 8632cf0fa8eb76efe47cef5be9224fea021f554c Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Wed, 3 Oct 2012 14:10:52 -0500 Subject: [PATCH 28/34] [cage] silence @noinline@ warning on unknown compilers e.g. solaris cc --- config/auto/gcc.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/auto/gcc.pm b/config/auto/gcc.pm index d3bc38abdd..54c8046643 100644 --- a/config/auto/gcc.pm +++ b/config/auto/gcc.pm @@ -47,8 +47,10 @@ sub _probe_for_gcc { sub _evaluate_gcc { my ($self, $conf, $gnucref) = @_; - # Set gccversion to undef. This will also trigger any hints-file - # callbacks that depend on knowing whether or not we're using gcc. + # Set empty noonline and gccversion to undef. + # This will also trigger any hints-file callbacks that depend on + # knowing whether or not we're using gcc. + $conf->data->set( noinline => '' ); # This key should always exist unless the program couldn't be run, # which should have been caught by the 'die' above. From 5f6ffbca4397768342ea300eda37a1e8c206867e Mon Sep 17 00:00:00 2001 From: Josh Juran Date: Thu, 4 Oct 2012 11:17:46 -0700 Subject: [PATCH 29/34] config/auto/thread: Correct "has thread" grammar --- config/auto/thread.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/auto/thread.pm b/config/auto/thread.pm index ec4bd51183..fe400128c0 100644 --- a/config/auto/thread.pm +++ b/config/auto/thread.pm @@ -6,7 +6,7 @@ config/auto/thread.pm - Thread support =head1 DESCRIPTION -Determining if the system has a Thread support. +Determining if the system has thread support. =cut @@ -22,7 +22,7 @@ use Parrot::Configure::Utils ':auto'; sub _init { my $self = shift; my %data; - $data{description} = q{Does your system has thread}; + $data{description} = q{Does your system have threads}; $data{result} = q{}; return \%data; } From 6236d2d7f970d2f0aab19a3afeb3049f888aa6fc Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Fri, 5 Oct 2012 08:04:26 -0500 Subject: [PATCH 30/34] [cage] Fix .c.i rule for solaris cc With solaris cc -c overrides -E. cc: Warning: "-c" redefines goal from "preprocessed source (file)" to "object file" --- config/gen/makefiles/root.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/gen/makefiles/root.in b/config/gen/makefiles/root.in index 3b619b86ff..c2e736414c 100644 --- a/config/gen/makefiles/root.in +++ b/config/gen/makefiles/root.in @@ -596,7 +596,7 @@ MAKE_C = @make_c@ .c$(O) : # suffix rule (limited support) $(CC) $(CFLAGS) @optimize@ $(CC_WARN) -I$(@D) -Isrc/ @cc_o_out@$@ -c $< .c.i : # suffix rule (limited support) - $(CC) -E $(CFLAGS) -I$(@D) -Isrc/ @cc_o_out@$@ -c $< + $(CC) -E $(CFLAGS) -I$(@D) -Isrc/ @cc_o_out@$@ $< #UNLESS(win32):.s$(O) : # suffix rule (limited support) #UNLESS(win32): $(CC) $(CFLAGS) @optimize@ $(CC_WARN) -I$(@D) @cc_o_out@$@ -c $< From d7d2245aa9d8ca20fbc0efcc6b7768649fc675dc Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 15 Oct 2012 21:23:21 -0700 Subject: [PATCH 31/34] Remove empty sections from ChangeLog --- ChangeLog | 2 -- 1 file changed, 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd8bf77f4c..39856ab1e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -32,8 +32,6 @@ running.pod [GH #838] - Tools + Improved gdb pretty-printing for multi-byte strings - - Tests - - Community 2012-09-18 release 4.8.0 - Core From 3afb63c5dab7396fe7376d6031a6167236553272 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 15 Oct 2012 21:51:04 -0700 Subject: [PATCH 32/34] Update various things related to the 4.9.0 release --- MANIFEST.generated | 6 +++--- README.pod | 2 +- VERSION | 2 +- docs/parrothist.pod | 1 + docs/project/release_manager_guide.pod | 1 - include/parrot/oplib/core_ops.h | 2 +- src/ops/core_ops.c | 6 +++--- tools/release/release.json | 10 +++++----- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/MANIFEST.generated b/MANIFEST.generated index 1c23af4f69..783e8aaa2c 100644 --- a/MANIFEST.generated +++ b/MANIFEST.generated @@ -1,14 +1,14 @@ # See tools/dev/install_files.pl for documentation on the # format of this file. # Please re-sort this file after *EVERY* modification -blib/lib/libparrot.4.8.0.dylib [main]lib +blib/lib/libparrot.4.9.0.dylib [main]lib blib/lib/libparrot.a [main]lib blib/lib/libparrot.dylib [main]lib blib/lib/libparrot.so [main]lib -blib/lib/libparrot.so.4.8.0 [main]lib +blib/lib/libparrot.so.4.9.0 [main]lib compilers/data_json/data_json.pbc [data_json] config/gen/call_list/opengl.in [] -cygparrot-4.8.0.dll [main]bin +cygparrot-4.9.0.dll [main]bin docs/ops/bit.pod [doc] docs/ops/cmp.pod [doc] docs/ops/core.pod [doc] diff --git a/README.pod b/README.pod index b4a0f0495c..7825095b49 100644 --- a/README.pod +++ b/README.pod @@ -4,7 +4,7 @@ =head1 NAME -README.pod - Readme to Parrot, version 4.8.0. +README.pod - Readme to Parrot, version 4.9.0. =head1 DESCRIPTION diff --git a/VERSION b/VERSION index 88f181192c..6ed7776bf3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.8.0 +4.9.0 diff --git a/docs/parrothist.pod b/docs/parrothist.pod index 6dc98d4398..b341a75894 100644 --- a/docs/parrothist.pod +++ b/docs/parrothist.pod @@ -147,5 +147,6 @@ Starred release numbers indicate supported releases. rurban 4.6.0 * 2012-Jul-17 "Wild Parrots of Telegraph Hill" Whiteknight 4.7.0 2012-Aug-22 "Hispaniolan" alvis 4.8.0 2012-Sep-18 "Spix's Macaw" + dukeleto 4.9.0 * 2012-Oct-16 "Proto-Hydra" =cut diff --git a/docs/project/release_manager_guide.pod b/docs/project/release_manager_guide.pod index 55faab9794..ab990adc87 100644 --- a/docs/project/release_manager_guide.pod +++ b/docs/project/release_manager_guide.pod @@ -544,7 +544,6 @@ The calendar of releases is available at the C Google calendar, visible at L. - - Oct 16, 2012 - 4.9.0 - dukeleto - Nov 20, 2012 - 4.10.0 - rurban - Dec 18, 2012 - 4.11.0 - ?? - Jan 15, 2013 - 5.0.0 - dukeleto diff --git a/include/parrot/oplib/core_ops.h b/include/parrot/oplib/core_ops.h index 1912f72b3a..a7d6fc2fb8 100644 --- a/include/parrot/oplib/core_ops.h +++ b/include/parrot/oplib/core_ops.h @@ -19,7 +19,7 @@ #include "parrot/runcore_api.h" PARROT_EXPORT -op_lib_t *Parrot_DynOp_core_4_8_0(PARROT_INTERP, long init); +op_lib_t *Parrot_DynOp_core_4_9_0(PARROT_INTERP, long init); opcode_t * Parrot_end(opcode_t *, PARROT_INTERP); opcode_t * Parrot_noop(opcode_t *, PARROT_INTERP); diff --git a/src/ops/core_ops.c b/src/ops/core_ops.c index 131193790d..44d135d58f 100644 --- a/src/ops/core_ops.c +++ b/src/ops/core_ops.c @@ -24439,7 +24439,7 @@ op_lib_t core_op_lib = { PARROT_FUNCTION_CORE, /* core_type = PARROT_XX_CORE */ 0, /* flags */ 4, /* major_version */ - 8, /* minor_version */ + 9, /* minor_version */ 0, /* patch_version */ 1125, /* op_count */ core_op_info_table, /* op_info_table */ @@ -24568,7 +24568,7 @@ static void hop_deinit(PARROT_INTERP) hop_buckets = NULL; }PARROT_EXPORT op_lib_t * -Parrot_DynOp_core_4_8_0(PARROT_INTERP, long init) { +Parrot_DynOp_core_4_9_0(PARROT_INTERP, long init) { /* initialize and return op_lib ptr */ if (init == 1) { @@ -24597,7 +24597,7 @@ Parrot_lib_core_ops_load(PARROT_INTERP) { PMC *const lib = Parrot_pmc_new(interp, enum_class_ParrotLibrary); - ((Parrot_ParrotLibrary_attributes*)PMC_data(lib))->oplib_init = (void *) Parrot_DynOp_core_4_8_0; + ((Parrot_ParrotLibrary_attributes*)PMC_data(lib))->oplib_init = (void *) Parrot_DynOp_core_4_9_0; dynop_register(interp, lib); return lib; } diff --git a/tools/release/release.json b/tools/release/release.json index 74b657ff32..a134058ccd 100644 --- a/tools/release/release.json +++ b/tools/release/release.json @@ -1,8 +1,8 @@ { - "release.version" : "4.8.0", - "release.name" : "Spix's Macaw", + "release.version" : "4.9.0", + "release.name" : "Proto-Hydra", "release.day" : "Tuesday", - "release.nextdate" : "16 October 2012", + "release.nextdate" : "12 November 2012", "web.root" : "http://parrot.org/", "web.source" : "download", @@ -11,10 +11,10 @@ "web.org_root" : "https://github.com/parrot", "bugday.day" : "Saturday", - "bugday.date" : "13 October 2012", + "bugday.date" : "10 November 2012", "wiki.root" : "https://github.com/parrot/parrot/wiki", "wiki.bugday" : "bug_day_2012_10_13", - "ftp.path" : "ftp://ftp.parrot.org/pub/parrot/releases/devel/4.8.0/" + "ftp.path" : "ftp://ftp.parrot.org/pub/parrot/releases/devel/4.9.0/" } From 1101abb1cf3ce236b0552166bd0043851ddcc3b7 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 15 Oct 2012 21:55:32 -0700 Subject: [PATCH 33/34] Update pbc testing files --- t/native_pbc/annotations.pbc | Bin 1408 -> 1408 bytes t/native_pbc/integer.pbc | Bin 944 -> 944 bytes t/native_pbc/number.pbc | Bin 3312 -> 3312 bytes t/native_pbc/string.pbc | Bin 1328 -> 1328 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/t/native_pbc/annotations.pbc b/t/native_pbc/annotations.pbc index 6f5db6695ad3e92ffaed11ac39e80e2fe83269cc..c3d1bdbab12f6b589e45a54aede50b3cc1a2ece5 100644 GIT binary patch delta 34 qcmZqRZr~R97vSW~%O%Cd!N9=6!N9|~QQ!jO Date: Tue, 16 Oct 2012 20:43:43 -0700 Subject: [PATCH 34/34] update native pbc test data --- t/native_pbc/integer_4.pbc | Bin 1312 -> 1312 bytes t/native_pbc/number_4.pbc | Bin 4016 -> 4016 bytes t/native_pbc/number_5.pbc | Bin 4864 -> 4864 bytes t/native_pbc/string_4.pbc | Bin 1840 -> 1840 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/t/native_pbc/integer_4.pbc b/t/native_pbc/integer_4.pbc index 4f46b52ec21c6ce7ca003337102c4305ab3bdada..6f51c19a769cadfb375741981d62dd41100409bf 100644 GIT binary patch literal 1312 zcmb`FPfNo<5XDz5VnYj_Ja`gMiqQBGG)b?m&|Ex)ZC#{LlV!8|nLPRl{mcA%m=cWO zUS8(SytlKHdB4l@adMg*88aA~(VkIfhfw*bVjUg`0g}IxkL=KK&>rqB{}X7X=j0vJo z1nFDZ8$F+!>$BtUny&ftZt|-pxT^6jzVttY5JU&P6a#$VLFPf+h1|FGkq4cNpy%)1 zzV}dc7xnXIb7{5vL=tcM{$UMi&kba=qD|lk`)b*Vsdiwkg@&B*+ao;C^R(UA^ literal 1312 zcmaizKWhR(6vS8KKMsWiEP@2F2q6{*@)6?2%5Vm}#wNisVDwPa=Ys@n^C@GR`B{uC zcg@_)+nM)v_wMg?oOY64(hAjDGqfwgo-@JfcgCGoC0tnHN_@P?C+X~Y^8T^jKNQQ| zr}VzCB_u~Q;7@1SJb%h^_cIrMe9qCqqaL_pncvqt_kApMz_D{K>xU1#Uw^Gu!w~9f z{N@7~Z-^JdZw1xF=?~sYr(auqU^;d7d(gR}pZYGh+s!_NOZguyhdH{^Uxe3@_2fHx zKkDS)SU&ZEbddc|rLzu<_0jSZ{MdO=AZHiJA4&H*eYtpNNp3&j>v1{8$cnt9~XBm={@M6eZp2IS9=l`IeL+=0p diff --git a/t/native_pbc/number_4.pbc b/t/native_pbc/number_4.pbc index 169ddfc911199be03721f1ed03a3f5dafcc82ac2..5789d5ab9e6f945f27f2661c35bfe5a74006f7ad 100644 GIT binary patch delta 29 kcmdlWzd@e&Ux1S{FP9V-2Ll5O=SJRQc1F(4jqLgy0C189g8%>k delta 31 ncmdlWzd@e&Ux1S{FP9V-2Ll5O`$pbk_Q@H{0-GnWD{ue+gGC30 diff --git a/t/native_pbc/number_5.pbc b/t/native_pbc/number_5.pbc index 5709a4844eff31e9ae572d36274fed3a242d9bee..51ed335d3c6d980453643b6c914f52754e758812 100644 GIT binary patch delta 483 zcmZorYfuyT7vSW~%O%Cd!NA1A$-u)nQNVz4!$imPj46`^8T}a(HYYO5voUf`Ze))K z3O!`Et!HS^bzndS4XkKhVeA=N^^2F5mE^g6~!5&H*e(aXPSI~H)6AczyT%zmLN6O diff --git a/t/native_pbc/string_4.pbc b/t/native_pbc/string_4.pbc index 6c1eda5fac01e6c80a96fb32f3d452b50fab147e..0d95ce9fdd63f4982e3a66bd8363a2aa3e4c60b2 100644 GIT binary patch delta 29 kcmdnMw}FrMUx1S{FP9V-2Ll5O=SJRQCPvQ9jZEuV0Bykr(*OVf delta 29 kcmdnMw}FrMUx1S{FP9V-2Ll5O`$pbkCPwznjZEuV0BxNH&j0`b