Skip to content
Browse files

Added '.so' and '.a' to .gitignore, added 'readline' C extension.

  • Loading branch information...
1 parent 68e0514 commit 2efb901b899e76298d6abe0a1b64bad348e1c093 @orangea orangea committed Dec 21, 2010
Showing with 31 additions and 1 deletion.
  1. +2 −1 .gitignore
  2. +9 −0 lib/readline/Makefile
  3. +20 −0 lib/readline/readline.c
View
3 .gitignore
@@ -15,4 +15,5 @@ syntax.c
gc-test
._*
.DS_Store
-
+*.so
+*.a
View
9 lib/readline/Makefile
@@ -0,0 +1,9 @@
+CC ?= gcc
+INCS = -I../../core -L../..
+LIBS = -lreadline -lpotion
+CFLAGS = $(INCS) $(LIBS) -Wall -fno-strict-aliasing -Wno-return-type -fpic -Wl,-flat_namespace
+
+all: readline.so
+
+readline.so:
+ @$(CC) -shared $(CFLAGS) -o $@ readline.c
View
20 lib/readline/readline.c
@@ -0,0 +1,20 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <potion.h>
+#include <readline/readline.h>
+
+PN pn_readline(Potion *P, PN cl, PN self, PN start) {
+ char *line = readline(PN_STR_PTR(start));
+ PN r;
+ if (line) {
+ add_history(line);
+ r = potion_str(P, line);
+ free(line);
+ return r;
+ }
+ return PN_NIL;
+}
+
+void Potion_Init_readline(Potion *P) {
+ potion_method(P->lobby, "readline", pn_readline, "start=S");
+}

0 comments on commit 2efb901

Please sign in to comment.
Something went wrong with that request. Please try again.