ref: 61bf5454dff9f50a2e2867f77737439d29a80ed4
parent: 10a967094109f5bf7f91332d977289bbbafb8079
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Dec 6 12:38:30 EST 2019
playlist: allow moving entries around by changing the track index
--- a/zuke.c
+++ b/zuke.c
@@ -569,8 +569,12 @@
for(i = 0; i < plnum; i++, s = endrec){
if(plraw+plrawsize < s+10)
sysfatal("truncated playlist");
- if(s[0] != '#' || s[1] != ' ' || !isdigit(s[2]) || strtol(s+2, &e, 10) != i)
+ if(s[0] != '#' || s[1] != ' ' || !isdigit(s[2]))
sysfatal("invalid record");
+ if((n = strtol(s+2, &e, 10)) < 0 || n > plnum)
+ sysfatal("invalid track index");
+ if(pl[n].path != nil)
+ sysfatal("duplicate track index");
s[-1] = 0;
sz = strtol(e, &s, 10);
@@ -579,7 +583,7 @@
sysfatal("truncated playlist");
s[sz-1] = 0; /* '\n'→'\0' to mark the end of the record */
endrec = s+sz;
- m = &pl[i];
+ m = &pl[n];
for(;;){
if(s[0] == Pimage){