Skip to content

Commit

Permalink
Fix issue with parsing bitmask expressions with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Sep 21, 2023
1 parent e3e83c2 commit 40abcf1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
4 changes: 1 addition & 3 deletions flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -46556,7 +46556,6 @@ const char *ecs_parse_expr_token(
const char *ptr,
char *token)
{
const char *start = ptr;
char *token_ptr = token;

if (ptr[0] == '/') {
Expand Down Expand Up @@ -46594,12 +46593,11 @@ const char *ecs_parse_expr_token(

while ((ptr = ecs_parse_token(name, expr, ptr, token_ptr, 0))) {
if (ptr[0] == '|' && ptr[1] != '|') {
token_ptr = &token_ptr[ptr - start];
token_ptr = &token_ptr[ecs_os_strlen(token_ptr)];
token_ptr[0] = '|';
token_ptr[1] = '\0';
token_ptr ++;
ptr ++;
start = ptr;
} else {
break;
}
Expand Down
4 changes: 1 addition & 3 deletions src/addons/expr/deserialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ const char *ecs_parse_expr_token(
const char *ptr,
char *token)
{
const char *start = ptr;
char *token_ptr = token;

if (ptr[0] == '/') {
Expand Down Expand Up @@ -187,12 +186,11 @@ const char *ecs_parse_expr_token(

while ((ptr = ecs_parse_token(name, expr, ptr, token_ptr, 0))) {
if (ptr[0] == '|' && ptr[1] != '|') {
token_ptr = &token_ptr[ptr - start];
token_ptr = &token_ptr[ecs_os_strlen(token_ptr)];
token_ptr[0] = '|';
token_ptr[1] = '\0';
token_ptr ++;
ptr ++;
start = ptr;
} else {
break;
}
Expand Down
12 changes: 0 additions & 12 deletions test/meta/src/BitmaskTypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,3 @@ void BitmaskTypes_bitmask_w_short_notation(void) {

ecs_fini(world);
}

void BitmaskTypes_constant_w_name_prefix(void) {
// Implement testcase
}

void BitmaskTypes_constant_w_type_prefix(void) {
// Implement testcase
}

void BitmaskTypes_constant_w_name_type_prefix(void) {
// Implement testcase
}
7 changes: 7 additions & 0 deletions test/meta/src/DeserializeFromExpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,13 @@ void DeserializeFromExpr_bitmask(void) {
test_uint(value, Lettuce|Bacon|Tomato|Cheese);
}

{
uint32_t value = 0;
const char *ptr = ecs_parse_expr(world, "Lettuce | Bacon | Tomato | Cheese", &(ecs_value_t){t, &value}, NULL);
test_assert(ptr != NULL);
test_uint(value, Lettuce|Bacon|Tomato|Cheese);
}

{
uint32_t value = 0;
const char *ptr = ecs_parse_expr(world, "BLT", &(ecs_value_t){t, &value}, NULL);
Expand Down

0 comments on commit 40abcf1

Please sign in to comment.