mirror of
https://github.com/curl/curl.git
synced 2026-08-25 18:03:36 +03:00
curl_setup: Add macros for FOPEN_READTEXT, FOPEN_WRITETEXT
- Change fopen calls to use FOPEN_READTEXT instead of "r" or "rt" - Change fopen calls to use FOPEN_WRITETEXT instead of "w" or "wt" This change is to explicitly specify when we need to read/write text. Unfortunately 't' is not part of POSIX fopen so we can't specify it directly. Instead we now have FOPEN_READTEXT, FOPEN_WRITETEXT. Prior to this change we had an issue on Windows if an application that uses libcurl overrides the default file mode to binary. The default file mode in Windows is normally text mode (translation mode) and that's what libcurl expects. Bug: https://github.com/bagder/curl/pull/258#issuecomment-107093055 Reported-by: Orgad Shaneh
This commit is contained in:
parent
9f5dcab83d
commit
e8423f9ce1
10 changed files with 32 additions and 16 deletions
|
|
@ -79,7 +79,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
|
|||
/* Ok, this is somewhat hackish but we do it undocumented for now */
|
||||
config->trace_stream = config->errors; /* aka stderr */
|
||||
else {
|
||||
config->trace_stream = fopen(config->trace_dump, "w");
|
||||
config->trace_stream = fopen(config->trace_dump, FOPEN_WRITETEXT);
|
||||
config->trace_fopened = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ void dumpeasysrc(struct GlobalConfig *config)
|
|||
FILE *out;
|
||||
bool fopened = FALSE;
|
||||
if(strcmp(o, "-")) {
|
||||
out = fopen(o, "w");
|
||||
out = fopen(o, FOPEN_WRITETEXT);
|
||||
fopened = TRUE;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -681,7 +681,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||
|
||||
case 'v': /* --stderr */
|
||||
if(strcmp(nextarg, "-")) {
|
||||
FILE *newfile = fopen(nextarg, "wt");
|
||||
FILE *newfile = fopen(nextarg, FOPEN_WRITETEXT);
|
||||
if(!newfile)
|
||||
warnf(global, "Failed to open %s!\n", nextarg);
|
||||
else {
|
||||
|
|
@ -1748,7 +1748,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||
}
|
||||
else {
|
||||
fname = nextarg;
|
||||
file = fopen(nextarg, "r");
|
||||
file = fopen(nextarg, FOPEN_READTEXT);
|
||||
}
|
||||
err = file2string(&config->writeout, file);
|
||||
if(file && (file != stdin))
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
|
|||
/* Check if the file exists - if not, try CURLRC in the same
|
||||
* directory as our executable
|
||||
*/
|
||||
file = fopen(filebuffer, "r");
|
||||
file = fopen(filebuffer, FOPEN_READTEXT);
|
||||
if(file != NULL) {
|
||||
fclose(file);
|
||||
filename = filebuffer;
|
||||
|
|
@ -115,7 +115,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
|
|||
}
|
||||
|
||||
if(strcmp(filename, "-"))
|
||||
file = fopen(filename, "r");
|
||||
file = fopen(filename, FOPEN_READTEXT);
|
||||
else
|
||||
file = stdin;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue