public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-4669] diagnostics: special-case -fdiagnostics-text-art-charset=ascii for LANG=C
Date: Mon, 16 Oct 2023 23:05:53 +0000 (GMT)	[thread overview]
Message-ID: <20231016230553.95925385702F@sourceware.org> (raw)

https://gcc.gnu.org/g:04013e4464020b4440aa41524a222658d7e36937

commit r14-4669-g04013e4464020b4440aa41524a222658d7e36937
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Mon Oct 16 19:04:50 2023 -0400

    diagnostics: special-case -fdiagnostics-text-art-charset=ascii for LANG=C
    
    In the LWN discussion of the "ASCII" art in GCC 14
      https://lwn.net/Articles/946733/#Comments
    there was some concern about the use of non-ASCII characters in the
    output.
    
    Currently -fdiagnostics-text-art-charset defaults to "emoji".
    To better handle older terminals by default, this patch special-cases
    LANG=C to use -fdiagnostics-text-art-charset=ascii.
    
    gcc/ChangeLog:
            * diagnostic.cc (diagnostic_initialize): When LANG=C, update
            default for -fdiagnostics-text-art-charset from emoji to ascii.
            * doc/invoke.texi (fdiagnostics-text-art-charset): Document the above.
    
    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

Diff:
---
 gcc/diagnostic.cc   | 13 +++++++++++--
 gcc/doc/invoke.texi |  3 ++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index 03637459c56c..6e46371b3b4e 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -226,8 +226,17 @@ diagnostic_initialize (diagnostic_context *context, int n_opts)
   context->includes_seen = NULL;
   context->m_client_data_hooks = NULL;
   context->m_diagrams.m_theme = NULL;
-  diagnostics_text_art_charset_init (context,
-				     DIAGNOSTICS_TEXT_ART_CHARSET_DEFAULT);
+
+  enum diagnostic_text_art_charset text_art_charset
+    = DIAGNOSTICS_TEXT_ART_CHARSET_DEFAULT;
+  if (const char *lang = getenv ("LANG"))
+    {
+      /* For LANG=C, don't assume the terminal supports anything
+	 other than ASCII.  */
+      if (!strcmp (lang, "C"))
+	text_art_charset = DIAGNOSTICS_TEXT_ART_CHARSET_ASCII;
+    }
+  diagnostics_text_art_charset_init (context, text_art_charset);
 }
 
 /* Maybe initialize the color support. We require clients to do this
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2a500c1baeea..db59d8b6d4af 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -5688,7 +5688,8 @@ value further adds the possibility of emoji in the output (such as emitting
 U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the
 emoji variant of the character).
 
-The default is @samp{emoji}.
+The default is @samp{emoji}, except when the environment variable @env{LANG}
+is set to @samp{C}, in which case the default is @samp{ascii}.
 
 @opindex fdiagnostics-format
 @item -fdiagnostics-format=@var{FORMAT}

                 reply	other threads:[~2023-10-16 23:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231016230553.95925385702F@sourceware.org \
    --to=dmalcolm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).