Hi Bruno, > Le 22 mars 2019 à 20:19, Akim Demaille <[email protected]> a écrit : > > Hi Bruno, > > I missed your message, sorry! > >> Le 20 mars 2019 à 02:25, Bruno Haible <[email protected]> a écrit : >> >>> I have checked that the file you sent was sufficient to cover >>> Bison's needs, and it's almost perfect: >> >> Thanks, I have added it as a module to gnulib.
Here's the update I installed in Bison. commit 4d34b06fb3a38eb050439084476a6b3e292c5680 Author: Akim Demaille <[email protected]> Date: Sun Mar 17 19:40:08 2019 +0100 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. diff --git a/NEWS b/NEWS index f41a5931..8a423fdf 100644 --- a/NEWS +++ b/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 diff --git a/bootstrap.conf b/bootstrap.conf index f8fb1a11..c32acb59 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -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 diff --git a/data/diagnostics.css b/data/diagnostics.css index 5a9da591..515802ec 100644 --- a/data/diagnostics.css +++ b/data/diagnostics.css @@ -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; } diff --git a/gnulib b/gnulib index 9a943f69..0d8714b7 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 9a943f69480d97e805b3ea419c69ea54615d19e4 +Subproject commit 0d8714b7ced8e0e524014c57eb884a170d62cf43 diff --git a/lib/.gitignore b/lib/.gitignore index b6fc6fe8..344caefd 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -319,3 +319,5 @@ /rmdir.c /same-inode.h /assure.h +/fsync.c +/textstyle.in.h diff --git a/m4/.gitignore b/m4/.gitignore index f8c49fc6..dc2901fa 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -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 diff --git a/src/complain.c b/src/complain.c index 70ff4204..b0daa4a9 100644 --- a/src/complain.c +++ b/src/complain.c @@ -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 diff --git a/src/getargs.c b/src/getargs.c index 3e28d1cf..4f8153a3 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -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 }
