summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2004-06-07 12:18:22 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2004-06-07 12:18:22 +0000
commita2c671004a551cfe307513beb161d64c1b63488a (patch)
treef8dfb11c36dcaa8b30b1a40e967516c90be53fc5
parent7161125e1df06b71c2f1910d2c4930c413e5c622 (diff)
downloadmdk-a2c671004a551cfe307513beb161d64c1b63488a.tar.gz
mdk-a2c671004a551cfe307513beb161d64c1b63488a.tar.bz2
always use prompts ending in whitespace.
-rw-r--r--mixlib/mix_config.c13
-rw-r--r--mixutils/mixvm_loop.c14
2 files changed, 9 insertions, 18 deletions
diff --git a/mixlib/mix_config.c b/mixlib/mix_config.c
index 9d1c04b..cba9c80 100644
--- a/mixlib/mix_config.c
+++ b/mixlib/mix_config.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mix_config.c :
* Implementation of the functions declared in mix_config.h
* ------------------------------------------------------------------
- * $Id: mix_config.c,v 1.9 2004/06/07 05:29:01 jao Exp $
+ * $Id: mix_config.c,v 1.10 2004/06/07 12:18:22 jao Exp $
* ------------------------------------------------------------------
* Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
*
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
@@ -84,15 +85,9 @@ mix_config_new (const gchar *dirname, const gchar *filename)
if (line && line[0] != COMMENT_PREFIX_)
{
gchar **vals = g_strsplit (line, "=", 2);
- gchar *key = g_strdup (g_strstrip (vals[0]));
- gchar *value =
- (vals[1][0] == '"')
- ? g_strndup (vals[1] + 1, strlen (vals[1]) - 2)
- : g_strdup (g_strstrip (vals[1]));
g_hash_table_insert (result->items,
- (gpointer)key,
- (gpointer)value);
- g_strfreev (vals);
+ (gpointer) g_strstrip (vals[0]),
+ (gpointer) g_strstrip (vals[1]));
}
}
fclose (f);
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);
}
}