diff options
| author | Ferenc Wágner <wferi@niif.hu> | 2013-10-10 16:48:04 +0200 |
|---|---|---|
| committer | Ferenc Wágner <wferi@niif.hu> | 2014-03-01 17:40:34 +0100 |
| commit | 4cfcef19a983dfa971608a8917cd74ebfa0d7376 (patch) | |
| tree | 0c5abe5d8abc190d02847bd99424c24be6fadb18 /com32/lua/test | |
| parent | a06818de2a4c49bd64a024dd4f4a09a0caf1f0ac (diff) | |
| download | syslinux-4cfcef19a983dfa971608a8917cd74ebfa0d7376.tar.gz | |
lua: import Lua 5.2.2
Source downloaded from http://www.lua.org/ftp/lua-5.2.2.tar.gz.
The com32/lua directory now matches exactly the source distribution,
plus the various Syslinux extension modules and their documentation.
Diffstat (limited to 'com32/lua/test')
| -rw-r--r-- | com32/lua/test/README | 26 | ||||
| -rw-r--r-- | com32/lua/test/bisect.lua | 27 | ||||
| -rw-r--r-- | com32/lua/test/cf.lua | 16 | ||||
| -rw-r--r-- | com32/lua/test/cpu.lua | 19 | ||||
| -rw-r--r-- | com32/lua/test/dmi.lua | 21 | ||||
| -rw-r--r-- | com32/lua/test/echo.lua | 5 | ||||
| -rw-r--r-- | com32/lua/test/env.lua | 7 | ||||
| -rw-r--r-- | com32/lua/test/factorial.lua | 32 | ||||
| -rw-r--r-- | com32/lua/test/fib.lua | 40 | ||||
| -rw-r--r-- | com32/lua/test/fibfor.lua | 13 | ||||
| -rw-r--r-- | com32/lua/test/globals.lua | 13 | ||||
| -rw-r--r-- | com32/lua/test/hello.lua | 3 | ||||
| -rw-r--r-- | com32/lua/test/life.lua | 111 | ||||
| -rw-r--r-- | com32/lua/test/luac.lua | 7 | ||||
| -rw-r--r-- | com32/lua/test/pci.lua | 34 | ||||
| -rw-r--r-- | com32/lua/test/printf.lua | 7 | ||||
| -rw-r--r-- | com32/lua/test/readonly.lua | 12 | ||||
| -rw-r--r-- | com32/lua/test/sieve.lua | 29 | ||||
| -rw-r--r-- | com32/lua/test/sort.lua | 66 | ||||
| -rw-r--r-- | com32/lua/test/syslinux-derivative.lua | 38 | ||||
| -rw-r--r-- | com32/lua/test/syslinux.lua | 1 | ||||
| -rw-r--r-- | com32/lua/test/table.lua | 12 | ||||
| -rw-r--r-- | com32/lua/test/trace-calls.lua | 32 | ||||
| -rw-r--r-- | com32/lua/test/trace-globals.lua | 38 | ||||
| -rw-r--r-- | com32/lua/test/vesa.lua | 55 | ||||
| -rw-r--r-- | com32/lua/test/xd.lua | 14 |
26 files changed, 0 insertions, 678 deletions
diff --git a/com32/lua/test/README b/com32/lua/test/README deleted file mode 100644 index 0c7f38bc..00000000 --- a/com32/lua/test/README +++ /dev/null @@ -1,26 +0,0 @@ -These are simple tests for Lua. Some of them contain useful code. -They are meant to be run to make sure Lua is built correctly and also -to be read, to see how Lua programs look. - -Here is a one-line summary of each program: - - bisect.lua bisection method for solving non-linear equations - cf.lua temperature conversion table (celsius to farenheit) - echo.lua echo command line arguments - env.lua environment variables as automatic global variables - factorial.lua factorial without recursion - fib.lua fibonacci function with cache - fibfor.lua fibonacci numbers with coroutines and generators - globals.lua report global variable usage - hello.lua the first program in every language - life.lua Conway's Game of Life - luac.lua bare-bones luac - printf.lua an implementation of printf - readonly.lua make global variables readonly - sieve.lua the sieve of of Eratosthenes programmed with coroutines - sort.lua two implementations of a sort function - table.lua make table, grouping all data for the same item - trace-calls.lua trace calls - trace-globals.lua trace assigments to global variables - xd.lua hex dump - diff --git a/com32/lua/test/bisect.lua b/com32/lua/test/bisect.lua deleted file mode 100644 index f91e69bf..00000000 --- a/com32/lua/test/bisect.lua +++ /dev/null @@ -1,27 +0,0 @@ --- bisection method for solving non-linear equations - -delta=1e-6 -- tolerance - -function bisect(f,a,b,fa,fb) - local c=(a+b)/2 - io.write(n," c=",c," a=",a," b=",b,"\n") - if c==a or c==b or math.abs(a-b)<delta then return c,b-a end - n=n+1 - local fc=f(c) - if fa*fc<0 then return bisect(f,a,c,fa,fc) else return bisect(f,c,b,fc,fb) end -end - --- find root of f in the inverval [a,b]. needs f(a)*f(b)<0 -function solve(f,a,b) - n=0 - local z,e=bisect(f,a,b,f(a),f(b)) - io.write(string.format("after %d steps, root is %.17g with error %.1e, f=%.1e\n",n,z,e,f(z))) -end - --- our function -function f(x) - return x*x*x-x-1 -end - --- find zero in [1,2] -solve(f,1,2) diff --git a/com32/lua/test/cf.lua b/com32/lua/test/cf.lua deleted file mode 100644 index 8cda54b9..00000000 --- a/com32/lua/test/cf.lua +++ /dev/null @@ -1,16 +0,0 @@ --- temperature conversion table (celsius to farenheit) - -for c0=-20,50-1,10 do - io.write("C ") - for c=c0,c0+10-1 do - io.write(string.format("%3.0f ",c)) - end - io.write("\n") - - io.write("F ") - for c=c0,c0+10-1 do - f=(9/5)*c+32 - io.write(string.format("%3.0f ",f)) - end - io.write("\n\n") -end diff --git a/com32/lua/test/cpu.lua b/com32/lua/test/cpu.lua deleted file mode 100644 index e9045025..00000000 --- a/com32/lua/test/cpu.lua +++ /dev/null @@ -1,19 +0,0 @@ - cpuflags = cpu.flags() - - print("Vendor = " .. cpuflags["vendor"]) - print("Model = " .. cpuflags["model"]) - print("Cores = " .. cpuflags["cores"]) - print("L1 Instruction Cache = " .. cpuflags["l1_instruction_cache"]) - print("L1 Data Cache = " .. cpuflags["l1_data_cache"]) - print("L2 Cache = " .. cpuflags["l2_cache"]) - print("Family ID = " .. cpuflags["family_id"]) - print("Model ID = " .. cpuflags["model_id"]) - print("Stepping = " .. cpuflags["stepping"]) - - if ( string.match(cpuflags["vendor"], "Intel") ) then - print("Intel Processor Found") --- syslinux.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw") - else - print("Does not match") - end - diff --git a/com32/lua/test/dmi.lua b/com32/lua/test/dmi.lua deleted file mode 100644 index 0f5526c7..00000000 --- a/com32/lua/test/dmi.lua +++ /dev/null @@ -1,21 +0,0 @@ -if (dmi.supported()) then - - dmitable = dmi.gettable() - - for k,v in pairs(dmitable) do - print(k, v) - end - - print(dmitable["system.manufacturer"]) - print(dmitable["system.product_name"]) - print(dmitable["bios.bios_revision"]) - - if ( string.match(dmitable["system.product_name"], "ESPRIMO P7935") ) then - print("Matches") - syslinux.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw") - else - print("Does not match") - end - -end - diff --git a/com32/lua/test/echo.lua b/com32/lua/test/echo.lua deleted file mode 100644 index 4313439a..00000000 --- a/com32/lua/test/echo.lua +++ /dev/null @@ -1,5 +0,0 @@ --- echo command line arguments - -for i=0,table.getn(arg) do - print(i,arg[i]) -end diff --git a/com32/lua/test/env.lua b/com32/lua/test/env.lua deleted file mode 100644 index 9e62a57f..00000000 --- a/com32/lua/test/env.lua +++ /dev/null @@ -1,7 +0,0 @@ --- read environment variables as if they were global variables - -local f=function (t,i) return os.getenv(i) end -setmetatable(getfenv(),{__index=f}) - --- an example -print(a,USER,PATH) diff --git a/com32/lua/test/factorial.lua b/com32/lua/test/factorial.lua deleted file mode 100644 index 7c4cf0fa..00000000 --- a/com32/lua/test/factorial.lua +++ /dev/null @@ -1,32 +0,0 @@ --- function closures are powerful - --- traditional fixed-point operator from functional programming -Y = function (g) - local a = function (f) return f(f) end - return a(function (f) - return g(function (x) - local c=f(f) - return c(x) - end) - end) -end - - --- factorial without recursion -F = function (f) - return function (n) - if n == 0 then return 1 - else return n*f(n-1) end - end - end - -factorial = Y(F) -- factorial is the fixed point of F - --- now test it -function test(x) - io.write(x,"! = ",factorial(x),"\n") -end - -for n=0,16 do - test(n) -end diff --git a/com32/lua/test/fib.lua b/com32/lua/test/fib.lua deleted file mode 100644 index 97a921b1..00000000 --- a/com32/lua/test/fib.lua +++ /dev/null @@ -1,40 +0,0 @@ --- fibonacci function with cache - --- very inefficient fibonacci function -function fib(n) - N=N+1 - if n<2 then - return n - else - return fib(n-1)+fib(n-2) - end -end - --- a general-purpose value cache -function cache(f) - local c={} - return function (x) - local y=c[x] - if not y then - y=f(x) - c[x]=y - end - return y - end -end - --- run and time it -function test(s,f) - N=0 - local c=os.clock() - local v=f(n) - local t=os.clock()-c - print(s,n,v,t,N) -end - -n=arg[1] or 24 -- for other values, do lua fib.lua XX -n=tonumber(n) -print("","n","value","time","evals") -test("plain",fib) -fib=cache(fib) -test("cached",fib) diff --git a/com32/lua/test/fibfor.lua b/com32/lua/test/fibfor.lua deleted file mode 100644 index 8bbba39c..00000000 --- a/com32/lua/test/fibfor.lua +++ /dev/null @@ -1,13 +0,0 @@ --- example of for with generator functions - -function generatefib (n) - return coroutine.wrap(function () - local a,b = 1, 1 - while a <= n do - coroutine.yield(a) - a, b = b, a+b - end - end) -end - -for i in generatefib(1000) do print(i) end diff --git a/com32/lua/test/globals.lua b/com32/lua/test/globals.lua deleted file mode 100644 index d4c20e15..00000000 --- a/com32/lua/test/globals.lua +++ /dev/null @@ -1,13 +0,0 @@ --- reads luac listings and reports global variable usage --- lines where a global is written to are marked with "*" --- typical usage: luac -p -l file.lua | lua globals.lua | sort | lua table.lua - -while 1 do - local s=io.read() - if s==nil then break end - local ok,_,l,op,g=string.find(s,"%[%-?(%d*)%]%s*([GS])ETGLOBAL.-;%s+(.*)$") - if ok then - if op=="S" then op="*" else op="" end - io.write(g,"\t",l,op,"\n") - end -end diff --git a/com32/lua/test/hello.lua b/com32/lua/test/hello.lua deleted file mode 100644 index 0925498f..00000000 --- a/com32/lua/test/hello.lua +++ /dev/null @@ -1,3 +0,0 @@ --- the first program in every language - -io.write("Hello world, from ",_VERSION,"!\n") diff --git a/com32/lua/test/life.lua b/com32/lua/test/life.lua deleted file mode 100644 index 911d9fe1..00000000 --- a/com32/lua/test/life.lua +++ /dev/null @@ -1,111 +0,0 @@ --- life.lua --- original by Dave Bollinger <DBollinger@compuserve.com> posted to lua-l --- modified to use ANSI terminal escape sequences --- modified to use for instead of while - -local write=io.write - -ALIVE="¥" DEAD="þ" -ALIVE="O" DEAD="-" - -function delay() -- NOTE: SYSTEM-DEPENDENT, adjust as necessary - for i=1,10000 do end - -- local i=os.clock()+1 while(os.clock()<i) do end -end - -function ARRAY2D(w,h) - local t = {w=w,h=h} - for y=1,h do - t[y] = {} - for x=1,w do - t[y][x]=0 - end - end - return t -end - -_CELLS = {} - --- give birth to a "shape" within the cell array -function _CELLS:spawn(shape,left,top) - for y=0,shape.h-1 do - for x=0,shape.w-1 do - self[top+y][left+x] = shape[y*shape.w+x+1] - end - end -end - --- run the CA and produce the next generation -function _CELLS:evolve(next) - local ym1,y,yp1,yi=self.h-1,self.h,1,self.h - while yi > 0 do - local xm1,x,xp1,xi=self.w-1,self.w,1,self.w - while xi > 0 do - local sum = self[ym1][xm1] + self[ym1][x] + self[ym1][xp1] + - self[y][xm1] + self[y][xp1] + - self[yp1][xm1] + self[yp1][x] + self[yp1][xp1] - next[y][x] = ((sum==2) and self[y][x]) or ((sum==3) and 1) or 0 - xm1,x,xp1,xi = x,xp1,xp1+1,xi-1 - end - ym1,y,yp1,yi = y,yp1,yp1+1,yi-1 - end -end - --- output the array to screen -function _CELLS:draw() - local out="" -- accumulate to reduce flicker - for y=1,self.h do - for x=1,self.w do - out=out..(((self[y][x]>0) and ALIVE) or DEAD) - end - out=out.."\n" - end - write(out) -end - --- constructor -function CELLS(w,h) - local c = ARRAY2D(w,h) - c.spawn = _CELLS.spawn - c.evolve = _CELLS.evolve - c.draw = _CELLS.draw - return c -end - --- --- shapes suitable for use with spawn() above --- -HEART = { 1,0,1,1,0,1,1,1,1; w=3,h=3 } -GLIDER = { 0,0,1,1,0,1,0,1,1; w=3,h=3 } -EXPLODE = { 0,1,0,1,1,1,1,0,1,0,1,0; w=3,h=4 } -FISH = { 0,1,1,1,1,1,0,0,0,1,0,0,0,0,1,1,0,0,1,0; w=5,h=4 } -BUTTERFLY = { 1,0,0,0,1,0,1,1,1,0,1,0,0,0,1,1,0,1,0,1,1,0,0,0,1; w=5,h=5 } - --- the main routine -function LIFE(w,h) - -- create two arrays - local thisgen = CELLS(w,h) - local nextgen = CELLS(w,h) - - -- create some life - -- about 1000 generations of fun, then a glider steady-state - thisgen:spawn(GLIDER,5,4) - thisgen:spawn(EXPLODE,25,10) - thisgen:spawn(FISH,4,12) - - -- run until break - local gen=1 - write("\027[2J") -- ANSI clear screen - while 1 do - thisgen:evolve(nextgen) - thisgen,nextgen = nextgen,thisgen - write("\027[H") -- ANSI home cursor - thisgen:draw() - write("Life - generation ",gen,"\n") - gen=gen+1 - if gen>2000 then break end - --delay() -- no delay - end -end - -LIFE(40,20) diff --git a/com32/lua/test/luac.lua b/com32/lua/test/luac.lua deleted file mode 100644 index 96a0a97c..00000000 --- a/com32/lua/test/luac.lua +++ /dev/null @@ -1,7 +0,0 @@ --- bare-bones luac in Lua --- usage: lua luac.lua file.lua - -assert(arg[1]~=nil and arg[2]==nil,"usage: lua luac.lua file.lua") -f=assert(io.open("luac.out","wb")) -assert(f:write(string.dump(assert(loadfile(arg[1]))))) -assert(f:close()) diff --git a/com32/lua/test/pci.lua b/com32/lua/test/pci.lua deleted file mode 100644 index 8d7f7d42..00000000 --- a/com32/lua/test/pci.lua +++ /dev/null @@ -1,34 +0,0 @@ --- get nice output -printf = function(s,...) - return io.write(s:format(...)) - end - --- get device info -pciinfo = pci.getinfo() - --- get plain text device description -pciids = pci.getidlist("/pci.ids") - --- list all pci busses -for dind,device in pairs(pciinfo) do - - -- search for device description - search = string.format("%04x%04x", device['vendor'], device['product']) - - printf(" %04x:%04x:%04x:%04x = ", device['vendor'], device['product'], - device['sub_vendor'], device['sub_product']) - - if ( pciids[search] ) then - printf("%s\n", pciids[search]) - else - printf("Unknown\n") - end -end - --- print(pciids["8086"]) --- print(pciids["10543009"]) --- print(pciids["00700003"]) --- print(pciids["0070e817"]) --- print(pciids["1002437a1002437a"]) - - diff --git a/com32/lua/test/printf.lua b/com32/lua/test/printf.lua deleted file mode 100644 index 58c63ff5..00000000 --- a/com32/lua/test/printf.lua +++ /dev/null @@ -1,7 +0,0 @@ --- an implementation of printf - -function printf(...) - io.write(string.format(...)) -end - -printf("Hello %s from %s on %s\n",os.getenv"USER" or "there",_VERSION,os.date()) diff --git a/com32/lua/test/readonly.lua b/com32/lua/test/readonly.lua deleted file mode 100644 index 85c0b4e0..00000000 --- a/com32/lua/test/readonly.lua +++ /dev/null @@ -1,12 +0,0 @@ --- make global variables readonly - -local f=function (t,i) error("cannot redefine global variable `"..i.."'",2) end -local g={} -local G=getfenv() -setmetatable(g,{__index=G,__newindex=f}) -setfenv(1,g) - --- an example -rawset(g,"x",3) -x=2 -y=1 -- cannot redefine `y' diff --git a/com32/lua/test/sieve.lua b/com32/lua/test/sieve.lua deleted file mode 100644 index 0871bb21..00000000 --- a/com32/lua/test/sieve.lua +++ /dev/null @@ -1,29 +0,0 @@ --- the sieve of of Eratosthenes programmed with coroutines --- typical usage: lua -e N=1000 sieve.lua | column - --- generate all the numbers from 2 to n -function gen (n) - return coroutine.wrap(function () - for i=2,n do coroutine.yield(i) end - end) -end - --- filter the numbers generated by `g', removing multiples of `p' -function filter (p, g) - return coroutine.wrap(function () - while 1 do - local n = g() - if n == nil then return end - if math.mod(n, p) ~= 0 then coroutine.yield(n) end - end - end) -end - -N=N or 1000 -- from command line -x = gen(N) -- generate primes up to N -while 1 do - local n = x() -- pick a number until done - if n == nil then break end - print(n) -- must be a prime number - x = filter(n, x) -- now remove its multiples -end diff --git a/com32/lua/test/sort.lua b/com32/lua/test/sort.lua deleted file mode 100644 index 0bcb15f8..00000000 --- a/com32/lua/test/sort.lua +++ /dev/null @@ -1,66 +0,0 @@ --- two implementations of a sort function --- this is an example only. Lua has now a built-in function "sort" - --- extracted from Programming Pearls, page 110 -function qsort(x,l,u,f) - if l<u then - local m=math.random(u-(l-1))+l-1 -- choose a random pivot in range l..u - x[l],x[m]=x[m],x[l] -- swap pivot to first position - local t=x[l] -- pivot value - m=l - local i=l+1 - while i<=u do - -- invariant: x[l+1..m] < t <= x[m+1..i-1] - if f(x[i],t) then - m=m+1 - x[m],x[i]=x[i],x[m] -- swap x[i] and x[m] - end - i=i+1 - end - x[l],x[m]=x[m],x[l] -- swap pivot to a valid place - -- x[l+1..m-1] < x[m] <= x[m+1..u] - qsort(x,l,m-1,f) - qsort(x,m+1,u,f) - end -end - -function selectionsort(x,n,f) - local i=1 - while i<=n do - local m,j=i,i+1 - while j<=n do - if f(x[j],x[m]) then m=j end - j=j+1 - end - x[i],x[m]=x[m],x[i] -- swap x[i] and x[m] - i=i+1 - end -end - -function show(m,x) - io.write(m,"\n\t") - local i=1 - while x[i] do - io.write(x[i]) - i=i+1 - if x[i] then io.write(",") end - end - io.write("\n") -end - -function testsorts(x) - local n=1 - while x[n] do n=n+1 end; n=n-1 -- count elements - show("original",x) - qsort(x,1,n,function (x,y) return x<y end) - show("after quicksort",x) - selectionsort(x,n,function (x,y) return x>y end) - show("after reverse selection sort",x) - qsort(x,1,n,function (x,y) return x<y end) - show("after quicksort again",x) -end - --- array to be sorted -x={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"} - -testsorts(x) diff --git a/com32/lua/test/syslinux-derivative.lua b/com32/lua/test/syslinux-derivative.lua deleted file mode 100644 index fbdf5d57..00000000 --- a/com32/lua/test/syslinux-derivative.lua +++ /dev/null @@ -1,38 +0,0 @@ --- get nice output -printf = function(s,...) - return io.write(s:format(...)) - end - --- get syslinux derivative (ISOLINUX, PXELINUX, SYSLINUX) -derivative = syslinux.derivative() - -printf("Run specific command depending on the Syslinux derivate:\n") -printf("--------------------------------------------------------\n\n") -printf(" Detected Syslinux derivative: %s\n", derivative) - -if derivative == "SYSLINUX" then - -- swap internal (hd1) hard drive with USB stick (hd0) - commandline = 'chain.c32 hd1 swap' -elseif derivative == "ISOLINUX" then - -- boot first hard drive - commandline = 'chain.c32 hd0' -elseif derivative == "PXELINUX" then - -- boot first hard drive - commandline = 'chain.c32 hd0' -else - printf("Do nothing\n") - return 1 -end - -printf("\n commandline for derivative: %s\n\n", commandline) - - --- Count down from 7 -for time = 7, 1, -1 do - printf(" Boot in %d second(s)... \r", time) - syslinux.sleep(1) -end - --- Boot -syslinux.run_command(commandline) - diff --git a/com32/lua/test/syslinux.lua b/com32/lua/test/syslinux.lua deleted file mode 100644 index 3f72ebea..00000000 --- a/com32/lua/test/syslinux.lua +++ /dev/null @@ -1 +0,0 @@ -syslinux.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw") diff --git a/com32/lua/test/table.lua b/com32/lua/test/table.lua deleted file mode 100644 index 235089c0..00000000 --- a/com32/lua/test/table.lua +++ /dev/null @@ -1,12 +0,0 @@ --- make table, grouping all data for the same item --- input is 2 columns (item, data) - -local A -while 1 do - local l=io.read() - if l==nil then break end - local _,_,a,b=string.find(l,'"?([_%w]+)"?%s*(.*)$') - if a~=A then A=a io.write("\n",a,":") end - io.write(" ",b) -end -io.write("\n") diff --git a/com32/lua/test/trace-calls.lua b/com32/lua/test/trace-calls.lua deleted file mode 100644 index 6d7a7b3b..00000000 --- a/com32/lua/test/trace-calls.lua +++ /dev/null @@ -1,32 +0,0 @@ --- trace calls --- example: lua -ltrace-calls bisect.lua - -local level=0 - -local function hook(event) - local t=debug.getinfo(3) - io.write(level," >>> ",string.rep(" ",level)) - if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end - t=debug.getinfo(2) - if event=="call" then - level=level+1 - else - level=level-1 if level<0 then level=0 end - end - if t.what=="main" then - if event=="call" then - io.write("begin ",t.short_src) - else - io.write("end ",t.short_src) - end - elseif t.what=="Lua" then --- table.foreach(t,print) - io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") - else - io.write(event," ",t.name or "(C)"," [",t.what,"] ") - end - io.write("\n") -end - -debug.sethook(hook,"cr") -level=0 diff --git a/com32/lua/test/trace-globals.lua b/com32/lua/test/trace-globals.lua deleted file mode 100644 index 295e670c..00000000 --- a/com32/lua/test/trace-globals.lua +++ /dev/null @@ -1,38 +0,0 @@ --- trace assigments to global variables - -do - -- a tostring that quotes strings. note the use of the original tostring. - local _tostring=tostring - local tostring=function(a) - if type(a)=="string" then - return string.format("%q",a) - else - return _tostring(a) - end - end - - local log=function (name,old,new) - local t=debug.getinfo(3,"Sl") - local line=t.currentline - io.write(t.short_src) - if line>=0 then io.write(":",line) end - io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n") - end - - local g={} - local set=function (t,name,value) - log(name,g[name],value) - g[name]=value - end - setmetatable(getfenv(),{__index=g,__newindex=set}) -end - --- an example - -a=1 -b=2 -a=10 -b=20 -b=nil -b=200 -print(a,b,c) diff --git a/com32/lua/test/vesa.lua b/com32/lua/test/vesa.lua deleted file mode 100644 index 8913accf..00000000 --- a/com32/lua/test/vesa.lua +++ /dev/null @@ -1,55 +0,0 @@ --- get nice output -printf = function(s,...) - return io.write(s:format(...)) - end - --- list available vesa modes --- only one supported right now, not of much use -modes = vesa.getmodes() - -for mind,mode in pairs(modes) do - printf("%04x: %dx%dx%d\n", mode['mode'], mode['hres'], mode['vres'], mode['bpp']) -end - -printf("Hello World! - text mode") - --- lets go to graphics land -vesa.setmode() - -printf("Hello World! - VESA mode") - -syslinux.sleep(1) - --- some text to display "typing style" -textline=[[ - -From syslinux GSOC 2009 home page: - -Finish the Lua engine - -We already have a Lua interpreter integrated with the Syslinux build. However, right now it is not very useful. We need to create a set of bindings to the Syslinux functionality, and have an array of documentation and examples so users can use them. - -This is not a documentation project, but the documentation deliverable will be particularly important for this one, since the intended target is system administrators, not developers. -]] - - --- do display loop --- keep in mind: background change will not erase text! -while ( true ) do - -vesa.load_background("/PXE-RRZE_small.jpg") - -syslinux.sleep(1) - -for i = 1, #textline do - local c = textline:sub(i,i) - printf("%s", c) - syslinux.msleep(200) -end - -syslinux.sleep(10) - -vesa.load_background("/sample2.jpg") -syslinux.sleep(10) - -end diff --git a/com32/lua/test/xd.lua b/com32/lua/test/xd.lua deleted file mode 100644 index ebc3effc..00000000 --- a/com32/lua/test/xd.lua +++ /dev/null @@ -1,14 +0,0 @@ --- hex dump --- usage: lua xd.lua < file - -local offset=0 -while true do - local s=io.read(16) - if s==nil then return end - io.write(string.format("%08X ",offset)) - string.gsub(s,"(.)", - function (c) io.write(string.format("%02X ",string.byte(c))) end) - io.write(string.rep(" ",3*(16-string.len(s)))) - io.write(" ",string.gsub(s,"%c","."),"\n") - offset=offset+16 -end |
