aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-17 00:35:58 +0200
committerMax Kellermann <max@duempel.org>2013-10-17 00:36:52 +0200
commit1b8a1d4140c58030bc71665eef4dc3485812817e (patch)
treef463333b71117b2c64d3845e70c3a123d6607b80
parente132d10aec524962c5b5cbe135930aaabccba810 (diff)
downloadmpd-1b8a1d4140c58030bc71665eef4dc3485812817e.tar.gz
mpd-1b8a1d4140c58030bc71665eef4dc3485812817e.tar.xz
mpd-1b8a1d4140c58030bc71665eef4dc3485812817e.zip
ArchiveLookup: return const strings
-rw-r--r--src/ArchiveLookup.cxx4
-rw-r--r--src/ArchiveLookup.hxx4
-rw-r--r--src/input/ArchiveInputPlugin.cxx4
-rw-r--r--test/test_archive.cxx8
4 files changed, 12 insertions, 8 deletions
diff --git a/src/ArchiveLookup.cxx b/src/ArchiveLookup.cxx
index 8cd87f5ec..7cea655fd 100644
--- a/src/ArchiveLookup.cxx
+++ b/src/ArchiveLookup.cxx
@@ -29,7 +29,9 @@
#include <unistd.h>
#include <errno.h>
-bool archive_lookup(char *pathname, char **archive, char **inpath, char **suffix)
+bool
+archive_lookup(char *pathname, const char **archive,
+ const char **inpath, const char **suffix)
{
char *pathdupe;
int len, idx;
diff --git a/src/ArchiveLookup.hxx b/src/ArchiveLookup.hxx
index 62ebbc0c5..0c4da9c93 100644
--- a/src/ArchiveLookup.hxx
+++ b/src/ArchiveLookup.hxx
@@ -37,7 +37,9 @@
* inarchive pathname: Talco - Combat Circus/12 - A la pachenka.mp3
* and suffix: zip
*/
-bool archive_lookup(char *pathname, char **archive, char **inpath, char **suffix);
+bool
+archive_lookup(char *pathname, const char **archive,
+ const char **inpath, const char **suffix);
#endif
diff --git a/src/input/ArchiveInputPlugin.cxx b/src/input/ArchiveInputPlugin.cxx
index a43340994..84f0ca168 100644
--- a/src/input/ArchiveInputPlugin.cxx
+++ b/src/input/ArchiveInputPlugin.cxx
@@ -45,14 +45,14 @@ input_archive_open(const char *pathname,
Error &error)
{
const struct archive_plugin *arplug;
- char *archive, *filename, *suffix, *pname;
struct input_stream *is;
if (!Path::IsAbsoluteFS(pathname))
return NULL;
- pname = g_strdup(pathname);
+ char *pname = g_strdup(pathname);
// archive_lookup will modify pname when true is returned
+ const char *archive, *filename, *suffix;
if (!archive_lookup(pname, &archive, &filename, &suffix)) {
FormatDebug(archive_domain,
"not an archive, lookup %s failed", pname);
diff --git a/test/test_archive.cxx b/test/test_archive.cxx
index 2a2952885..e16b49061 100644
--- a/test/test_archive.cxx
+++ b/test/test_archive.cxx
@@ -23,7 +23,7 @@ public:
void
ArchiveLookupTest::TestArchiveLookup()
{
- char *archive, *inpath, *suffix;
+ const char *archive, *inpath, *suffix;
char *path = strdup("");
CPPUNIT_ASSERT_EQUAL(false,
@@ -48,16 +48,16 @@ ArchiveLookupTest::TestArchiveLookup()
path = strdup("Makefile/foo/bar");
CPPUNIT_ASSERT_EQUAL(true,
archive_lookup(path, &archive, &inpath, &suffix));
- CPPUNIT_ASSERT_EQUAL(path, archive);
+ CPPUNIT_ASSERT_EQUAL((const char *)path, archive);
CPPUNIT_ASSERT_EQUAL(0, strcmp(archive, "Makefile"));
CPPUNIT_ASSERT_EQUAL(0, strcmp(inpath, "foo/bar"));
- CPPUNIT_ASSERT_EQUAL((char *)nullptr, suffix);
+ CPPUNIT_ASSERT_EQUAL((const char *)nullptr, suffix);
g_free(path);
path = strdup("config.h/foo/bar");
CPPUNIT_ASSERT_EQUAL(true,
archive_lookup(path, &archive, &inpath, &suffix));
- CPPUNIT_ASSERT_EQUAL(path, archive);
+ CPPUNIT_ASSERT_EQUAL((const char *)path, archive);
CPPUNIT_ASSERT_EQUAL(0, strcmp(archive, "config.h"));
CPPUNIT_ASSERT_EQUAL(0, strcmp(inpath, "foo/bar"));
CPPUNIT_ASSERT_EQUAL(0, strcmp(suffix, "h"));