From: Ben Pfaff Date: Wed, 3 Feb 2010 05:44:14 +0000 (-0800) Subject: message: Give MSG_ values for categories and severities different prefixes X-Git-Tag: v0.7.4~24 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=beac6e15a941bd498ae9301cc91e409653be6c1a;p=pspp-builds.git message: Give MSG_ values for categories and severities different prefixes This reduces confusion in reading and writing code that uses these values. --- diff --git a/src/data/data-in.c b/src/data/data-in.c index 285c777b..63e644c1 100644 --- a/src/data/data-in.c +++ b/src/data/data-in.c @@ -1199,8 +1199,8 @@ vdata_warning (const struct data_in *i, const char *format, va_list args) ds_put_format (&text, _("%s field) "), fmt_name (i->format)); ds_put_vformat (&text, format, args); - m.category = MSG_DATA; - m.severity = MSG_WARNING; + m.category = MSG_C_DATA; + m.severity = MSG_S_WARNING; m.text = ds_cstr (&text); m.where.file_name = NULL; m.where.line_number = -1; diff --git a/src/data/por-file-reader.c b/src/data/por-file-reader.c index a4631242..55f616ec 100644 --- a/src/data/por-file-reader.c +++ b/src/data/por-file-reader.c @@ -102,8 +102,8 @@ error (struct pfm_reader *r, const char *msg, ...) ds_put_vformat (&text, msg, args); va_end (args); - m.category = MSG_GENERAL; - m.severity = MSG_ERROR; + m.category = MSG_C_GENERAL; + m.severity = MSG_S_ERROR; m.where.file_name = NULL; m.where.line_number = 0; m.text = ds_cstr (&text); @@ -131,8 +131,8 @@ warning (struct pfm_reader *r, const char *msg, ...) ds_put_vformat (&text, msg, args); va_end (args); - m.category = MSG_GENERAL; - m.severity = MSG_WARNING; + m.category = MSG_C_GENERAL; + m.severity = MSG_S_WARNING; m.where.file_name = NULL; m.where.line_number = 0; m.text = ds_cstr (&text); diff --git a/src/language/expressions/helpers.c b/src/language/expressions/helpers.c index 85705098..7e9e1d6c 100644 --- a/src/language/expressions/helpers.c +++ b/src/language/expressions/helpers.c @@ -30,8 +30,8 @@ expr_error (void *aux UNUSED, const char *format, ...) struct msg m; va_list args; - m.category = MSG_SYNTAX; - m.severity = MSG_ERROR; + m.category = MSG_C_SYNTAX; + m.severity = MSG_S_ERROR; va_start (args, format); m.text = xvasprintf (format, args); va_end (args); diff --git a/src/libpspp/message.h b/src/libpspp/message.h index 3aca7789..b1e09253 100644 --- a/src/libpspp/message.h +++ b/src/libpspp/message.h @@ -24,17 +24,19 @@ /* What kind of message is this? */ enum msg_category { - MSG_GENERAL, /* General info. */ - MSG_SYNTAX, /* Messages that relate to syntax files. */ - MSG_DATA /* Messages that relate to data files. */ + MSG_C_GENERAL, /* General info. */ + MSG_C_SYNTAX, /* Messages that relate to syntax files. */ + MSG_C_DATA, /* Messages that relate to data files. */ + MSG_N_CATEGORIES }; /* How important a condition is it? */ enum msg_severity { - MSG_ERROR, - MSG_WARNING, - MSG_NOTE + MSG_S_ERROR, + MSG_S_WARNING, + MSG_S_NOTE, + MSG_N_SEVERITIES }; /* Combination of a category and a severity for convenience. */ @@ -46,7 +48,6 @@ enum msg_class MSG_CLASS_CNT, }; - static inline enum msg_category msg_class_to_category (enum msg_class class) { diff --git a/src/ui/gui/message-dialog.c b/src/ui/gui/message-dialog.c index 75132953..ccb43640 100644 --- a/src/ui/gui/message-dialog.c +++ b/src/ui/gui/message-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ #define _(msgid) gettext (msgid) #define N_(msgid) msgid +#include #include #include #include @@ -92,53 +93,53 @@ format_message (struct msg *m, struct string *msg) switch (m->severity) { - case MSG_ERROR: + case MSG_S_ERROR: switch (m->category) { - case MSG_SYNTAX: + case MSG_C_SYNTAX: label = _("syntax error"); break; - case MSG_DATA: + case MSG_C_DATA: label = _("data file error"); break; - case MSG_GENERAL: + case MSG_C_GENERAL: default: label = _("PSPP error"); break; } break; - case MSG_WARNING: + case MSG_S_WARNING: switch (m->category) { - case MSG_SYNTAX: + case MSG_C_SYNTAX: label = _("syntax warning"); break; - case MSG_DATA: + case MSG_C_DATA: label = _("data file warning"); break; - case MSG_GENERAL: + case MSG_C_GENERAL: default: label = _("PSPP warning"); break; } break; - case MSG_NOTE: + case MSG_S_NOTE: default: switch (m->category) { - case MSG_SYNTAX: + case MSG_C_SYNTAX: label = _("syntax information"); break; - case MSG_DATA: + case MSG_C_DATA: label = _("data file information"); break; - case MSG_GENERAL: + case MSG_C_GENERAL: default: label = _("PSPP information"); break; @@ -156,15 +157,17 @@ enqueue_msg (const struct msg *msg) switch (m->severity) { - case MSG_ERROR: + case MSG_S_ERROR: error_cnt++; break; - case MSG_WARNING: + case MSG_S_WARNING: warning_cnt++; break; - case MSG_NOTE: + case MSG_S_NOTE: note_cnt++; break; + case MSG_N_SEVERITIES: + NOT_REACHED (); } if (g_queue_get_length (early_queue) < MAX_EARLY_MESSAGES)