Use bitfield `flags` flags in file instead of `int` variables `mode`, `error`, `eof`. And rewrite weird logic opening/close files Reviewed-on: #691 Reviewed-by: Ivan B <1+dunkaist@noreply.localhost> Reviewed-by: Kiril Lipatov <lipatov.kiril@gmail.com> Co-authored-by: Egor00f <y.yarin@inbox.ru>
15 lines
286 B
C
15 lines
286 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "_stdio.h"
|
|
|
|
FILE* freopen(const char* restrict _name, const char* restrict _mode, FILE* restrict out)
|
|
{
|
|
fclose_r(out);
|
|
|
|
if (_name == NULL) {
|
|
_name = out->name;
|
|
}
|
|
|
|
return fopen_r(_name, _mode, out);
|
|
}
|