Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save matthewyang204/a86bb42070041f62d6338237346bac07 to your computer and use it in GitHub Desktop.

Select an option

Save matthewyang204/a86bb42070041f62d6338237346bac07 to your computer and use it in GitHub Desktop.
Patch sed 4.9 to build cleanly and correctly with gcc 4.2
From 08e7901611a781cd33aa62cab680d41f2b718222 Mon Sep 17 00:00:00 2001
From: Matthew Yang <[email protected]>
Date: Thu, 4 Dec 2025 16:17:59 -0800
Subject: [PATCH] Patch unneeded #pragma GCC diagnostics
---
sed/compile.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sed/compile.c b/sed/compile.c
index f96fbca..2378ea2 100644
--- a/sed/compile.c
+++ b/sed/compile.c
@@ -203,10 +203,10 @@ bad_command (char ch)
{
const char *msg = _(UNKNOWN_CMD);
char *unknown_cmd = xmalloc (strlen (msg));
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+// #pragma GCC diagnostic push
+// #pragma GCC diagnostic ignored "-Wformat-nonliteral"
sprintf (unknown_cmd, msg, ch);
-#pragma GCC diagnostic pop
+// #pragma GCC diagnostic pop
bad_prog (unknown_cmd);
}
--
2.50.1

This patch makes sed 4.9 build correctly without encountering errors regarding #pragma GCC diagnostic related errors in functions. Since GCC 4.2 does not support diagnostics, and these are useless and only for supressing warnings, this patch comments out the unneeded lines containing these. These patches should satisfy the needs of most people using GCC 4.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment