@@ -49,13 +49,8 @@ function FILE.load(path,args,venv)
4949 ' string'
5050
5151 if mode == ' luaon' then
52- local lackReturn = s :match (" ^%s*{" )
53- if s :sub (1 ,1 )~= ' \27 ' then
54- s = " --[[" .. STRING .simplifyPath (path ).. ' ]]' .. (lackReturn and ' return' or ' ' ).. s
55- else
56- s = (lackReturn and ' return' or ' ' ).. s
57- end
58- local func ,err_mes = loadstring (s )
52+ s = (s :match (" ^%s*{" ) and " return" or " " ).. s
53+ local func ,err_mes = loadstring (s ,STRING .simplifyPath (path ))
5954 if func then
6055 setfenv (func ,venv or {})
6156 local res = func ()
@@ -64,8 +59,7 @@ function FILE.load(path,args,venv)
6459 error (" FILE.load: Decode error: " .. err_mes )
6560 end
6661 elseif mode == ' lua' then
67- if s :sub (1 ,1 )~= ' \27 ' then s = " --[[" .. STRING .simplifyPath (path ).. ' ]]' .. s end
68- local func ,err_mes = loadstring (s )
62+ local func ,err_mes = loadstring (s ,STRING .simplifyPath (path ))
6963 if func then
7064 local res = func ()
7165 return assert (res ," FILE.load: run error" )
@@ -93,8 +87,10 @@ function FILE.save(data,path,args)
9387 if type (data )== ' table' then
9488 local suc
9589 if STRING .sArg (args ,' -luaon' ) then
96- suc ,data = pcall (STRING .sArg (args ,' -expand' ) and TABLE .dump or TABLE .dumpDeflate ,data )
90+ local expand = STRING .sArg (args ,' -expand' )
91+ suc ,data = pcall (expand and TABLE .dump or TABLE .dumpDeflate ,data )
9792 assert (suc ," FILE.save: Luaon-encoding error: " .. data )
93+ data = (expand and " return " or " return" ).. data
9894 else
9995 suc ,data = pcall (JSON .encode ,data )
10096 assert (suc ," FILE.save: Json-encoding error: " .. data )
0 commit comments