From 89e8d7070169d11e7f188754006e03a40699c5dc Mon Sep 17 00:00:00 2001
From: Mike Pall <mike>
Date: Sun, 22 Dec 2013 11:43:44 +0100
Subject: Fix compilation of string.byte(s, nil, n).

---
 src/lj_ffrecord.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

(limited to 'src')

diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c
index 35e2e88e..693fd297 100644
--- a/src/lj_ffrecord.c
+++ b/src/lj_ffrecord.c
@@ -657,20 +657,19 @@ static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
       end = argv2int(J, &rd->argv[2]);
     }
   } else {  /* string.byte(str, [,start [,end]]) */
-    if (!tref_isnil(J->base[1])) {
+    if (tref_isnil(J->base[1])) {
+      start = 1;
+      trstart = lj_ir_kint(J, 1);
+    } else {
       start = argv2int(J, &rd->argv[1]);
       trstart = lj_opt_narrow_toint(J, J->base[1]);
-      trend = J->base[2];
-      if (tref_isnil(trend)) {
-	trend = trstart;
-	end = start;
-      } else {
-	trend = lj_opt_narrow_toint(J, trend);
-	end = argv2int(J, &rd->argv[2]);
-      }
+    }
+    if (J->base[1] && !tref_isnil(J->base[2])) {
+      trend = lj_opt_narrow_toint(J, J->base[2]);
+      end = argv2int(J, &rd->argv[2]);
     } else {
-      trend = trstart = lj_ir_kint(J, 1);
-      end = start = 1;
+      trend = trstart;
+      end = start;
     }
   }
   if (end < 0) {
-- 
cgit v1.2.3-55-g6feb