/* bad.c -- Implementation File (module.c template V1.0)
- Copyright (C) 1995 Free Software Foundation, Inc.
- Contributed by James Craig Burley (burley@gnu.ai.mit.edu).
+ Copyright (C) 1995, 2002 Free Software Foundation, Inc.
+ Contributed by James Craig Burley.
This file is part of GNU Fortran.
/* Include files. */
#include "proj.h"
-#include <ctype.h>
#include "bad.h"
+#include "flags.h"
#include "com.h"
+#include "toplev.h"
#include "where.h"
+#include "intl.h"
+#include "diagnostic.h"
/* Externals defined here. */
struct _ffebad_message_
{
- ffebadSeverity severity;
- char *message;
+ const ffebadSeverity severity;
+ const char *const message;
};
/* Static objects accessed by functions in this module. */
-static struct _ffebad_message_ ffebad_messages_[]
+static const struct _ffebad_message_ ffebad_messages_[]
=
{
-#define FFEBAD_MSGS1(KWD,SEV,MSG) { SEV, MSG },
+#define FFEBAD_MSG(kwd,sev,msgid) { sev, msgid },
#if FFEBAD_LONG_MSGS_ == 0
-#define FFEBAD_MSGS2(KWD,SEV,LMSG,SMSG) { SEV, SMSG },
+#define LONG(m)
+#define SHORT(m) m
#else
-#define FFEBAD_MSGS2(KWD,SEV,LMSG,SMSG) { SEV, LMSG },
+#define LONG(m) m
+#define SHORT(m)
#endif
#include "bad.def"
-#undef FFEBAD_MSGS1
-#undef FFEBAD_MSGS2
+#undef FFEBAD_MSG
+#undef LONG
+#undef SHORT
};
static struct
}
ffebad_here_[FFEBAD_MAX_];
-static char *ffebad_string_[FFEBAD_MAX_];
+static const char *ffebad_string_[FFEBAD_MAX_];
static ffebadIndex ffebad_order_[FFEBAD_MAX_];
static ffebad ffebad_errnum_;
static ffebadSeverity ffebad_severity_;
-static char *ffebad_message_;
+static const char *ffebad_message_;
static unsigned char ffebad_index_;
static ffebadIndex ffebad_places_;
static bool ffebad_is_temp_inhibited_; /* Effective setting of
/* Static functions (internal). */
-static int ffebad_bufputs_ (char buf[], int bufi, char *s);
+static int ffebad_bufputs_ (char buf[], int bufi, const char *s);
/* Internal macros. */
\f
static int
-ffebad_bufputs_ (char buf[], int bufi, char *s)
+ffebad_bufputs_ (char buf[], int bufi, const char *s)
{
for (; *s != '\0'; ++s)
bufi = ffebad_bufputc_ (buf, bufi, *s);
bool
ffebad_start_ (bool lex_override, ffebad errnum, ffebadSeverity sev,
- char *message)
+ const char *msgid)
{
unsigned char i;
if (errnum != FFEBAD)
{
ffebad_severity_ = ffebad_messages_[errnum].severity;
- ffebad_message_ = ffebad_messages_[errnum].message;
+ ffebad_message_ = gettext (ffebad_messages_[errnum].message);
}
else
{
ffebad_severity_ = sev;
- ffebad_message_ = message;
+ ffebad_message_ = gettext (msgid);
}
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
- {
- extern int inhibit_warnings; /* From toplev.c. */
-
- switch (ffebad_severity_)
- { /* Tell toplev.c about this message. */
- case FFEBAD_severityINFORMATIONAL:
- case FFEBAD_severityTRIVIAL:
- if (inhibit_warnings)
- { /* User wants no warnings. */
- ffebad_is_temp_inhibited_ = TRUE;
- return FALSE;
- }
- /* Fall through. */
- case FFEBAD_severityWARNING:
- case FFEBAD_severityPECULIAR:
- case FFEBAD_severityPEDANTIC:
- if ((ffebad_severity_ != FFEBAD_severityPEDANTIC)
- || !flag_pedantic_errors)
- {
- if (count_error (1) == 0)
- { /* User wants no warnings. */
- ffebad_is_temp_inhibited_ = TRUE;
- return FALSE;
- }
- break;
- }
- /* Fall through (PEDANTIC && flag_pedantic_errors). */
- case FFEBAD_severityFATAL:
- case FFEBAD_severityWEIRD:
- case FFEBAD_severitySEVERE:
- case FFEBAD_severityDISASTER:
- count_error (0);
- break;
+ switch (ffebad_severity_)
+ { /* Tell toplev.c about this message. */
+ case FFEBAD_severityINFORMATIONAL:
+ case FFEBAD_severityTRIVIAL:
+ if (inhibit_warnings)
+ { /* User wants no warnings. */
+ ffebad_is_temp_inhibited_ = TRUE;
+ return FALSE;
+ }
+ /* Fall through. */
+ case FFEBAD_severityWARNING:
+ case FFEBAD_severityPECULIAR:
+ case FFEBAD_severityPEDANTIC:
+ if ((ffebad_severity_ != FFEBAD_severityPEDANTIC)
+ || !flag_pedantic_errors)
+ {
+ if (!diagnostic_count_diagnostic (global_dc, DK_WARNING))
+ { /* User wants no warnings. */
+ ffebad_is_temp_inhibited_ = TRUE;
+ return FALSE;
+ }
+ break;
+ }
+ /* Fall through (PEDANTIC && flag_pedantic_errors). */
+ case FFEBAD_severityFATAL:
+ case FFEBAD_severityWEIRD:
+ case FFEBAD_severitySEVERE:
+ case FFEBAD_severityDISASTER:
+ diagnostic_count_diagnostic (global_dc, DK_ERROR);
+ break;
- default:
- break;
- }
- }
-#endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
+ default:
+ break;
+ }
ffebad_is_temp_inhibited_ = FALSE;
ffebad_errnum_ = errnum;
/* Establish string for next index (always in order) of message
- ffebad_string(char *string);
+ ffebad_string(const char *string);
Call ffebad_start to establish the message, ffebad_here and ffebad_string
to send run-time data to it as necessary, then ffebad_finish when through
the argument passed in until then. */
void
-ffebad_string (char *string)
+ffebad_string (const char *string)
{
if (ffebad_is_temp_inhibited_)
return;
ffebad_finish ()
{
#define MAX_SPACES 132
- static char *spaces
+ static const char *const spaces
= "...>\
\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\
\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\
ffebadIndex bi;
unsigned short i;
char pointer;
- char c;
- char *s;
- char *fn;
+ unsigned char c;
+ unsigned const char *s;
+ const char *fn;
static char buf[1024];
int bufi;
int index;
switch (ffebad_severity_)
{
case FFEBAD_severityINFORMATIONAL:
- s = "note:";
+ s = _("note:");
break;
case FFEBAD_severityWARNING:
- s = "warning:";
+ s = _("warning:");
break;
case FFEBAD_severitySEVERE:
- s = "fatal:";
+ s = _("fatal:");
break;
default:
{
if (bi != 0)
fputc ('\n', stderr);
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
- report_error_function (fn);
-#endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
+ diagnostic_report_current_function (global_dc);
fprintf (stderr,
-#if 0
- "Line %" ffewhereLineNumber_f "u of %s:\n %s\n %s%c",
- rn, fn,
-#else
/* the trailing space on the <file>:<line>: line
fools emacs19 compilation mode into finding the
report */
"%s:%" ffewhereLineNumber_f "u: %s\n %s\n %s%c",
fn, rn,
-#endif
s,
ffewhere_line_content (l),
&spaces[cn > MAX_SPACES ? 0 : MAX_SPACES - cn + 4],
pointer);
last_line_num = ln;
last_col_num = cn;
- s = "(continued):";
+ s = _("(continued):");
}
else
{
if (ffebad_places_ == 0)
{
/* Didn't output "warning:" string, capitalize it for message. */
- if ((s[0] != '\0') && isalpha (s[0]) && islower (s[0]))
+ if (s[0] != '\0')
{
char c;
- c = toupper (s[0]);
+ c = TOUPPER (s[0]);
fprintf (stderr, "%c%s ", c, &s[1]);
}
else if (s[0] != '\0')
if (c == '%')
{
c = ffebad_message_[++i];
- if (isalpha (c) && isupper (c))
+ if (ISUPPER (c))
{
index = c - 'A';
if ((index < 0) || (index >= FFEBAD_MAX_))
{
- bufi = ffebad_bufputs_ (buf, bufi, "[REPORT BUG!!] %");
+ bufi = ffebad_bufputs_ (buf, bufi, _("[REPORT BUG!!] %"));
bufi = ffebad_bufputc_ (buf, bufi, c);
}
else
{
s = ffebad_string_[index];
if (s == NULL)
- bufi = ffebad_bufputs_ (buf, bufi, "[REPORT BUG!!]");
+ bufi = ffebad_bufputs_ (buf, bufi, _("[REPORT BUG!!]"));
else
bufi = ffebad_bufputs_ (buf, bufi, s);
}
}
- else if (isdigit (c))
+ else if (ISDIGIT (c))
{
index = c - '0';
if ((index < 0) || (index >= FFEBAD_MAX_))
{
- bufi = ffebad_bufputs_ (buf, bufi, "[REPORT BUG!!] %");
+ bufi = ffebad_bufputs_ (buf, bufi, _("[REPORT BUG!!] %"));
bufi = ffebad_bufputc_ (buf, bufi, c);
}
else
bufi = ffebad_bufputc_ (buf, bufi, '%');
else
{
- bufi = ffebad_bufputs_ (buf, bufi, "[REPORT BUG!!]");
+ bufi = ffebad_bufputs_ (buf, bufi, _("[REPORT BUG!!]"));
bufi = ffebad_bufputc_ (buf, bufi, '%');
bufi = ffebad_bufputc_ (buf, bufi, c);
}