mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Revert "Add multipul patterns function to Lua API tio.expect()"
This reverts commit d1ff5f7142.
This commit is contained in:
parent
67bd6b1a8c
commit
b5944275d3
1 changed files with 3 additions and 10 deletions
13
src/script.c
13
src/script.c
|
|
@ -58,22 +58,15 @@ static char script_init[] =
|
||||||
"end\n"
|
"end\n"
|
||||||
"tio.expect = function(pattern, timeout)\n"
|
"tio.expect = function(pattern, timeout)\n"
|
||||||
" local str = ''\n"
|
" local str = ''\n"
|
||||||
" if type(pattern) ~= 'table' then\n"
|
|
||||||
" pattern = { pattern }\n"
|
|
||||||
" end\n"
|
|
||||||
" while true do\n"
|
" while true do\n"
|
||||||
" local idx, pat\n"
|
|
||||||
" local c = tio.read(1, timeout)\n"
|
" local c = tio.read(1, timeout)\n"
|
||||||
" if c then\n"
|
" if c then\n"
|
||||||
" str = str .. c\n"
|
" str = str .. c\n"
|
||||||
" for idx, pat in ipairs(pattern) do\n"
|
" if string.match(str, pattern) then\n"
|
||||||
" local matched = { string.match(str, pat) }\n"
|
" return string.match(str, pattern)\n"
|
||||||
" if matched[1] then\n"
|
|
||||||
" return matched, str, idx\n"
|
|
||||||
" end\n"
|
|
||||||
" end\n"
|
" end\n"
|
||||||
" else\n"
|
" else\n"
|
||||||
" return nil, str, 0\n"
|
" return nil, str\n"
|
||||||
" end\n"
|
" end\n"
|
||||||
" end\n"
|
" end\n"
|
||||||
"end\n"
|
"end\n"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue