From 89f4c53fba914c0b43fb208a2e9aeea381748f5c Mon Sep 17 00:00:00 2001 From: 8nl <8nlight@disroot.org> Date: Fri, 12 Jan 2024 17:14:58 +0000 Subject: [PATCH] Upload files to "/" --- cutecat.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cutecat.c b/cutecat.c index 7483a43..71bd815 100644 --- a/cutecat.c +++ b/cutecat.c @@ -30,11 +30,11 @@ void OwO(char *buf, off_t len) { } void PrintRainbow(char c, off_t i) { - int red = sin(FREQ * i) * 127 + 128; - int blue = sin(FREQ * i + 2 * M_PI / 3) * 127 + 128; - int green = sin(FREQ * i + 4 * M_PI / 3) * 127 + 128; + unsigned int red = sin(FREQ * i) * 127 + 128; + unsigned int blue = sin(FREQ * i + 2 * M_PI / 3) * 127 + 128; + unsigned int green = sin(FREQ * i + 4 * M_PI / 3) * 127 + 128; - printf("\033[38;2;%d;%d;%dm%c\033[0m", red, green, blue, c); + printf("\033[38;2;%u;%u;%um%c\033[0m", red, green, blue, c); } int cat(const char *path) { @@ -50,13 +50,17 @@ int cat(const char *path) { char buf[1025]; off_t len = 0; + off_t n_line = 0; while ((len = read(fd, buf, sizeof(buf))) > 0) { OwO(buf, len); for (off_t i = 0; i < len; i++) { + if (buf[i] == '\n') + n_line++; + if (!isspace(buf[i]) && !r_flag) - PrintRainbow(buf[i], i); + PrintRainbow(buf[i], len + n_line); else putchar(buf[i]);