summaryrefslogtreecommitdiff
path: root/rushs/tinyprintf/rotx
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-10-11 22:19:00 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-10-11 22:19:00 +0200
commit73c2b00a10c5786ddeeacc915e233fd4df1c9321 (patch)
treee299ea4e8ac161b2b21170172ff8f182c1c3fe1a /rushs/tinyprintf/rotx
parentc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (diff)
fix: evalexpr & tinyprintf contenaient toute la piscine
Diffstat (limited to 'rushs/tinyprintf/rotx')
-rw-r--r--rushs/tinyprintf/rotx/rotx.c59
1 files changed, 0 insertions, 59 deletions
diff --git a/rushs/tinyprintf/rotx/rotx.c b/rushs/tinyprintf/rotx/rotx.c
deleted file mode 100644
index a2cb820..0000000
--- a/rushs/tinyprintf/rotx/rotx.c
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <stdlib.h>
-#include <unistd.h>
-
-#define BUFFER_SIZE 10
-
-int main(int argc, char **argv)
-{
- if (argc != 2)
- {
- return 0;
- }
-
- int rot = atoi(argv[1]);
- int rod = rot;
- if (rot < 0)
- {
- rot = (rot % 26) + 26;
- rod = (rod % 10) + 10;
- }
-
- char buf[BUFFER_SIZE];
- ssize_t r;
-
- while ((r = read(STDIN_FILENO, buf, BUFFER_SIZE)))
- {
- if (r == -1)
- {
- return 1;
- }
-
- for (ssize_t i = 0; i < r; i++)
- {
- if (buf[i] >= 'a' && buf[i] <= 'z')
- {
- buf[i] = ((buf[i] - 'a') + rot) % 26 + 'a';
- }
- else if (buf[i] >= 'A' && buf[i] <= 'Z')
- {
- buf[i] = ((buf[i] - 'A') + rot) % 26 + 'A';
- }
- else if (buf[i] >= '0' && buf[i] <= '9')
- {
- buf[i] = ((buf[i] - '0') + rod) % 10 + '0';
- }
- }
-
- ssize_t w = write(STDOUT_FILENO, buf, r);
- while (w != r)
- {
- w += write(STDOUT_FILENO, buf, r);
- if (w == -1)
- {
- return 1;
- }
- }
- }
-
- return 0;
-}