Avoid end-of-lines problem in generated shell scripts on Cygwin.
diff --git a/ChangeLog b/ChangeLog
index 98b2a58..2117753 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-11-26  Bruno Haible  <bruno@clisp.org>
+
+	Avoid end-of-lines problem in generated shell scripts on Cygwin.
+	Patch by Feiyun Wang <feiyunw@yahoo.com>.
+	* lib/genaliases.c (main): Create canonical.sh and canonical_local.sh
+	with Unix end-of-line characters, regardless of Cygwin choice of
+	text mode vs. binary mode.
+
 2017-07-15  Bruno Haible  <bruno@clisp.org>
 
 	Allow building statically linked binaries, through LDFLAGS="-static".
diff --git a/lib/genaliases.c b/lib/genaliases.c
index 0efdbb0..b37fd0f 100644
--- a/lib/genaliases.c
+++ b/lib/genaliases.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2001, 2003, 2005, 2008, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2001, 2003, 2005, 2008, 2012, 2017 Free Software Foundation, Inc.
    This file is part of the GNU LIBICONV Library.
 
    The GNU LIBICONV Library is free software; you can redistribute it
@@ -98,7 +98,7 @@
 #define BRACIFY(...) { __VA_ARGS__ }
 #define DEFALIAS(xxx_alias,xxx) emit_alias(aliases_file,xxx_alias,#xxx);
 
-  canonical_sh_file = fopen(canonical_sh_file_name, "w");
+  canonical_sh_file = fopen(canonical_sh_file_name, "wb");
   if (canonical_sh_file == NULL) {
     fprintf(stderr, "Could not open '%s' for writing\n", canonical_sh_file_name);
     exit(1);
@@ -107,7 +107,7 @@
   if (ferror(canonical_sh_file) || fclose(canonical_sh_file))
     exit(1);
 
-  canonical_sh_file = fopen(canonical_local_sh_file_name, "w");
+  canonical_sh_file = fopen(canonical_local_sh_file_name, "wb");
   if (canonical_sh_file == NULL) {
     fprintf(stderr, "Could not open '%s' for writing\n", canonical_local_sh_file_name);
     exit(1);