Skip to content

Commit

Permalink
Merge pull request #206 from Joe7M/master
Browse files Browse the repository at this point in the history
Fix TSAVE bug #205
  • Loading branch information
chrisws committed Feb 24, 2024
2 parents 418617d + e8f887b commit 6e0f3a6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions samples/distro-examples/tests/all.bas
Expand Up @@ -92,10 +92,10 @@ print "STKDUMP:" ':STKDUMP
print "SWAP:"; :sa=10:sb=20:SWAP sa,sb: PRINT sa;sb
print "THROW:" ':THROW [info [, ...]]
print "TIMEHMS:" ':TIMEHMS hms| timer, BYREF h, BYREF m, BYREF s
print "TLOAD:" ':TLOAD file, BYREF var [, type]
print "TRON:" :TRON
print "TROFF:" :TROFF
print "TSAVE:" ':TSAVE file, var
print "TSAVE:" : tsavetest = [1,2,3, "test"]: tsave "tsave.txt", tsavetest
print "TLOAD: "; : tload "tsave.txt", tloadtest: print tloadtest
print "VIEW:" ':VIEW [x1,y1,x2,y2 [,color [,border-color]]]
print "WINDOW:" ':WINDOW [x1,y1,x2,y2]
print "WRITE:" ':WRITE #fileN; var1 [, ...]
Expand Down
4 changes: 2 additions & 2 deletions samples/distro-examples/tests/output/all.out
Expand Up @@ -75,10 +75,10 @@ STKDUMP:
SWAP:2010
THROW:
TIMEHMS:
TLOAD:
TRON:
<97>TROFF:
<96>TROFF:
TSAVE:
TLOAD: [1,2,3,test]
VIEW:
WINDOW:
WRITE:
Expand Down
24 changes: 12 additions & 12 deletions src/common/blib_db.c
Expand Up @@ -660,15 +660,11 @@ void cmd_floadln() {
// type == 1, build string
v_free(var_p);
int len = dev_flength(handle);
if (len < 1 || prog_error) {
err_throw(FSERR_NOT_FOUND);
} else {
v_init_str(var_p, len);
if (var_p->v.p.length > 1) {
dev_fread(handle, (byte *)var_p->v.p.ptr, var_p->v.p.length - 1);
var_p->v.p.ptr[var_p->v.p.length - 1] = '\0';
}
}
v_init_str(var_p, len);
if (var_p->v.p.length > 1) {
dev_fread(handle, (byte *)var_p->v.p.ptr, var_p->v.p.length - 1);
var_p->v.p.ptr[var_p->v.p.length - 1] = '\0';
}
}
if (flags == DEV_FILE_INPUT) {
dev_fclose(handle);
Expand Down Expand Up @@ -722,10 +718,14 @@ void cmd_fsaveln() {

if (var_p->type == V_ARRAY) {
// parameter is an array
for (int i = 0; i < v_asize(array_p); i++) {
var_p = v_elem(array_p, i);
if(v_asize(array_p) > 0) {
var_p = v_elem(array_p, 0);
fprint_var(handle, var_p);
dev_fwrite(handle, (byte *)OS_LINESEPARATOR, OS_LINESEPARATOR_LEN);
for (int i = 1; i < v_asize(array_p); i++) {
var_p = v_elem(array_p, i);
dev_fwrite(handle, (byte *)OS_LINESEPARATOR, OS_LINESEPARATOR_LEN);
fprint_var(handle, var_p);
}
}
} else {
// parameter is an string
Expand Down

0 comments on commit 6e0f3a6

Please sign in to comment.