diff options
author | Brent Cook <busterb@gmail.com> | 2015-12-05 13:58:37 -0600 |
---|---|---|
committer | Brent Cook <busterb@gmail.com> | 2015-12-05 13:58:37 -0600 |
commit | 75ef5bb160fb261da1950abfd3d22f54011458e1 (patch) | |
tree | 22c96a95db483b11f4914a5ddcea72245966a0a2 /crypto | |
parent | d7317353a98930650711fa94c6110b16f191d4f2 (diff) | |
download | portable-75ef5bb160fb261da1950abfd3d22f54011458e1.tar.gz portable-75ef5bb160fb261da1950abfd3d22f54011458e1.tar.bz2 portable-75ef5bb160fb261da1950abfd3d22f54011458e1.zip |
wrap gets on Windows, replacing '\r\n' with '\n'
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/compat/posix_win.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c index 0dcc046..c6ff924 100644 --- a/crypto/compat/posix_win.c +++ b/crypto/compat/posix_win.c | |||
@@ -38,6 +38,20 @@ posix_fopen(const char *path, const char *mode) | |||
38 | return fopen(path, mode); | 38 | return fopen(path, mode); |
39 | } | 39 | } |
40 | 40 | ||
41 | char * | ||
42 | posix_fgets(char *s, int size, FILE *stream) | ||
43 | { | ||
44 | char *ret = fgets(s, size, stream); | ||
45 | if (ret != NULL) { | ||
46 | size_t end = strlen(ret); | ||
47 | if (end >= 2 && ret[end - 2] == '\r' && ret[end - 1] == '\n') { | ||
48 | ret[end - 2] = '\n'; | ||
49 | ret[end - 1] = '\0'; | ||
50 | } | ||
51 | } | ||
52 | return ret; | ||
53 | } | ||
54 | |||
41 | int | 55 | int |
42 | posix_rename(const char *oldpath, const char *newpath) | 56 | posix_rename(const char *oldpath, const char *newpath) |
43 | { | 57 | { |