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
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+
2333static 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