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
28ad4a41
Commit
28ad4a41
authored
Jan 21, 2003
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* sub.c: fixed handling for subrip subtitle with \r\n instead of \n and
added some sanity checks.
parent
ec6e7418
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
modules/demux/util/sub.c
modules/demux/util/sub.c
+18
-12
No files found.
modules/demux/util/sub.c
View file @
28ad4a41
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* sub.c
* sub.c
*****************************************************************************
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* Copyright (C) 1999-2001 VideoLAN
* $Id: sub.c,v 1.
1 2002/11/15 18:10:26
fenrir Exp $
* $Id: sub.c,v 1.
2 2003/01/21 16:46:17
fenrir Exp $
*
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
*
...
@@ -533,7 +533,7 @@ static int sub_MicroDvdRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_mi
...
@@ -533,7 +533,7 @@ static int sub_MicroDvdRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_mi
}
}
p_subtitle
->
i_start
=
(
mtime_t
)
i_start
*
(
mtime_t
)
i_microsecperframe
;
p_subtitle
->
i_start
=
(
mtime_t
)
i_start
*
(
mtime_t
)
i_microsecperframe
;
p_subtitle
->
i_stop
=
(
mtime_t
)
i_stop
*
(
mtime_t
)
i_microsecperframe
;
p_subtitle
->
i_stop
=
(
mtime_t
)
i_stop
*
(
mtime_t
)
i_microsecperframe
;
p_subtitle
->
psz_text
=
str
dup
(
buffer_text
);
p_subtitle
->
psz_text
=
str
ndup
(
buffer_text
,
MAX_LINE
);
return
(
0
);
return
(
0
);
}
}
...
@@ -557,11 +557,11 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr
...
@@ -557,11 +557,11 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr
for
(
;;
)
for
(
;;
)
{
{
int
h1
,
m1
,
s1
,
d1
,
h2
,
m2
,
s2
,
d2
;
int
h1
,
m1
,
s1
,
d1
,
h2
,
m2
,
s2
,
d2
;
if
(
fgets
(
buffer
,
MAX_LINE
,
p_file
)
<=
0
)
if
(
fgets
(
buffer
,
MAX_LINE
,
p_file
)
<=
0
)
{
{
return
(
-
1
);
return
(
-
1
);
}
}
if
(
sscanf
(
buffer
,
if
(
sscanf
(
buffer
,
"%d:%d:%d,%d --> %d:%d:%d,%d"
,
"%d:%d:%d,%d --> %d:%d:%d,%d"
,
&
h1
,
&
m1
,
&
s1
,
&
d1
,
&
h1
,
&
m1
,
&
s1
,
&
d1
,
&
h2
,
&
m2
,
&
s2
,
&
d2
)
==
8
)
&
h2
,
&
m2
,
&
s2
,
&
d2
)
==
8
)
...
@@ -575,7 +575,7 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr
...
@@ -575,7 +575,7 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr
(
mtime_t
)
m2
*
60
*
1000
+
(
mtime_t
)
m2
*
60
*
1000
+
(
mtime_t
)
s2
*
1000
+
(
mtime_t
)
s2
*
1000
+
(
mtime_t
)
d2
)
*
1000
;
(
mtime_t
)
d2
)
*
1000
;
/* Now read text until an empty line */
/* Now read text until an empty line */
for
(
i_buffer_text
=
0
;;
)
for
(
i_buffer_text
=
0
;;
)
{
{
...
@@ -584,9 +584,11 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr
...
@@ -584,9 +584,11 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr
{
{
return
(
-
1
);
return
(
-
1
);
}
}
buffer
[
MAX_LINE
]
=
'\0'
;
// just in case
i_len
=
strlen
(
buffer
);
i_len
=
strlen
(
buffer
);
if
(
i_len
<=
1
)
// newline
if
(
buffer
[
0
]
==
'\r'
||
buffer
[
0
]
==
'\n'
||
i_len
<=
1
)
{
{
// empty line -> end of this subtitle
buffer_text
[
__MAX
(
i_buffer_text
-
1
,
0
)]
=
'\0'
;
buffer_text
[
__MAX
(
i_buffer_text
-
1
,
0
)]
=
'\0'
;
p_subtitle
->
i_start
=
i_start
;
p_subtitle
->
i_start
=
i_start
;
p_subtitle
->
i_stop
=
i_stop
;
p_subtitle
->
i_stop
=
i_stop
;
...
@@ -595,12 +597,16 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr
...
@@ -595,12 +597,16 @@ static int sub_SubRipRead( FILE *p_file, subtitle_t *p_subtitle, mtime_t i_micr
}
}
else
else
{
{
memcpy
(
buffer_text
+
i_buffer_text
,
if
(
i_buffer_text
+
i_len
+
1
<
10
*
MAX_LINE
)
buffer
,
{
i_len
);
memcpy
(
buffer_text
+
i_buffer_text
,
i_buffer_text
+=
i_len
;
buffer
,
buffer_text
[
i_buffer_text
]
=
'\n'
;
i_len
);
i_buffer_text
++
;
i_buffer_text
+=
i_len
;
buffer_text
[
i_buffer_text
]
=
'\n'
;
i_buffer_text
++
;
}
}
}
}
}
}
}
...
...
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