Skip to content

Commit e4ab832

Browse files
author
3oheicrw
authored
Merge branch 'smallbasic:master' into master
2 parents 3eaf936 + 6e0f3a6 commit e4ab832

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

samples/distro-examples/tests/all.bas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ print "STKDUMP:" ':STKDUMP
9292
print "SWAP:"; :sa=10:sb=20:SWAP sa,sb: PRINT sa;sb
9393
print "THROW:" ':THROW [info [, ...]]
9494
print "TIMEHMS:" ':TIMEHMS hms| timer, BYREF h, BYREF m, BYREF s
95-
print "TLOAD:" ':TLOAD file, BYREF var [, type]
9695
print "TRON:" :TRON
9796
print "TROFF:" :TROFF
98-
print "TSAVE:" ':TSAVE file, var
97+
print "TSAVE:" : tsavetest = [1,2,3, "test"]: tsave "tsave.txt", tsavetest
98+
print "TLOAD: "; : tload "tsave.txt", tloadtest: print tloadtest
9999
print "VIEW:" ':VIEW [x1,y1,x2,y2 [,color [,border-color]]]
100100
print "WINDOW:" ':WINDOW [x1,y1,x2,y2]
101101
print "WRITE:" ':WRITE #fileN; var1 [, ...]

samples/distro-examples/tests/output/all.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ STKDUMP:
7575
SWAP:2010
7676
THROW:
7777
TIMEHMS:
78-
TLOAD:
7978
TRON:
80-
<97>TROFF:
79+
<96>TROFF:
8180
TSAVE:
81+
TLOAD: [1,2,3,test]
8282
VIEW:
8383
WINDOW:
8484
WRITE:

src/common/blib_db.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -660,15 +660,11 @@ void cmd_floadln() {
660660
// type == 1, build string
661661
v_free(var_p);
662662
int len = dev_flength(handle);
663-
if (len < 1 || prog_error) {
664-
err_throw(FSERR_NOT_FOUND);
665-
} else {
666-
v_init_str(var_p, len);
667-
if (var_p->v.p.length > 1) {
668-
dev_fread(handle, (byte *)var_p->v.p.ptr, var_p->v.p.length - 1);
669-
var_p->v.p.ptr[var_p->v.p.length - 1] = '\0';
670-
}
671-
}
663+
v_init_str(var_p, len);
664+
if (var_p->v.p.length > 1) {
665+
dev_fread(handle, (byte *)var_p->v.p.ptr, var_p->v.p.length - 1);
666+
var_p->v.p.ptr[var_p->v.p.length - 1] = '\0';
667+
}
672668
}
673669
if (flags == DEV_FILE_INPUT) {
674670
dev_fclose(handle);
@@ -722,10 +718,14 @@ void cmd_fsaveln() {
722718

723719
if (var_p->type == V_ARRAY) {
724720
// parameter is an array
725-
for (int i = 0; i < v_asize(array_p); i++) {
726-
var_p = v_elem(array_p, i);
721+
if(v_asize(array_p) > 0) {
722+
var_p = v_elem(array_p, 0);
727723
fprint_var(handle, var_p);
728-
dev_fwrite(handle, (byte *)OS_LINESEPARATOR, OS_LINESEPARATOR_LEN);
724+
for (int i = 1; i < v_asize(array_p); i++) {
725+
var_p = v_elem(array_p, i);
726+
dev_fwrite(handle, (byte *)OS_LINESEPARATOR, OS_LINESEPARATOR_LEN);
727+
fprint_var(handle, var_p);
728+
}
729729
}
730730
} else {
731731
// parameter is an string

0 commit comments

Comments
 (0)