ref: 58d8c8fa11e2249d5fa145e182153da85ff44ed6
parent: 91dd37b744437850197c71ca338a7ed42f3e14a2
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Feb 21 16:50:50 EST 2016
mkplist: always separate tracks from different directories
--- a/mkfile
+++ b/mkfile
@@ -5,6 +5,12 @@
mkplist\
zuke\
+HFILES=\
+ plist.h\
+
+UPDATE=\
+ $HFILES\
+
BIN=/$objtype/bin/audio
</sys/src/cmd/mkmany
--- a/mkplist.c
+++ b/mkplist.c
@@ -9,6 +9,8 @@
Maxdepth = 16, /* max recursion depth */
};
+#define MAX(a, b) (a > b ? a : b)
+
static int fd;
static Meta *curr;
static Meta *all;
@@ -229,6 +231,7 @@
cmpmeta(void *a_, void *b_)
{
Meta *a, *b;
+ char *ae, *be;
int i, x;
a = a_;
@@ -248,6 +251,11 @@
if(a->album != nil && b->album == nil) return 1;
if((x = cistrcmp(a->album, b->album)) != 0) return x;
}
+
+ ae = utfrrune(a->path, '/');
+ be = utfrrune(b->path, '/');
+ if(ae != nil && be != nil && (x = strncmp(a->path, b->path, MAX(ae-a->path, be-b->path))) != 0)
+ return x;
if(a->track != nil || b->track != nil){
if(a->track == nil && b->track != nil) return -1;