ref: 8e1f1ff85586694dd7587f749e28de008f51fb8f
parent: 2ab2e801072d772e3e9370a6c0f17de80cf974fb
author: qwx <qwx@sciops.net>
date: Sat Aug 10 05:05:43 EDT 2024
fix loading multiple files
--- a/chunk.c
+++ b/chunk.c
@@ -222,7 +222,6 @@
d.cur = d.from = dp->from < d.totalsz ? dp->from : 0;
d.to = d.totalsz;
d.off = -1;
- d.trk = dp->trk;
return d;
}
@@ -529,4 +528,24 @@
d->from = 0;
*d = newdot(d);
return c;
+}
+
+void
+appendfile(char *path)
+{
+ int fd;
+ Chunk *c;
+ Dot d;
+
+ if((fd = path != nil ? open(path, OREAD) : 0) < 0)
+ sysfatal("open: %r");
+ if((c = loadfile(fd, &d)) == nil)
+ sysfatal("initcmd: %r");
+ close(fd);
+ if(dot.totalsz == 0){
+ dot = d;
+ return;
+ }
+ linkchunk(dot.norris->left, c);
+ dot.totalsz += d.totalsz;
}
--- a/cmd.c
+++ b/cmd.c
@@ -308,15 +308,3 @@
noted(NCONT);
noted(NDFLT);
}
-
-void
-addtrack(char *path)
-{
- int fd;
-
- if((fd = path != nil ? open(path, OREAD) : 0) < 0)
- sysfatal("open: %r");
- if(loadfile(fd, &dot) == nil)
- sysfatal("initcmd: %r");
- close(fd);
-}
--- a/dat.h
+++ b/dat.h
@@ -21,7 +21,6 @@
Chunk *right;
};
struct Dot{
- ssize trk;
usize from;
usize to;
usize cur;
--- a/draw.c
+++ b/draw.c
@@ -233,7 +233,6 @@
drawstat();
flushimage(display, 1);
unlockdisplay(display);
- //sleep(100);
t = nsec() / 1000000.0;
Δt = t0 - t;
if(Δt > 0)
--- a/fns.h
+++ b/fns.h
@@ -9,7 +9,7 @@
void ccrop(Dot*);
Chunk* loadfile(int, Dot*);
int cmd(char*);
-void addtrack(char*);
+void appendfile(char*);
void refresh(int);
void setzoom(int, int);
int zoominto(vlong, vlong);
--- a/pplay.c
+++ b/pplay.c
@@ -121,9 +121,9 @@
fmtinstall(L'τ', τfmt);
if(*argv != nil)
while(*argv != nil)
- addtrack(*argv++);
+ appendfile(*argv++);
else
- addtrack(nil);
+ appendfile(nil);
initdrw(notriob);
if((kc = initkeyboard(nil)) == nil)
sysfatal("initkeyboard: %r");