on master help sign in
fix history
commit7b418162063e438472111d84bb3452b960ca510c authormason clayton <masongclayton@gmail.com> dateWed 20 Feb 2019, 18:18 (8 years ago) parent6f6ebf4
6 files changed+42−86
languages/lua/lua.c+3−1 languages/lua/main.go+1−1 tests/lua/always_try_expression.exp+8 tests/lua/history.exp+30 tests/lua/own_eval.exp−42 tests/lua/returns.exp−42
languages/lua/lua.c+3−1
@@ -13,6 +13,7 @@
1313#include <string.h>
1414
1515#define lua_c
16+#define LUA_USE_LINUX
1617
1718#include <lua.h>
1819
@@ -182,7 +183,8 @@ static int loadline(lua_State *L) {
182183 return -1; /* no input */
183184
184185 for (;;) { /* repeat until gets a complete line */
185− if (!try_expression(L))
186+ status = try_expression(L);
187+ if (!status)
186188 break;
187189
188190 status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin");
languages/lua/main.go+1−1
@@ -1,7 +1,7 @@
11package main
22
33/*
4−#cgo pkg-config: lua-5.1
4+#cgo pkg-config: lua-5.1 readline
55#include <stdlib.h>
66#include <lua.h>
77#include <lauxlib.h>
tests/lua/always_try_expression.exp+8
@@ -9,10 +9,18 @@ expect -exact "function a() return 123 end\r
99--> "
1010send -- "a()\r"
1111expect -exact "a()\r
12+123\r
1213--> "
1314send -- "return a()\r"
1415expect -exact "return a()\r
1516123\r
1617--> "
18+send -- "a(\r"
19+expect -exact "a(\r
20+... "
21+send -- ")\r"
22+expect -exact ")\r
23+123\r
24+--> "
1725send -- ""
1826expect eof
tests/lua/history.expnew file+30
@@ -0,0 +1,30 @@
1+#!/usr/bin/expect -f
2+
3+set timeout -1
4+spawn ./prybar-lua -q -i
5+match_max 100000
6+expect -exact "--> "
7+send -- "1\r"
8+expect -exact "1\r
9+1\r
10+--> "
11+send -- "2\r"
12+expect -exact "2\r
13+2\r
14+--> "
15+send -- "3\r"
16+expect -exact "3\r
17+3\r
18+--> "
19+send -- "\[A"
20+expect -exact "3"
21+send -- "\[A"
22+expect -exact "2"
23+send -- "\[A"
24+expect -exact "1"
25+send -- "\r"
26+expect -exact "\r
27+1\r
28+--> "
29+send -- ""
30+expect eof
tests/lua/own_eval.exp−42
@@ -1,46 +1,4 @@
11#!/usr/bin/expect -f
2−#
3−# This Expect script was generated by autoexpect on Wed Feb 20 15:53:16 2019
4−# Expect and autoexpect were both written by Don Libes, NIST.
5−#
6−# Note that autoexpect does not guarantee a working script. It
7−# necessarily has to guess about certain things. Two reasons a script
8−# might fail are:
9−#
10−# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
11−# etc.) and devices discard or ignore keystrokes that arrive "too
12−# quickly" after prompts. If you find your new script hanging up at
13−# one spot, try adding a short sleep just before the previous send.
14−# Setting "force_conservative" to 1 (see below) makes Expect do this
15−# automatically - pausing briefly before sending each character. This
16−# pacifies every program I know of. The -c flag makes the script do
17−# this in the first place. The -C flag allows you to define a
18−# character to toggle this mode off and on.
19−
20−set force_conservative 0 ;# set to 1 to force conservative mode even if
21− ;# script wasn't run conservatively originally
22−if {$force_conservative} {
23− set send_slow {1 .1}
24− proc send {ignore arg} {
25− sleep .1
26− exp_send -s -- $arg
27− }
28−}
29−
30−#
31−# 2) differing output - Some programs produce different output each time
32−# they run. The "date" command is an obvious example. Another is
33−# ftp, if it produces throughput statistics at the end of a file
34−# transfer. If this causes a problem, delete these patterns or replace
35−# them with wildcards. An alternative is to use the -p flag (for
36−# "prompt") which makes Expect only look for the last line of output
37−# (i.e., the prompt). The -P flag allows you to define a character to
38−# toggle this mode off and on.
39−#
40−# Read the man page for more info.
41−#
42−# -Don
43−
442
453set timeout -1
464spawn ./prybar-lua -I
tests/lua/returns.exp−42
@@ -1,46 +1,4 @@
11#!/usr/bin/expect -f
2−#
3−# This Expect script was generated by autoexpect on Wed Feb 20 15:56:43 2019
4−# Expect and autoexpect were both written by Don Libes, NIST.
5−#
6−# Note that autoexpect does not guarantee a working script. It
7−# necessarily has to guess about certain things. Two reasons a script
8−# might fail are:
9−#
10−# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
11−# etc.) and devices discard or ignore keystrokes that arrive "too
12−# quickly" after prompts. If you find your new script hanging up at
13−# one spot, try adding a short sleep just before the previous send.
14−# Setting "force_conservative" to 1 (see below) makes Expect do this
15−# automatically - pausing briefly before sending each character. This
16−# pacifies every program I know of. The -c flag makes the script do
17−# this in the first place. The -C flag allows you to define a
18−# character to toggle this mode off and on.
19−
20−set force_conservative 0 ;# set to 1 to force conservative mode even if
21− ;# script wasn't run conservatively originally
22−if {$force_conservative} {
23− set send_slow {1 .1}
24− proc send {ignore arg} {
25− sleep .1
26− exp_send -s -- $arg
27− }
28−}
29−
30−#
31−# 2) differing output - Some programs produce different output each time
32−# they run. The "date" command is an obvious example. Another is
33−# ftp, if it produces throughput statistics at the end of a file
34−# transfer. If this causes a problem, delete these patterns or replace
35−# them with wildcards. An alternative is to use the -p flag (for
36−# "prompt") which makes Expect only look for the last line of output
37−# (i.e., the prompt). The -P flag allows you to define a character to
38−# toggle this mode off and on.
39−#
40−# Read the man page for more info.
41−#
42−# -Don
43−
442
453set timeout -1
464spawn ./prybar-lua -q -i