+Sun Apr 23 22:00:23 2006 Ben Pfaff <blp@gnu.org>
+
+ Continue reforming error message support. In this phase, get rid
+ of message "titles" and put the message text in `struct error'.
+ Now `struct error' encapsulates a message more properly.
+
+ * message.c: (tmsg) Removed.
+ (msg) Use err_msg() instead of err_vmsg(). Format message
+ ourselves.
+ (err_vmsg) Renamed err_msg(). Changed interface, dropping message
+ and va_list args which are now in the error struct.
+
Sun Apr 23 20:35:28 2006 Ben Pfaff <blp@gnu.org>
Continue reforming error message support.
+Sun Apr 23 22:04:45 2006 Ben Pfaff <blp@gnu.org>
+
+ Continue reforming error message support. In this phase, get rid
+ of message "titles" and put the message text in `struct error'.
+ Now `struct error' encapsulates a message more properly.
+
+ * casefile.c: (io_error) Use err_msg() instead of err_vmsg().
+ Format message ourselves.
+
+ * data-in.c: (vdls_error) Ditto.
+
+ * por-file-reader.c: (error) Ditto.
+
+ * sys-file-reader.c: (corrupt_msg) Ditto.
+
Sun Apr 16 18:49:51 2006 Ben Pfaff <blp@gnu.org>
GNU standards require "file name" instead of "filename" in
e.severity = MSG_ERROR;
e.where.file_name = NULL;
e.where.line_number = -1;
- e.title = NULL;
-
va_start (args, format);
- err_vmsg (&e, format, args);
+ e.text = xvasprintf (format, args);
va_end (args);
+
+ err_msg (&e);
}
cf->ok = false;
}
vdls_error (const struct data_in *i, const char *format, va_list args)
{
struct error e;
- struct string title;
+ struct string text;
if (i->flags & DI_IGNORE_ERROR)
return;
- ds_init (&title, 64);
+ ds_init (&text, 64);
if (i->f1 == i->f2)
- ds_printf (&title, _("(column %d"), i->f1);
+ ds_printf (&text, _("(column %d"), i->f1);
else
- ds_printf (&title, _("(columns %d-%d"), i->f1, i->f2);
- ds_printf (&title, _(", field type %s) "), fmt_to_string (&i->format));
+ ds_printf (&text, _("(columns %d-%d"), i->f1, i->f2);
+ ds_printf (&text, _(", field type %s) "), fmt_to_string (&i->format));
+ ds_vprintf (&text, format, args);
e.category = MSG_DATA;
e.severity = MSG_ERROR;
err_location (&e.where);
- e.title = ds_c_str (&title);
+ e.text = ds_c_str (&text);
- err_vmsg (&e, format, args);
-
- ds_destroy (&title);
+ err_msg (&e);
}
static void
error (struct pfm_reader *r, const char *msg, ...)
{
struct error e;
- const char *file_name;
- char *title;
+ struct string text;
va_list args;
+ ds_init (&text, 64);
+ ds_printf (&text, _("portable file %s corrupt at offset %ld: "),
+ fh_get_file_name (r->fh), ftell (r->file));
+ va_start (args, msg);
+ ds_vprintf (&text, msg, args);
+ va_end (args);
+
e.category = MSG_GENERAL;
e.severity = MSG_ERROR;
e.where.file_name = NULL;
e.where.line_number = 0;
- file_name = fh_get_file_name (r->fh);
- e.title = title = pool_alloc (r->pool, strlen (file_name) + 80);
- sprintf (title, _("portable file %s corrupt at offset %ld: "),
- file_name, ftell (r->file));
-
- va_start (args, msg);
- err_vmsg (&e, msg, args);
- va_end (args);
+ e.text = ds_c_str (&text);
+
+ err_msg (&e);
r->ok = false;
{
struct error e;
va_list args;
+ struct string text;
+
+ ds_create (&text, _("corrupt system file: "));
+ va_start (args, format);
+ ds_vprintf (&text, format, args);
+ va_end (args);
e.category = msg_class_to_category (class);
e.severity = msg_class_to_severity (class);
e.where.file_name = NULL;
e.where.line_number = 0;
- e.title = _("corrupt system file: ");
+ e.text = ds_c_str (&text);
- va_start (args, format);
- err_vmsg (&e, format, args);
- va_end (args);
+ err_msg (&e);
}
/* Closes a system file after we're done with it. */
+Sun Apr 23 22:05:58 2006 Ben Pfaff <blp@gnu.org>
+
+ Continue reforming error message support. In this phase, get rid
+ of message "titles" and put the message text in `struct error'.
+ Now `struct error' encapsulates a message more properly.
+
+ * data-list.c: (macro RPD_ERR) Removed.
+ (rpd_msg) New function. Updated all references to tmsg() to call
+ this function instead.
+
Sat Apr 15 19:38:13 2006 Ben Pfaff <blp@gnu.org>
Remove last users of struct file_ext so we can get rid of it
static const struct case_source_class data_list_source_class;
+static void rpd_msg (enum msg_class, const char *format, ...);
static int parse_fixed (struct data_list_pgm *);
static int parse_free (struct dls_var_spec **, struct dls_var_spec **);
static void dump_fixed_table (const struct dls_var_spec *,
static trns_free_func data_list_trns_free;
static trns_proc_func data_list_trns_proc;
-/* Message title for REPEATING DATA. */
-#define RPD_ERR "REPEATING DATA: "
-
int
cmd_data_list (void)
{
data_out (actual_str, &t->id_var->print, id_temp);
actual_str[t->id_var->print.w] = '\0';
- tmsg (SE, RPD_ERR,
- _("Encountered mismatched record ID \"%s\" expecting \"%s\"."),
- actual_str, expected_str);
+ rpd_msg (SE,
+ _("Encountered mismatched record ID \"%s\" "
+ "expecting \"%s\"."),
+ actual_str, expected_str);
return 0;
}
{
warned = 1;
- tmsg (SW, RPD_ERR,
- _("Variable %s starting in column %d extends "
- "beyond physical record length of %d."),
- var_spec->v->name, fc, info->len);
+ rpd_msg (SW,
+ _("Variable %s starting in column %d extends "
+ "beyond physical record length of %d."),
+ var_spec->v->name, fc, info->len);
}
{
occurs_left = occurs = realize_value (&t->occurs, c);
if (occurs <= 0)
{
- tmsg (SE, RPD_ERR, _("Invalid value %d for OCCURS."), occurs);
+ rpd_msg (SE, _("Invalid value %d for OCCURS."), occurs);
return TRNS_NEXT_CASE;
}
starts_beg = realize_value (&t->starts_beg, c);
if (starts_beg <= 0)
{
- tmsg (SE, RPD_ERR, _("Beginning column for STARTS (%d) must be "
- "at least 1."),
- starts_beg);
+ rpd_msg (SE, _("Beginning column for STARTS (%d) must be at least 1."),
+ starts_beg);
return TRNS_NEXT_CASE;
}
starts_end = realize_value (&t->starts_end, c);
if (starts_end < starts_beg)
{
- tmsg (SE, RPD_ERR, _("Ending column for STARTS (%d) is less than "
- "beginning column (%d)."),
- starts_end, starts_beg);
+ rpd_msg (SE, _("Ending column for STARTS (%d) is less than "
+ "beginning column (%d)."),
+ starts_end, starts_beg);
skip_first_record = 1;
}
length = realize_value (&t->length, c);
if (length < 0)
{
- tmsg (SE, RPD_ERR, _("Invalid value %d for LENGTH."), length);
+ rpd_msg (SE, _("Invalid value %d for LENGTH."), length);
length = 1;
occurs = occurs_left = 1;
}
cont_beg = realize_value (&t->cont_beg, c);
if (cont_beg < 0)
{
- tmsg (SE, RPD_ERR, _("Beginning column for CONTINUED (%d) must be "
- "at least 1."),
- cont_beg);
+ rpd_msg (SE, _("Beginning column for CONTINUED (%d) must be "
+ "at least 1."),
+ cont_beg);
return TRNS_DROP_CASE;
}
cont_end = realize_value (&t->cont_end, c);
if (cont_end < cont_beg)
{
- tmsg (SE, RPD_ERR, _("Ending column for CONTINUED (%d) is less than "
- "beginning column (%d)."),
- cont_end, cont_beg);
+ rpd_msg (SE, _("Ending column for CONTINUED (%d) is less than "
+ "beginning column (%d)."),
+ cont_end, cont_beg);
return TRNS_DROP_CASE;
}
continuation records. */
if (occurs_left > 0 && cont_beg == 0)
{
- tmsg (SE, RPD_ERR,
- _("Number of repetitions specified on OCCURS (%d) "
- "exceed number of repetitions available in "
- "space on STARTS (%d), and CONTINUED not specified."),
- occurs, (starts_end - starts_beg + 1) / length);
+ rpd_msg (SE,
+ _("Number of repetitions specified on OCCURS (%d) "
+ "exceed number of repetitions available in "
+ "space on STARTS (%d), and CONTINUED not specified."),
+ occurs, (starts_end - starts_beg + 1) / length);
return TRNS_DROP_CASE;
}
/* Read in another record. */
if (dfm_eof (t->reader))
{
- tmsg (SE, RPD_ERR,
- _("Unexpected end of file with %d repetitions "
- "remaining out of %d."),
- occurs_left, occurs);
+ rpd_msg (SE,
+ _("Unexpected end of file with %d repetitions "
+ "remaining out of %d."),
+ occurs_left, occurs);
return TRNS_DROP_CASE;
}
dfm_expand_tabs (t->reader);
t->write_case = write_case;
t->wc_data = wc_data;
}
+
+/* Reports a message in CLASS with the given FORMAT as text,
+ prefixing the message with "REPEATING DATA: " to make the
+ cause clear. */
+static void
+rpd_msg (enum msg_class class, const char *format, ...)
+{
+ struct error e;
+ va_list args;
+ struct string text;
+
+ ds_create (&text, "REPEATING DATA: ");
+ va_start (args, format);
+ ds_vprintf (&text, format, args);
+ va_end (args);
+
+ e.category = msg_class_to_category (class);
+ e.severity = msg_class_to_severity (class);
+ e.where.file_name = NULL;
+ e.where.line_number = 0;
+ e.text = ds_c_str (&text);
+
+ err_msg (&e);
+}
+Sun Apr 23 22:06:45 2006 Ben Pfaff <blp@gnu.org>
+
+ Continue reforming error message support. In this phase, get rid
+ of message "titles" and put the message text in `struct error'.
+ Now `struct error' encapsulates a message more properly.
+
+ * helpers.c: (expr_error) Use err_msg() instead of err_vmsg().
+ Format message ourselves.
+
Thu Mar 2 08:40:33 WST 2006 John Darrington <john@darrington.wattle.id.au>
* Moved files from src directory
e.category = MSG_SYNTAX;
e.severity = MSG_ERROR;
err_location (&e.where);
- e.title = NULL;
-
va_start (args, format);
- err_vmsg (&e, format, args);
+ e.text = xvasprintf (format, args);
va_end (args);
+
+ err_msg (&e);
}
double
+Sun Apr 23 22:07:06 2006 Ben Pfaff <blp@gnu.org>
+
+ Continue reforming error message support. In this phase, get rid
+ of message "titles" and put the message text in `struct error'.
+ Now `struct error' encapsulates a message more properly.
+
+ * message.h: (struct error) Remove `title' member. Add `text'
+ member.
+
Sun Apr 16 20:43:35 2006 Ben Pfaff <blp@gnu.org>
Continue reforming error message support. In this phase, we
enum msg_category category; /* Message category. */
enum msg_severity severity; /* Message severity. */
struct file_locator where; /* File location, or (NULL, -1). */
- const char *title; /* Special text inserted if not null. */
+ char *text; /* Error text. */
};
/* Number of errors, warnings reported. */
/* Nonnegative verbosity level. Higher value == more verbose. */
extern int err_verbosity;
-/* Functions. */
+/* Emitting messages. */
void msg (enum msg_class, const char *format, ...)
PRINTF_FORMAT (2, 3);
-void tmsg (enum msg_class, const char *title, const char *format, ...)
- PRINTF_FORMAT (3, 4);
+void err_msg (const struct error *);
void verbose_msg (int level, const char *format, ...)
PRINTF_FORMAT (2, 3);
void err_set_command_name (const char *);
void err_done (void);
void err_check_count (void);
-void err_vmsg (const struct error *, const char *, va_list);
/* Used in panic situations only */
void request_bug_report_and_abort(const char *msg );
\f
/* Public functions. */
-/* Writes error message in CLASS, with title TITLE and text FORMAT,
- formatted with printf, to the standard places. */
-void
-tmsg (enum msg_class class, const char *title, const char *format, ...)
-{
- struct error e;
- va_list args;
-
- e.category = msg_class_to_category (class);
- e.severity = msg_class_to_severity (class);
- err_location (&e.where);
- e.title = title;
-
- va_start (args, format);
- err_vmsg (&e, format, args);
- va_end (args);
-}
-
/* Writes error message in CLASS, with text FORMAT, formatted with
printf, to the standard places. */
void
e.category = msg_class_to_category (class);
e.severity = msg_class_to_severity (class);
err_location (&e.where);
- e.title = NULL;
-
va_start (args, format);
- err_vmsg (&e, format, args);
+ e.text = xvasprintf (format, args);
va_end (args);
+
+ err_msg (&e);
}
/* Writes MESSAGE formatted with printf, to stderr, if the
readln_uninitialize();
}
+/* Emits E as an error message.
+ Frees `text' member in E. */
void
-err_vmsg (const struct error *e, const char *format, va_list args)
+err_msg (const struct error *e)
{
struct category
{
if (category->show_command_name && command_name != NULL)
ds_printf (&msg, "%s: ", command_name);
- if (e->title)
- ds_puts (&msg, e->title);
-
- ds_vprintf (&msg, format, args);
+ ds_puts (&msg, e->text);
/* FIXME: Check set_messages and set_errors to determine where to
send errors and messages. */
dump_message (ds_c_str (&msg), puts_stdout, get_viewwidth (), 8);
ds_destroy (&msg);
+ free (e->text);
}
\f
/* Private functions. */
+Sun Apr 23 22:07:49 2006 Ben Pfaff <blp@gnu.org>
+
+ Continue reforming error message support. In this phase, get rid
+ of message "titles" and put the message text in `struct error'.
+ Now `struct error' encapsulates a message more properly.
+
+ * message-dialog.c: (err_vmsg) Rename err_msg(). Updated
+ interface.
+
Sun Apr 16 20:45:35 2006 Ben Pfaff <blp@gnu.org>
Continue reforming error message support. In this phase, we
void
-err_vmsg (const struct error *e, const char *format, va_list args)
+err_msg (const struct error *e)
{
vmsg(msg_class_from_category_and_severity (e->category, e->severity),
- format, args);
+ "%s", e->text);
}