Permalink
Browse files

Tweak file reading (but it still needs doing properly)

  • Loading branch information...
1 parent 2e3fd5b commit cab41e51578916b0fa5cef8616c3daaea8699f50 Edwin Brady committed Dec 15, 2011
Showing with 12 additions and 2 deletions.
  1. +10 −1 evm/stdfuns.c
  2. +2 −1 evm/stdfuns.h
View
@@ -52,7 +52,16 @@ char* readStr() {
}
// FIXME: Do this properly!
-void* freadStr(void* h) {
+char* freadStr(void* h) {
+ char *buf = NULL;
+ if (buf==NULL) { buf = EMALLOC(sizeof(char)*512); } // yeah, right...
+ fgets(buf,512,(FILE*)h);
+// char *loc = strchr(buf,'\n');
+// if (loc) *(loc+1) = '\0'; else buf[0]='\0';
+ return buf;
+}
+
+void* freadStrAny(void* h) {
static char bufin[128];
bufin[0]='\0';
View
@@ -32,7 +32,8 @@ int strlt(char* x, char* y);
void* fileOpen(char* name, char* mode);
void fileClose(void* h);
-void* freadStr(void* h);
+char* freadStr(void* h);
+void* freadStrAny(void* h);
void fputStr(void* h, char* str);
int isNull(void* ptr);

0 comments on commit cab41e5

Please sign in to comment.