X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/a8747834bb7d56ef1e57be5404824d6a638ba2d4..8ab2aa9fd51a89e06d92a4f7c3792aaa4a08cc71:/lib/trackname.c
diff --git a/lib/trackname.c b/lib/trackname.c
index cef77b8..644d069 100644
--- a/lib/trackname.c
+++ b/lib/trackname.c
@@ -1,39 +1,34 @@
/*
* This file is part of DisOrder
- * Copyright (C) 2005, 2006 Richard Kettlewell
+ * Copyright (C) 2005, 2006, 2007 Richard Kettlewell
*
- * This program is free software; you can redistribute it and/or modify
+ * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
+ * along with this program. If not, see .
*/
-
-#include
-#include "types.h"
-
-#include
+/** @file lib/trackname.c
+ * @brief Track name calculation
+ */
+#include "common.h"
#include
-#include
-#include
#include "trackname.h"
#include "configuration.h"
#include "regsub.h"
#include "log.h"
#include "filepart.h"
-#include "words.h"
+#include "unicode.h"
-const char *find_track_root(const char *track) {
+const struct collection *find_track_collection(const char *track) {
int n;
size_t l, tl = strlen(track);
@@ -44,11 +39,22 @@ const char *find_track_root(const char *track) {
&& track[l] == '/')
break;
}
- if(n >= config->collection.n) {
- error(0, "found track in no collection '%s'", track);
+ if(n < config->collection.n)
+ return &config->collection.s[n];
+ else
return 0;
- }
- return config->collection.s[n].root;
+}
+
+const char *find_track_root(const char *track) {
+ const struct collection *c = find_track_collection(track);
+ if(c)
+ return c->root;
+ /* Suppress this message for scratches */
+ for(int n = 0; n < config->scratch.n; ++n)
+ if(!strcmp(track, config->scratch.s[n]))
+ return 0;
+ disorder_error(0, "found track in no collection '%s'", track);
+ return 0;
}
const char *track_rootless(const char *track) {
@@ -102,41 +108,6 @@ const char *trackname_transform(const char *type,
return subject;
}
-int compare_tracks(const char *sa, const char *sb,
- const char *da, const char *db,
- const char *ta, const char *tb) {
- int c;
-
- if((c = strcmp(casefold(sa), casefold(sb)))) return c;
- if((c = strcmp(sa, sb))) return c;
- if((c = strcmp(casefold(da), casefold(db)))) return c;
- if((c = strcmp(da, db))) return c;
- return compare_path(ta, tb);
-}
-
-int compare_path_raw(const unsigned char *ap, size_t an,
- const unsigned char *bp, size_t bn) {
- while(an > 0 && bn > 0) {
- if(*ap == *bp) {
- ap++;
- bp++;
- an--;
- bn--;
- } else if(*ap == '/') {
- return -1; /* /a/b < /aa/ */
- } else if(*bp == '/') {
- return 1; /* /aa > /a/b */
- } else
- return *ap - *bp;
- }
- if(an > 0)
- return 1; /* /a/b > /a and /ab > /a */
- else if(bn > 0)
- return -1; /* /a < /ab and /a < /a/b */
- else
- return 0;
-}
-
/*
Local Variables:
c-basic-offset:2