Mercurial Hosting > luan
comparison src/luan/modules/Io.luan @ 1277:5ba660381bd5
fix Io.print()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 11 Dec 2018 03:38:43 -0700 |
parents | 623dfe0e2e73 |
children | 781ec0a92bb5 |
comparison
equal
deleted
inserted
replaced
1276:623dfe0e2e73 | 1277:5ba660381bd5 |
---|---|
26 local ipairs = Luan.ipairs or error() | 26 local ipairs = Luan.ipairs or error() |
27 local pairs = Luan.pairs or error() | 27 local pairs = Luan.pairs or error() |
28 local values = Luan.values or error() | 28 local values = Luan.values or error() |
29 local load = Luan.load or error() | 29 local load = Luan.load or error() |
30 local Table = require "luan:Table.luan" | 30 local Table = require "luan:Table.luan" |
31 local pack = Table.pack or error() | |
31 local unpack = Table.unpack or error() | 32 local unpack = Table.unpack or error() |
32 local String = require "luan:String.luan" | 33 local String = require "luan:String.luan" |
33 local encode = String.encode or error() | 34 local encode = String.encode or error() |
34 local matches = String.matches or error() | 35 local matches = String.matches or error() |
35 | 36 |
47 list[#list+1] = '\t' | 48 list[#list+1] = '\t' |
48 end | 49 end |
49 if #list > 0 then | 50 if #list > 0 then |
50 list[#list] = '\n' | 51 list[#list] = '\n' |
51 out.write( unpack(list) ) | 52 out.write( unpack(list) ) |
53 else | |
54 out.write('\n') | |
52 end | 55 end |
53 end | 56 end |
54 | 57 |
55 function Io.print(...) | 58 function Io.print(...) |
56 Io.print_to(Io.stdout,...) | 59 Io.print_to(Io.stdout,...) |
99 end | 102 end |
100 catch = function(e) | 103 catch = function(e) |
101 fn = load(line,"stdin",env) | 104 fn = load(line,"stdin",env) |
102 end | 105 end |
103 } | 106 } |
104 Io.print( fn() ) | 107 local rtn = pack( fn() ) |
108 if rtn.n > 0 then | |
109 Io.print( unpack(rtn) ) | |
110 end | |
105 end | 111 end |
106 catch = function(e) | 112 catch = function(e) |
107 Io.print(e) | 113 Io.print(e) |
108 end | 114 end |
109 } | 115 } |