+ // Count chapters in the title.
+ unsigned n_chapters = 0;
+ for (vob_list::const_iterator
+ it = contents.titles[title_index].begin(),
+ end = contents.titles[title_index].end();
+ it != end;
+ ++it)
+ {
+ // Chapter start times may be specified in the "chapters"
+ // attribute as a comma-separated list. If this is not
+ // specified then the beginning of each file starts a new
+ // chapter. Thus the number of chapters in each file is
+ // the number of commas in the chapter attribute, plus 1.
+ ++n_chapters;
+ std::size_t pos = 0;
+ while ((pos = it->chapters.find(',', pos)) != std::string::npos)
+ {
+ ++n_chapters;
+ ++pos;
+ }
+ }
+
+ // Generate jump "table" for chapters.
+ for (unsigned chapter_num = 1;
+ chapter_num <= n_chapters;
+ ++chapter_num)
+ file <<
+ " if (g3 == " << chapter_num << ")\n"
+ " jump chapter " << chapter_num << ";\n";
+
+ file <<
+ " </pre>\n";
+
+ for (vob_list::const_iterator
+ it = contents.titles[title_index].begin(),
+ end = contents.titles[title_index].end();