mirror of
https://github.com/janet-lang/janet
synced 2025-01-12 16:40:27 +00:00
Remove readline and add travis
This commit is contained in:
parent
a7a9ff7629
commit
b23fc136dd
7
.travis.yml
Normal file
7
.travis.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
language: c
|
||||||
|
|
||||||
|
script: make test
|
||||||
|
|
||||||
|
compiler:
|
||||||
|
- clang
|
||||||
|
- gcc
|
2
Makefile
2
Makefile
@ -3,7 +3,7 @@
|
|||||||
######################################################
|
######################################################
|
||||||
##### Set global variables for all gst Makefiles #####
|
##### Set global variables for all gst Makefiles #####
|
||||||
######################################################
|
######################################################
|
||||||
CFLAGS=-std=c99 -Wall -Wextra -Wpedantic -I./include -lreadline -g
|
CFLAGS=-std=c99 -Wall -Wextra -Wpedantic -I./include -g
|
||||||
PREFIX=/usr/local
|
PREFIX=/usr/local
|
||||||
GST_TARGET=client/gst
|
GST_TARGET=client/gst
|
||||||
GST_CORELIB=core/libgst.a
|
GST_CORELIB=core/libgst.a
|
||||||
|
@ -24,9 +24,35 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
/* Use readline support for now */
|
/* Simple read line functionality */
|
||||||
#include <readline/readline.h>
|
char *getline() {
|
||||||
#include <readline/history.h>
|
char *line = malloc(100);
|
||||||
|
char *linep = line;
|
||||||
|
size_t lenmax = 100;
|
||||||
|
size_t len = lenmax;
|
||||||
|
int c;
|
||||||
|
if (line == NULL)
|
||||||
|
return NULL;
|
||||||
|
for (;;) {
|
||||||
|
c = fgetc(stdin);
|
||||||
|
if (c == EOF)
|
||||||
|
break;
|
||||||
|
if (--len == 0) {
|
||||||
|
len = lenmax;
|
||||||
|
char *linen = realloc(linep, lenmax *= 2);
|
||||||
|
if (linen == NULL) {
|
||||||
|
free(linep);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
line = linen + (line - linep);
|
||||||
|
linep = linen;
|
||||||
|
}
|
||||||
|
if ((*line++ = c) == '\n')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*line = '\0';
|
||||||
|
return linep;
|
||||||
|
}
|
||||||
|
|
||||||
/* Compile and run an ast */
|
/* Compile and run an ast */
|
||||||
int debug_compile_and_run(Gst *vm, GstValue ast, GstValue last) {
|
int debug_compile_and_run(Gst *vm, GstValue ast, GstValue last) {
|
||||||
@ -98,7 +124,7 @@ int debug_run(Gst *vm, FILE *in) {
|
|||||||
|
|
||||||
/* A simple repl */
|
/* A simple repl */
|
||||||
int debug_repl(Gst *vm) {
|
int debug_repl(Gst *vm) {
|
||||||
const char *buffer, *reader;
|
char *buffer, *reader;
|
||||||
GstParser p;
|
GstParser p;
|
||||||
buffer = reader = NULL;
|
buffer = reader = NULL;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -109,10 +135,12 @@ int debug_repl(Gst *vm) {
|
|||||||
if (p.status == GST_PARSER_ERROR || p.status == GST_PARSER_FULL)
|
if (p.status == GST_PARSER_ERROR || p.status == GST_PARSER_FULL)
|
||||||
break;
|
break;
|
||||||
if (!reader || *reader == '\0') {
|
if (!reader || *reader == '\0') {
|
||||||
buffer = readline(">> ");
|
printf("\x1B[32m>>\x1B[0m ");
|
||||||
if (*buffer == '\0')
|
if (buffer)
|
||||||
|
free(buffer);
|
||||||
|
buffer = getline();
|
||||||
|
if (!buffer || *buffer == '\0')
|
||||||
return 0;
|
return 0;
|
||||||
add_history(buffer);
|
|
||||||
reader = buffer;
|
reader = buffer;
|
||||||
}
|
}
|
||||||
reader += gst_parse_cstring(&p, reader);
|
reader += gst_parse_cstring(&p, reader);
|
||||||
|
Loading…
Reference in New Issue
Block a user