Skip to content

Commit 41e0bd4

Browse files
committed
On z/OS, allow charset tagging of temporary shell scripts.
Reported by Mike Fulton <mikefultonpersonal@gmail.com> in <https://lists.gnu.org/archive/html/bug-gnu-libiconv/2023-05/msg00002.html>. * lib/genaliases.c (BINARY_MODE): New macro. (main): Use it instead of "b".
1 parent af375a3 commit 41e0bd4

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2023-05-17 Bruno Haible <bruno@clisp.org>
2+
3+
On z/OS, allow charset tagging of temporary shell scripts.
4+
Reported by Mike Fulton <mikefultonpersonal@gmail.com> in
5+
<https://lists.gnu.org/archive/html/bug-gnu-libiconv/2023-05/msg00002.html>.
6+
* lib/genaliases.c (BINARY_MODE): New macro.
7+
(main): Use it instead of "b".
8+
19
2023-05-12 Bruno Haible <bruno@clisp.org>
210

311
Integrate the last change.

lib/genaliases.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 1999-2001, 2003, 2005, 2008, 2012, 2017 Free Software Foundation, Inc.
1+
/* Copyright (C) 1999-2001, 2003, 2005, 2008, 2012, 2017, 2023 Free Software Foundation, Inc.
22
This file is part of the GNU LIBICONV Library.
33
44
The GNU LIBICONV Library is free software; you can redistribute it
@@ -20,6 +20,16 @@
2020
#include <stdio.h>
2121
#include <stdlib.h>
2222

23+
/* When we create shell scripts, we need to make sure that on Cygwin they have
24+
Unix end-of-line characters, regardless of Cygwin choice of text mode vs.
25+
binary mode. On z/OS, however, binary mode turns off charset tagging for
26+
output files, which is not what we want. */
27+
#if defined __MVS__
28+
# define BINARY_MODE ""
29+
#else
30+
# define BINARY_MODE "b"
31+
#endif
32+
2333
static void emit_alias (FILE* out1, const char* alias, const char* c_name)
2434
{
2535
/* Output alias in upper case. */
@@ -98,7 +108,7 @@ int main (int argc, char* argv[])
98108
#define BRACIFY(...) { __VA_ARGS__ }
99109
#define DEFALIAS(xxx_alias,xxx) emit_alias(aliases_file,xxx_alias,#xxx);
100110

101-
canonical_sh_file = fopen(canonical_sh_file_name, "wb");
111+
canonical_sh_file = fopen(canonical_sh_file_name, "w" BINARY_MODE);
102112
if (canonical_sh_file == NULL) {
103113
fprintf(stderr, "Could not open '%s' for writing\n", canonical_sh_file_name);
104114
exit(1);
@@ -107,7 +117,7 @@ int main (int argc, char* argv[])
107117
if (ferror(canonical_sh_file) || fclose(canonical_sh_file))
108118
exit(1);
109119

110-
canonical_sh_file = fopen(canonical_local_sh_file_name, "wb");
120+
canonical_sh_file = fopen(canonical_local_sh_file_name, "w" BINARY_MODE);
111121
if (canonical_sh_file == NULL) {
112122
fprintf(stderr, "Could not open '%s' for writing\n", canonical_local_sh_file_name);
113123
exit(1);

0 commit comments

Comments
 (0)