From 9d8f80df19bc47f419aa09f7a2f1b9d8ff7a4d99 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 23 Aug 2001 17:08:26 +0000 Subject: [PATCH] Made dependency on readline optional. --- test/test_physfs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test_physfs.c b/test/test_physfs.c index 5e02ec0e..f65b2f62 100644 --- a/test/test_physfs.c +++ b/test/test_physfs.c @@ -9,9 +9,18 @@ #include #include #include +#include + +#if (!defined WIN32) +#define HAVE_READLINE +#endif + +#if (defined HAVE_READLINE) #include #include #include +#endif + #include "physfs.h" #define TEST_VERSION_MAJOR 0 @@ -473,12 +482,15 @@ static int process_command(char *complete_cmd) if (i->cmd == NULL) printf("Unknown command. Enter \"help\" for instructions.\n"); +#if (defined HAVE_READLINE) add_history(complete_cmd); if (history_file) { fprintf(history_file, "%s\n", complete_cmd); fflush(history_file); } /* if */ +#endif + } /* if */ free(cmd_copy); @@ -488,6 +500,7 @@ static int process_command(char *complete_cmd) static void open_history_file(void) { +#if (defined HAVE_READLINE) #if 0 const char *envr = getenv("TESTPHYSFS_HISTORY"); if (!envr) @@ -530,6 +543,7 @@ static void open_history_file(void) " Will not be able to record this session's history.\n\n", envr); } /* if */ +#endif } /* open_history_file */ @@ -555,7 +569,13 @@ int main(int argc, char **argv) do { +#if (defined HAVE_READLINE) buf = readline("> "); +#else + buf = malloc(512); + memset(buf, '\0', 512); + scanf("%s", buf); +#endif rc = process_command(buf); free(buf); } while (rc);