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
2a913149
Commit
2a913149
authored
Nov 04, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/UriExtract: pass std::string_view to uri_get_suffix()
parent
35a23210
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
12 deletions
+14
-12
FingerprintCommands.cxx
src/command/FingerprintCommands.cxx
+2
-2
UriExtract.cxx
src/util/UriExtract.cxx
+9
-8
UriExtract.hxx
src/util/UriExtract.hxx
+1
-1
ContainerScan.cxx
test/ContainerScan.cxx
+2
-1
No files found.
src/command/FingerprintCommands.cxx
View file @
2a913149
...
...
@@ -164,7 +164,7 @@ GetChromaprintCommand::DecodeStream(InputStream &is,
inline
void
GetChromaprintCommand
::
DecodeStream
(
InputStream
&
is
)
{
const
auto
suffix
=
uri_get_suffix
(
uri
.
c_str
()
);
const
auto
suffix
=
uri_get_suffix
(
uri
);
decoder_plugins_try
([
this
,
&
is
,
suffix
](
const
DecoderPlugin
&
plugin
){
return
DecodeStream
(
is
,
suffix
,
plugin
);
...
...
@@ -222,7 +222,7 @@ GetChromaprintCommand::DecodeFile(std::string_view suffix, InputStream &is,
inline
void
GetChromaprintCommand
::
DecodeFile
()
{
const
auto
suffix
=
uri_get_suffix
(
uri
.
c_str
()
);
const
auto
suffix
=
uri_get_suffix
(
uri
);
if
(
suffix
.
empty
())
return
;
...
...
src/util/UriExtract.cxx
View file @
2a913149
...
...
@@ -122,20 +122,21 @@ uri_get_path(std::string_view uri) noexcept
/* suffixes should be ascii only characters */
std
::
string_view
uri_get_suffix
(
const
char
*
uri
)
noexcept
uri_get_suffix
(
std
::
string_view
_
uri
)
noexcept
{
const
char
*
suffix
=
std
::
strrchr
(
uri
,
'.'
);
if
(
suffix
==
nullptr
||
suffix
==
uri
||
suffix
[
-
1
]
==
'/'
||
suffix
[
-
1
]
==
'\\'
)
StringView
uri
(
_uri
);
const
char
*
dot
=
uri
.
FindLast
(
'.'
);
if
(
dot
==
nullptr
||
dot
==
uri
.
data
||
dot
[
-
1
]
==
'/'
||
dot
[
-
1
]
==
'\\'
)
return
{};
++
suffix
;
if
(
strpbrk
(
suffix
,
"/
\\
"
)
!=
nullptr
)
auto
suffix
=
uri
.
substr
(
dot
+
1
)
;
if
(
suffix
.
Find
(
'/'
)
!=
nullptr
||
suffix
.
Find
(
'\\'
)
!=
nullptr
)
/* this was not the last path segment */
return
{};
/* remove the query string */
return
StringView
(
suffix
)
.
Split
(
'?'
).
first
;
return
suffix
.
Split
(
'?'
).
first
;
}
const
char
*
...
...
src/util/UriExtract.hxx
View file @
2a913149
...
...
@@ -63,7 +63,7 @@ uri_get_path(std::string_view uri) noexcept;
gcc_pure
std
::
string_view
uri_get_suffix
(
const
char
*
uri
)
noexcept
;
uri_get_suffix
(
std
::
string_view
uri
)
noexcept
;
/**
* Returns the URI fragment, i.e. the portion after the '#', but
...
...
test/ContainerScan.cxx
View file @
2a913149
...
...
@@ -48,7 +48,8 @@ FindContainerDecoderPlugin(std::string_view suffix)
static
const
DecoderPlugin
*
FindContainerDecoderPlugin
(
Path
path
)
{
const
auto
suffix
=
uri_get_suffix
(
path
.
ToUTF8Throw
().
c_str
());
const
auto
path_utf8
=
path
.
ToUTF8Throw
();
const
auto
suffix
=
uri_get_suffix
(
path_utf8
);
if
(
suffix
.
empty
())
return
nullptr
;
...
...
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