X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/a8747834bb7d56ef1e57be5404824d6a638ba2d4..f6033c46c877646b95bc2e99ce69097203bc5c77:/lib/trackname.c diff --git a/lib/trackname.c b/lib/trackname.c index cef77b8..53824d7 100644 --- a/lib/trackname.c +++ b/lib/trackname.c @@ -1,6 +1,6 @@ /* * 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 * it under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ #include "filepart.h" #include "words.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 +44,18 @@ 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; + error(0, "found track in no collection '%s'", track); + return 0; } const char *track_rootless(const char *track) {