summaryrefslogtreecommitdiff
path: root/src/lib/subrip.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-01-15 11:07:04 +0000
committerCarl Hetherington <cth@carlh.net>2014-01-15 11:07:04 +0000
commita890bedf688f0066d70dd5e9b07cbd86736cc0b1 (patch)
tree683fdd79cfd5e218df23a46fa990b1965f6e5b59 /src/lib/subrip.cc
parentf9608c5299d0a58bc01b33e521d89a80be26ed23 (diff)
More testing / SubRip parse fixes.
Diffstat (limited to 'src/lib/subrip.cc')
-rw-r--r--src/lib/subrip.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/subrip.cc b/src/lib/subrip.cc
index 1fdadf87e..04765532f 100644
--- a/src/lib/subrip.cc
+++ b/src/lib/subrip.cc
@@ -29,6 +29,7 @@
using std::string;
using std::list;
using std::vector;
+using std::cout;
using boost::shared_ptr;
using boost::lexical_cast;
using boost::algorithm::trim;
@@ -54,8 +55,12 @@ SubRip::SubRip (shared_ptr<SubRipContent> content)
while (!feof (f)) {
fgets (buffer, sizeof (buffer), f);
+ if (feof (f)) {
+ break;
+ }
+
string line (buffer);
- trim (line);
+ trim_right_if (line, boost::is_any_of ("\n\r"));
switch (state) {
case COUNTER:
@@ -93,6 +98,7 @@ SubRip::SubRip (shared_ptr<SubRipContent> content)
current->y1 = convert_coordinate (p[5]);
current->y2 = convert_coordinate (p[6]);
}
+ state = CONTENT;
break;
}
case CONTENT:
@@ -109,6 +115,11 @@ SubRip::SubRip (shared_ptr<SubRipContent> content)
}
}
+ if (state == CONTENT) {
+ current->pieces = convert_content (lines);
+ _subtitles.push_back (current.get ());
+ }
+
fclose (f);
}
@@ -217,7 +228,6 @@ SubRip::convert_content (list<string> t)
Time
SubRip::length () const
{
- boost::mutex::scoped_lock lm (_mutex);
if (_subtitles.empty ()) {
return 0;
}