Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
1fb78f47
Commit
1fb78f47
authored
Oct 18, 2009
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Subtitles: small fixes and cosmetics
and for counter scopes
parent
a4b3126b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
17 deletions
+15
-17
src/input/subtitles.c
src/input/subtitles.c
+15
-17
No files found.
src/input/subtitles.c
View file @
1fb78f47
/*****************************************************************************
/*****************************************************************************
* subtitles.c
* subtitles.c
: subtitles detection
*****************************************************************************
*****************************************************************************
* Copyright (C) 2003-200
6
the VideoLAN team
* Copyright (C) 2003-200
9
the VideoLAN team
* $Id$
* $Id$
*
*
* Authors: Derk-Jan Hartman <hartman at videolan.org>
* Authors: Derk-Jan Hartman <hartman at videolan.org>
...
@@ -32,7 +32,6 @@
...
@@ -32,7 +32,6 @@
#endif
#endif
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_input.h>
#include <vlc_charset.h>
#include <vlc_charset.h>
#include <vlc_url.h>
#include <vlc_url.h>
...
@@ -40,14 +39,14 @@
...
@@ -40,14 +39,14 @@
# include <dirent.h>
# include <dirent.h>
#endif
#endif
#include <limits.h>
#ifdef HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
# include <unistd.h>
# include <unistd.h>
#endif
#endif
#include <sys/stat.h>
#include <sys/stat.h>
#include <ctype.h>
#include <ctype.h>
/* isalnum */
#include "input_internal.h"
#include "input_internal.h"
/**
/**
...
@@ -55,7 +54,6 @@
...
@@ -55,7 +54,6 @@
*/
*/
#define MAX_SUBTITLE_FILES 128
#define MAX_SUBTITLE_FILES 128
/**
/**
* The possible extensions for subtitle files we support
* The possible extensions for subtitle files we support
*/
*/
...
@@ -136,11 +134,11 @@ static int whiteonly( const char *s )
...
@@ -136,11 +134,11 @@ static int whiteonly( const char *s )
enum
enum
{
{
SUB_PRIORITY_NONE
=
0
,
SUB_PRIORITY_NONE
=
0
,
SUB_PRIORITY_MATCH_NONE
=
1
,
SUB_PRIORITY_MATCH_NONE
=
1
,
SUB_PRIORITY_MATCH_RIGHT
=
2
,
SUB_PRIORITY_MATCH_RIGHT
=
2
,
SUB_PRIORITY_MATCH_LEFT
=
3
,
SUB_PRIORITY_MATCH_LEFT
=
3
,
SUB_PRIORITY_MATCH_ALL
=
4
,
SUB_PRIORITY_MATCH_ALL
=
4
,
};
};
typedef
struct
typedef
struct
{
{
...
@@ -173,13 +171,12 @@ static int compare_sub_priority( const void *a, const void *b )
...
@@ -173,13 +171,12 @@ static int compare_sub_priority( const void *a, const void *b )
int
subtitles_Filter
(
const
char
*
psz_dir_content
)
int
subtitles_Filter
(
const
char
*
psz_dir_content
)
{
{
const
char
*
tmp
=
strrchr
(
psz_dir_content
,
'.'
);
const
char
*
tmp
=
strrchr
(
psz_dir_content
,
'.'
);
int
i
;
if
(
!
tmp
)
if
(
!
tmp
)
return
0
;
return
0
;
tmp
++
;
tmp
++
;
for
(
i
=
0
;
sub_exts
[
i
][
0
];
i
++
)
for
(
i
nt
i
=
0
;
sub_exts
[
i
][
0
];
i
++
)
if
(
strcasecmp
(
sub_exts
[
i
],
tmp
)
==
0
)
if
(
strcasecmp
(
sub_exts
[
i
],
tmp
)
==
0
)
return
1
;
return
1
;
return
0
;
return
0
;
...
@@ -262,16 +259,18 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
...
@@ -262,16 +259,18 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
vlc_subfn_t
*
result
=
NULL
;
/* unsorted results */
vlc_subfn_t
*
result
=
NULL
;
/* unsorted results */
char
**
result2
;
/* sorted results */
char
**
result2
;
/* sorted results */
const
char
*
psz_fname
=
psz_name_org
;
if
(
!
psz_fname
)
if
(
!
psz_fname
)
return
NULL
;
return
NULL
;
const
char
*
psz_fname
=
decode_URI
(
psz_name_org
);
if
(
!
strncmp
(
psz_fname
,
"file://"
,
7
)
)
if
(
!
strncmp
(
psz_fname
,
"file://"
,
7
)
)
{
{
psz_fname
+=
7
;
psz_fname
+=
7
;
if
(
!
strncmp
(
psz_fname
,
"localhost"
,
9
)
)
if
(
!
strncmp
(
psz_fname
,
"localhost"
,
9
)
)
psz_fname
+=
9
;
psz_fname
+=
9
;
}
}
psz_fname
=
decode_URI
(
psz_fname
);
/* extract filename & dirname from psz_fname */
/* extract filename & dirname from psz_fname */
tmp
=
strrchr
(
psz_fname
,
DIR_SEP_CHAR
);
tmp
=
strrchr
(
psz_fname
,
DIR_SEP_CHAR
);
...
@@ -329,7 +328,6 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
...
@@ -329,7 +328,6 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
const
char
*
psz_dir
=
j
<
0
?
f_dir
:
subdirs
[
j
];
const
char
*
psz_dir
=
j
<
0
?
f_dir
:
subdirs
[
j
];
char
**
ppsz_dir_content
;
char
**
ppsz_dir_content
;
int
i_dir_content
;
int
i_dir_content
;
int
a
;
if
(
psz_dir
==
NULL
||
(
j
>=
0
&&
!
strcmp
(
psz_dir
,
f_dir
)
)
)
if
(
psz_dir
==
NULL
||
(
j
>=
0
&&
!
strcmp
(
psz_dir
,
f_dir
)
)
)
continue
;
continue
;
...
@@ -341,7 +339,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
...
@@ -341,7 +339,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
continue
;
continue
;
msg_Dbg
(
p_this
,
"looking for a subtitle file in %s"
,
psz_dir
);
msg_Dbg
(
p_this
,
"looking for a subtitle file in %s"
,
psz_dir
);
for
(
a
=
0
;
a
<
i_dir_content
&&
i_sub_count
<
MAX_SUBTITLE_FILES
;
a
++
)
for
(
int
a
=
0
;
a
<
i_dir_content
&&
i_sub_count
<
MAX_SUBTITLE_FILES
;
a
++
)
{
{
char
*
psz_name
=
ppsz_dir_content
[
a
];
char
*
psz_name
=
ppsz_dir_content
[
a
];
char
tmp_fname_noext
[
strlen
(
psz_name
)
+
1
];
char
tmp_fname_noext
[
strlen
(
psz_name
)
+
1
];
...
@@ -415,7 +413,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
...
@@ -415,7 +413,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
}
}
if
(
ppsz_dir_content
)
if
(
ppsz_dir_content
)
{
{
for
(
a
=
0
;
a
<
i_dir_content
;
a
++
)
for
(
int
a
=
0
;
a
<
i_dir_content
;
a
++
)
free
(
ppsz_dir_content
[
a
]
);
free
(
ppsz_dir_content
[
a
]
);
free
(
ppsz_dir_content
);
free
(
ppsz_dir_content
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment