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
6b39a562
Commit
6b39a562
authored
Aug 07, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
locate: add "casefold" flag to parser
Fold the case during construction, without having to create another copy.
parent
0d46e118
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
26 additions
and
72 deletions
+26
-72
DatabaseCommands.cxx
src/DatabaseCommands.cxx
+8
-8
DatabasePlaylist.cxx
src/DatabasePlaylist.cxx
+2
-9
DatabasePrint.cxx
src/DatabasePrint.cxx
+2
-9
DatabaseQueue.cxx
src/DatabaseQueue.cxx
+2
-9
command.c
src/command.c
+2
-2
locate.c
src/locate.c
+7
-18
locate.h
src/locate.h
+1
-9
queue_print.c
src/queue_print.c
+2
-8
No files found.
src/DatabaseCommands.cxx
View file @
6b39a562
...
@@ -60,7 +60,7 @@ enum command_return
...
@@ -60,7 +60,7 @@ enum command_return
handle_find
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
handle_find
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
{
struct
locate_item_list
*
list
=
struct
locate_item_list
*
list
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
);
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
false
);
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
!=
NULL
)
if
(
list
!=
NULL
)
...
@@ -84,7 +84,7 @@ enum command_return
...
@@ -84,7 +84,7 @@ enum command_return
handle_findadd
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
handle_findadd
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
{
struct
locate_item_list
*
list
=
struct
locate_item_list
*
list
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
);
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
false
);
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
!=
NULL
)
if
(
list
!=
NULL
)
locate_item_list_free
(
list
);
locate_item_list_free
(
list
);
...
@@ -108,7 +108,7 @@ enum command_return
...
@@ -108,7 +108,7 @@ enum command_return
handle_search
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
handle_search
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
{
struct
locate_item_list
*
list
=
struct
locate_item_list
*
list
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
);
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
true
);
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
!=
NULL
)
if
(
list
!=
NULL
)
...
@@ -132,7 +132,7 @@ enum command_return
...
@@ -132,7 +132,7 @@ enum command_return
handle_searchadd
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
handle_searchadd
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
{
struct
locate_item_list
*
list
=
struct
locate_item_list
*
list
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
);
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
true
);
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
!=
NULL
)
if
(
list
!=
NULL
)
...
@@ -159,7 +159,7 @@ handle_searchaddpl(struct client *client, int argc, char *argv[])
...
@@ -159,7 +159,7 @@ handle_searchaddpl(struct client *client, int argc, char *argv[])
const
char
*
playlist
=
argv
[
1
];
const
char
*
playlist
=
argv
[
1
];
struct
locate_item_list
*
list
=
struct
locate_item_list
*
list
=
locate_item_list_parse
(
argv
+
2
,
argc
-
2
);
locate_item_list_parse
(
argv
+
2
,
argc
-
2
,
true
);
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
!=
NULL
)
if
(
list
!=
NULL
)
...
@@ -184,7 +184,7 @@ enum command_return
...
@@ -184,7 +184,7 @@ enum command_return
handle_count
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
handle_count
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
{
struct
locate_item_list
*
list
=
struct
locate_item_list
*
list
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
);
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
false
);
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
!=
NULL
)
if
(
list
!=
NULL
)
...
@@ -245,14 +245,14 @@ handle_list(struct client *client, int argc, char *argv[])
...
@@ -245,14 +245,14 @@ handle_list(struct client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
locate_item_list_parse
(
argv
+
1
,
argc
-
1
);
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
false
);
conditionals
=
locate_item_list_new
(
1
);
conditionals
=
locate_item_list_new
(
1
);
conditionals
->
items
[
0
].
tag
=
TAG_ARTIST
;
conditionals
->
items
[
0
].
tag
=
TAG_ARTIST
;
conditionals
->
items
[
0
].
needle
=
g_strdup
(
argv
[
2
]);
conditionals
->
items
[
0
].
needle
=
g_strdup
(
argv
[
2
]);
}
else
{
}
else
{
conditionals
=
conditionals
=
locate_item_list_parse
(
argv
+
2
,
argc
-
2
);
locate_item_list_parse
(
argv
+
2
,
argc
-
2
,
false
);
if
(
conditionals
==
NULL
)
{
if
(
conditionals
==
NULL
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"not able to parse args"
);
"not able to parse args"
);
...
...
src/DatabasePlaylist.cxx
View file @
6b39a562
...
@@ -66,15 +66,8 @@ search_add_to_playlist(const char *uri, const char *playlist_path_utf8,
...
@@ -66,15 +66,8 @@ search_add_to_playlist(const char *uri, const char *playlist_path_utf8,
{
{
const
DatabaseSelection
selection
(
uri
,
true
);
const
DatabaseSelection
selection
(
uri
,
true
);
struct
locate_item_list
*
new_list
=
locate_item_list_casefold
(
criteria
);
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
SearchAddSong
,
playlist_path_utf8
,
const
auto
f
=
std
::
bind
(
SearchAddSong
,
playlist_path_utf8
,
new_list
,
_1
,
_2
);
criteria
,
_1
,
_2
);
bool
success
=
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
return
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
locate_item_list_free
(
new_list
);
return
success
;
}
}
src/DatabasePrint.cxx
View file @
6b39a562
...
@@ -155,16 +155,9 @@ searchForSongsIn(struct client *client, const char *uri,
...
@@ -155,16 +155,9 @@ searchForSongsIn(struct client *client, const char *uri,
{
{
const
DatabaseSelection
selection
(
uri
,
true
);
const
DatabaseSelection
selection
(
uri
,
true
);
struct
locate_item_list
*
new_list
=
locate_item_list_casefold
(
criteria
);
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
SearchPrintSong
,
client
,
new_list
,
_1
);
const
auto
f
=
std
::
bind
(
SearchPrintSong
,
client
,
criteria
,
_1
);
bool
success
=
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
return
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
locate_item_list_free
(
new_list
);
return
success
;
}
}
static
bool
static
bool
...
...
src/DatabaseQueue.cxx
View file @
6b39a562
...
@@ -92,14 +92,7 @@ search_add_songs(struct player_control *pc, const char *uri,
...
@@ -92,14 +92,7 @@ search_add_songs(struct player_control *pc, const char *uri,
{
{
const
DatabaseSelection
selection
(
uri
,
true
);
const
DatabaseSelection
selection
(
uri
,
true
);
struct
locate_item_list
*
new_list
=
locate_item_list_casefold
(
criteria
);
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
SearchAddSong
,
pc
,
new_list
,
_1
,
_2
);
const
auto
f
=
std
::
bind
(
SearchAddSong
,
pc
,
criteria
,
_1
,
_2
);
bool
success
=
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
return
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
locate_item_list_free
(
new_list
);
return
success
;
}
}
src/command.c
View file @
6b39a562
...
@@ -677,7 +677,7 @@ static enum command_return
...
@@ -677,7 +677,7 @@ static enum command_return
handle_playlistfind
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
handle_playlistfind
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
{
struct
locate_item_list
*
list
=
struct
locate_item_list
*
list
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
);
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
false
);
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
!=
NULL
)
if
(
list
!=
NULL
)
...
@@ -698,7 +698,7 @@ static enum command_return
...
@@ -698,7 +698,7 @@ static enum command_return
handle_playlistsearch
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
handle_playlistsearch
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
{
struct
locate_item_list
*
list
=
struct
locate_item_list
*
list
=
locate_item_list_parse
(
argv
+
1
,
argc
-
1
);
locate_item_list_parse
(
argv
+
1
,
argc
-
1
,
true
);
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
==
NULL
||
list
->
length
==
0
)
{
if
(
list
!=
NULL
)
if
(
list
!=
NULL
)
...
...
src/locate.c
View file @
6b39a562
...
@@ -50,14 +50,17 @@ locate_parse_type(const char *str)
...
@@ -50,14 +50,17 @@ locate_parse_type(const char *str)
static
bool
static
bool
locate_item_init
(
struct
locate_item
*
item
,
locate_item_init
(
struct
locate_item
*
item
,
const
char
*
type_string
,
const
char
*
needle
)
const
char
*
type_string
,
const
char
*
needle
,
bool
fold_case
)
{
{
item
->
tag
=
locate_parse_type
(
type_string
);
item
->
tag
=
locate_parse_type
(
type_string
);
if
(
item
->
tag
<
0
)
if
(
item
->
tag
<
0
)
return
false
;
return
false
;
item
->
needle
=
g_strdup
(
needle
);
item
->
needle
=
fold_case
?
g_utf8_casefold
(
needle
,
-
1
)
:
g_strdup
(
needle
);
return
true
;
return
true
;
}
}
...
@@ -83,7 +86,7 @@ locate_item_list_new(unsigned length)
...
@@ -83,7 +86,7 @@ locate_item_list_new(unsigned length)
}
}
struct
locate_item_list
*
struct
locate_item_list
*
locate_item_list_parse
(
char
*
argv
[],
int
argc
)
locate_item_list_parse
(
char
*
argv
[],
int
argc
,
bool
fold_case
)
{
{
if
(
argc
%
2
!=
0
)
if
(
argc
%
2
!=
0
)
return
NULL
;
return
NULL
;
...
@@ -92,7 +95,7 @@ locate_item_list_parse(char *argv[], int argc)
...
@@ -92,7 +95,7 @@ locate_item_list_parse(char *argv[], int argc)
for
(
unsigned
i
=
0
;
i
<
list
->
length
;
++
i
)
{
for
(
unsigned
i
=
0
;
i
<
list
->
length
;
++
i
)
{
if
(
!
locate_item_init
(
&
list
->
items
[
i
],
argv
[
i
*
2
],
if
(
!
locate_item_init
(
&
list
->
items
[
i
],
argv
[
i
*
2
],
argv
[
i
*
2
+
1
]))
{
argv
[
i
*
2
+
1
]
,
fold_case
))
{
locate_item_list_free
(
list
);
locate_item_list_free
(
list
);
return
NULL
;
return
NULL
;
}
}
...
@@ -101,20 +104,6 @@ locate_item_list_parse(char *argv[], int argc)
...
@@ -101,20 +104,6 @@ locate_item_list_parse(char *argv[], int argc)
return
list
;
return
list
;
}
}
struct
locate_item_list
*
locate_item_list_casefold
(
const
struct
locate_item_list
*
list
)
{
struct
locate_item_list
*
new_list
=
locate_item_list_new
(
list
->
length
);
for
(
unsigned
i
=
0
;
i
<
list
->
length
;
i
++
){
new_list
->
items
[
i
].
needle
=
g_utf8_casefold
(
list
->
items
[
i
].
needle
,
-
1
);
new_list
->
items
[
i
].
tag
=
list
->
items
[
i
].
tag
;
}
return
new_list
;
}
static
bool
static
bool
locate_tag_search
(
const
struct
song
*
song
,
enum
tag_type
type
,
const
char
*
str
)
locate_tag_search
(
const
struct
song
*
song
,
enum
tag_type
type
,
const
char
*
str
)
{
{
...
...
src/locate.h
View file @
6b39a562
...
@@ -61,15 +61,7 @@ locate_item_list_new(unsigned length);
...
@@ -61,15 +61,7 @@ locate_item_list_new(unsigned length);
/* return number of items or -1 on error */
/* return number of items or -1 on error */
gcc_nonnull
(
1
)
gcc_nonnull
(
1
)
struct
locate_item_list
*
struct
locate_item_list
*
locate_item_list_parse
(
char
*
argv
[],
int
argc
);
locate_item_list_parse
(
char
*
argv
[],
int
argc
,
bool
fold_case
);
/**
* Duplicate the struct locate_item_list object and convert all
* needles with g_utf8_casefold().
*/
gcc_nonnull
(
1
)
struct
locate_item_list
*
locate_item_list_casefold
(
const
struct
locate_item_list
*
list
);
gcc_nonnull
(
1
)
gcc_nonnull
(
1
)
void
void
...
...
src/queue_print.c
View file @
6b39a562
...
@@ -95,18 +95,12 @@ void
...
@@ -95,18 +95,12 @@ void
queue_search
(
struct
client
*
client
,
const
struct
queue
*
queue
,
queue_search
(
struct
client
*
client
,
const
struct
queue
*
queue
,
const
struct
locate_item_list
*
criteria
)
const
struct
locate_item_list
*
criteria
)
{
{
unsigned
i
;
for
(
unsigned
i
=
0
;
i
<
queue_length
(
queue
);
i
++
)
{
struct
locate_item_list
*
new_list
=
locate_item_list_casefold
(
criteria
);
for
(
i
=
0
;
i
<
queue_length
(
queue
);
i
++
)
{
const
struct
song
*
song
=
queue_get
(
queue
,
i
);
const
struct
song
*
song
=
queue_get
(
queue
,
i
);
if
(
locate_song_search
(
song
,
new_list
))
if
(
locate_song_search
(
song
,
criteria
))
queue_print_song_info
(
client
,
queue
,
i
);
queue_print_song_info
(
client
,
queue
,
i
);
}
}
locate_item_list_free
(
new_list
);
}
}
void
void
...
...
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