Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ LIBS = @READLINE_LIBS@ @LIBS@ $(ADDLIBS)
HFILES = config.h es.h gc.h input.h prim.h print.h sigmsgs.h \
stdenv.h syntax.h term.h token.h var.h
CFILES = access.c closure.c conv.c dict.c eval.c except.c fd.c gc.c glob.c \
glom.c input.c heredoc.c history.c list.c main.c match.c open.c opt.c \
prim-ctl.c prim-etc.c prim-io.c prim-sys.c prim.c print.c proc.c \
sigmsgs.c signal.c split.c status.c str.c syntax.c term.c token.c \
tree.c util.c var.c vec.c version.c y.tab.c dump.c
glom.c input.c heredoc.c list.c main.c match.c open.c opt.c \
prim-ctl.c prim-etc.c prim-io.c prim-readline.c prim-sys.c prim.c \
print.c proc.c sigmsgs.c signal.c split.c status.c str.c syntax.c \
term.c token.c tree.c util.c var.c vec.c version.c y.tab.c dump.c
OFILES = access.o closure.o conv.o dict.o eval.o except.o fd.o gc.o glob.o \
glom.o input.o heredoc.o history.o list.o main.o match.o open.o opt.o \
prim-ctl.o prim-etc.o prim-io.o prim-sys.o prim.o print.o proc.o \
sigmsgs.o signal.o split.o status.o str.o syntax.o term.o token.o \
tree.o util.o var.o vec.o version.o y.tab.o
glom.o input.o heredoc.o list.o main.o match.o open.o opt.o \
prim-ctl.o prim-etc.o prim-io.o prim-readline.o prim-sys.o prim.o \
print.o proc.o sigmsgs.o signal.o split.o status.o str.o syntax.o \
term.o token.o tree.o util.o var.o vec.o version.o y.tab.o
OTHER = Makefile parse.y mksignal
GEN = esdump y.tab.h y.output sigmsgs.c initial.c version.h

Expand Down Expand Up @@ -134,7 +134,6 @@ glob.o : glob.c es.h config.h stdenv.h gc.h
glom.o : glom.c es.h config.h stdenv.h gc.h
input.o : input.c es.h config.h stdenv.h input.h token.h
heredoc.o : heredoc.c es.h config.h stdenv.h gc.h input.h syntax.h token.h
history.o : history.c es.h config.h stdenv.h gc.h input.h token.h
list.o : list.c es.h config.h stdenv.h gc.h
main.o : main.c es.h config.h stdenv.h
match.o : match.c es.h config.h stdenv.h
Expand All @@ -144,6 +143,7 @@ prim.o : prim.c es.h config.h stdenv.h prim.h
prim-ctl.o : prim-ctl.c es.h config.h stdenv.h prim.h
prim-etc.o : prim-etc.c es.h config.h stdenv.h prim.h version.h
prim-io.o : prim-io.c es.h config.h stdenv.h gc.h prim.h
prim-readline.o : prim-readline.c es.h config.h stdenv.h gc.h prim.h
prim-sys.o : prim-sys.c es.h config.h stdenv.h prim.h
print.o : print.c es.h config.h stdenv.h print.h
proc.o : proc.c es.h config.h stdenv.h prim.h
Expand Down
24 changes: 2 additions & 22 deletions es.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,13 @@ extern Boolean streq2(const char *s, const char *t1, const char *t2);

/* input.c */

extern Tree *parse(char *prompt1, char *prompt2);
extern Tree *parse(List *reader);
extern Tree *parsestring(const char *str);
extern Boolean isinteractive(void);
extern Boolean isfromfd(void);
extern void initinput(void);

extern List *runfd(int fd, const char *name, int flags);
extern List *runstring(const char *str, const char *name, int flags);
extern List *runstring(const char *str, int flags);

/* eval_* flags are also understood as runflags */
#define run_interactive 4 /* -i or $0[0] = '-' */
Expand All @@ -304,25 +303,6 @@ extern List *runstring(const char *str, const char *name, int flags);
#define run_printcmds 32 /* -x */
#define run_lisptrees 64 /* -L and defined(LISPTREES) */

#if HAVE_READLINE
extern Boolean resetterminal;
#endif


/* history.c */
#if HAVE_READLINE
extern void inithistory(void);

extern void sethistory(char *file);
extern void loghistory(char *cmd);
extern void setmaxhistorylength(int length);
extern void checkhistory(void);
#endif

extern void newhistbuffer(void);
extern void addhistbuffer(char c);
extern char *dumphistbuffer(void);


/* opt.c */

Expand Down
2 changes: 1 addition & 1 deletion heredoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extern Tree *snarfheredoc(Parser *p, const char *eof, Boolean quoted) {

for (tree = NULL, tailp = &tree, buf = openbuffer(0);;) {
int c;
print_prompt2(p);
p->input->lineno++;
for (s = (unsigned char *) eof; (c = get(p)) == *s; s++)
;
if (*s == '\0' && (c == '\n' || c == EOF)) {
Expand Down
163 changes: 0 additions & 163 deletions history.c

This file was deleted.

32 changes: 31 additions & 1 deletion initial.es
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,39 @@ if {~ <=$&primitives writehistory} {
# The parsed code is executed only if it is non-empty, because otherwise
# result gets set to zero when it should not be.

fn-%parse = $&parse
fn-%batch-loop = $&batchloop
fn-%is-interactive = $&isinteractive

if {~ <=$&primitives readline} {
fn-%read-line = $&readline
} {
fn %read-line prompt {
echo -n $prompt
$&read
}
}

fn %parse {
if %is-interactive {
let (in = (); p = $*(1))
unwind-protect {
$&parse {
let (r = <={%read-line $p}) {
in = $in $r
p = $*(2)
result $r
}
}
} {
if {!~ $#fn-%write-history 0 && !~ $#in 0} {
%write-history <={%flatten \n $in}
}
}
} {
$&parse # fall back to built-in read with no prompt
}
}

fn %interactive-loop {
let (result = <=true) {
catch @ e type msg {
Expand Down Expand Up @@ -685,6 +714,7 @@ fn %interactive-loop {
}
}


# These functions are potentially passed to a REPL as the %dispatch
# function. (For %eval-noprint, note that an empty list prepended
# to a command just causes the command to be executed.)
Expand Down
Loading