X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=misc.c;h=6b9e761d1b0ecd9375a66390c2214e92f68e1654;hb=da76563f40474ed90eb274da0796714633d60c3a;hp=e005d8138d470dd05c227a641e20591dffe3150c;hpb=a418ebb38c14d434620b573cb5841bc1d5dd42a3;p=open-adventure.git diff --git a/misc.c b/misc.c index e005d81..6b9e761 100644 --- a/misc.c +++ b/misc.c @@ -3,9 +3,10 @@ #include #include #include + #include "advent.h" -#include "funcs.h" #include "database.h" +#include "linenoise/linenoise.h" /* hack to ignore GCC Unused Result */ #define IGNORE(r) do{if (r){}}while(0) @@ -819,8 +820,8 @@ void fSAVEIO(long op, long in, long arr[]) * automatically. Finishing reading can be a no-op as long as a subsequent * SAVEIO(0,false,X) will still work.) */ { - static FILE *fp = NULL; - char name[50]; + static FILE *fp = NULL; + char* name; switch (op < 0 ? -1 : (op > 0 ? 1 : 0)) { @@ -829,12 +830,12 @@ void fSAVEIO(long op, long in, long arr[]) break; case 0: while (fp == NULL) { - printf("\nFile name: "); - IGNORE(fgets(name, sizeof(name), stdin)); + name = linenoise("File name: "); fp = fopen(name,(in ? READ_MODE : WRITE_MODE)); if (fp == NULL) printf("Can't open file %s, try again.\n", name); } + linenoiseFree(name); break; case 1: if (in)