Made dependency on readline optional.
This commit is contained in:
parent
7aa0c252a9
commit
9d8f80df19
|
@ -9,9 +9,18 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if (!defined WIN32)
|
||||||
|
#define HAVE_READLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined HAVE_READLINE)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <readline.h>
|
#include <readline.h>
|
||||||
#include <history.h>
|
#include <history.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "physfs.h"
|
#include "physfs.h"
|
||||||
|
|
||||||
#define TEST_VERSION_MAJOR 0
|
#define TEST_VERSION_MAJOR 0
|
||||||
|
@ -473,12 +482,15 @@ static int process_command(char *complete_cmd)
|
||||||
if (i->cmd == NULL)
|
if (i->cmd == NULL)
|
||||||
printf("Unknown command. Enter \"help\" for instructions.\n");
|
printf("Unknown command. Enter \"help\" for instructions.\n");
|
||||||
|
|
||||||
|
#if (defined HAVE_READLINE)
|
||||||
add_history(complete_cmd);
|
add_history(complete_cmd);
|
||||||
if (history_file)
|
if (history_file)
|
||||||
{
|
{
|
||||||
fprintf(history_file, "%s\n", complete_cmd);
|
fprintf(history_file, "%s\n", complete_cmd);
|
||||||
fflush(history_file);
|
fflush(history_file);
|
||||||
} /* if */
|
} /* if */
|
||||||
|
#endif
|
||||||
|
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
free(cmd_copy);
|
free(cmd_copy);
|
||||||
|
@ -488,6 +500,7 @@ static int process_command(char *complete_cmd)
|
||||||
|
|
||||||
static void open_history_file(void)
|
static void open_history_file(void)
|
||||||
{
|
{
|
||||||
|
#if (defined HAVE_READLINE)
|
||||||
#if 0
|
#if 0
|
||||||
const char *envr = getenv("TESTPHYSFS_HISTORY");
|
const char *envr = getenv("TESTPHYSFS_HISTORY");
|
||||||
if (!envr)
|
if (!envr)
|
||||||
|
@ -530,6 +543,7 @@ static void open_history_file(void)
|
||||||
" Will not be able to record this session's history.\n\n",
|
" Will not be able to record this session's history.\n\n",
|
||||||
envr);
|
envr);
|
||||||
} /* if */
|
} /* if */
|
||||||
|
#endif
|
||||||
} /* open_history_file */
|
} /* open_history_file */
|
||||||
|
|
||||||
|
|
||||||
|
@ -555,7 +569,13 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
#if (defined HAVE_READLINE)
|
||||||
buf = readline("> ");
|
buf = readline("> ");
|
||||||
|
#else
|
||||||
|
buf = malloc(512);
|
||||||
|
memset(buf, '\0', 512);
|
||||||
|
scanf("%s", buf);
|
||||||
|
#endif
|
||||||
rc = process_command(buf);
|
rc = process_command(buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
} while (rc);
|
} while (rc);
|
||||||
|
|
Loading…
Reference in New Issue