Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
1b8a1d41
Commit
1b8a1d41
authored
Oct 17, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ArchiveLookup: return const strings
parent
e132d10a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
8 deletions
+12
-8
ArchiveLookup.cxx
src/ArchiveLookup.cxx
+3
-1
ArchiveLookup.hxx
src/ArchiveLookup.hxx
+3
-1
ArchiveInputPlugin.cxx
src/input/ArchiveInputPlugin.cxx
+2
-2
test_archive.cxx
test/test_archive.cxx
+4
-4
No files found.
src/ArchiveLookup.cxx
View file @
1b8a1d41
...
...
@@ -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
;
...
...
src/ArchiveLookup.hxx
View file @
1b8a1d41
...
...
@@ -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
src/input/ArchiveInputPlugin.cxx
View file @
1b8a1d41
...
...
@@ -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
);
...
...
test/test_archive.cxx
View file @
1b8a1d41
...
...
@@ -23,7 +23,7 @@ public:
void
ArchiveLookupTest
::
TestArchiveLookup
()
{
char
*
archive
,
*
inpath
,
*
suffix
;
c
onst
c
har
*
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
((
c
onst
c
har
*
)
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"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment