Implemented repl and stdin piping support.
h3rald h3rald@h3rald.com
Sat, 16 Nov 2024 21:33:35 +0000
1 files changed,
5 insertions(+),
4 deletions(-)
jump to
M
hex.c
→
hex.c
@@ -698,6 +698,8 @@ fclose(file);
return buffer; } +volatile sig_atomic_t keep_running = 1; + void repl() { char line[1024]; printf("hex Interactive REPL. Type 'exit' to quit or press Ctrl+C.\n");@@ -718,11 +720,10 @@ break;
} // Tokenize and process the input - tokenize_and_process(line); + process(line); } } -volatile sig_atomic_t keep_running = 1; void handle_sigint(int sig) { (void)sig; // Suppress unused warning@@ -739,7 +740,7 @@ return;
} buffer[bytesRead] = '\0'; // Null-terminate the input - tokenize_and_process(buffer); + process(buffer); } int main(int argc, char *argv[]) {@@ -754,7 +755,7 @@ if (!fileContent) {
return EXIT_FAILURE; } - tokenize_and_process(fileContent); + process(fileContent); free(fileContent); // Free the allocated memory } else if (!isatty(fileno(stdin))) { // Process piped input from stdin