lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Can anyone please help here? 

On Mon, 2 Aug, 2021, 3:15 pm aman agrawal, <aman.161089@gmail.com> wrote:
Hi,

I'm trying to run the attached program in Lua 5.2.2 and 5.4.3 but I'm getting different number of arguments in Lua stack when I check in hook function. Is anything changed related to Lua hook function call?.

I compiled the attached program as:
In 5.4: 
cc -o test_set_hook test_set_hook.c -Wall -I /var/views/lua/lua-5.4.3/src/ -L/var/views/lua/lua-5.4.3/src/ -lm -llua
In 5.2:
cc -o test_set_hook test_set_hook.c -Wall -I /var/views/lua/lua-5.2.2/src/ -L/var/views/lua/lua-5.2.2/src/ -lm -llua

I'm doing this compilation in FeeBSD -11.4 (AMD 64).

Here is the output of the program:
In Lua 5.4:

[Aman_freebsd114:/var/views/lua/lua-5.4.3/src]# ./test_set_hook
In C, calling Lua->test_sethook_1("abcdef")

top : 2
Checking top element value : (null)
Back in C again
Returned string=abcdef

---------------------------------
In C, calling Lua->test_sethook_2("abcdef")

top : 17
Checking top element value :
top : 17
Checking top element value :
top : 17
Checking top element value :  !"#$%&'()*+,-./
top : 17
Checking top element value : 0123456789:;<=>?
top : 17
Checking top element value : @ABCDEFGHIJKLMNO
top : 17
Checking top element value : PQRSTUVWXYZ[\]^_
top : 17
Checking top element value : `abcdefghijklmno
top : 17
Checking top element value : pqrstuvwxyz{|}~
top : 17
Checking top element value :

top : 17
Checking top element value :  
top : 17
Checking top element value :  ¡¢£¤¥¦§¨©ª«¬­®¯
top : 17
Checking top element value : °±²³´µ¶·¸¹º»¼½¾¿
top : 17
Checking top element value : AÃŅLJɉˋ͍Ϗ
top : 17
Checking top element value : ёӓՕחٙۛݝߟ
top : 17
Checking top element value : ᢢ䥥稨ꫫ󻠍
top : 17
Checking top element value : 񲳳񶷷򻼼
top : 24
Checking top element value : 255
Back in C again
Returned string=abcdef





Lua 5.2.2:

[Aman_freebsd114:/var/views/lua/lua-5.2.2/src]# cc -o test_set_hook test_set_hook.c -Wall -I /var/views/lua/lua-5.2.2/src/ -L/var/views/lua/lua-5.2.2/src/ -lm -llua
[Aman_freebsd114:/var/views/lua/lua-5.2.2/src]# ./test_set_hook
In C, calling Lua->test_sethook_1("abcdef")

top : 1
Checking top element value : abcdef
Back in C again
Returned string=abcdef

---------------------------------
In C, calling Lua->test_sethook_2("abcdef")

top : 17
Checking top element value :
top : 17
Checking top element value :
top : 17
Checking top element value :  !"#$%&'()*+,-./  
top : 17
Checking top element value : 0123456789:;<=>?  
top : 17
Checking top element value : @ABCDEFGHIJKLMNO  
top : 17
Checking top element value : PQRSTUVWXYZ[\]^_  
top : 17
Checking top element value : `abcdefghijklmno  
top : 17
Checking top element value : pqrstuvwxyz{|}~    
top : 17
Checking top element value :

top : 17
Checking top element value :
top : 17
Checking top element value :  ¡¢£¤¥¦§¨©ª«¬­®¯  
top : 17
Checking top element value : °±²³´µ¶·¸¹º»¼½¾¿  
top : 17
Checking top element value : AÃŅLJɉˋ͍Ϗ  
top : 17
Checking top element value : ёӓՕחٙۛݝߟ  
top : 17
Checking top element value : ᢢ䥥稨ꫫ󻮠
top : 17
Checking top element value : 񲳳񶷷򻼼񞞠
top : 1
Checking top element value : abcdef
Back in C again
Returned string=abcdef
[Aman_freebsd114:/var/views/lua/lua-5.2.2/src]# 
--
Best Regards
Aman Agrawal