mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
diagnostics: use gnulib's libtextstyle-optional
Bruno Haible just added a default implementation of libtextstyle's interface when the library is not available. https://lists.gnu.org/archive/html/bison-patches/2019-03/msg00025.html * gnulib: Update. * bootstrap.conf: Replace libtextstyle with libtextstyle-optional. * src/complain.c, src/getargs.c: Remove now useless cpp guards.
This commit is contained in:
28
NEWS
28
NEWS
@@ -10,6 +10,34 @@ GNU Bison NEWS
|
||||
|
||||
** New features
|
||||
|
||||
*** Colored diagnostics
|
||||
|
||||
As an experimental feature, Bison now generates colored diagnostics,
|
||||
controlled by the new options --color and --style.
|
||||
|
||||
Install the libtextstyle library before configuring Bison to use them.
|
||||
It is available from
|
||||
|
||||
https://alpha.gnu.org/gnu/gettext/
|
||||
|
||||
for instance
|
||||
|
||||
https://alpha.gnu.org/gnu/gettext/libtextstyle-0.7.tar.gz
|
||||
|
||||
The option --color supports the following arguments:
|
||||
- always, yes: Enable colors.
|
||||
- never, no: Disable colors.
|
||||
- auto, tty (default): Enable colors if the output device is a tty.
|
||||
|
||||
To customize the styles, create a CSS file similar to
|
||||
|
||||
/* black-and-white.css */
|
||||
.warning { }
|
||||
.error { font-weight: 800; text-decoration: underline; }
|
||||
.note { }
|
||||
|
||||
then invoke bison with --style=black-and-white.css.
|
||||
|
||||
*** Disabling output
|
||||
|
||||
When given -fsyntax-only, the diagnostics are reported, but no output is
|
||||
|
||||
@@ -28,7 +28,7 @@ gnulib_modules='
|
||||
gpl-3.0 hash inttypes isnan javacomp-script
|
||||
javaexec-script
|
||||
ldexpl
|
||||
libtextstyle
|
||||
libtextstyle-optional
|
||||
malloc-gnu
|
||||
mbswidth
|
||||
non-recursive-gnulib-prefix-hack
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
.warning { color : purple; }
|
||||
.error { color : red; }
|
||||
.note { color : cyan; }
|
||||
/* CSS style for Bison's diagnostics.
|
||||
|
||||
This is an experimental feature. The class names may change in the
|
||||
future. */
|
||||
|
||||
.warning { color: purple; }
|
||||
.error { color: red; }
|
||||
.note { color: cyan; }
|
||||
|
||||
2
gnulib
2
gnulib
Submodule gnulib updated: 9a943f6948...0d8714b7ce
2
lib/.gitignore
vendored
2
lib/.gitignore
vendored
@@ -319,3 +319,5 @@
|
||||
/rmdir.c
|
||||
/same-inode.h
|
||||
/assure.h
|
||||
/fsync.c
|
||||
/textstyle.in.h
|
||||
|
||||
46
m4/.gitignore
vendored
46
m4/.gitignore
vendored
@@ -5,6 +5,8 @@
|
||||
/asm-underscore.m4
|
||||
/assert.m4
|
||||
/calloc.m4
|
||||
/canonicalize.m4
|
||||
/clock_time.m4
|
||||
/close-stream.m4
|
||||
/close.m4
|
||||
/closeout.m4
|
||||
@@ -36,19 +38,26 @@
|
||||
/frexpl.m4
|
||||
/fseterr.m4
|
||||
/fstat.m4
|
||||
/fsync.m4
|
||||
/getdtablesize.m4
|
||||
/gethrxtime.m4
|
||||
/getopt.m4
|
||||
/getprogname.m4
|
||||
/getrusage.m4
|
||||
/gettext.m4
|
||||
/gettime.m4
|
||||
/gettimeofday.m4
|
||||
/glibc2.m4
|
||||
/glibc21.m4
|
||||
/gnulib-cache.m4
|
||||
/gnulib-common.m4
|
||||
/gnulib-comp.m4
|
||||
/gnulib-tool.m4
|
||||
/host-cpu-c-abi.m4
|
||||
/iconv.m4
|
||||
/include_next.m4
|
||||
/intdiv0.m4
|
||||
/intl-thread-locale.m4
|
||||
/intl.m4
|
||||
/intldir.m4
|
||||
/intlmacosx.m4
|
||||
@@ -70,12 +79,15 @@
|
||||
/lib-ld.m4
|
||||
/lib-link.m4
|
||||
/lib-prefix.m4
|
||||
/libtextstyle-optional.m4
|
||||
/libtextstyle.m4
|
||||
/libunistring-base.m4
|
||||
/limits-h.m4
|
||||
/localcharset.m4
|
||||
/locale-fr.m4
|
||||
/locale-ja.m4
|
||||
/locale-zh.m4
|
||||
/localtime-buffer.m4
|
||||
/lock.m4
|
||||
/longlong.m4
|
||||
/lstat.m4
|
||||
@@ -117,9 +129,15 @@
|
||||
/quotearg.m4
|
||||
/raise.m4
|
||||
/rawmemchr.m4
|
||||
/readlink.m4
|
||||
/realloc.m4
|
||||
/relocatable-lib.m4
|
||||
/relocatable.m4
|
||||
/rename.m4
|
||||
/rmdir.m4
|
||||
/sched_h.m4
|
||||
/setenv.m4
|
||||
/sh-filename.m4
|
||||
/sig_atomic_t.m4
|
||||
/sigaction.m4
|
||||
/signal_h.m4
|
||||
@@ -132,7 +150,9 @@
|
||||
/spawn_h.m4
|
||||
/sprintf-posix.m4
|
||||
/ssize_t.m4
|
||||
/stat-time.m4
|
||||
/stat.m4
|
||||
/std-gnu11.m4
|
||||
/stdbool.m4
|
||||
/stddef_h.m4
|
||||
/stdint.m4
|
||||
@@ -148,12 +168,16 @@
|
||||
/strndup.m4
|
||||
/strnlen.m4
|
||||
/strverscmp.m4
|
||||
/sys_resource_h.m4
|
||||
/sys_socket_h.m4
|
||||
/sys_stat_h.m4
|
||||
/sys_time_h.m4
|
||||
/sys_times_h.m4
|
||||
/sys_types_h.m4
|
||||
/sys_wait_h.m4
|
||||
/threadlib.m4
|
||||
/time_h.m4
|
||||
/timespec.m4
|
||||
/uintmax_t.m4
|
||||
/unistd-safer.m4
|
||||
/unistd_h.m4
|
||||
@@ -177,25 +201,3 @@
|
||||
/xalloc.m4
|
||||
/xsize.m4
|
||||
/xstrndup.m4
|
||||
/host-cpu-c-abi.m4
|
||||
/stat-time.m4
|
||||
/sys_time_h.m4
|
||||
/sys_times_h.m4
|
||||
/sh-filename.m4
|
||||
/clock_time.m4
|
||||
/gethrxtime.m4
|
||||
/getrusage.m4
|
||||
/gettime.m4
|
||||
/gettimeofday.m4
|
||||
/localtime-buffer.m4
|
||||
/sys_resource_h.m4
|
||||
/timespec.m4
|
||||
/intl-thread-locale.m4
|
||||
/canonicalize.m4
|
||||
/readlink.m4
|
||||
/relocatable-lib.m4
|
||||
/relocatable.m4
|
||||
/libtextstyle.m4
|
||||
/rename.m4
|
||||
/rmdir.m4
|
||||
/std-gnu11.m4
|
||||
|
||||
@@ -23,13 +23,10 @@
|
||||
#include "system.h"
|
||||
|
||||
#include <argmatch.h>
|
||||
#include <stdarg.h>
|
||||
#include <progname.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if HAVE_LIBTEXTSTYLE
|
||||
# include <textstyle.h>
|
||||
#endif
|
||||
#include <textstyle.h>
|
||||
|
||||
#include "complain.h"
|
||||
#include "files.h"
|
||||
@@ -68,41 +65,33 @@ static severity warnings_flag[warnings_size];
|
||||
|
||||
static unsigned *indent_ptr = NULL;
|
||||
|
||||
#if HAVE_LIBTEXTSTYLE
|
||||
styled_ostream_t errstream = NULL;
|
||||
#endif
|
||||
|
||||
void
|
||||
begin_use_class (const char *s _GL_UNUSED, FILE *out _GL_UNUSED)
|
||||
begin_use_class (const char *s, FILE *out)
|
||||
{
|
||||
#if HAVE_LIBTEXTSTYLE
|
||||
if (out == stderr)
|
||||
{
|
||||
styled_ostream_begin_use_class (errstream, s);
|
||||
styled_ostream_flush_to_current_style (errstream);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
end_use_class (const char *s _GL_UNUSED, FILE *out _GL_UNUSED)
|
||||
end_use_class (const char *s, FILE *out)
|
||||
{
|
||||
#if HAVE_LIBTEXTSTYLE
|
||||
if (out == stderr)
|
||||
{
|
||||
styled_ostream_end_use_class (errstream, s);
|
||||
styled_ostream_flush_to_current_style (errstream);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
flush (FILE *out _GL_UNUSED)
|
||||
flush (FILE *out)
|
||||
{
|
||||
#if HAVE_LIBTEXTSTYLE
|
||||
if (out == stderr)
|
||||
ostream_flush (errstream, FLUSH_THIS_STREAM);
|
||||
#endif
|
||||
fflush (out);
|
||||
}
|
||||
|
||||
@@ -267,10 +256,11 @@ complain_init_color (void)
|
||||
else
|
||||
/* No styling. */
|
||||
style_file_name = NULL;
|
||||
#endif
|
||||
|
||||
errstream =
|
||||
styled_ostream_create (STDERR_FILENO, "(stderr)", TTYCTL_AUTO,
|
||||
style_file_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -30,10 +30,7 @@
|
||||
#include <getopt.h>
|
||||
#include <progname.h>
|
||||
#include <quote.h>
|
||||
|
||||
#if HAVE_LIBTEXTSTYLE
|
||||
# include <textstyle.h>
|
||||
#endif
|
||||
#include <textstyle.h>
|
||||
|
||||
#include "complain.h"
|
||||
#include "files.h"
|
||||
@@ -590,7 +587,6 @@ command_line_location (void)
|
||||
static void
|
||||
getargs_colors (int argc _GL_UNUSED, char *argv[] _GL_UNUSED)
|
||||
{
|
||||
#if HAVE_LIBTEXTSTYLE
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
const char *arg = argv[i];
|
||||
@@ -600,7 +596,6 @@ getargs_colors (int argc _GL_UNUSED, char *argv[] _GL_UNUSED)
|
||||
handle_style_option (arg + strlen ("--style="));
|
||||
}
|
||||
complain_init_color ();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user