diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a4edcb..56c2ff9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,9 +8,9 @@ if (NOT MAN_OUTPUT_PATH) endif() # set some options -#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -g -std=c99 -Wno-unused-result") +#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -g -std=c11 -Wno-unused-result") #set(CMAKE_BUILD_TYPE Debug) -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wall -Wextra -Os -std=c99 -Wno-unused-result") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wall -Wextra -Os -std=c11 -Wno-unused-result") set(CMAKE_BUILD_TYPE Release) set(SRC ${PROJECT_SOURCE_DIR}/src) diff --git a/src/catimg.c b/src/catimg.c index 151a616..185e3d1 100644 --- a/src/catimg.c +++ b/src/catimg.c @@ -3,7 +3,7 @@ #include #include "sh_image.h" #include "sh_utils.h" -#include +#include #include #define USAGE "Usage: catimg [-hct] [-w width] [-l loops] [-r resolution] image-file\n\n" \ @@ -58,6 +58,14 @@ char supportsUTF8() { || (LC_CTYPE && strstr(LC_CTYPE, UTF)); } +// sleep for at least delay / 100 seconds +void mysleep(const uint16_t delay) { + struct timespec time; + time.tv_sec = delay / 100; + time.tv_nsec = (delay - 100 * (time.tv_sec)) * 10000; + while (nanosleep(&time, &time)); +} + int main(int argc, char *argv[]) { init_hash_colors(); @@ -140,9 +148,9 @@ int main(int argc, char *argv[]) for (uint32_t frame = 0; frame < img.frames; frame++) { if (frame > 0 || loop > 0) { if (frame > 0) - usleep(img.delays[frame - 1] * 10000); + mysleep(img.delays[frame - 1]); else - usleep(img.delays[img.frames - 1] * 10000); + mysleep(img.delays[img.frames - 1]); printf("\e[u"); } uint32_t index, x, y;