Skip to content

Commit 49bcd17

Browse files
committed
FIX: Bincode - the output buffer position was not updated
1 parent 1029eae commit 49bcd17

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/core/u-bincode.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ float float16to32(float16_s f16) {
111111
return f32.v;
112112
}
113113

114-
//float float64to16(float16_s f16) {
115-
// half s;
116-
//}
117-
118114
#pragma pack(4)
119115
typedef union {
120116
u16 num;
@@ -799,12 +795,12 @@ static REBCNT EncodedU32_Size(u32 value) {
799795
case SYM_FLOAT:
800796
f32.v = (float)(IS_INTEGER(next) ? VAL_INT64(next) : VAL_DECIMAL(next));
801797
memcpy(cp, (REBYTE*)&f32, 4);
802-
cp += 4;
798+
n = 4;
803799
break;
804800
case SYM_DOUBLE:
805801
dbl = (REBDEC)(IS_INTEGER(next) ? VAL_INT64(next) : VAL_DECIMAL(next));
806802
memcpy(cp, (REBYTE*)&dbl, 8);
807-
cp += 8;
803+
n = 8;
808804
break;
809805
case SYM_FLOAT16:
810806
d32 = (REBDEC)(IS_INTEGER(next) ? VAL_INT64(next) : VAL_DECIMAL(next));
@@ -827,7 +823,7 @@ static REBCNT EncodedU32_Size(u32 value) {
827823
ushort = (u16)t1;
828824
}
829825
memcpy(cp, (REBYTE*)&ushort, 2);
830-
cp += 2;
826+
n = 2;
831827
break;
832828

833829
case SYM_AT:

src/tests/units/bincode-test.r3

+1
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ is-protected-error?: func[code][
337337
--test-- "BinCode - FLOAT16, FLOAT, DOUBLE (write/read NAN)"
338338
b: binary/write #{} [float16 1.#NaN float 1.#NaN double 1.#NaN]
339339
--assert b/buffer = #{007E0000C07F000000000000F87F}
340+
--assert tail? b/buffer-write
340341
;@@ using MOLD as: 1.#nan <> 1.#nan
341342
--assert "[1.#NaN 1.#NaN 1.#NaN]" = mold binary/read b [float16 float double]
342343

0 commit comments

Comments
 (0)