Shmuel Zeigerman wrote: > Jerome Vuarand wrote: >> Without a dump of the actual data, the problem can come from either >> struct of FB. Try: >> >> a = struct.pack("BHIL",1,2,3,4) >> print(table.concat({string.byte(a,1,#a)}," ")) >> >> On my 32bits WinXP it gives: >> >> 1 2 0 3 0 0 0 4 0 0 0 >> >> which is the expected result. > > This test on my system gave incorrect result: 1 2 0 3 4 0 0 0 which > explains why the DLL I sent to Merick didn't work for him (though it > passed teststruct.lua OK). > > The source for the DLL was taken from: > http://www.inf.puc-rio.br/~roberto/struct/ > > The problem appears on the line 83 of struct.c, here's the patch: > - case 'i': return getnum(fmt, sizeof(int)); > + case 'i': case 'I': return getnum(fmt, sizeof(int)); Ah, yes, that's right. I just realized I have such a patch in my version. It's applied automatically by my build system so I just forgot about it. I attached my patch file. The issue was already discussed here in January [1], but the online version of struct still has the problem. [1] http://lua-users.org/lists/lua-l/2008-01/msg00439.html
Attachment:
struct-In.patch
Description: struct-In.patch