From 0ddc31415ef6c8c3cc972d6d75922dd9718def7b Mon Sep 17 00:00:00 2001 From: Kolja Waschk Date: Sun, 9 Dec 2007 12:21:57 +0000 Subject: [PATCH] Allow compilation of jtag.c if readline isn't installed (needs more work) git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@824 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 1 + jtag/src/jtag.c | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index c0288893..197c2c79 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,5 +1,6 @@ 2007-12-09 [822] Kolja Waschk + * src/jtag.c: show version from config.h, compile without readline * configure.ac: Improve detection of flex version, get Subversion revision from 1. svn info, or 2. ChangeLog, or 3. Revision tag * src/version.awk: not needed anymore as SVN info is now put into diff --git a/jtag/src/jtag.c b/jtag/src/jtag.c index d9391505..532d37d6 100644 --- a/jtag/src/jtag.c +++ b/jtag/src/jtag.c @@ -35,9 +35,9 @@ #include #include #include -#ifdef HAVE_READLINE +#ifdef HAVE_LIBREADLINE #include -#ifdef HAVE_READLINE_HISTORY +#ifdef HAVE_READLINE_HISTORY_H #include #endif #endif @@ -96,6 +96,7 @@ jtag_create_jtagdir( void ) free( jdir ); } +#ifdef HAVE_LIBREADLINE #ifdef HAVE_READLINE_HISTORY static void @@ -149,6 +150,7 @@ jtag_save_history( void ) } #endif /* HAVE_READLINE_HISTORY */ +#endif static int jtag_parse_line( char *line ) @@ -223,6 +225,7 @@ static int jtag_readline_multiple_commands_support(char * line) /* multiple comm static void jtag_readline_loop( const char *prompt ) { +#ifdef HAVE_LIBREADLINE char *line = NULL; /* Iterate */ @@ -232,11 +235,23 @@ jtag_readline_loop( const char *prompt ) /* Read a line from the terminal */ line = readline( prompt ); +#ifdef HAVE_READLINE_HISTORY /* Check if we actually got something */ if (line && (strlen( line ) > 0)) add_history( line ); +#endif } free( line ); +#else + char line[1024]; + line[0] = 0; + do + { + printf("%s", prompt); + jtag_readline_multiple_commands_support( line ); + } + while(fgets(line, 1023, stdin)); +#endif } static int @@ -498,14 +513,18 @@ main( int argc, const char **argv ) free(s); } +#ifdef HAVE_READLINE_HISTORY /* Load history */ jtag_load_history(); +#endif /* main loop */ jtag_readline_loop( "jtag> " ); +#ifdef HAVE_READLINE_HISTORY /* Save history */ jtag_save_history(); +#endif } cleanup();