From 58f73bc0f85cce878370e9f3a14360b871d8f9dd Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 21 Jul 2021 19:49:29 +0100 Subject: [PATCH] Simpler SIMPLE_ERRORS and new LOW_MEM FORCE_TEXT --- src/calc.c | 8 +++++++- src/object.c | 15 +++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/calc.c b/src/calc.c index 28be130..cd4a741 100644 --- a/src/calc.c +++ b/src/calc.c @@ -257,10 +257,16 @@ static void code_click_subscribe(void *context) window_single_click_subscribe(BUTTON_ID_BACK, click_backspace); } +#ifdef LOW_MEM + #define DISPLAY_LINE " (hrt) \":\" (mnt))\n" +#else + #define DISPLAY_LINE " (hrt) \":\" (if (> 10 (mnt)) \"0\" \"\") (mnt))\n" +#endif + #define FORCE_TEXT \ "(def time (fn () (utl tt \n"\ " (cat \"Hey, it's \" \n"\ - " (hrt) \":\" (mnt))\n"\ + DISPLAY_LINE \ ")))\n" \ "(def ww (cw))\n" \ "(def tt (atl ww \":\"))\n" \ diff --git a/src/object.c b/src/object.c index 4f9cc67..45aa9d3 100644 --- a/src/object.c +++ b/src/object.c @@ -195,6 +195,7 @@ void nf_addToList(Object *dest, const Object src) allocObject(&tail(dest)->forward, src); } +#ifndef SIMPLE_ERRORS static const char *errorText[] = { "MISMATCHED_PARENS", "BAD_LIST_OF_SYMBOL_STRINGS", @@ -219,17 +220,7 @@ static const char *errorText[] = { "NO_CLONE_SPECIFIED", "CAN_ONLY_EVAL_STRINGS" }; - -/** - * Prints out the error of a given error Object - * Doesn't print anything if `obj` is NULL or not an error type - * @param obj A pointer to the Object to print - */ -void printErr(const Object *obj) -{ - if(!obj || obj->type != TYPE_ERROR) - return; -} +#endif /** * Creates a string from a given list Object @@ -294,7 +285,7 @@ char* stringNObj(char *dest, const Object *obj, const size_t len) { case TYPE_ERROR: { int code = getErrorCode(*obj); #ifdef SIMPLE_ERRORS - snprintf(dest, len, "%s", errorText[code]); + snprintf(dest, len, "E[%d]", (int)code); #else if (obj->error->context && obj->error->context[0] != '\0') { snprintf(dest, len, "'%s': %s",