From 91af3e14ef6304760db6e4e7a54dc217f96719f8 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 5 May 2024 19:13:24 +0530 Subject: [PATCH] Clean up code --- .gitignore | 1 + lib/base.h | 8 ++++---- test/lib/test-base.h | 6 +++--- vm/struct.c | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 0ab48f4..59e32c1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/* *.out TAGS compile_commands.json +.cache/* diff --git a/lib/base.h b/lib/base.h index 02663c2..ef79846 100644 --- a/lib/base.h +++ b/lib/base.h @@ -19,10 +19,10 @@ #define ARR_SIZE(xs) (sizeof(xs) / sizeof(xs[0])) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) > (b) ? (b) : (a)) -#define TERM_GREEN "\e[0;32m" -#define TERM_YELLOW "\e[0;33m" -#define TERM_RED "\e[0;31m" -#define TERM_RESET "\e[0;0m" +#define TERM_GREEN "\033[32m" +#define TERM_YELLOW "\033[33m" +#define TERM_RED "\033[31m" +#define TERM_RESET "\033[0m" // Flags for program behaviour (usually related to printing) #ifndef VERBOSE diff --git a/test/lib/test-base.h b/test/lib/test-base.h index 82df48d..d728229 100644 --- a/test/lib/test-base.h +++ b/test/lib/test-base.h @@ -184,7 +184,7 @@ void test_lib_base_bytes_to_hword(void) } tests[] = {{{0, 0, 0, 0}, 0}, {{0xFF, 0xFF, 0xFF, 0xFF}, HWORD_MAX}, {{1, 0, 0, 0}, 1}, - {{0, 0, 0, 0b10000000}, 1U << 31}, + {{0, 0, 0, 0x80}, 1U << 31}, {{0x89, 0xab, 0xcd, 0xef}, 0xefcdab89}}; const size_t n = size_byte_array_to_string(4); @@ -216,7 +216,7 @@ void test_lib_base_bytes_to_word(void) {{0, 0, 0, 0}, 0}, {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, WORD_MAX}, {{0x01, 0, 0, 0, 0, 0, 0, 0}, 1}, - {{0, 0, 0, 0, 0, 0, 0, 0b10000000}, 1LU << 63}, + {{0, 0, 0, 0, 0, 0, 0, 0x80}, 1LU << 63}, {{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}, 0xefcdab8967452301}}; const size_t n = size_byte_array_to_string(8); @@ -283,7 +283,7 @@ void test_lib_base_word_to_bytes(void) {0, {0, 0, 0, 0}}, {WORD_MAX, {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}}, {1, {0x01, 0, 0, 0, 0, 0, 0, 0}}, - {1LU << 63, {0, 0, 0, 0, 0, 0, 0, 0b10000000}}, + {1LU << 63, {0, 0, 0, 0, 0, 0, 0, 0x80}}, {0xefcdab8967452301, {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}}}; for (size_t i = 0; i < ARR_SIZE(tests); ++i) diff --git a/vm/struct.c b/vm/struct.c index 2a49b39..6ba429d 100644 --- a/vm/struct.c +++ b/vm/struct.c @@ -191,7 +191,7 @@ void vm_print_heap(vm_t *vm, FILE *fp) fprintf(fp, "\n"); for (size_t i = 0; i < heap.pages; ++i) { - fprintf(fp, "\t[%lu]@%p: ", i, cur); + fprintf(fp, "\t[%lu]@%p: ", i, (void *)cur); if (!cur) fprintf(fp, "\n"); else