Conversation
These functions are used to load all external files, not only subtitles.
Similar to the method used elsewhere in mpv.
The documentation says that the scripts are loaded in alphabetical order, which indicates that the case is not sensitive. Use strcasecmp to satisfy this requirement.
These functions always set endptr to non-null so there is no need to check.
Prevents UB if the value cannot be represented.
misc/bstr.c
Outdated
| return true; | ||
| } | ||
|
|
||
| int bstr_find_in_list(bstr str, char **list, bool case_sensitive) |
There was a problem hiding this comment.
shouldn't this be bstr str, bstr *list?
There was a problem hiding this comment.
Converting char ** list to bstr * list is bothersome and needs memory allocation, so I want to keep it accepting char ** for now. How about renaming it to bstr_find_in_list0?
There was a problem hiding this comment.
I think list0 would be consistent with other bstr function naming.
There was a problem hiding this comment.
OK, changed the name.
demux/demux_playlist.c
Outdated
|
|
||
| bstr ext = bstr_get_ext(bstr0(path)); | ||
| if (autocreate & AUTO_VIDEO && str_in_list(ext, p->mp_opts->video_exts)) | ||
| if (autocreate & AUTO_VIDEO && bstr_in_list(ext, p->mp_opts->video_exts, false)) |
There was a problem hiding this comment.
Does it have to be false everywhere?
There was a problem hiding this comment.
All current uses are false, but future changes can use true. Because it is a general function, if the parameter is dropped the function needs to be renamed to something like bstr_case_in_list which is less general and not much less typing.
There was a problem hiding this comment.
All current uses are false, but future changes can use true.
When future uses use true it can be evaluated how to proceed with that.
In general I don't see why you would need case sensitive lookup like that, in most cases you want it to be insensitive, so I don't expect future uses to change that.
There was a problem hiding this comment.
Changed to always case insensitive for bstr_in_list0.
This will be used to unify several find in list handlings.
Rename it to bstr_in_list0 and implement it in bstr_find_in_list0.
Removes redundant find_list_bstr function.
Since cb56c2f, the priority of --cover-art-auto and --cover-art-whitelist is unclear. Depending on the number of elements in --cover-art-whitelist, the priority of --cover-art-whitelist files can be lower, equal, or higher than --cover-art-auto matches, creating unpredictable behavior. Fix this by making --cover-art-whitelist priority always between "fuzzy" and "all" priority. test_cover_filename now uses bstr_find_in_list0 to return a negative priority value depending on the position in list. The "all" priority is set to INT_MIN. Modify filter_subidx to use 0 priority as removal marker, since all files in the external files list already have non-zero priority.
They are not considered potential external files.
Various string related fixes. Add
bstr_find_in_listfunction to unify several similar handlings and also use it to fix--cover-art-whitelistpriority.