Fixed bugs in the binary searching for condition keys in both the Ruby and Java
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sat, 28 Apr 2007 20:08:28 +0000 (20:08 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sat, 28 Apr 2007 20:08:28 +0000 (20:08 +0000)
code generation.

git-svn-id: http://svn.complang.org/ragel/trunk@204 052ea7fc-9027-0410-9066-f65837a77df0

rlgen-java/javacodegen.cpp
rlgen-ruby/rubycodegen.cpp

index 77efbcc..12afca2 100644 (file)
@@ -277,7 +277,7 @@ void JavaTabCodeGen::COND_TRANSLATE()
                "                       _mid = _lower + (((_upper-_lower) >> 1) & ~1);\n"
                "                       if ( " << GET_WIDE_KEY() << " < " << CK() << "[_mid] )\n"
                "                               _upper = _mid - 2;\n"
-               "                       else if ( " << GET_WIDE_KEY() << " > " << CK() << "[_mid] )\n"
+               "                       else if ( " << GET_WIDE_KEY() << " > " << CK() << "[_mid+1] )\n"
                "                               _lower = _mid + 2;\n"
                "                       else {\n"
                "                               switch ( " << C() << "[" << CO() << "[" << CS() << "]"
index 87a1134..209e80a 100644 (file)
@@ -123,7 +123,7 @@ void RubyCodeGen::COND_TRANSLATE()
                << INDENT_S() <<      "_mid = _lower + (((_upper-_lower) >> 1) & ~1)" 
                << INDENT_U() <<      "if " << GET_WIDE_KEY() << " < " << CK() << "[_mid]" 
                << INDENT_O() <<         "_upper = _mid - 2" 
-               << INDENT_U() <<      "elsif " << GET_WIDE_KEY() << " > " << CK() << "[_mid]" 
+               << INDENT_U() <<      "elsif " << GET_WIDE_KEY() << " > " << CK() << "[_mid+1]" 
                << INDENT_O() <<         "_lower = _mid + 2" 
                << INDENT_U() <<      "else" 
                << INDENT_U() <<         "case " << C() << "[" << CO() << "[" << CS() << "]"