Skip to content

Commit

Permalink
--no-glob also affects 'id3' and 'id3 -v' commands (issue #7)
Browse files Browse the repository at this point in the history
  • Loading branch information
squell committed Jan 12, 2024
1 parent f90a32d commit 250fbee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Changelog for 'id3'.

2024-012 (W02):
added ability to escape '[', '*' and '?' using a backslash in filenames
varexp.cpp: added ability to escape '[', '*' and '?' using a backslash in filenames
main.cpp: --no-glob also affects 'id3' and 'id3-v' commands

2023-180 (W26): ---------[v0.81]-----------
added test cases from a project to increase test coverage
Expand Down
29 changes: 17 additions & 12 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ inline static char* argpath(char* arg)

/* ====================================================== */

void without_globbing(fileexp::find& work, const char* name)
{
fileexp::record dummy = { };
strncpy(dummy.path, name, PATH_MAX-1);
work.file(dummy.path, dummy);
}

/* ====================================================== */

class verbose : public mass_tag {
public:
verbose(const tag::writer& write, const tag::reader& read)
Expand Down Expand Up @@ -218,14 +227,6 @@ class verbose : public mass_tag {
eprintf("could not edit tag in %s\n", f.path);
return 1;
}

public:
void without_globbing(const char* name)
{
fileexp::record dummy = { };
strncpy(dummy.path, name, PATH_MAX-1);
file(dummy.path, dummy);
}
};

bool verbose::enable;
Expand Down Expand Up @@ -571,15 +572,19 @@ int main_(int argc, char *argv[])
eprintf("cannot combine -q with any modifying operation\n");
shelp();
case op::no_op:
if(verbose::enable)
return process_(tag, &argv[i], state & recur);
listtag viewer(*source);
return process_(viewer, &argv[i], state & recur);
fileexp::find& work = verbose::enable? (fileexp::find&)tag : viewer;
if(state & noglob) {
without_globbing(tag, argv[i]);
if(argv[i+1]) continue; else return exitc;
} else {
return process_(work, &argv[i], state & recur);
}
}

verbose tagger(*selected, *source);
if(state & noglob) {
tagger.without_globbing(argv[i]);
without_globbing(tagger, argv[i]);
if(argv[i+1]) continue; else return exitc;
} else {
return process_(tagger, &argv[i], state & recur);
Expand Down

0 comments on commit 250fbee

Please sign in to comment.