summaryrefslogtreecommitdiff
path: root/lib/curl_setup.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/curl_setup.h')
-rw-r--r--lib/curl_setup.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/curl_setup.h b/lib/curl_setup.h
index 9c7cc07eb..cbec34f26 100644
--- a/lib/curl_setup.h
+++ b/lib/curl_setup.h
@@ -707,4 +707,24 @@ int netware_init(void);
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
+/* In Windows the default file mode is text but an application can override it.
+Therefore we specify it explicitly. https://github.com/bagder/curl/pull/258
+*/
+#if defined(WIN32)
+#define FOPEN_READTEXT "rt"
+#define FOPEN_WRITETEXT "wt"
+#elif defined(__CYGWIN__)
+/* Cygwin has specific behavior we need to address when WIN32 is not defined.
+https://cygwin.com/cygwin-ug-net/using-textbinary.html
+For write we want our output to have line endings of LF and be compatible with
+other Cygwin utilities. For read we want to handle input that may have line
+endings either CRLF or LF so 't' is appropriate.
+*/
+#define FOPEN_READTEXT "rt"
+#define FOPEN_WRITETEXT "w"
+#else
+#define FOPEN_READTEXT "r"
+#define FOPEN_WRITETEXT "w"
+#endif
+
#endif /* HEADER_CURL_SETUP_H */