# New Ticket Created by  Robert G. Jakabosky 
# Please include the string:  [perl #57504]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=57504 >


Hello everyone,
        This is my first patch to the parrot project.

This patch fixes 19 failed tests for the Lua language.

Changes to 'languages/lua/src/build/translator.pl':
When the 32bit Lua instruction codes are being decoded they are stored in a 
64bit signed integer.  The top 32bits where not always masked off.  This 
caused a problem for instructions that had the 31st bit sit, since the top 
32bits would have been sign-extended (filled with 1s).

Changes to 'languages/lua/t/os.t':
1 test from 'os.t' fails on 64bit systems because 'os.time()' does not return 
a 'nil' for dates with year < 1970.  'os.time()' only returns 'nil' when 
mktime returns ((time_t)-1).  On 32bit systems mktime uses -1 for dates 
outside year range 1970-2038.  On 64bit systems mktime returns negative 
values for dates before year 1970, so there is only one date that will cause 
mktime to return -1 and make 'os.time()' in lua return 'nil'.  I have updated 
the test to use that one date that returns 'nil' on both 32bit & 64bit 
systems.


 CREDITS                               |    4 ++++
 languages/lua/src/build/translator.pl |    4 ++++
 languages/lua/t/os.t                  |   16 +++++++++-------
 3 files changed, 17 insertions(+), 7 deletions(-)

-- 
Robert G. Jakabosky
Index: CREDITS
===================================================================
--- CREDITS	(revision 29918)
+++ CREDITS	(working copy)
@@ -568,6 +568,10 @@
 
 N: Ritz Daniel
 
+N: Robert G. Jakabosky
+E: [EMAIL PROTECTED]
+D: language Lua bugfix.
+
 N: Robert Spier
 D: Keeps us running
 
Index: languages/lua/t/os.t
===================================================================
--- languages/lua/t/os.t	(revision 29918)
+++ languages/lua/t/os.t	(working copy)
@@ -197,14 +197,16 @@
 
 -- os.time returns nil when C mktime returns -1
 -- this test needs a out of range value on any platform
+-- On 64bit systems the following date & time is the only
+-- on that mktime will return -1 for.
 print(os.time({
-    sec = 0,
-    min = 0,
-    hour = 0,
-    day = 1,
-    month = 1,
-    year = 1000,
-    isdst = 0,
+    sec = 59,
+    min = 59,
+    hour = 15,
+    day = 31,
+    month = 12,
+    year = 1969,
+    isdst = false,
 }))
 CODE
 /^
Index: languages/lua/src/build/translator.pl
===================================================================
--- languages/lua/src/build/translator.pl	(revision 29918)
+++ languages/lua/src/build/translator.pl	(working copy)
@@ -361,10 +361,12 @@
 
     if ($rule->{format} =~ /sBx$/) {
         $pir .= "    arg_b = cur_ic >>> 14\n";
+        $pir .= "    arg_b &= 0x0003ffff\n";
         $pir .= "    arg_b -= 131071\n";
     }
     elsif ($rule->{format} =~ /Bx$/) {
         $pir .= "    arg_b = cur_ic >>> 14\n";
+        $pir .= "    arg_b &= 0x0003ffff\n";
     }
     elsif ($rule->{format} =~ /B/) {
         $pir .= "    arg_b = cur_ic >> 23\n";
@@ -433,11 +435,13 @@
 
     if ($rule->{format} =~ /sBx$/) {
         $pir .= "    arg_b = cur_ic >>> 14\n";
+        $pir .= "    arg_b &= 0x0003ffff\n";
         $pir .= "    arg_b -= 131071\n";
         $pir .= "    push args, arg_b\n";
     }
     elsif ($rule->{format} =~ /Bx$/) {
         $pir .= "    arg_b = cur_ic >>> 14\n";
+        $pir .= "    arg_b &= 0x0003ffff\n";
         $pir .= "    push args, arg_b\n";
     }
     elsif ($rule->{format} =~ /B/) {

Reply via email to