mirror of
https://github.com/stupidcomputer/jsfw.git
synced 2024-12-26 21:42:23 -06:00
small bugfix
This commit is contained in:
parent
59502c2502
commit
04a22a9c54
@ -154,6 +154,7 @@ void define_structs(Program *p, Writer *w, void (*define)(Writer *w, StructObjec
|
|||||||
char *pascal_to_snake_case(StringSlice str) {
|
char *pascal_to_snake_case(StringSlice str) {
|
||||||
CharVec res = vec_init();
|
CharVec res = vec_init();
|
||||||
vec_grow(&res, str.len + 4);
|
vec_grow(&res, str.len + 4);
|
||||||
|
bool was_upper = false;
|
||||||
for (size_t i = 0; i < str.len; i++) {
|
for (size_t i = 0; i < str.len; i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
vec_push(&res, tolower(str.ptr[i]));
|
vec_push(&res, tolower(str.ptr[i]));
|
||||||
@ -161,9 +162,12 @@ char *pascal_to_snake_case(StringSlice str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char c = str.ptr[i];
|
char c = str.ptr[i];
|
||||||
if (isupper(c)) {
|
if (isupper(c) && !was_upper) {
|
||||||
vec_push(&res, '_');
|
vec_push(&res, '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
was_upper = isupper(c);
|
||||||
|
|
||||||
vec_push(&res, tolower(c));
|
vec_push(&res, tolower(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1179,9 +1179,6 @@ static void resolve_messages(EvaluationContext *ctx) {
|
|||||||
message.fields = (FieldVec)vec_init();
|
message.fields = (FieldVec)vec_init();
|
||||||
vec_grow(&message.fields, msg.fields.len);
|
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++) {
|
for (size_t k = 0; k < msg.fields.len; k++) {
|
||||||
Field f;
|
Field f;
|
||||||
f.name = string_slice_from_token(msg.fields.data[k].name);
|
f.name = string_slice_from_token(msg.fields.data[k].name);
|
||||||
|
Loading…
Reference in New Issue
Block a user