]> git.ipfire.org Git - thirdparty/gcc.git/commit
pretty-print: support URL escape sequences (PR 87488)
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Oct 2019 16:57:30 +0000 (16:57 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Oct 2019 16:57:30 +0000 (16:57 +0000)
commit4f99d8385c5d0370a6c6b12035d887e1a9666285
tree2e7dd9497cc9cb72adfaa573f0772f25b9e0b92a
parentbddff888c8225c059ebeca938c5daf28ccfcca3c
pretty-print: support URL escape sequences (PR 87488)

https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
describes an emerging standard for embedding URLs in escape sequences
for marking up text output.  This is supported e.g. by recent releases
of GNOME Terminal.

This patch adds support to our pretty-printing framework for emitting
URLs.

A followup patch uses this to add URLs to the pertinent documentation
for the output of -fdiagnostics-show-option.

gcc/ChangeLog:
PR 87488
* common.opt (fdiagnostics-urls=): New option.
(diagnostic-url.h): Add SourceInclude.
(diagnostic_url_rule): New enum.
* diagnostic-color.c: Include "diagnostic-url.h".
(diagnostic_urls_enabled_p): New function.
* diagnostic-url.h: New file.
* diagnostic.c: Include "diagnostic-url.h".
(diagnostic_urls_init): New function.
* diagnostic.h (diagnostic_urls_init): New decl.
* doc/invoke.texi (Diagnostic Message Formatting Options): Add
-fdiagnostics-urls to the list.
(-fdiagnostics-urls): New option.
* gcc.c (driver_handle_option): Handle OPT_fdiagnostics_urls_.
(driver::global_initializations): Call diagnostic_urls_init.
* opts-global.c (init_options_once): Likewise.
* opts.c (common_handle_option): Handle OPT_fdiagnostics_urls_.
* pretty-print.c (pretty_printer::pretty_printer): Initialize
show_urls.
(pp_begin_url): New function.
(pp_end_url): New function.
(selftest::test_urls): New selftest.
(selftest::pretty_print_c_tests): Call it.
* pretty-print.h (pretty_printer::show_urls): New field.
(pp_begin_url): New decl.
(pp_end_url): New decl.

gcc/testsuite/ChangeLog:
PR 87488
* lib/prune.exp (TEST_ALWAYS_FLAGS): Add -fdiagnostics-urls=never.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@276841 138bc75d-0d04-0410-961f-82ee72b054a4
14 files changed:
gcc/ChangeLog
gcc/common.opt
gcc/diagnostic-color.c
gcc/diagnostic-url.h [new file with mode: 0644]
gcc/diagnostic.c
gcc/diagnostic.h
gcc/doc/invoke.texi
gcc/gcc.c
gcc/opts-global.c
gcc/opts.c
gcc/pretty-print.c
gcc/pretty-print.h
gcc/testsuite/ChangeLog
gcc/testsuite/lib/prune.exp