From 618a58ebb4c59dff83374278e44b7375b3865935 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 4 Jul 2006 04:39:04 +0000 Subject: [PATCH] Encapsulated msg_location inside msg_emit --- po/de.po | 2 +- po/pspp.pot | 2 +- src/data/data-in.c | 1 - src/language/expressions/helpers.c | 3 --- src/language/line-buffer.c | 5 +++-- src/language/line-buffer.h | 6 ++++-- src/libpspp/message.c | 12 ++++++++---- src/libpspp/message.h | 6 ++++-- src/math/automake.mk | 1 + src/ui/gui/message-dialog.c | 23 +++++++++++------------ src/ui/terminal/msg-ui.c | 3 ++- 11 files changed, 35 insertions(+), 29 deletions(-) diff --git a/po/de.po b/po/de.po index 60027149..6c670049 100644 --- a/po/de.po +++ b/po/de.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.4.2\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2006-07-04 09:03+0800\n" +"POT-Creation-Date: 2006-07-04 10:49+0800\n" "PO-Revision-Date: 2006-05-26 17:49+0800\n" "Last-Translator: John Darrington \n" "Language-Team: German \n" diff --git a/po/pspp.pot b/po/pspp.pot index 6438e010..6659e7e3 100644 --- a/po/pspp.pot +++ b/po/pspp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2006-07-04 09:03+0800\n" +"POT-Creation-Date: 2006-07-04 10:49+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/data/data-in.c b/src/data/data-in.c index 462f8557..0b9e0623 100644 --- a/src/data/data-in.c +++ b/src/data/data-in.c @@ -64,7 +64,6 @@ vdls_error (const struct data_in *i, const char *format, va_list args) m.category = MSG_DATA; m.severity = MSG_ERROR; - msg_location (&m.where); m.text = ds_cstr (&text); msg_emit (&m); diff --git a/src/language/expressions/helpers.c b/src/language/expressions/helpers.c index fd78e734..bddc7126 100644 --- a/src/language/expressions/helpers.c +++ b/src/language/expressions/helpers.c @@ -13,11 +13,8 @@ expr_error (void *aux UNUSED, const char *format, ...) struct msg m; va_list args; - /* FIXME: we can do better about saying where the error - occurred. */ m.category = MSG_SYNTAX; m.severity = MSG_ERROR; - msg_location (&m.where); va_start (args, format); m.text = xvasprintf (format, args); va_end (args); diff --git a/src/language/line-buffer.c b/src/language/line-buffer.c index 96ef8559..f0e69720 100644 --- a/src/language/line-buffer.c +++ b/src/language/line-buffer.c @@ -377,6 +377,7 @@ getl_location (const char **fn, int *ln) /* File locator stack. */ static const struct msg_locator **file_loc; + static int nfile_loc, mfile_loc; /* Close getl. */ @@ -423,10 +424,10 @@ msg_pop_msg_locator (const struct msg_locator *loc) nfile_loc--; } -/* Puts the current file and line number in F, or NULL and -1 if +/* Puts the current file and line number into LOC, or NULL and -1 if none. */ void -msg_location (struct msg_locator *loc) +get_msg_location (struct msg_locator *loc) { if (nfile_loc) *loc = *file_loc[nfile_loc - 1]; diff --git a/src/language/line-buffer.h b/src/language/line-buffer.h index b47a2ce3..db9076c5 100644 --- a/src/language/line-buffer.h +++ b/src/language/line-buffer.h @@ -57,10 +57,12 @@ bool getl_is_interactive (void); bool getl_read_line (bool *interactive); -void getl_location (const char **, int *); - const char *getl_get_prompt (enum getl_prompt_style); void getl_set_prompt (enum getl_prompt_style, const char *); void getl_set_prompt_style (enum getl_prompt_style); +struct msg_locator; +void get_msg_location (struct msg_locator *loc); + + #endif /* line-buffer.h */ diff --git a/src/libpspp/message.c b/src/libpspp/message.c index b88c1247..fe16c6b2 100644 --- a/src/libpspp/message.c +++ b/src/libpspp/message.c @@ -1,5 +1,5 @@ /* PSPP - computes sample statistics. - Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc. Written by Ben Pfaff . This program is free software; you can redistribute it and/or @@ -36,7 +36,9 @@ static char *command_name; /* Message handler as set by msg_init(). */ -static void (*msg_handler) (const struct msg *); +static void (*msg_handler) (const struct msg *); +static void (*msg_location) (struct msg_locator *); + /* Public functions. */ @@ -50,7 +52,6 @@ msg (enum msg_class class, const char *format, ...) m.category = msg_class_to_category (class); m.severity = msg_class_to_severity (class); - msg_location (&m.where); va_start (args, format); m.text = xvasprintf (format, args); va_end (args); @@ -59,9 +60,11 @@ msg (enum msg_class class, const char *format, ...) } void -msg_init (void (*handler) (const struct msg *)) +msg_init ( void (*handler) (const struct msg *), + void (*location) (struct msg_locator *) ) { msg_handler = handler; + msg_location = location; } void @@ -95,6 +98,7 @@ msg_destroy(struct msg *m) void msg_emit (struct msg *m) { + msg_location (&m->where); msg_handler (m); free (m->text); } diff --git a/src/libpspp/message.h b/src/libpspp/message.h index d46ea97d..9f037cb2 100644 --- a/src/libpspp/message.h +++ b/src/libpspp/message.h @@ -86,7 +86,9 @@ struct msg }; /* Initialization. */ -void msg_init (void (*handler) (const struct msg *)); +void msg_init ( void (*handler) (const struct msg *), + void (*location) (struct msg_locator *) ) ; + void msg_done (void); struct msg * msg_dup(const struct msg *m); @@ -102,7 +104,7 @@ void msg_set_command_name (const char *); const char *msg_get_command_name (void); void msg_push_msg_locator (const struct msg_locator *); void msg_pop_msg_locator (const struct msg_locator *); -void msg_location (struct msg_locator *); + /* Used in panic situations only. */ void request_bug_report_and_abort (const char *msg); diff --git a/src/math/automake.mk b/src/math/automake.mk index 0966e734..45543fc3 100644 --- a/src/math/automake.mk +++ b/src/math/automake.mk @@ -1,5 +1,6 @@ ## Process this file with automake to produce Makefile.in -*- makefile -*- +include $(top_srcdir)/src/math/ts/automake.mk include $(top_srcdir)/src/math/linreg/automake.mk noinst_LIBRARIES += src/math/libpspp_math.a diff --git a/src/ui/gui/message-dialog.c b/src/ui/gui/message-dialog.c index 840e1e2a..af1886c9 100644 --- a/src/ui/gui/message-dialog.c +++ b/src/ui/gui/message-dialog.c @@ -43,16 +43,25 @@ extern GladeXML *xml; -static void enqueue_msg(const struct msg *m); +static void enqueue_msg (const struct msg *m); static GQueue *message_queue; + +static void +msg_location (struct msg_locator *loc) +{ + loc->file_name = NULL; + loc->line_number = -1; +} + + void message_dialog_init (void) { message_queue = g_queue_new(); - msg_init(enqueue_msg); + msg_init (enqueue_msg, msg_location); } @@ -155,13 +164,3 @@ popup_message(const struct msg *m) gtk_widget_destroy (dialog); } -/* FIXME: This is a stub . - * A temporary workaround until getl.c is rearranged - */ -void -msg_location (struct msg_locator *loc) -{ - loc->file_name = 0; - loc->line_number = -1; -} - diff --git a/src/ui/terminal/msg-ui.c b/src/ui/terminal/msg-ui.c index 3e354a7b..9b71cb51 100644 --- a/src/ui/terminal/msg-ui.c +++ b/src/ui/terminal/msg-ui.c @@ -41,7 +41,7 @@ static void handle_msg (const struct msg *); void msg_ui_init (void) { - msg_init (handle_msg); + msg_init (handle_msg, get_msg_location); } void @@ -50,6 +50,7 @@ msg_ui_done (void) msg_done (); } + /* Checks whether we've had so many errors that it's time to quit processing this syntax file. */ void -- 2.30.2