From 2fb66433264984e8fc73ad22ffc9143e9f53d8c3 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Thu, 31 Mar 2022 14:12:52 -0400 Subject: [PATCH] A bit of cleanup and warning-hushing. --- src/env.c | 6 ++++-- src/object.c | 2 +- src/object.h | 2 +- src/pebblisp.c | 1 - src/pebblisp.h | 4 +--- src/pebcom.c | 27 --------------------------- 6 files changed, 7 insertions(+), 35 deletions(-) diff --git a/src/env.c b/src/env.c index c82eed1..7b9b7f4 100644 --- a/src/env.c +++ b/src/env.c @@ -37,12 +37,14 @@ Object fetchFromEnvironment(const char* name, struct Environment* env) } for (int i = 0; i < env->capacity; i++) { - if (env->strings[i] == NULL) { printd("Try %d (NULL)\n", i); + if (env->strings[i] == NULL) { + printd("Try %d (NULL)\n", i); break; } printd("Try %d (%s)\n", i, env->strings[i]); - if (strcmp(name, env->strings[i]) == 0) { printd("Returning!\n"); + if (strcmp(name, env->strings[i]) == 0) { + printd("Returning!\n"); return cloneObject(env->objects[i]); } } diff --git a/src/object.c b/src/object.c index 0e4109b..e9e0ce7 100644 --- a/src/object.c +++ b/src/object.c @@ -680,7 +680,7 @@ inline Object numberObject(int num) inline Object boolObject(int b) { Object o = newObject(TYPE_BOOL); - o.number = !!b; + o.number = b != 0; return o; } diff --git a/src/object.h b/src/object.h index 0951ee3..4a5b1b7 100644 --- a/src/object.h +++ b/src/object.h @@ -11,7 +11,7 @@ #ifdef DEBUG #define printd(...) printf(__VA_ARGS__) #else -#define printd(...) ; +#define printd(...) do { } while (0) #endif #endif diff --git a/src/pebblisp.c b/src/pebblisp.c index c31dad7..429b4da 100644 --- a/src/pebblisp.c +++ b/src/pebblisp.c @@ -9,7 +9,6 @@ #include #include "tokens.h" -#include "plfunc.h" #ifdef STANDALONE diff --git a/src/pebblisp.h b/src/pebblisp.h index 7cbae66..4cf6c43 100644 --- a/src/pebblisp.h +++ b/src/pebblisp.h @@ -12,7 +12,7 @@ #define fnn(_name, _docs, ...) \ static const char * const _name ## Doc = _docs; \ -static const char * const _name ## Tests[] = {__VA_ARGS__}; \ +__attribute__((unused)) static const char * const _name ## Tests[] = {__VA_ARGS__}; \ _Static_assert(array_length(_name ## Tests) % 2 == 0, "Array of test strings must have exactly one expected result for each test."); \ Object _name(Object* params, int length, struct Environment* env) @@ -53,8 +53,6 @@ Object parseEval(const char* input, struct Environment* env); Object evalList(const Object* obj, struct Environment* env); -void copySlice(char* dest, struct Slice* src); - Object evalLambdaArgs(const Object* arg_forms, struct Environment* env); Object listEvalLambda(Object* lambda, const Object* remaining, int evalLength, diff --git a/src/pebcom.c b/src/pebcom.c index 9fe9547..0e2d4b6 100644 --- a/src/pebcom.c +++ b/src/pebcom.c @@ -2,33 +2,6 @@ #include -struct tm* getTime() -{ - time_t t = time(NULL); - return localtime(&t); -} - -Object getSeconds(Object o1, Object o2, struct Environment* env) -{ - return numberObject(getTime()->tm_sec); -} - -Object getMinutes(Object o1, Object o2, struct Environment* env) -{ - return numberObject(getTime()->tm_min); -} - -Object getHours(Object o1, Object o2, struct Environment* env) -{ - return numberObject(getTime()->tm_hour); -} - -Object getTwelveHours(Object o1, Object o2, struct Environment* env) -{ - int hour = (getTime()->tm_hour % 12) ?: 12; - return numberObject(hour); -} - Object doVibe(Object patternList, Object o2, struct Environment* env) { int length = listLength(&patternList);