aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-06-10 12:00:49 +0200
committerFederico Angelilli <code@fedang.net>2024-06-10 12:00:49 +0200
commit8236685559919f47d9954ec1fc8de7451b4c7757 (patch)
treee86c4d6aba394ee2916880f1bd2f5a5708e15e81
parent6c05a5fd7c977d641f181bf1e2c7340854a6114f (diff)
Minor fixes to any_sexp
-rw-r--r--any_log.h2
-rw-r--r--any_sexp.h16
2 files changed, 9 insertions, 9 deletions
diff --git a/any_log.h b/any_log.h
index b1c1c2a..c4f143c 100644
--- a/any_log.h
+++ b/any_log.h
@@ -585,7 +585,7 @@ void any_log_value(any_log_level_t level, const char *module,
case 'x':
case 'u': {
unsigned int value = va_arg(args, unsigned int);
- fprintf(any_log_stream, ANY_LOG_VALUE_HEX(key, va_arg(args, unsigned int)));
+ fprintf(any_log_stream, ANY_LOG_VALUE_HEX(key, value));
break;
}
diff --git a/any_sexp.h b/any_sexp.h
index 0d54c20..fa8c95a 100644
--- a/any_sexp.h
+++ b/any_sexp.h
@@ -49,8 +49,8 @@ typedef struct any_sexp {
};
} any_sexp_t;
-#define ANY_SEXP_ERROR (any_sexp_error())
-#define ANY_SEXP_NIL (any_sexp_nil())
+#define ANY_SEXP_ERROR ((any_sexp_t) { .tag = ANY_SEXP_TAG_ERROR })
+#define ANY_SEXP_NIL ((any_sexp_t) { .tag = ANY_SEXP_TAG_NIL })
#define ANY_SEXP_GET_TAG(sexp) ((sexp).tag)
#define ANY_SEXP_GET_CONS(sexp) ((sexp).cons)
@@ -326,7 +326,7 @@ any_sexp_t any_sexp_read(any_sexp_reader_t *reader)
do {
if (length < ANY_SEXP_READER_BUFFER_LENGTH) {
- number = number && (length == 0 && reader->c == '-' || isdigit(reader->c));
+ number = number && ((length == 0 && reader->c == '-') || isdigit(reader->c));
buffer[length++] = reader->c;
}
@@ -522,6 +522,8 @@ int any_sexp_write(any_sexp_writer_t *writer, any_sexp_t sexp)
return sign + any_sexp_writer_putnum(writer, value);
}
}
+
+ return 0;
}
int any_sexp_fprint(FILE *file, any_sexp_t sexp)
@@ -704,11 +706,6 @@ any_sexp_t any_sexp_append(any_sexp_t a, any_sexp_t b)
any_sexp_t any_sexp_copy(any_sexp_t sexp)
{
switch (ANY_SEXP_GET_TAG(sexp)) {
- case ANY_SEXP_TAG_ERROR:
- case ANY_SEXP_TAG_NIL:
- case ANY_SEXP_TAG_NUMBER:
- return sexp;
-
case ANY_SEXP_TAG_CONS:
return any_sexp_cons(any_sexp_car(sexp), any_sexp_cdr(sexp));
@@ -721,6 +718,9 @@ any_sexp_t any_sexp_copy(any_sexp_t sexp)
char *string = ANY_SEXP_GET_STRING(sexp);
return any_sexp_symbol(string, strlen(string));
}
+
+ default:
+ return sexp;
}
}