1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2024-11-08 18:02:23 +05:30

freadln.c: test: support POSIX sleep

This commit is contained in:
Intel A80486DX2-66 2024-04-07 17:38:40 +03:00
parent 8f8ee0eb53
commit 60e8d00b5b
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -4,6 +4,9 @@
* The `freadln` function reads a line from STDIN into a string, allocating
* memory for it.
*
* NOTE: Test: Declare macro POSIX when compiling if you're using a POSIX
* system.
*
* TODO: Figure out potential problems
* TODO: Add 'flushing' of STDIN (while there are characters, read them) before
* the input reading loop to avoid input queues
@ -76,7 +79,11 @@ int freadln(FILE* f, char** output, size_t* length_out) {
}
#ifdef TEST
# if defined(_WIN32) || defined(WIN32)
# if POSIX
# include <unistd.h>
# define SLEEP_FN sleep
# define DO_SLEEP 1
# elif defined(_WIN32) || defined(WIN32)
# include <windows.h>
# define SLEEP_FN(x) Sleep((DWORD) x)
# define DO_SLEEP 1