Fixed compilation if no libreadline was detected.
authorshort <>
Tue, 28 Oct 2003 17:44:22 +0000 (17:44 +0000)
committershort <>
Tue, 28 Oct 2003 17:44:22 +0000 (17:44 +0000)
 - SUSE-9.0 incompatibility bugreported by Christian Kristukat.

src/client/cmdline/cmd_shell.c

index 3ea8b44..fe03e15 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <glib/gstrfuncs.h>
 #include <glib/gmem.h>
+#include <string.h>
 
 #ifdef HAVE_LIBREADLINE
 #include <readline/readline.h>
@@ -64,10 +65,9 @@ const struct poptOption cmd_shell_table[]={
  */
 void cmd_shell(const char **cmd_argv,GError **errp)
 {
-#ifdef HAVE_LIBREADLINE
 char *line;
-#else /* HAVE_LIBREADLINE */
-char line[1024],*s;
+#ifndef HAVE_LIBREADLINE
+char linebuf[1024],*s;
 #endif /* HAVE_LIBREADLINE */
 int errint,line_argc;
 const char **line_argv=NULL;
@@ -94,7 +94,7 @@ const char *cmd_cd_args[]={NULL};
 #endif /* HAVE_ADD_HISTORY */
 #else /* HAVE_LIBREADLINE */
                fputs(prompt,stdout); fflush(stdout);
-               line=fgets(line,sizeof(line),stdin);
+               line=fgets(linebuf,sizeof(linebuf),stdin);
 #endif /* HAVE_LIBREADLINE */
                g_free(prompt);
                if (!line) {
@@ -110,7 +110,7 @@ const char *cmd_cd_args[]={NULL};
 
                line_argv=NULL;
                errint=poptParseArgvString(line,&line_argc,&line_argv);
-#ifndef HAVE_LIBREADLINE
+#ifdef HAVE_LIBREADLINE
                free(line);
 #endif /* HAVE_LIBREADLINE */
                if (errint!=0) {