[libdvdnav-devel] [PATCH 3/7] Use correct constant
Petri Hintukainen
phintuka at gmail.com
Thu May 21 10:36:58 CEST 2015
On to, 2015-05-21 at 11:39 +1200, Lawrence D'Oliveiro wrote:
> On Wed, 20 May 2015 13:41:38 +0300, Petri Hintukainen wrote:
>
> > #if defined(_WIN32) || defined(__OS2__)
> > - if(strlen(path_copy) > TITLES_MAX) {
> > - if(!strcasecmp(&(path_copy[strlen( path_copy ) - TITLES_MAX]),
> > + if( strlen( path_copy ) > 9 ) {
> > + if( !strcasecmp( &(path_copy[ strlen( path_copy ) - 9 ]),
> > "\\video_ts"))
> > - path_copy[strlen(path_copy) - (TITLES_MAX-1)] = '\0';
> > + path_copy[ strlen( path_copy ) - (9-1) ] = '\0';
> ^^^
> > }
> > #endif
> > - if( strlen( path_copy ) > TITLES_MAX ) {
> > - if( !strcasecmp( &(path_copy[ strlen( path_copy ) - TITLES_MAX
> > ]),
> > + if( strlen( path_copy ) > 9 ) {
> > + if( !strcasecmp( &(path_copy[ strlen( path_copy ) - 9 ]),
> > "/video_ts" ) ) {
> > - path_copy[ strlen( path_copy ) - TITLES_MAX ] = '\0';
> > + path_copy[ strlen( path_copy ) - 9 ] = '\0';
> ^
> > }
> > }
> >
>
> Why is one of these “9-1” and the other “9”? Both strings are the same
> length.
It preserves the slash in Windows. Without it ex. D:\VIDEO_TS would
become D: , not D:\ . But, don't ask why it is needed (the code was like
that before).
With quick search I didn't find any place where it would matter if we
have D: or D:\ . Actually, that string (path_copy) is not even used in
Windows...
Maybe some other change made it unused. Maybe it was used ages ago in
some other fork of the library. Or maybe it is there just because of the
function is a big mess of system-specific ifdefs ...
In most Unix-like systems trailing slash must be removed or mount point
search won't work. And there's another check that handles the special
case when VIDEO_TS is directly under root ...
- Petri
More information about the libdvdnav-devel
mailing list