From 2dd9392ef91b953ad5741fa8a955cfd7694a2e05 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 20 Apr 2024 14:58:32 -0400 Subject: Fix USE_COLOR --- builtins/array.h | 4 +--- builtins/functions.c | 2 -- builtins/table.h | 7 +++---- builtins/tomo.h | 2 -- builtins/util.c | 2 ++ builtins/util.h | 3 +++ tomo.c | 2 -- 7 files changed, 9 insertions(+), 13 deletions(-) diff --git a/builtins/array.h b/builtins/array.h index 5ee115ae..a2e76f18 100644 --- a/builtins/array.h +++ b/builtins/array.h @@ -5,12 +5,10 @@ #include #include -#include "util.h" #include "datatypes.h" #include "functions.h" #include "types.h" - -extern bool USE_COLOR; +#include "util.h" // Convert negative indices to back-indexed without branching: index0 = index + (index < 0)*(len+1)) - 1 #define Array_get(item_type, arr_expr, index_expr, filename, start, end) *({ \ diff --git a/builtins/functions.c b/builtins/functions.c index a1ebc6a8..2b4d45d4 100644 --- a/builtins/functions.c +++ b/builtins/functions.c @@ -21,8 +21,6 @@ #include "types.h" #include "util.h" -extern bool USE_COLOR; - public const char *TOMO_HASH_VECTOR = "tomo hash vector ---------------------------------------------"; public void fail(CORD fmt, ...) diff --git a/builtins/table.h b/builtins/table.h index f51a8b31..5de87dc8 100644 --- a/builtins/table.h +++ b/builtins/table.h @@ -6,11 +6,10 @@ #include #include -#include "types.h" -#include "datatypes.h" #include "array.h" - -extern bool USE_COLOR; +#include "datatypes.h" +#include "types.h" +#include "util.h" #define Table(key_t, val_t, key_info, value_info, fb, def, N, ...) ({ \ struct { key_t k; val_t v; } ents[N] = {__VA_ARGS__}; \ diff --git a/builtins/tomo.h b/builtins/tomo.h index bc8523df..f0455ad1 100644 --- a/builtins/tomo.h +++ b/builtins/tomo.h @@ -29,6 +29,4 @@ #include "text.h" #include "types.h" -extern bool USE_COLOR; - // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 diff --git a/builtins/util.c b/builtins/util.c index 095d605b..f7fa9f92 100644 --- a/builtins/util.c +++ b/builtins/util.c @@ -9,6 +9,8 @@ #include "util.h" +public bool USE_COLOR; + public char *heap_strn(const char *str, size_t len) { if (!str) return NULL; diff --git a/builtins/util.h b/builtins/util.h index 79925a51..a091c40e 100644 --- a/builtins/util.h +++ b/builtins/util.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -24,6 +25,8 @@ #define public __attribute__ ((visibility ("default"))) #endif +extern bool USE_COLOR; + char *heap_strn(const char *str, size_t len); char *heap_str(const char *str); char *heap_strf(const char *fmt, ...); diff --git a/tomo.c b/tomo.c index 74b6b09e..ea399193 100644 --- a/tomo.c +++ b/tomo.c @@ -317,8 +317,6 @@ int compile_executable(const char *filename, const char *object_files, module_co "#include \n" "#include \"", filename, ".h\"\n" "\n" - "public bool USE_COLOR = true;\n" - "\n" "int main(int argc, char *argv[]) {\n" "GC_INIT();\n" "USE_COLOR = getenv(\"COLOR\") ? strcmp(getenv(\"COLOR\"), \"1\") == 0 : isatty(STDOUT_FILENO);\n" -- cgit v1.2.3