Skip to content

Commit

Permalink
* Partial line completion.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgicor committed Dec 4, 2017
1 parent 27c1080 commit 4353401
Show file tree
Hide file tree
Showing 8 changed files with 315 additions and 9 deletions.
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ AM_INIT_AUTOMAKE(-Wall -Werror -Wportability subdir-objects
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
PKG_PROG_PKG_CONFIG
AC_PROG_CC
AC_PROG_YACC
AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir)
Expand All @@ -34,6 +35,13 @@ AC_SUBST(WARN_CFLAGS)

# Checks for library functions.
AC_SEARCH_LIBS([pow], [m])
# AC_SEARCH_LIBS([initscr], [ncurses])
# AC_SEARCH_LIBS([el_init], [edit])
# AC_SEARCH_LIBS([readline], [readline], , ,[-lncurses])
# AC_SEARCH_LIBS([readline], [edit], , ,[-lncurses])
PKG_CHECK_MODULES([LIBEDIT], [libedit],
[ AC_DEFINE([HAVE_LIBEDIT], [1], [Use libedit]) ],
[ AC_DEFINE([HAVE_LIBEDIT], [0], [Use libedit]) ])

AC_CONFIG_FILES([Makefile
src/Makefile
Expand Down
5 changes: 3 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
AM_CFLAGS = $(WARN_CFLAGS)
BUILT_SOURCES = grammar.h
AM_YFLAGS = -d
bin_PROGRAMS = bas55
bas55_CFLAGS = $(AM_CFLAGS)
bas55_CPPFLAGS = $(LIBEDIT_CFLAGS)
bas55_CFLAGS = $(WARN_CFLAGS)
bas55_LDADD = $(LIBEDIT_LIBS)
bas55_SOURCES = ecma55.c ecma55.h \
cmd.c code.c \
codedvar.c data.c \
Expand Down
2 changes: 1 addition & 1 deletion src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ int load(const char *fname, int max_errors, int batch_mode)

nerrors = 0;
linecnt = 0;
while ((ecode = get_line(line, sizeof line, fp)) != E_EOF) {
while ((ecode = get_line("", line, sizeof line, fp)) != E_EOF) {
linecnt++;
if (ecode == E_LINE_TOO_LONG) {
print_and_continue: fprintf(stderr, "%s:", fname);
Expand Down
4 changes: 3 additions & 1 deletion src/ecma55.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <config.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "ecma55.h"
#include "ngetopt.h"

Expand Down Expand Up @@ -155,6 +155,8 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}

init_readline();

if (argc == ngo.optind) {
s_debug_mode = 1;
edit();
Expand Down
3 changes: 2 additions & 1 deletion src/ecma55.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ void edit(void);

enum error_code grow_array(void *p, int elem_size, int cur_len, int grow_k,
void **new_array, int *new_len);
enum error_code get_line(char *buf, int maxlen, FILE *fp);
void init_readline(void);
enum error_code get_line(const char *prompt, char *buf, int maxlen, FILE *fp);
size_t min_size(size_t a, size_t b);
void toupper_str(char *str);
void copy_to_str(char *dst, const char *src, size_t len);
Expand Down
9 changes: 8 additions & 1 deletion src/edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <ctype.h>
#include <limits.h>
#include <stdio.h>

// #include <stdlib.h>
// #include <string.h>
// #include <editline/readline.h>
// #include <readline/readline.h>
// #include <readline/history.h>

#include "ecma55.h"

static void pready (void)
Expand All @@ -43,7 +50,7 @@ void edit(void)
print_version(stderr);
fputs("\nType HELP for a list of allowed commands.\n\n", stderr);
pready();
while ((ecode = get_line(line, sizeof(line), stdin)) != E_EOF) {
while ((ecode = get_line("", line, sizeof(line), stdin)) != E_EOF) {
if (ecode == E_LINE_TOO_LONG) {
eprint(E_LINE_TOO_LONG);
enl();
Expand Down

0 comments on commit 4353401

Please sign in to comment.