summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile.am5
-rw-r--r--README48
-rw-r--r--configure.in39
-rw-r--r--doc/Makefile.am11
-rw-r--r--mixgtk/Makefile.am4
-rw-r--r--mixgtk/mixgtk.glade2
-rw-r--r--mixgtk/mixgtk_cmd_dispatcher.c36
-rw-r--r--mixgtk/mixgtk_widgets.c3
-rw-r--r--mixgtk/mixgtk_widgets.h3
-rw-r--r--mixlib/mix_vm_command.c171
-rw-r--r--mixlib/mix_vm_command.h5
11 files changed, 225 insertions, 102 deletions
diff --git a/Makefile.am b/Makefile.am
index 95d1e62..d216294 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,3 +13,8 @@
EXTRA_DIST = ABOUT-NLS autogen.sh configure
SUBDIRS = po intl doc mixlib mixutils mixgtk misc samples
+docdir = $(top_builddir)/doc
+
+html:
+ echo Making html in $(docdir)
+ cd $(docdir) && make html
diff --git a/README b/README
index 2846875..af4447e 100644
--- a/README
+++ b/README
@@ -1,26 +1,44 @@
Welcome to GNU MDK.
-MDK stands for MIX Development Kit and provides tools for developing
-and executing, in a MIX virtual machine, MIXAL programs. The MIX is
-Donald Knuth's mythical computer, described in the first volume of The
-Art of Computer Programming, which is programmed using MIXAL, the MIX
-assembly language. MDK includes a MIXAL assembler (mixasm) and a MIX
-virtual machine (mixvm) with a command line interface. Using this
-interface, you can debug your MIXAL programs at source code level, and
-read/modify the contents of all the components of the MIX computer
-(including block devices, which are simultated using the file system).
+GNU MDK is an official GNU package [0].
+
+MDK stands for MIX Development Kit, and provides tools for developing
+and executing, in a MIX virtual machine, MIXAL programs.
+
+The MIX is Donald Knuth's mythical computer, described in the first
+volume of The Art of Computer Programming, which is programmed using
+MIXAL, the MIX assembly language.
+
+MDK includes a MIXAL assembler (mixasm) and a MIX virtual machine
+(mixvm) with a command line interface. In addition, a GTK+ GUI to
+mixvm, called gmixvm, is provided; and, in case you are an Emacs guy,
+you can try misc/mixvm.el, which allows running mixvm inside an Emacs
+GUD buffer.
+
+Using these interfaces, you can debug your MIXAL programs at source
+code level, and read/modify the contents of all the components of the
+MIX computer (including block devices, which are simultated using the
+file system).
+
URLs:
-project homepage: http://mdk.sourceforge.net
-download: http://download.sourceforge.net/mdk/mdk-0.1.tar.gz
+Project homepage: http://mdk.sourceforge.net
+Download: http://download.sourceforge.net/mdk/
+
+GNU MDK is free software. Please see the file COPYING for details.
-MDK is free software. Please see the file COPYING for details.
For documentation, please see the files in the doc subdirectory.
+
For building and installation instructions please see the INSTALL file.
+
For sample MIXAL programs, please see the samples subdirectory.
-For translations (MDK uses GNU's gettext), please see the po subdirectory[0].
+
+For translations (MDK uses GNU's gettext), please see the po subdirectory[1].
--
-[0] New translations are welcome. If you'd like to contribute one,
- please contact the author, jaortega@acm.org. \ No newline at end of file
+[0] To learn more about GNU, the FSF and its goals, please visit
+ http://www.gnu.org.
+
+[1] New translations are welcome. If you'd like to contribute one,
+ please contact the author, jao@gnu.org.
diff --git a/configure.in b/configure.in
index 02c9684..a8c1c47 100644
--- a/configure.in
+++ b/configure.in
@@ -10,7 +10,7 @@
AC_INIT(mixlib/mix.h)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(mdk,0.2)
+AM_INIT_AUTOMAKE(mdk,0.3)
AM_MAINTAINER_MODE
@@ -40,14 +40,31 @@ AM_PATH_GLIB(1.2.0,
[LIBS="$LIBS $GLIB_LIBS" CFLAGS="$CFLAGS $GLIB_CFLAGS"],
AC_MSG_ERROR(Cannot find GLIB), "gmodule" )
+dnl Check if the gtk gui is required
+AC_ARG_ENABLE(gui,
+[ --enable-gui build the GTK+ GUI for mixvm (gmixvm)],
+[case "${enableval}" in
+ yes) gui=true ;;
+ no) gui=false ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-gui) ;;
+esac],[gui=true])
+
dnl Check for gtk+
-AM_PATH_GTK(1.2.0,
- [LIBS="$LIBS $GTK_LIBS" CFLAGS="$CFLAGS $GTK_CFLAGS"],
- AC_MSG_ERROR(Cannot find GTK), "gmodule" )
+if test x$gui = xtrue; then
+ AM_PATH_GTK(1.2.0,
+ [LIBS="$LIBS $GTK_LIBS" CFLAGS="$CFLAGS $GTK_CFLAGS"],
+ [AC_MSG_WARN(Cannot find GTK+: the GUI shall not be built) gui=false],
+ "gmodule" )
+fi
dnl Check for libglade
-AM_PATH_LIBGLADE([LIBS="$LIBS $LIBGLADE_LIBS" CFLAGS="$CFLAGS $LIBGLADE_CFLAGS"],
- AC_MSG_ERROR(Cannot find libglade))
+if test x$gui = xtrue; then
+ AM_PATH_LIBGLADE([LIBS="$LIBS $LIBGLADE_LIBS"
+ CFLAGS="$CFLAGS $LIBGLADE_CFLAGS"],
+ [AC_MSG_WARN(Cannot find GTK+: the GUI shall not be built) gui=false])
+fi
+
+AM_CONDITIONAL(MAKE_GUI, test x$gui = xtrue)
CFLAGS="$CFLAGS -Wall"
AC_SUBST(CFLAGS)
@@ -66,3 +83,13 @@ samples/Makefile
po/Makefile.in
)
+echo
+echo "*** GNU MDK $VERSION has been successfully configured. ***"
+echo
+echo "Type make to build the following utilities:"
+echo " - mixasm (MIX assembler)"
+echo " - mixvm (MIX virtual machine)"
+if test x$gui = xtrue; then
+echo " - gmixvm (mixvm GTK+ GUI)"
+fi
+echo
diff --git a/doc/Makefile.am b/doc/Makefile.am
index fefea7d..cda27ea 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -11,5 +11,16 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
SUBDIRS = html
+SUFFIXES = .html
+
+
info_TEXINFOS = mdk.texi
mdk_TEXINFOS = gpl.texi
+
+html_docs = mdk.html
+
+.texi.html:
+ $(MAKEINFO) --html $<
+
+.PHONY: html
+html: version.texi gpl.texi $(html_docs) \ No newline at end of file
diff --git a/mixgtk/Makefile.am b/mixgtk/Makefile.am
index eb084a0..f8b1bcf 100644
--- a/mixgtk/Makefile.am
+++ b/mixgtk/Makefile.am
@@ -15,7 +15,7 @@ INCLUDES = -I$(includedir) -DGLADE_FILE=\""$(pkgdatadir)/mixgtk.glade"\"\
-DLOCAL_GLADE_FILE=\"mixgtk.glade\"
LDADD = $(top_builddir)/mixlib/libmix.a
-
+if MAKE_GUI
pkgdata_DATA = mixgtk.glade
bin_PROGRAMS = gmixvm
gmixvm_SOURCES = mixgtk.c mixgtk_gen_handlers.h mixgtk_gen_handlers.c \
@@ -25,7 +25,7 @@ gmixvm_SOURCES = mixgtk.c mixgtk_gen_handlers.h mixgtk_gen_handlers.c \
mixgtk_mixvm.h mixgtk_mixvm.c \
mixgtk_mixal.h mixgtk_mixal.c \
mixgtk_input.h mixgtk_input.c
-
+endif
diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade
index 0ef2698..0d30282 100644
--- a/mixgtk/mixgtk.glade
+++ b/mixgtk/mixgtk.glade
@@ -23,7 +23,7 @@
<handler>on_main_window_destroy</handler>
<last_modification_time>Tue, 20 Feb 2001 21:58:29 GMT</last_modification_time>
</signal>
- <title>mixgtk</title>
+ <title>gmixvm</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
diff --git a/mixgtk/mixgtk_cmd_dispatcher.c b/mixgtk/mixgtk_cmd_dispatcher.c
index 71b5877..11acc1d 100644
--- a/mixgtk/mixgtk_cmd_dispatcher.c
+++ b/mixgtk/mixgtk_cmd_dispatcher.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mixgtk_cmd_dispatcher.c :
* Implementation of the functions declared in mixgtk_cmd_dispatcher.h
* ------------------------------------------------------------------
- * Last change: Time-stamp: "01/03/12 02:05:43 jose"
+ * Last change: Time-stamp: "01/03/15 16:01:43 jose"
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -40,6 +40,8 @@ struct mixgtk_dispatch_
size_t out_buffer_size;
GtkWidget *prompt;
GtkWidget *log;
+ GtkWidget *status;
+ guint context;
GCompletion *completions;
};
@@ -101,8 +103,21 @@ static void
load_post_hook_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg,
gpointer data)
{
- mixgtk_mixal_load_file ();
- mixgtk_mixal_update ();
+ static glong id = -1;
+
+ if (mix_vm_cmd_dispatcher_get_last_result (dis))
+ {
+ gchar *file = g_strdup (arg);
+ mixgtk_mixal_load_file ();
+ mixgtk_mixal_update ();
+
+ if (id != -1)
+ gtk_statusbar_remove (GTK_STATUSBAR (dis_data_.status),
+ dis_data_.context, (guint)id);
+ id =
+ gtk_statusbar_push (GTK_STATUSBAR (dis_data_.status), dis_data_.context,
+ file);
+ }
}
static void
@@ -182,22 +197,31 @@ mixgtk_cmd_dispatcher_init (void)
if (!dis_data_.prompt)
{
dis_data_.prompt = mixgtk_widget_factory_get (MIXGTK_WIDGET_PROMPT);
- if (!dis_data_.prompt) return FALSE;
+ g_return_val_if_fail (dis_data_.prompt != NULL, FALSE);
dis_data_.log = mixgtk_widget_factory_get (MIXGTK_WIDGET_LOG);
- if (!dis_data_.log) return FALSE;
+ g_return_val_if_fail (dis_data_.log != NULL, FALSE);
}
if (!dis_data_.dispatcher)
{
FILE *out = open_memstream (&(dis_data_.out_buffer),
&(dis_data_.out_buffer_size));
- if (!out) return FALSE;
+ g_return_val_if_fail (out != NULL, FALSE);
dis_data_.out = out;
dis_data_.dispatcher = mix_vm_cmd_dispatcher_new (out, out);
mix_vm_cmd_dispatcher_print_time (dis_data_.dispatcher, FALSE);
install_hooks_ ();
}
+ if (!dis_data_.status)
+ {
+ dis_data_.status = mixgtk_widget_factory_get (MIXGTK_WIDGET_STATUSBAR);
+ g_return_val_if_fail (dis_data_.status != NULL, FALSE);
+ dis_data_.context = gtk_statusbar_get_context_id (GTK_STATUSBAR
+ (dis_data_.status),
+ "cmd_dis_context");
+ }
+
if (!dis_data_.completions) init_completions_ ();
return TRUE;
diff --git a/mixgtk/mixgtk_widgets.c b/mixgtk/mixgtk_widgets.c
index 13b675e..165da81 100644
--- a/mixgtk/mixgtk_widgets.c
+++ b/mixgtk/mixgtk_widgets.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mixgtk_widgets.c :
* Implementation of the functions declared in mixgtk_widgets.h
* ------------------------------------------------------------------
- * Last change: Time-stamp: "01/03/14 16:54:22 jose"
+ * Last change: Time-stamp: "01/03/15 14:42:37 jose"
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -33,6 +33,7 @@ static GladeXML *xml_ = NULL;
/* widget names */
static const gchar *names_[] = {
"main_window",
+ "main_statusbar",
"word_dialog",
"about_dialog",
"goto_dialog",
diff --git a/mixgtk/mixgtk_widgets.h b/mixgtk/mixgtk_widgets.h
index 4a6f281..f20ddc3 100644
--- a/mixgtk/mixgtk_widgets.h
+++ b/mixgtk/mixgtk_widgets.h
@@ -1,7 +1,7 @@
/* -*-c-*- ---------------- mixgtk_widgets.h :
* glade-based factory of mixvm widgets
* ------------------------------------------------------------------
- * Last change: Time-stamp: <01/03/14 15:36:43 jose>
+ * Last change: Time-stamp: <01/03/15 14:42:13 jose>
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -31,6 +31,7 @@
/* enumeration of mixvm widget ids */
typedef enum {
MIXGTK_WIDGET_MAIN, /* main app window */
+ MIXGTK_WIDGET_STATUSBAR,
MIXGTK_WIDGET_WORD_DIALOG, /* input dialog for a mix word */
MIXGTK_WIDGET_ABOUT_DIALOG,
MIXGTK_WIDGET_GOTO_DIALOG,
diff --git a/mixlib/mix_vm_command.c b/mixlib/mix_vm_command.c
index 90283f0..9cc0d52 100644
--- a/mixlib/mix_vm_command.c
+++ b/mixlib/mix_vm_command.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mix_vm_command.c :
* Implementation of the functions declared in mix_vm_command.h
* ------------------------------------------------------------------
- * Last change: Time-stamp: "01/03/11 01:50:17 jose"
+ * Last change: Time-stamp: "01/03/15 15:57:52 jose"
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -48,6 +48,7 @@ typedef struct
struct mix_vm_cmd_dispatcher_t
{
mix_vm_t *vm; /* the virtual machine */
+ gboolean result; /* last command's outcome */
gchar *program; /* the name of the last loaded program */
FILE *out; /* message output file */
FILE *err; /* error output file */
@@ -65,7 +66,7 @@ struct mix_vm_cmd_dispatcher_t
};
/* command handlers */
-typedef int (*Function_)(mix_vm_cmd_dispatcher_t *, const gchar *);
+typedef gboolean (*Function_)(mix_vm_cmd_dispatcher_t *, const gchar *);
#define DEC_FUN(name) \
static int cmd_##name (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
@@ -189,6 +190,7 @@ mix_vm_cmd_dispatcher_new (FILE *out_fd, /* output messages file */
g_return_val_if_fail (out_fd && err_fd, NULL);
result = g_new (mix_vm_cmd_dispatcher_t, 1);
+ result->result = TRUE;
result->out = out_fd;
result->err = err_fd;
result->uptime = result->laptime = result->progtime = 0;
@@ -270,7 +272,6 @@ gboolean /* TRUE if success, FALSE otherwise */
mix_vm_cmd_dispatcher_dispatch (mix_vm_cmd_dispatcher_t *dis,
mix_vm_command_t cmd, const gchar *arg)
{
- gboolean result = FALSE;
g_return_val_if_fail (dis != NULL, FALSE);
if (dis->global_pre.func)
@@ -280,7 +281,7 @@ mix_vm_cmd_dispatcher_dispatch (mix_vm_cmd_dispatcher_t *dis,
{
if (dis->pre_hooks[cmd].func)
(dis->pre_hooks[cmd].func)(dis, arg, dis->pre_hooks[cmd].data);
- result = (commands_[cmd].func)(dis, arg);
+ dis->result = (commands_[cmd].func)(dis, arg);
if (dis->post_hooks[cmd].func)
(dis->post_hooks[cmd].func)(dis, arg, dis->post_hooks[cmd].data);
}
@@ -294,7 +295,7 @@ mix_vm_cmd_dispatcher_dispatch (mix_vm_cmd_dispatcher_t *dis,
fflush (dis->out);
fflush (dis->err);
- return result;
+ return dis->result;
}
/* dispatch a command in text format */
@@ -325,6 +326,14 @@ mix_vm_cmd_dispatcher_dispatch_text (mix_vm_cmd_dispatcher_t *dis,
return result;
}
+/* get the last dispatch's result */
+gboolean
+mix_vm_cmd_dispatcher_get_last_result (const mix_vm_cmd_dispatcher_t *dis)
+{
+ g_return_val_if_fail (dis != NULL, FALSE);
+ return dis->result;
+}
+
/* get total uptime */
mix_time_t
mix_vm_cmd_dispatcher_get_uptime (const mix_vm_cmd_dispatcher_t *dis)
@@ -421,7 +430,7 @@ print_time_ (mix_vm_cmd_dispatcher_t *dis)
/* commands */
-static int
+static gboolean
cmd_help_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
static const int NO_OF_COLS = 6;
@@ -462,14 +471,14 @@ cmd_help_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
return TRUE;
}
-static int
+static gboolean
cmd_load_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
errno = 0;
if (arg == NULL || *arg == '\0')
{
fputs (_("Missing file name\n"), dis->err);
- return TRUE;
+ return FALSE;
}
mix_eval_remove_symbols_from_table (dis->eval,
mix_vm_get_symbol_table (dis->vm));
@@ -479,8 +488,8 @@ cmd_load_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
if ( errno == 0 )
fputs (_("Wrong file format\n"), dis->err);
else
- perror (NULL);
- return TRUE + 1;
+ fprintf (dis->err, "%s\n", strerror (errno));
+ return FALSE;
}
if (dis->program != arg)
@@ -500,11 +509,11 @@ cmd_load_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
}
-static int
+static gboolean
cmd_run_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
if (arg != NULL && *arg != '\0' && cmd_load_ (dis, arg) != TRUE)
- return TRUE;
+ return FALSE;
if (mix_vm_is_halted (dis->vm)) cmd_load_ (dis, dis->program);
@@ -539,7 +548,7 @@ cmd_run_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
return TRUE;
}
-static int
+static gboolean
cmd_next_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
int ins_no = 1;
@@ -553,7 +562,8 @@ cmd_next_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
if (arg[k] != '\0')
{
fprintf (dis->err, _("Invalid argument: %s\n"), arg);
- return cmd_help_ (dis, "next");
+ cmd_help_ (dis, "next");
+ return FALSE;
}
ins_no = atoi (arg);
}
@@ -582,16 +592,17 @@ cmd_next_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
return TRUE;
}
-static int
+static gboolean
cmd_pc_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
fprintf (dis->out, "Current address: %d\n", mix_vm_get_prog_count (dis->vm));
return TRUE;
}
-static int
+static gboolean
cmd_psym_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
+ gboolean result = FALSE;
const mix_symbol_table_t *table = mix_eval_symbol_table (dis->eval);
if ( table == NULL )
fputs (_("Symbol table not available\n"), dis->err);
@@ -601,17 +612,21 @@ cmd_psym_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
mix_word_print (mix_symbol_table_value (table, arg), NULL);
putc ('\n', dis->out);
+ result = TRUE;
}
else
fprintf (dis->out, _("%s: symbol not defined\n"), arg);
}
else
- mix_symbol_table_print (table, MIX_SYM_ROWS, stdout, TRUE);
+ {
+ mix_symbol_table_print (table, MIX_SYM_ROWS, stdout, TRUE);
+ result = TRUE;
+ }
- return TRUE;
+ return result;
}
-static int
+static gboolean
cmd_preg_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
mix_dump_context_set_opt (dis->dump, MIX_DUMP_NONE);
@@ -642,7 +657,7 @@ cmd_preg_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
if ( i < 0 || i > 5 )
{
fprintf (dis->err, _("Invalid I index: %d"), i);
- return TRUE;
+ return FALSE;
}
mix_dump_context_add_opt (dis->dump, opt[i]);
}
@@ -650,13 +665,13 @@ cmd_preg_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
break;
default:
fprintf (dis->err, _("Invalid argument: %s\n"), arg);
- return TRUE;
+ return FALSE;
}
mix_vm_dump (dis->vm, dis->dump);
return TRUE;
}
-static int
+static gboolean
cmd_pflags_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
mix_dump_context_set_opt (dis->dump, MIX_DUMP_CMP | MIX_DUMP_OVER);
@@ -664,7 +679,7 @@ cmd_pflags_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
return TRUE;
}
-static int
+static gboolean
cmd_pall_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
mix_dump_context_set_opt (dis->dump, MIX_DUMP_ALL_NOMEM);
@@ -672,7 +687,7 @@ cmd_pall_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
return TRUE;
}
-static int
+static gboolean
cmd_pmem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg)
{
glong begin = MIX_SHORT_ZERO, end = MIX_SHORT_ZERO;
@@ -683,7 +698,7 @@ cmd_pmem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg)
if ( strlen (carg) == 0 )
{
fputs (_("Missing memory address\n"), dis->err);
- return TRUE;
+ return FALSE;
}
arg = g_strdup (carg);
while (isdigit (arg[i]))
@@ -718,6 +733,7 @@ cmd_pmem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg)
else if ( end < begin || end > MIX_VM_CELL_NO - 1 )
{
fprintf (dis->err, _("Invalid range: %ld-%ld\n"), begin, end);
+ error = TRUE;
}
else
{
@@ -727,10 +743,10 @@ cmd_pmem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg)
mix_vm_dump (dis->vm, dis->dump);
}
g_free (arg);
- return TRUE;
+ return !error;
}
-static int
+static gboolean
cmd_sreg_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
int i = 0;
@@ -785,10 +801,10 @@ cmd_sreg_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
cmd_help_ (dis, "sreg");
}
- return TRUE;
+ return ok;
}
-static int
+static gboolean
cmd_scmp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
gboolean ok = (strlen (arg) == 1);
@@ -812,10 +828,10 @@ cmd_scmp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
cmd_help_ (dis, "scmp");
}
- return TRUE;
+ return ok;
}
-static int
+static gboolean
cmd_sover_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
gboolean ok = (strlen (arg) == 1);
@@ -836,10 +852,10 @@ cmd_sover_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
cmd_help_ (dis, "sover");
}
- return TRUE;
+ return ok;
}
-static int
+static gboolean
cmd_smem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg)
{
gboolean ok = (strlen (carg) > 2 && isdigit (carg[0]));
@@ -879,16 +895,17 @@ cmd_smem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg)
}
g_free (arg);
- return TRUE;
+ return ok;
}
-static int
+static gboolean
cmd_ssym_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
+ gboolean result = FALSE;
if (arg == NULL || strlen(arg) == 0)
{
fprintf (dis->err, _("Missing arguments\n"));
- return cmd_help_ (dis, "ssym");
+ cmd_help_ (dis, "ssym");
}
else
{
@@ -898,8 +915,10 @@ cmd_ssym_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
if (w != NULL && strtok (NULL, " \t") == NULL)
{
cmd_weval_ (dis, w);
- if (mix_eval_last_error (dis->eval) == MIX_EVAL_OK)
+ if (mix_eval_last_error (dis->eval) == MIX_EVAL_OK) {
mix_eval_set_symbol (dis->eval, s, mix_eval_value (dis->eval));
+ result = TRUE;
+ }
}
else
{
@@ -907,11 +926,11 @@ cmd_ssym_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
cmd_help_ (dis, "ssym");
}
g_free (a);
- return TRUE;
}
+ return result;
}
-static int
+static gboolean
cmd_sbp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
glong lineno;
@@ -920,7 +939,8 @@ cmd_sbp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
if (arg[k] != '\0')
{
fprintf (dis->err, _("Invalid argument: %s\n"), arg);
- return cmd_help_ (dis, "sbp");
+ cmd_help_ (dis, "sbp");
+ return FALSE;
}
lineno = atol (arg);
switch (k = mix_vm_set_breakpoint (dis->vm, lineno))
@@ -937,12 +957,12 @@ cmd_sbp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
break;
default:
fprintf (dis->err, _("Breakpoint set at line %ld\n"), k);
- break;
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
-static int
+static gboolean
cmd_sbpa_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
glong address;
@@ -951,7 +971,8 @@ cmd_sbpa_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
if (arg[k] != '\0')
{
fprintf (dis->err, _("Invalid argument: %s\n"), arg);
- return cmd_help_ (dis, "sbpa");
+ cmd_help_ (dis, "sbpa");
+ return FALSE;
}
address = atol (arg);
switch (mix_vm_set_breakpoint_address (dis->vm, address))
@@ -964,12 +985,12 @@ cmd_sbpa_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
break;
default:
fprintf (dis->err, _("Breakpoint set at address %ld\n"), address);
- break;
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
-static int
+static gboolean
cmd_cbp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
glong lineno;
@@ -978,7 +999,8 @@ cmd_cbp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
if (arg[k] != '\0')
{
fprintf (dis->err, _("Invalid argument: %s\n"), arg);
- return cmd_help_ (dis, "cbp");
+ cmd_help_ (dis, "cbp");
+ return FALSE;
}
lineno = atol (arg);
switch (mix_vm_clear_breakpoint (dis->vm, lineno))
@@ -994,15 +1016,15 @@ cmd_cbp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
break;
case MIX_VM_BP_OK:
fprintf (dis->err, _("Breakpoint cleared at line %ld\n"), lineno);
- break;
+ return TRUE;
default:
g_assert_not_reached ();
break;
}
- return TRUE;
+ return FALSE;
}
-static int
+static gboolean
cmd_cbpa_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
glong address;
@@ -1011,7 +1033,8 @@ cmd_cbpa_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
if (arg[k] != '\0')
{
fprintf (dis->err, _("Invalid argument: %s\n"), arg);
- return cmd_help_ (dis, "cbpa");
+ cmd_help_ (dis, "cbpa");
+ return FALSE;
}
address = atol (arg);
switch (mix_vm_clear_breakpoint_address (dis->vm, address))
@@ -1024,36 +1047,41 @@ cmd_cbpa_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
break;
default:
fprintf (dis->err, _("Breakpoint cleared at address %ld\n"), address);
- break;
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
-static int
+static gboolean
cmd_cabp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
if (strlen (arg) != 0)
{
fprintf (dis->err, _("Invalid argument: %s\n"), arg);
- return cmd_help_ (dis, "cabp");
+ cmd_help_ (dis, "cabp");
+ return FALSE;
}
mix_vm_clear_all_breakpoints (dis->vm);
return TRUE;
}
-static int
+static gboolean
cmd_weval_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
if ( strlen (arg) == 0 )
- return cmd_help_ (dis, "weval");
-
+ {
+ cmd_help_ (dis, "weval");
+ return FALSE;
+ }
+
if (mix_eval_expression_with_loc (dis->eval, arg,
mix_vm_get_prog_count (dis->vm)) ==
MIX_EVAL_OK)
{
mix_word_print_to_file (mix_eval_value (dis->eval), NULL, dis->out);
putc ('\n', dis->out);
+ return TRUE;
}
else
{
@@ -1066,16 +1094,18 @@ cmd_weval_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
for (k = pos; k < len; ++k) fputc (arg[k], dis->err);
fprintf (dis->err, _("\nEvaluation error: %s\n"),
mix_eval_last_error_string (dis->eval));
+ return FALSE;
}
-
- return TRUE;
}
-static int
+static gboolean
cmd_w2d_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
if ( strlen (arg) == 0 )
- return cmd_help_ (dis, "w2d");
+ {
+ cmd_help_ (dis, "w2d");
+ return FALSE;
+ }
else
{
gchar *cp = g_strdup (arg), *a = cp;
@@ -1102,8 +1132,11 @@ cmd_w2d_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
if (success)
{
if (strtok (NULL, "\t") != NULL)
- fprintf (dis->err, _("The expression %s does not fit in a word\n"),
- arg);
+ {
+ fprintf (dis->err,
+ _("The expression %s does not fit in a word\n"), arg);
+ success = FALSE;
+ }
else
{
mix_word_t w = mix_bytes_to_word (bytes, k);
@@ -1112,12 +1145,12 @@ cmd_w2d_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
}
}
g_free (cp);
- }
- return TRUE;
+ return success;
+ }
}
-static int
+static gboolean
cmd_tron_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
dis->trace = TRUE;
@@ -1125,7 +1158,7 @@ cmd_tron_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
return TRUE;
}
-static int
+static gboolean
cmd_troff_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
dis->trace = FALSE;
diff --git a/mixlib/mix_vm_command.h b/mixlib/mix_vm_command.h
index a805e68..856c2d5 100644
--- a/mixlib/mix_vm_command.h
+++ b/mixlib/mix_vm_command.h
@@ -1,7 +1,7 @@
/* -*-c-*- ---------------- mix_vm_command.h :
* declarations for mix_vm_command_t, describing commands issued to a vm
* ------------------------------------------------------------------
- * Last change: Time-stamp: <01/03/09 21:53:43 jose>
+ * Last change: Time-stamp: <01/03/15 15:57:36 jose>
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -107,6 +107,9 @@ extern gboolean
mix_vm_cmd_dispatcher_dispatch_text (mix_vm_cmd_dispatcher_t *dis,
const gchar *text);
+/* get the last dispatch's result */
+extern gboolean
+mix_vm_cmd_dispatcher_get_last_result (const mix_vm_cmd_dispatcher_t *dis);
/* get total uptime */
extern mix_time_t