Fixed a major issue in the stergios.c where LIMIT was int32_t instead of int128_t and also implented a version where a user can run the stergios step counter from a file (example format being in the example file).

This commit is contained in:
metallaxis committed 2026-06-28 00:03:49 +03:00
1 parent 9d7b7016d2
commit 7decb09e2f
31 files changed
+65368 -15

No files matched your search

+43 -2
View File
@@ -1,7 +1,48 @@
#include "io.h"
#include <stdio.h>
#include <stdlib.h>
bool read_line(FILE* stream, char** msgptr, size_t* n) {
if (msgptr == NULL || n == NULL) return 1;
if (*msgptr == NULL) {
*n = 128;
*msgptr = malloc(*n);
if (*msgptr == NULL) return 1;
}
while (1) {
size_t pos = 0;
int32_t c;
while ((c = fgetc(stream)) != EOF) {
/* If the string dosent fit, double the size */
if (pos + 1 >= *n) {
size_t new_size = *n * 2;
char* new_ptr = realloc(*msgptr, new_size);
if (new_ptr == NULL) return 1;
*msgptr = new_ptr;
*n = new_size;
}
if (c == '\n' || c == '#') {
/* Skip the info after comments */
if (c == '#') {
/* Read and discard the rest of the line until a newline or EOF */
while ((c = fgetc(stream)) != EOF && c != '\n');
}
break; /* Stop reading for this line. */
}
(*msgptr)[pos++] = (char)c; /* Add the corresponding characters */
}
if (pos == 0) {
if (c == EOF) return 1;
else continue;
}
(*msgptr)[pos] = '\0'; /* Add null byte */
return 0;
}
}
int read_int128_triplet(const char* prompt, int128_t* a, int128_t* b, int128_t* c) {
char sa[256], sb[256], sc[256];