| From 89170435bde2d889dee8b20c74d7771e6af8f19e Mon Sep 17 00:00:00 2001 |
| From: Tim S <stahta01@users.sourceforge.net> |
| Date: Sun, 16 Sep 2018 10:35:04 -0400 |
| Subject: [PATCH] Use LF as newline in envsubst |
| |
| Now using underline prefix in functions as stated at: |
| https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmode |
| And, change mode back to prior mode |
| |
| --- |
| gettext-runtime/src/envsubst.c | 18 ++++++++++++++++++ |
| 1 file changed, 18 insertions(+) |
| |
| diff --git a/gettext-runtime/src/envsubst.c b/gettext-runtime/src/envsubst.c |
| index 941452b03..2afceb9ac 100644 |
| --- a/gettext-runtime/src/envsubst.c |
| +++ b/gettext-runtime/src/envsubst.c |
| @@ -27,6 +27,11 @@ |
| #include <string.h> |
| #include <locale.h> |
| |
| +#ifdef _WIN32 |
| +# include <io.h> /* for _setmode() */ |
| +# include <fcntl.h> |
| +#endif |
| + |
| #include "closeout.h" |
| #include "error.h" |
| #include "progname.h" |
| @@ -281,8 +286,21 @@ find_variables (const char *string, |
| static void |
| print_variable (const char *var_ptr, size_t var_len) |
| { |
| + int oldmode; |
| + |
| fwrite (var_ptr, var_len, 1, stdout); |
| +#if defined(_WIN32) |
| + /* Change to binary mode */ |
| + oldmode = _setmode( _fileno( stdout ), _O_BINARY ); |
| +#endif |
| putchar ('\n'); |
| +#if defined(_WIN32) |
| + fflush(stdout); /* Must flush before changing mode back */ |
| + if ( oldmode != -1 ) |
| + { /* Return to prior mode */ |
| + _setmode( _fileno( stdout ), oldmode ); |
| + } |
| +#endif |
| } |
| |
| /* Print the variables contained in STRING to stdout, each one followed by a |
| -- |
| 2.19.0.windows.1 |
| |