From 04a22a9c54c22aad86f7b7d714494b2fb4edc8a1 Mon Sep 17 00:00:00 2001 From: viandoxdev Date: Fri, 19 May 2023 11:00:24 +0200 Subject: [PATCH] small bugfix --- ser/codegen.c | 6 +++++- ser/eval.c | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ser/codegen.c b/ser/codegen.c index 7028da3..467e168 100644 --- a/ser/codegen.c +++ b/ser/codegen.c @@ -154,6 +154,7 @@ void define_structs(Program *p, Writer *w, void (*define)(Writer *w, StructObjec char *pascal_to_snake_case(StringSlice str) { CharVec res = vec_init(); vec_grow(&res, str.len + 4); + bool was_upper = false; for (size_t i = 0; i < str.len; i++) { if (i == 0) { vec_push(&res, tolower(str.ptr[i])); @@ -161,9 +162,12 @@ char *pascal_to_snake_case(StringSlice str) { } char c = str.ptr[i]; - if (isupper(c)) { + if (isupper(c) && !was_upper) { vec_push(&res, '_'); } + + was_upper = isupper(c); + vec_push(&res, tolower(c)); } diff --git a/ser/eval.c b/ser/eval.c index 3caeb51..11e8201 100644 --- a/ser/eval.c +++ b/ser/eval.c @@ -1179,9 +1179,6 @@ static void resolve_messages(EvaluationContext *ctx) { message.fields = (FieldVec)vec_init(); vec_grow(&message.fields, msg.fields.len); - if (msg.fields.len == 0) { - vec_push(&ctx->errors, err_empty(msg.ident.span, ATMessage, message.name)); - } for (size_t k = 0; k < msg.fields.len; k++) { Field f; f.name = string_slice_from_token(msg.fields.data[k].name);