[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Directory restructuring
From: |
Ben Pfaff |
Subject: |
Re: Directory restructuring |
Date: |
Sun, 05 Feb 2006 08:55:41 -0800 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) |
John Darrington <address@hidden> writes:
> > 6. src/output depends on src/language which seems wrong to me. In
> > fact src/language/ contains only command.* and it's a very common
> > dependency, so perhaps this needs to be split or something.
>
> I think src/output only wants command.h because it wants
> cur_proc, the name of the current command, to include it in the
> output. We could reverse the dependency by making command.c call
> a function in src/output. src/language definitely needs to call
> into src/output in any case, so how's that sound to you?
>
> Perhaps you can look at glob.c and at point 6. (above). I think I can
> do something better with output vs. output/charts.
Here's a patch for #6. It's relative to what I sent before and
includes the Makefile fix for q2c and the vfm fix for FILTER.
`make check' passes here.
Also as:
http://footstool.stanford.edu/~blp/reorg2.patch
http://footstool.stanford.edu/~blp/reorg2.tar.gz
diff -urpN -X pat reorg1/src/error.c reorg2/src/error.c
--- reorg1/src/error.c 2006-02-01 19:36:39.000000000 -0800
+++ reorg2/src/error.c 2006-02-05 08:45:20.000000000 -0800
@@ -24,7 +24,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "alloc.h"
-#include "command.h"
#include "getl.h"
#include "glob.h"
#include "lexer.h"
@@ -48,6 +47,7 @@ int err_already_flagged;
int err_verbosity;
+static char *command_name;
/* Fairly common public functions. */
@@ -230,8 +230,8 @@ err_vmsg (const struct error *e, const c
(*count)++;
}
- if (cur_proc && (error_classes[class].flags & ERR_IN_PROCEDURE))
- ds_printf (&msg, "%s: ", cur_proc);
+ if (command_name != NULL && (error_classes[class].flags & ERR_IN_PROCEDURE))
+ ds_printf (&msg, "%s: ", command_name);
if (e->title)
ds_puts (&msg, e->title);
@@ -438,6 +438,14 @@ dump_message (char *msg, unsigned indent
local_free (buf);
}
+/* Sets COMMAND_NAME as the command name included in some kinds
+ of error messages. */
+void
+err_set_command_name (const char *command_name_)
+{
+ free (command_name);
+ command_name = command_name_ ? xstrdup (command_name_) : NULL;
+}
void
request_bug_report_and_abort(const char *msg )
diff -urpN -X pat reorg1/src/language/command.c reorg2/src/language/command.c
--- reorg1/src/language/command.c 2006-02-02 21:23:02.000000000 -0800
+++ reorg2/src/language/command.c 2006-02-05 08:47:32.000000000 -0800
@@ -54,9 +54,6 @@
/* A STATE_* constant giving the current program state. */
int pgm_state;
-
-/* The name of the procedure currently executing, if any. */
-const char *cur_proc;
/* Static variables. */
@@ -248,16 +245,12 @@ cmd_parse (void)
{
int result;
- /* Call the command dispatcher. Save and restore the name of
- the current command around this call. */
- {
- const char *prev_proc;
-
- prev_proc = cur_proc;
- cur_proc = cp->name;
- result = cp->func ();
- cur_proc = prev_proc;
- }
+ /* Call the command dispatcher. */
+ err_set_command_name (cp->name);
+ tab_set_command_name (cp->name);
+ result = cp->func ();
+ err_set_command_name (NULL);
+ tab_set_command_name (NULL);
/* Perform the state transition if the command completed
successfully (at least in part). */
diff -urpN -X pat reorg1/src/language/command.h reorg2/src/language/command.h
--- reorg1/src/language/command.h 2006-02-01 19:33:35.000000000 -0800
+++ reorg2/src/language/command.h 2006-02-05 08:45:58.000000000 -0800
@@ -41,7 +41,6 @@ enum
};
extern int pgm_state;
-extern const char *cur_proc;
char *pspp_completion_function (const char *text, int state);
diff -urpN -X pat reorg1/src/language/stats/Makefile.am
reorg2/src/language/stats/Makefile.am
--- reorg1/src/language/stats/Makefile.am 2006-02-02 20:37:45.000000000
-0800
+++ reorg2/src/language/stats/Makefile.am 2006-02-05 08:04:34.000000000
-0800
@@ -42,9 +42,9 @@ CLEANFILES=$(q_sources_c)
-$(q_sources_c): $(top_srcdir)/src/language/lexer/q2c$(EXEEXT)
+$(q_sources_c): $(top_builddir)/src/language/lexer/q2c$(EXEEXT)
.q.c:
- $(top_srcdir)/src/language/lexer/q2c $< $@
+ $(top_builddir)/src/language/lexer/q2c $< $@
SUFFIXES = .q
diff -urpN -X pat reorg1/src/libpspp/pspp-error.h
reorg2/src/libpspp/pspp-error.h
--- reorg1/src/libpspp/pspp-error.h 2005-12-13 22:59:06.000000000 -0800
+++ reorg2/src/libpspp/pspp-error.h 2006-02-05 08:39:38.000000000 -0800
@@ -81,6 +81,7 @@ void err_pop_file_locator (const struct
void err_location (struct file_locator *);
/* Obscure functions. */
+void err_set_command_name (const char *);
void err_done (void);
void err_break (void);
void err_check_count (void);
diff -urpN -X pat reorg1/src/output/tab.c reorg2/src/output/tab.c
--- reorg1/src/output/tab.c 2006-02-01 21:54:49.000000000 -0800
+++ reorg2/src/output/tab.c 2006-02-05 08:47:05.000000000 -0800
@@ -26,7 +26,6 @@
#include "pspp-error.h"
#include "alloc.h"
#include "format.h"
-#include "command.h"
#include "magic.h"
#include "misc.h"
#include "output.h"
@@ -40,6 +39,7 @@
#include "debug-print.h"
struct som_table_class tab_table_class;
+static char *command_name;
/* Creates a table with NC columns and NR rows. If REALLOCABLE is
nonzero then the table's size can be increased later; otherwise,
@@ -1195,8 +1195,8 @@ tabi_title (int x, int y)
cp = spprintf (cp, "(%d:%d)", x, y);
else if (x)
cp = spprintf (cp, "(%d)", x);
- if (cur_proc)
- cp = spprintf (cp, " %s", cur_proc);
+ if (command_name != NULL)
+ cp = spprintf (cp, " %s", command_name);
cp = stpcpy (cp, ". ");
if (!ls_empty_p (&t->title))
{
@@ -1436,3 +1436,11 @@ render_strip (int x, int y, int r, int c
return x - x_origin;
}
+/* Sets COMMAND_NAME as the name of the current command,
+ for embedding in output. */
+void
+tab_set_command_name (const char *command_name_)
+{
+ free (command_name);
+ command_name = command_name_ ? xstrdup (command_name_) : NULL;
+}
diff -urpN -X pat reorg1/src/output/tab.h reorg2/src/output/tab.h
--- reorg1/src/output/tab.h 2006-02-01 19:33:36.000000000 -0800
+++ reorg2/src/output/tab.h 2006-02-05 08:32:05.000000000 -0800
@@ -191,5 +191,8 @@ void tab_next_row (struct tab_table *);
void tab_output_text (int options, const char *string, ...)
PRINTF_FORMAT (2, 3);
+/* Embedding the command name in the output. */
+void tab_set_command_name (const char *);
+
#endif /* tab_h */
diff -urpN -X pat reorg1/src/vfm.c reorg2/src/vfm.c
--- reorg1/src/vfm.c 2006-02-04 22:22:50.000000000 -0800
+++ reorg2/src/vfm.c 2006-02-05 08:49:04.000000000 -0800
@@ -449,8 +449,6 @@ close_active_file (void)
/* Cancel TEMPORARY, PROCESS IF, FILTER, N OF CASES, vectors,
and get rid of all the transformations. */
- if (dict_get_filter (temp_dict) == NULL)
- dict_set_filter (default_dict, NULL);
cancel_temporary ();
expr_free (process_if_expr);
process_if_expr = NULL;
--
Ben Pfaff
email: address@hidden
web: http://benpfaff.org
- Re: Directory restructuring, (continued)
- Re: Directory restructuring, Ben Pfaff, 2006/02/05
- Re: Directory restructuring, Ben Pfaff, 2006/02/05
- Re: Directory restructuring, Ben Pfaff, 2006/02/05
- Re: Directory restructuring, John Darrington, 2006/02/05
- Re: Directory restructuring, Ben Pfaff, 2006/02/05
- Re: Directory restructuring, Ben Pfaff, 2006/02/05
- Re: Directory restructuring,
Ben Pfaff <=
- Re: Directory restructuring, Ben Pfaff, 2006/02/05
- Re: Directory restructuring, John Darrington, 2006/02/05