summaryrefslogtreecommitdiffhomepage
path: root/mixutils/mixvm_loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'mixutils/mixvm_loop.c')
-rw-r--r--mixutils/mixvm_loop.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/mixutils/mixvm_loop.c b/mixutils/mixvm_loop.c
index 492ebc6..fb3a729 100644
--- a/mixutils/mixvm_loop.c
+++ b/mixutils/mixvm_loop.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mixvm_loop.c :
* Implementation of mix vm command loop.
* ------------------------------------------------------------------
- * $Id: mixvm_loop.c,v 1.12 2004/06/07 05:29:42 jao Exp $
+ * $Id: mixvm_loop.c,v 1.13 2004/06/07 12:18:46 jao Exp $
* ------------------------------------------------------------------
* Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
*
@@ -60,7 +60,8 @@ readline (char *prompt)
/* A static variable for holding the line. */
static char *line_read = (char *)NULL;
-static char *PROMPT = NULL;
+#define PROMPT_LEN 128
+static char PROMPT[PROMPT_LEN + 1] = {'m', 'i', 'x', '>'};
static const char *CONFIG_FILE_ = "mixvm.config";
static const char *PROMPT_KEY_ = "Prompt";
@@ -95,7 +96,6 @@ init_mixvm_ (const gchar *file, gboolean use_emacs)
{
static const gchar *HISTORY_FILE = "mixvm.history";
static gint HISTORY_SIZE = 100;
- const char *prompt = NULL;
config_ = mix_config_new (NULL, CONFIG_FILE_);
mix_config_set_autosave (config_, TRUE);
@@ -104,9 +104,7 @@ init_mixvm_ (const gchar *file, gboolean use_emacs)
if (mix_config_get_history_size (config_) == 0)
mix_config_set_history_size (config_, HISTORY_SIZE);
- prompt = mix_config_get (config_, PROMPT_KEY_);
- if (!prompt) prompt = "MIX > ";
- mix_vmloop_set_prompt (prompt);
+ mix_vmloop_set_prompt (mix_config_get (config_, PROMPT_KEY_));
return mixvm_cmd_init (config_, (char *)file, use_emacs);
}
@@ -116,9 +114,7 @@ mix_vmloop_set_prompt (const gchar *prompt)
{
if (prompt)
{
- if (PROMPT) g_free (PROMPT);
- PROMPT = g_strdup ((prompt[0] == '"') ? prompt + 1 : prompt);
- if (PROMPT[strlen (PROMPT) - 1] == '"') PROMPT[strlen (PROMPT) - 1] = 0;
+ g_snprintf (PROMPT, PROMPT_LEN, "%s ", prompt);
mix_config_update (config_, PROMPT_KEY_, prompt);
}
}