void-packages/srcpkgs/gnucobol/patches/errno.patch

27 lines
937 B
Diff

# Taken from: https://git.adelielinux.org/adelie/packages/-/commit/21fe3ef399c25f030d6657e83cc635335f3a9f40
# Fixes failing test 488 for musl
diff --git a/cobc/cobc.c b/cobc/cobc.c
index b3a52303c5..f591be3a2e 100644
--- a/cobc/cobc.c
+++ b/cobc/cobc.c
@@ -2358,6 +2358,10 @@ set_listing_date (void)
DECLNORET static void COB_A_NORETURN
cobc_terminate (const char *str)
{
+ /* must be executed before anything that may adjust errno, ...
+ like the listing code below. */
+ const char *errno_str = cb_get_strerror ();
+
if (cb_src_list_file) {
set_listing_date ();
set_standard_title ();
@@ -2365,7 +2369,7 @@ cobc_terminate (const char *str)
cobc_elided_strcpy (cb_listing_filename, str, sizeof (cb_listing_filename), 0);
print_program_header ();
}
- cb_perror (0, "cobc: %s: %s", str, cb_get_strerror ());
+ cb_perror (0, "cobc: %s: %s", str, errno_str);
if (cb_src_list_file) {
print_program_trailer ();
}