1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- $OpenBSD: patch-libdjvu_DjVmDir_cpp,v 1.1 2016/03/02 20:10:36 juanfra Exp $
- "accept documents with duplicate page titles"
- http://sourceforge.net/p/djvu/djvulibre-git/ci/77a4dca8dd3acd0acc1680fa14a352c11084e25d/
- https://bitbucket.org/jwilk/pdf2djvu/issues/113/duplicate-page-title-1
- --- libdjvu/DjVmDir.cpp.orig Tue Jul 8 23:15:07 2014
- +++ libdjvu/DjVmDir.cpp Wed Feb 3 01:51:28 2016
- @@ -223,7 +223,6 @@ DjVmDir::decode(const GP<ByteStream> &gstr)
- page2file.resize(-1);
- name2file.empty();
- id2file.empty();
- - title2file.empty();
-
- int ver=str.read8();
- bool bundled=(ver & 0x80)!=0;
- @@ -375,18 +374,6 @@ DjVmDir::decode(const GP<ByteStream> &gstr)
- G_THROW( ERR_MSG("DjVmDir.dupl_id") "\t" + file->id);
- id2file[file->id]=file;
- }
- -
- - // Generate title2file map
- - for(pos=files_list;pos;++pos)
- - {
- - GP<File> file=files_list[pos];
- - if (file->title.length())
- - {
- - if (title2file.contains(file->title))
- - G_THROW( ERR_MSG("DjVmDir.dupl_title") "\t" + file->title);
- - title2file[file->title]=file;
- - }
- - }
- }
- }
-
- @@ -556,11 +543,19 @@ DjVmDir::id_to_file(const GUTF8String &id) const
- }
-
- GP<DjVmDir::File>
- -DjVmDir::title_to_file(const GUTF8String &title) const
- +DjVmDir::title_to_file(const GUTF8String &title, GPosition spos) const
- {
- - GCriticalSectionLock lock((GCriticalSection *) &class_lock);
- - GPosition pos;
- - return (title2file.contains(title, pos))?title2file[pos]:(GP<DjVmDir::File>(0));
- + if (! title)
- + return 0;
- + GCriticalSectionLock lock((GCriticalSection *) &class_lock);
- + if (! spos)
- + for (GPosition pos = spos; pos; ++pos)
- + if (files_list[pos]->is_page() && files_list[pos]->title == title)
- + return files_list[pos];
- + for (GPosition pos = files_list; pos; ++pos)
- + if (files_list[pos]->is_page() && files_list[pos]->title == title)
- + return files_list[pos];
- + return 0;
- }
-
- GP<DjVmDir::File>
- @@ -661,14 +656,7 @@ DjVmDir::insert_file(const GP<File> & file, int pos_nu
- G_THROW( ERR_MSG("DjVmDir.dupl_name2") "\t" + file->name);
- name2file[file->name]=file;
- id2file[file->id]=file;
- - if (file->title.length())
- - {
- - if (title2file.contains(file->title))
- - // duplicate titles may become ok some day
- - G_THROW( ERR_MSG("DjVmDir.dupl_title2") "\t" + file->title);
- - title2file[file->title]=file;
- - }
- -
- +
- // Make sure that there is no more than one file with shared annotations
- if (file->is_shared_anno())
- {
- @@ -727,7 +715,6 @@ DjVmDir::delete_file(const GUTF8String &id)
- {
- name2file.del(f->name);
- id2file.del(f->id);
- - title2file.del(f->title);
- if (f->is_page())
- {
- for(int page=0;page<page2file.size();page++)
- @@ -788,9 +775,7 @@ DjVmDir::set_file_title(const GUTF8String &id, const G
- if (!id2file.contains(id, pos))
- G_THROW( ERR_MSG("DjVmDir.no_info") "\t" + GUTF8String(id));
- GP<File> file=id2file[pos];
- - title2file.del(file->title);
- file->title=title;
- - title2file[title]=file;
- }
-
- GPList<DjVmDir::File>
|