I am new to Lua, and although I have been reviewing previous mails trying to find the answer to this and studying the code, I could not find anything relevant.
I am trying to use Lua to extend a legacy 16-bit MSDOS application compiled with Borland C 3.1. I cannot change that environment (i.e. I cannot move to protected mode and DJGPP). I downloaded version 5.1 and made a new entry in the makefile with the following settings:
and after changing a few details, like ".o" for ".obj" and ".a" for ".lib", everything compiles and links properly. However, there is a strange bug both in lua.exe and in luac.exe. The bug seems to be related to the logical operator OR, when the left argument is nil or false and the right argument is a number constant (not a variable with a numeric value). For example,
> print(nil or 0)
> print(false or 1234.5678)
This should have printed the second argument. Other combinations work correctly:
> print(nil or x)
> print(nil or "hello")
> print(false or true)
> print(22 or 33)
> print(10 or false)
I tried different memory models like huge, increasing the stack size, a different compiler (Digital Mars), all with same result. Windows and Linux versions work OK with any compiler, so this looks like a 16/32 bit thing. Interestingly, the 16-bit version works properly if you compile with the following flag:
-Ddouble=float (this replaces 64-bit doubles with 32-bit floats).
So I guess that either the size or the alignment of something is wrong somewhere, but I cannot find it.
Thank you, Greg. It works perfectly now. Maybe I'm repeating myself, but I had a crash and I don't know if the previous message got out. I hadn't looked in the obvious place -- the bugs list.
*********** REPLY SEPARATOR ***********
On 27/03/06 at 16:32 Greg Falcon wrote:
>On 3/27/06, Hugo Etchegoyen <[hidden email]> wrote:
>> > print(nil or 0)
>> > print(false or 1234.5678)
>This is a known bug; a patch is available here: