Rearrange code and make a faster sha256sum program

This commit is contained in:
Justine Tunney 2022-11-02 23:12:32 -07:00
parent 5e60e5ad10
commit 89d1e5b8f2
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
32 changed files with 933 additions and 517 deletions

View file

@ -16,16 +16,17 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/errno.h"
#include "libc/stdio/stdio.h"
/**
* Returns nonzero if stream is in error state.
*
* @param f is file stream pointer
* @return non-zero if and only if it's an error state
* @return non-zero w/ errno only if `f` is in error state
* @note EOF doesn't count
* @see ferror(), feof()
*/
errno_t ferror_unlocked(FILE *f) {
return f->state > 0 ? f->state : 0;
return f->state > 0 ? (errno = f->state) : 0;
}