wrap gets on Windows, replacing '\r\n' with '\n'
This commit is contained in:
@@ -38,6 +38,20 @@ posix_fopen(const char *path, const char *mode)
|
||||
return fopen(path, mode);
|
||||
}
|
||||
|
||||
char *
|
||||
posix_fgets(char *s, int size, FILE *stream)
|
||||
{
|
||||
char *ret = fgets(s, size, stream);
|
||||
if (ret != NULL) {
|
||||
size_t end = strlen(ret);
|
||||
if (end >= 2 && ret[end - 2] == '\r' && ret[end - 1] == '\n') {
|
||||
ret[end - 2] = '\n';
|
||||
ret[end - 1] = '\0';
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
posix_rename(const char *oldpath, const char *newpath)
|
||||
{
|
||||
|
Reference in New Issue
Block a user