Lua on 16-bit MSDOS

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua on 16-bit MSDOS

Hugo Etchegoyen
Hi,

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:

CC=bcc CFLAGS="-ml -DLUA_ANSI" LIBS= RANLIB=echo MYLDFLAGS=-ml

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)
2.2968702947708e-180

> print(false or 1234.5678)
2.2968702947708e-180

This should have printed the second argument. Other combinations work correctly:

> x=0
> print(nil or x)
0

> print(nil or "hello")
hello

> print(false or true)
true

> print(22 or 33)
22

> print(10 or false)
10

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.

Any clues?

Thanks a lot,
Hugo Etchegoyen



Reply | Threaded
Open this post in threaded view
|

Re: Lua on 16-bit MSDOS

Greg Falcon
On 3/27/06, Hugo Etchegoyen <[hidden email]> wrote:
> > print(nil or 0)
> 2.2968702947708e-180
>
> > print(false or 1234.5678)
> 2.2968702947708e-180

This is a known bug; a patch is available here:
http://www.lua.org/bugs.html

Greg F
Reply | Threaded
Open this post in threaded view
|

Re: Lua on 16-bit MSDOS

Hugo Etchegoyen
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.

HE

*********** 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)
>> 2.2968702947708e-180
>>
>> > print(false or 1234.5678)
>> 2.2968702947708e-180
>
>This is a known bug; a patch is available here:
>http://www.lua.org/bugs.html
>
>Greg F