Skip to content

Commit 848198a

Browse files
committed
fix(cast): proper nulls handle on osx
1 parent d4abf2d commit 848198a

5 files changed

Lines changed: 9 additions & 9 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ obj: $(CORE_OBJECTS)
7777
app: $(APP_OBJECTS) obj
7878
$(CC) $(CFLAGS) -o $(TARGET) $(CORE_OBJECTS) $(APP_OBJECTS) $(LIBS) $(LDFLAGS)
7979

80-
tests: -DSTOP_ON_FAIL=$(STOP_ON_FAIL) -DDEBUG
81-
tests: LDFLAGS = $(DEBUG_LDFLAGS)
80+
tests: CFLAGS = $(RELEASE_CFLAGS) -DDEBUG $(if $(STOP_ON_FAIL),-DSTOP_ON_FAIL)
81+
tests: LDFLAGS = $(RELEASE_LDFLAGS)
8282
tests: $(TESTS_OBJECTS) $(APP_COMMON) obj
8383
$(CC) -include core/def.h $(CFLAGS) -o $(TARGET).test $(CORE_OBJECTS) $(APP_COMMON) $(TESTS_OBJECTS) $(LIBS) $(LDFLAGS)
8484
./$(TARGET).test

core/index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2492,7 +2492,7 @@ obj_p index_group_list_perfect(obj_p obj, obj_p filter) {
24922492
obj_p meta = clone_obj(AS_LIST(res)[6]);
24932493
obj_p ids = I64(flen);
24942494
i64_t *ids_data = AS_I64(ids);
2495-
for (i = 0; i < flen; i++)
2495+
for (i = 0; i < (u64_t)flen; i++)
24962496
ids_data[i] = keys[src[i] - shift_val];
24972497
drop_obj(res);
24982498
res = index_group_build(INDEX_TYPE_IDS, gc, ids, i64(NULL_I64), NULL_OBJ, clone_obj(filter), meta);

core/rayforce.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,7 @@ obj_p cast_obj(i8_t type, obj_p obj) {
24232423
case MTYPE2(-TYPE_I16, -TYPE_TIMESTAMP):
24242424
return i16(obj->i64);
24252425
case MTYPE2(-TYPE_I16, -TYPE_F64):
2426-
return i16((i16_t)obj->f64);
2426+
return ISNANF64(obj->f64) ? i16(NULL_I16) : i16((i16_t)obj->f64);
24272427

24282428
// I32 atom conversions
24292429
case MTYPE2(-TYPE_I32, -TYPE_B8):
@@ -2439,7 +2439,7 @@ obj_p cast_obj(i8_t type, obj_p obj) {
24392439
case MTYPE2(-TYPE_I32, -TYPE_DATE):
24402440
return i32(obj->i32);
24412441
case MTYPE2(-TYPE_I32, -TYPE_F64):
2442-
return i32((i32_t)obj->f64);
2442+
return ISNANF64(obj->f64) ? i32(NULL_I32) : i32((i32_t)obj->f64);
24432443

24442444
// I64 atom conversions
24452445
case MTYPE2(-TYPE_I64, -TYPE_B8):
@@ -2455,7 +2455,7 @@ obj_p cast_obj(i8_t type, obj_p obj) {
24552455
case MTYPE2(-TYPE_I64, -TYPE_TIMESTAMP):
24562456
return i64(obj->i64);
24572457
case MTYPE2(-TYPE_I64, -TYPE_F64):
2458-
return i64((i64_t)obj->f64);
2458+
return ISNANF64(obj->f64) ? i64(NULL_I64) : i64((i64_t)obj->f64);
24592459

24602460
// F64 atom conversions
24612461
case MTYPE2(-TYPE_F64, -TYPE_B8):

tests/casting.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ test_result_t test_cast_nulls() {
336336
// Null f64 cast - 0Nf is NaN, cast to int gives min values
337337
TEST_ASSERT_EQ("(as 'i64 0Nf)", "0Nl");
338338
TEST_ASSERT_EQ("(as 'i32 0Nf)", "0Ni");
339-
TEST_ASSERT_EQ("(as 'i16 0Nf)", "0");
339+
TEST_ASSERT_EQ("(as 'i16 0Nf)", "0Nh");
340340

341341
// Null date cast - date is internally i32, null = -2147483648
342342
TEST_ASSERT_EQ("(as 'i64 0Nd)", "-2147483648");

tests/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ test_result_t test_str_match() {
3232
TEST_ASSERT(!str_match("brown", 5, "br[?*]wn", 8), "brown\", \"br[?*]wn");
3333

3434
// FIX protocol message tests - previously caused infinite loop
35-
TEST_ASSERT(!str_match("8=FIX.4.29=004835=049=TR56=CL134=252=20250225-16:15:36.31410=157", 67, "*35=A*", 6),
35+
TEST_ASSERT(!str_match("8=FIX.4.29=004835=049=TR56=CL134=252=20250225-16:15:36.31410=157", 64, "*35=A*", 6),
3636
"FIX message with 35=0 tag should not match *35=A* pattern");
37-
TEST_ASSERT(str_match("8=FIX.4.29=004835=049=TR56=CL134=252=20250225-16:15:36.31410=157", 67, "*35=0*", 6),
37+
TEST_ASSERT(str_match("8=FIX.4.29=004835=049=TR56=CL134=252=20250225-16:15:36.31410=157", 64, "*35=0*", 6),
3838
"FIX message with 35=0 tag should match *35=0* pattern");
3939

4040
// Additional edge cases for backtracking

0 commit comments

Comments
 (0)