Subject: bug#78885: [PATCH] maint: assume that compilers support '\a' as specified by C89

From: Collin Funk <[email-masked]>
Date: Mon, 23 Jun 2025 21:44:28 -0700

Hi,

I noticed some very old code:

    #if defined __STDC__ && __STDC__-0
               case 'a': *q++ = '\a'; p++; continue;
    #else /* Not STDC; we'll just assume ASCII */
              case 'a': *q++ = '\007'; p++; continue;
    #endif

This is from before C89 when '\a' was standardized. In sed/debug.c and
in Gnulib we already assume it is supported. So the fallback code can be
removed.

And if compilers don't support it, they most certainly have other larger
problems than this. :)

Collin

>From 8e8f528ee5142945d2206e9d17c41d3141051a01 Mon Sep 17 00:00:00 2001
Message-ID: <8e8f[email-masked]>
From: Collin Funk <[email-masked]>
Date: Mon, 23 Jun 2025 21:36:40 -0700
Subject: [PATCH] maint: assume that compilers support '\a' as specified by C89

* sed/compile.c (normalize_text): Remove backup code for pre-C89
compilers.
* sed/execute.c (do_list): Likewise.
---
 sed/compile.c | 4 ----
 sed/execute.c | 4 ----
 2 files changed, 8 deletions(-)

diff --git a/sed/compile.c b/sed/compile.c
index 46b0bed..8a43945 100644
--- a/sed/compile.c
+++ b/sed/compile.c
@@ -1329,11 +1329,7 @@ normalize_text (char *buf, idx_t len, enum text_types buftype)
       if (*p == '\\' && p+1 < bufend && bracket_state == 0)
         switch (*++p)
           {
-#if defined __STDC__ && __STDC__-0
           case 'a': *q++ = '\a'; p++; continue;
-#else /* Not STDC; we'll just assume ASCII */
-          case 'a': *q++ = '\007'; p++; continue;
-#endif
           /* case 'b': *q++ = '\b'; p++; continue; --- conflicts with \b RE */
           case 'f': *q++ = '\f'; p++; continue;
           case '\n': /*fall through */
diff --git a/sed/execute.c b/sed/execute.c
index adc7575..63c7cc5 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -936,11 +936,7 @@ do_list (intmax_t line_len)
       } else {
           *o++ = '\\';
           switch (*p) {
-#if defined __STDC__ && __STDC__-0
             case '\a': *o++ = 'a'; break;
-#else /* Not STDC; we'll just assume ASCII */
-            case 007:  *o++ = 'a'; break;
-#endif
             case '\b': *o++ = 'b'; break;
             case '\f': *o++ = 'f'; break;
             case '\n': *o++ = 'n'; break;
-- 
2.49.0