summaryrefslogtreecommitdiffstats
path: root/subreader.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-06-07 19:01:15 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 04:07:12 +0200
commitc280fd08c3ee5b81dc3ef83d274cd9972c5c29bc (patch)
tree7565fc3e1f865f4de8d3e335d6b26f87ae3dff82 /subreader.c
parent074e6b4622429ee4f378d31be7537f72e4d4e7f2 (diff)
downloadmpv-c280fd08c3ee5b81dc3ef83d274cd9972c5c29bc.tar.bz2
mpv-c280fd08c3ee5b81dc3ef83d274cd9972c5c29bc.tar.xz
subreader.c: Extract duplicated code into a separate function.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31346 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'subreader.c')
-rw-r--r--subreader.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/subreader.c b/subreader.c
index 200fd6f9f5..63fed5d156 100644
--- a/subreader.c
+++ b/subreader.c
@@ -109,6 +109,15 @@ static char *stristr(const char *haystack, const char *needle) {
return NULL;
}
+static void sami_add_line(subtitle *current, char *buffer, char **pos) {
+ char *p = *pos;
+ *p = 0;
+ trail_space(buffer);
+ if (*buffer && current->lines < SUB_MAX_TEXT)
+ current->text[current->lines++] = strdup(buffer);
+ *pos = buffer;
+}
+
static subtitle *sub_read_line_sami(stream_t* st, subtitle *current, int utf16) {
static char line[LINE_LEN+1];
static char *s = NULL, *slacktime_s;
@@ -160,9 +169,7 @@ static subtitle *sub_read_line_sami(stream_t* st, subtitle *current, int utf16)
case 3: /* get all text until '<' appears */
if (*s == '\0') break;
else if (!strncasecmp (s, "<br>", 4)) {
- *p = '\0'; p = text; trail_space (text);
- if (text[0] != '\0' && current->lines < SUB_MAX_TEXT)
- current->text[current->lines++] = strdup (text);
+ sami_add_line(current, text, &p);
s += 4;
}
else if ((*s == '{') && !sub_no_text_pp) { state = 5; ++s; continue; }
@@ -241,9 +248,7 @@ static subtitle *sub_read_line_sami(stream_t* st, subtitle *current, int utf16)
// For the last subtitle
if (current->end <= 0) {
current->end = current->start + sub_slacktime;
- *p = '\0'; trail_space (text);
- if (text[0] != '\0' && current->lines < SUB_MAX_TEXT)
- current->text[current->lines++] = strdup (text);
+ sami_add_line(current, text, &p);
}
return current;