From 99bdab5d699f740b053f6201e3e57de64c9c1d0f Mon Sep 17 00:00:00 2001 From: "Marshall T. Vandegrift" Date: Thu, 18 Dec 2008 22:31:23 -0500 Subject: [PATCH 1/3] Fix Windows LZX compression endianness bug --- src/calibre/utils/lzx/lzxc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/utils/lzx/lzxc.c b/src/calibre/utils/lzx/lzxc.c index 1617e544d2..626c829480 100644 --- a/src/calibre/utils/lzx/lzxc.c +++ b/src/calibre/utils/lzx/lzxc.c @@ -32,9 +32,11 @@ #include #include -#if BYTE_ORDER == BIG_ENDIAN -#define LZX_BIG_ENDIAN -#endif +#ifdef BYTE_ORDER +# if BYTE_ORDER == BIG_ENDIAN +# define LZX_BIG_ENDIAN +# endif /* BYTE_ORDER == BIG_ENDIAN */ +#endif /* BYTE_ORDER */ #ifdef NONSLIDE #include "lzc.h" From 9a30cdc3f2a7812ffc1d4b3a30ac6d4fe33e2616 Mon Sep 17 00:00:00 2001 From: "Marshall T. Vandegrift" Date: Thu, 18 Dec 2008 22:37:04 -0500 Subject: [PATCH 2/3] Fix invalid /guide/reference detection bug. --- src/calibre/ebooks/lit/oeb.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/lit/oeb.py b/src/calibre/ebooks/lit/oeb.py index 339783f350..9bf1eb8c82 100644 --- a/src/calibre/ebooks/lit/oeb.py +++ b/src/calibre/ebooks/lit/oeb.py @@ -583,7 +583,8 @@ class OEBBook(object): self.guide = guide = Guide(self) for elem in xpath(opf, '/o2:package/o2:guide/o2:reference'): href = elem.get('href') - if href not in self.manifest.hrefs: + path, frag = urldefrag(href) + if path not in self.manifest.hrefs: self.logger.log_warn(u'Guide reference %r not found' % href) continue guide.add(elem.get('type'), elem.get('title'), href) From 6550c18745c5eb6b4b424f5a9b9bcb96fa5fe6d2 Mon Sep 17 00:00:00 2001 From: "Marshall T. Vandegrift" Date: Thu, 18 Dec 2008 22:51:25 -0500 Subject: [PATCH 3/3] Detect an NCX TOC which isn't mentioned by the /spine/@toc. --- src/calibre/ebooks/lit/oeb.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/lit/oeb.py b/src/calibre/ebooks/lit/oeb.py index 9bf1eb8c82..acc3275876 100644 --- a/src/calibre/ebooks/lit/oeb.py +++ b/src/calibre/ebooks/lit/oeb.py @@ -602,7 +602,10 @@ class OEBBook(object): def _toc_from_ncx(self, opf): result = xpath(opf, '/o2:package/o2:spine/@toc') if not result: - return False + expr = '/o2:package/o2:manifest/o2:item[@media-type="%s"]/@id' + result = xpath(opf, expr % NCX_MIME) + if len(result) != 1: + return False id = result[0] ncx = self.manifest[id].data self.manifest.remove(id)