#include <stdio.h>
#include <stdlib.h>
#include <libpspp/alloc.h>
-#include <data/filename.h>
+#include <data/file-name.h>
#include <language/line-buffer.h>
#include <language/lexer/lexer.h>
#include <data/settings.h>
#include <ui/terminal/read-line.h>
#include <libpspp/version.h>
+#include "progname.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
va_end (args);
}
+/* Writes MESSAGE formatted with printf, to stderr, if the
+ verbosity level is at least LEVEL. */
+void
+verbose_msg (int level, const char *format, ...)
+{
+ if (err_verbosity >= level)
+ {
+ va_list args;
+
+ va_start (args, format);
+ fprintf (stderr, "%s: ", program_name);
+ vfprintf (stderr, format, args);
+ putc ('\n', stderr);
+ va_end (args);
+ }
+}
+
/* Checks whether we've had so many errors that it's time to quit
processing this syntax file. */
void
enum
{
ERR_IN_PROCEDURE = 01, /* 1=Display name of current procedure. */
- ERR_WITH_FILE = 02, /* 1=Display filename and line number. */
+ ERR_WITH_FILE = 02, /* 1=Display file name and line number. */
};
/* Describes one class of error. */
const char *banner; /* Banner. */
};
- static const struct error_class error_classes[ERR_CLASS_COUNT] =
+ static const struct error_class error_classes[MSG_CLASS_CNT] =
{
{3, &err_error_count, N_("error")}, /* SE */
{3, &err_warning_count, N_("warning")}, /* SW */
};
struct string msg;
- int class;
- /* Check verbosity level. */
- class = e->class;
- if (((class >> ERR_VERBOSITY_SHIFT) & ERR_VERBOSITY_MASK) > err_verbosity)
- return;
- class &= ERR_CLASS_MASK;
-
- assert (class >= 0 && class < ERR_CLASS_COUNT);
+ assert (e->class >= 0 && e->class < MSG_CLASS_CNT);
assert (format != NULL);
ds_init (&msg, 64);
- if (e->where.filename && (error_classes[class].flags & ERR_WITH_FILE))
+ if (e->where.file_name && (error_classes[e->class].flags & ERR_WITH_FILE))
{
- ds_printf (&msg, "%s:", e->where.filename);
+ ds_printf (&msg, "%s:", e->where.file_name);
if (e->where.line_number != -1)
ds_printf (&msg, "%d:", e->where.line_number);
ds_putc (&msg, ' ');
}
- ds_printf (&msg, "%s: ", gettext (error_classes[class].banner));
+ ds_printf (&msg, "%s: ", gettext (error_classes[e->class].banner));
{
- int *count = error_classes[class].count;
+ int *count = error_classes[e->class].count;
if (count)
(*count)++;
}
- if (command_name != NULL && (error_classes[class].flags & ERR_IN_PROCEDURE))
+ if (command_name != NULL
+ && (error_classes[e->class].flags & ERR_IN_PROCEDURE))
ds_printf (&msg, "%s: ", command_name);
if (e->title)
static inline int
char_is_break (int quote, int c)
{
- return ((quote && c == DIR_SEPARATOR)
- || (!quote && (isspace (c) || c == '-' || c == '/')));
+ return ((quote && c == '/')
+ || (!quote && (isspace (c) || c == '-' || c == '/')));
}
/* Returns 1 if C is a break character where the break should be made