lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Luiz Henrique de Figueiredo wrote:

> 1. Add -lreadline in the Makefile:
> 
> $T: $(OBJS) $(LIB)/liblua.a $(LIB)/liblualib.a
>         $(CC) -o $@ $(OBJS) -L$(LIB) -llua -llualib $(EXTRA_LIBS) -lreadline

I also had to add -ltermcap:

$T: $(OBJS) $(LIB)/liblua.a $(LIB)/liblualib.a
        $(CC) -o $@ $(OBJS) -L$(LIB) -llua -llualib $(EXTRA_LIBS)
-lreadline -ltermcap

> 2. Replace manual_input in lua.c by this:
> 
> #include <readline/readline.h>
> #include <readline/history.h>
> 
> static void manual_input (int version, int prompt) {
...
...
>       buffer=readline(NULL);
>     if (buffer==NULL) break;

>     add_history(buffer);

It's rather convenient to change the add_history line to

if(buffer[0]) add_history(buffer);

This way, empty lines won't be added to the history.

Dolfi