diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | builtins/array.h | 2 | ||||
| -rw-r--r-- | builtins/color.c | 17 | ||||
| -rw-r--r-- | builtins/color.h | 11 | ||||
| -rw-r--r-- | builtins/table.h | 2 | ||||
| -rw-r--r-- | builtins/tomo.h | 1 | ||||
| -rw-r--r-- | tomo.c | 6 |
7 files changed, 9 insertions, 32 deletions
@@ -24,7 +24,7 @@ G=-ggdb O=-Og CFLAGS=$(CCONFIG) $(EXTRA) $(CWARN) $(G) $(O) $(OSFLAGS) LDLIBS=-lgc -lcord -lm -lunistring -ldl -L. -ltomo -BUILTIN_OBJS=builtins/array.o builtins/bool.o builtins/color.o builtins/nums.o builtins/functions.o builtins/integers.o \ +BUILTIN_OBJS=builtins/array.o builtins/bool.o builtins/nums.o builtins/functions.o builtins/integers.o \ builtins/pointer.o builtins/memory.o builtins/text.o builtins/table.o builtins/types.o builtins/util.o builtins/files.o all: libtomo.so tomo diff --git a/builtins/array.h b/builtins/array.h index a2c100d5..5ee115ae 100644 --- a/builtins/array.h +++ b/builtins/array.h @@ -10,6 +10,8 @@ #include "functions.h" #include "types.h" +extern bool USE_COLOR; + // 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) *({ \ const array_t arr = arr_expr; int64_t index = (int64_t)(index_expr); \ diff --git a/builtins/color.c b/builtins/color.c deleted file mode 100644 index d79aa9ef..00000000 --- a/builtins/color.c +++ /dev/null @@ -1,17 +0,0 @@ -// Logic for detecting whether console color should be used -#include <stdbool.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "util.h" -#include "color.h" - -public bool USE_COLOR = true; - -public void detect_color(void) -{ - USE_COLOR = getenv("COLOR") ? strcmp(getenv("COLOR"), "1") == 0 : isatty(STDOUT_FILENO); -} - -// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 diff --git a/builtins/color.h b/builtins/color.h deleted file mode 100644 index 26e912d8..00000000 --- a/builtins/color.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -// Logic for console color usage - -#include <stdbool.h> - -extern bool USE_COLOR; - -void detect_color(void); - -// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 diff --git a/builtins/table.h b/builtins/table.h index 0d7af587..f51a8b31 100644 --- a/builtins/table.h +++ b/builtins/table.h @@ -10,6 +10,8 @@ #include "datatypes.h" #include "array.h" +extern bool USE_COLOR; + #define Table(key_t, val_t, key_info, value_info, fb, def, N, ...) ({ \ struct { key_t k; val_t v; } ents[N] = {__VA_ARGS__}; \ table_t table = Table$from_entries((array_t){ \ diff --git a/builtins/tomo.h b/builtins/tomo.h index 03817e0f..f0455ad1 100644 --- a/builtins/tomo.h +++ b/builtins/tomo.h @@ -17,7 +17,6 @@ #include "array.h" #include "bool.h" -#include "color.h" #include "datatypes.h" #include "functions.h" #include "halfsiphash.h" @@ -316,11 +316,13 @@ int compile_executable(const char *filename, const char *object_files) "#include <tomo/tomo.h>\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" "srand(arc4random_uniform(UINT32_MAX));\n" - "srand48(arc4random_uniform(UINT32_MAX));\n" - "detect_color();\n", + "srand48(arc4random_uniform(UINT32_MAX));\n", module_name, "$main$run(argc, argv);\n", "return 0;\n" "}\n" |
