https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87488

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #13 from Tobias Burnus <burnus at gcc dot gnu.org> ---
While this works with xterm (ignored) and gnome-terminal (shows hyperlink), 
but using KDE Konsole, the warnings now have:

   warning: control reaches end of non-void function [\-Wreturn-type\]

That is: There are spurious \ in the output. Looking at the output of
Coreutil's 'ls --hyperlink', they use  \a  instead of  \033\

I don't know whether there is a downside, but it seems to work fine.

The quoted reference (second link below or comment above pp_begin_url) states:
   >  OSC 8 ; params ; URI ST
at the beginning and
   > OSC 8 ; ; ST
but not stating what ST exactly is.

Cross references:

* Coreutils: https://bugzilla.gnome.org/show_bug.cgi?id=779734 – they use '\a'
from the beginning w/o discussion
* https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda - this web
page suggests \033\
* KDE Konsole - no intention to implement it, cf.
  https://bugs.kde.org/show_bug.cgi?id=379294


Assuming there is no (known) downside, I suggest to apply the patch:

diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index c57a3dbd887..032baad0146 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -2052,7 +2052,7 @@ void
 pp_begin_url (pretty_printer *pp, const char *url)
 {
   if (pp->show_urls)
-    pp_printf (pp, "\33]8;;%s\33\\", url);
+    pp_printf (pp, "\33]8;;%s\a", url);
 }

 /* If URL-printing is enabled, write a "close URL" escape sequence to PP.  */
@@ -2061,7 +2061,7 @@ void
 pp_end_url (pretty_printer *pp)
 {
   if (pp->show_urls)
-    pp_string (pp, "\33]8;;\33\\");
+    pp_string (pp, "\33]8;;\a");
 }

 #if CHECKING_P
@@ -2369,7 +2369,7 @@ test_urls ()
     pp_begin_url (&pp, "http://example.com";);
     pp_string (&pp, "This is a link");
     pp_end_url (&pp);
-    ASSERT_STREQ ("\33]8;;http://example.com\33\\This is a link\33]8;;\33\\",
+    ASSERT_STREQ ("\33]8;;http://example.com\aThis is a link\33]8;;\a",
                  pp_formatted_text (&pp));
   }
 }

Reply via email to