mirror of
https://github.com/fmang/opustags.git
synced 2025-01-28 19:05:03 +01:00
Make read_comments work on std::list
For consistency with ot::opus_tags.
This commit is contained in:
parent
6da5545b30
commit
7206604f85
@ -138,13 +138,11 @@ ot::status ot::parse_options(int argc, char** argv, ot::options& opt, FILE* comm
|
||||
|
||||
if (set_all) {
|
||||
// Read comments from stdin and prepend them to opt.to_add.
|
||||
std::vector<std::string> comments;
|
||||
std::list<std::string> comments;
|
||||
auto rc = read_comments(comments_input, comments);
|
||||
if (rc != st::ok)
|
||||
return rc;
|
||||
comments.reserve(comments.size() + opt.to_add.size());
|
||||
std::move(opt.to_add.begin(), opt.to_add.end(), std::back_inserter(comments));
|
||||
opt.to_add = std::move(comments);
|
||||
opt.to_add.splice(opt.to_add.begin(), std::move(comments));
|
||||
}
|
||||
return st::ok;
|
||||
}
|
||||
@ -192,7 +190,7 @@ void ot::print_comments(const std::list<std::string>& comments, FILE* output)
|
||||
fputs("warning: Some tags contain control characters.\n", stderr);
|
||||
}
|
||||
|
||||
ot::status ot::read_comments(FILE* input, std::vector<std::string>& comments)
|
||||
ot::status ot::read_comments(FILE* input, std::list<std::string>& comments)
|
||||
{
|
||||
static ot::encoding_converter to_utf8("", "UTF-8");
|
||||
comments.clear();
|
||||
|
@ -430,7 +430,7 @@ struct options {
|
||||
*
|
||||
* Options: --add, --set, --set-all
|
||||
*/
|
||||
std::vector<std::string> to_add;
|
||||
std::list<std::string> to_add;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -456,7 +456,7 @@ void print_comments(const std::list<std::string>& comments, FILE* output);
|
||||
*
|
||||
* The comments are converted from the system encoding to UTF-8, and returned as UTF-8.
|
||||
*/
|
||||
status read_comments(FILE* input, std::vector<std::string>& comments);
|
||||
status read_comments(FILE* input, std::list<std::string>& comments);
|
||||
|
||||
/**
|
||||
* Remove all comments matching the specified selector, which may either be a field name or a
|
||||
|
6
t/cli.cc
6
t/cli.cc
@ -7,7 +7,7 @@ using namespace std::literals::string_literals;
|
||||
|
||||
void check_read_comments()
|
||||
{
|
||||
std::vector<std::string> comments;
|
||||
std::list<std::string> comments;
|
||||
ot::status rc;
|
||||
{
|
||||
std::string txt = "TITLE=a b c\n\nARTIST=X\nArtist=Y\n"s;
|
||||
@ -72,13 +72,13 @@ void check_good_arguments()
|
||||
if (opt.paths_in.size() != 1 || opt.paths_in.front() != "x" || !opt.path_out ||
|
||||
opt.path_out != "y" || !opt.delete_all || opt.overwrite || opt.to_delete.size() != 2 ||
|
||||
opt.to_delete[0] != "X" || opt.to_delete[1] != "a=b" ||
|
||||
opt.to_add.size() != 1 || opt.to_add[0] != "X=Y Z")
|
||||
opt.to_add != std::list<std::string>{"X=Y Z"})
|
||||
throw failure("unexpected option parsing result for case #1");
|
||||
|
||||
opt = parse({"opustags", "-S", "x", "-S", "-a", "x=y z", "-i"});
|
||||
if (opt.paths_in.size() != 1 || opt.paths_in.front() != "x" || opt.path_out ||
|
||||
!opt.overwrite || opt.to_delete.size() != 0 ||
|
||||
opt.to_add.size() != 2 || opt.to_add[0] != "N=1" || opt.to_add[1] != "x=y z")
|
||||
opt.to_add != std::list<std::string>{"N=1", "x=y z"})
|
||||
throw failure("unexpected option parsing result for case #2");
|
||||
|
||||
opt = parse({"opustags", "-i", "x", "y", "z"});
|
||||
|
Loading…
x
Reference in New Issue
Block a user