Skip to content

subtitles: better path list splitter + cleanup

Lyndon Brown requested to merge jnqnfe/vlc:subtitles_sizet into master
  • The helper that splits up the string list of extra paths to look for subtitles in has been overhauled:
    • It now handles ignoring spaces on the front of the string and on the end of list items.
    • It now removes the relative directory indicator ("./" / ".\\") when prepending basedir.
    • It now handles ensuring each path ends with a directory separator, rather than this being done on a per file basis in the directory scanning logic.
  • The big chunk of code in subtitles_Detect() that searches the contents of each directory has been moved out into a separate function, making things more manageable, and allowed removal of the ugly loop hack to get the current directory to be scanned as well as the list of extra directories.
  • Since these two functions were going through such big changes here anyway, and since many ugly variables names were having a significant negative impact upon the ability to understand the code, I ended up cleaning this up in addition.

Note: I put the new list splitter helper algorithm through a thorough set of tests in a unit test. It covers all cases the previous implementation did and goes beyond this to cover various additional poorly constructed inputs. I have not currently included the unit test in this MR since I built it outside of the codebase and I'm currently struggling with build system issues in trying to include it.

Edited by Lyndon Brown

Merge request reports