Skip to content

Commit 4596fb0

Browse files
committed
COMMON: Fixes TSAVE of arrays includes extra null character. smallbasic#119
1 parent eae21a9 commit 4596fb0

File tree

5 files changed

+6
-3
lines changed

5 files changed

+6
-3
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
2021-06-05 (12.22)
22
COMMON: Fixes 'Socket Client doesn't receive byte with value 13' #112
3+
COMMON: Fixes TSAVE of arrays includes extra null character. #119
34

45
2021-05-03 (12.22)
56
COMMON: Fix array access regression

src/common/blib.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ void cmd_print(int output) {
530530
if (code_peek() == kwTYPE_EOC || code_peek() == kwTYPE_LINE) {
531531
// There are no parameters
532532
if (dev_fstatus(handle)) {
533-
dev_fwrite(handle, (byte *)OS_LINESEPARATOR, sizeof(OS_LINESEPARATOR));
533+
dev_fwrite(handle, (byte *)OS_LINESEPARATOR, OS_LINESEPARATOR_LEN);
534534
} else {
535535
err_fopen();
536536
}

src/common/blib_db.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ void cmd_fsaveln() {
725725
for (int i = 0; i < v_asize(array_p); i++) {
726726
var_p = v_elem(array_p, i);
727727
fprint_var(handle, var_p);
728-
dev_fwrite(handle, (byte *)OS_LINESEPARATOR, sizeof(OS_LINESEPARATOR));
728+
dev_fwrite(handle, (byte *)OS_LINESEPARATOR, OS_LINESEPARATOR_LEN);
729729
}
730730
} else {
731731
// parameter is an string

src/common/scan.c

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ bcip_t comp_search_bc(bcip_t ip, code_t code);
2525
bcip_t comp_next_bc_cmd(bc_t *bc, bcip_t ip);
2626
extern void expr_parser(bc_t *bc);
2727

28-
#define STRLEN(s) ((sizeof(s) / sizeof(s[0])) - 1)
2928
const int LEN_OPTION = STRLEN(LCN_OPTION);
3029
const int LEN_IMPORT = STRLEN(LCN_IMPORT_WRS);
3130
const int LEN_UNIT = STRLEN(LCN_UNIT_WRS);

src/common/sys.h

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ extern "C" {
6060
#define OS_LINESEPARATOR "\n"
6161
#endif
6262

63+
#define STRLEN(s) ((sizeof(s) / sizeof(s[0])) - 1)
64+
#define OS_LINESEPARATOR_LEN STRLEN(OS_LINESEPARATOR)
65+
6366
#if UINTPTR_MAX == 0xffffffff
6467
#define SB_BIT_SZ "_32 "
6568
#else

0 commit comments

Comments
 (0)