diff options
-rw-r--r-- | poppler/Catalog.cc | 12 | ||||
-rw-r--r-- | poppler/Catalog.h | 2 | ||||
-rw-r--r-- | utils/pdftotext.cc | 6 |
3 files changed, 18 insertions, 2 deletions
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc index a06ae5f5..44643468 100644 --- a/poppler/Catalog.cc +++ b/poppler/Catalog.cc @@ -29,6 +29,7 @@ // Copyright (C) 2013 Julien Nabet <serval2412@yahoo.fr> // Copyright (C) 2013 Adrian Perez de Castro <aperez@igalia.com> // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013 José Aliste <jaliste@src.gnome.org> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -666,9 +667,20 @@ void NameTree::addEntry(Entry *entry) ++length; } +int NameTree::Entry::cmpEntry(const void *voidEntry, const void *voidOtherEntry) +{ + Entry *entry = *(NameTree::Entry **) voidEntry; + Entry *otherEntry = *(NameTree::Entry **) voidOtherEntry; + + return entry->name.cmp(&otherEntry->name); +} + void NameTree::init(XRef *xrefA, Object *tree) { xref = xrefA; parse(tree); + if (entries && length > 0) { + qsort(entries, length, sizeof(Entry *), Entry::cmpEntry); + } } void NameTree::parse(Object *tree) { diff --git a/poppler/Catalog.h b/poppler/Catalog.h index 40c783c7..bc9ce20b 100644 --- a/poppler/Catalog.h +++ b/poppler/Catalog.h @@ -24,6 +24,7 @@ // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2013 Adrian Perez de Castro <aperez@igalia.com> // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013 José Aliste <jaliste@src.gnome.org> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -80,6 +81,7 @@ private: GooString name; Object value; void free(); + static int cmpEntry(const void *voidEntry, const void *voidOtherEntry); static int cmp(const void *key, const void *entry); }; diff --git a/utils/pdftotext.cc b/utils/pdftotext.cc index c90968db..5eb2b414 100644 --- a/utils/pdftotext.cc +++ b/utils/pdftotext.cc @@ -439,7 +439,7 @@ static void printInfoString(FILE *f, Dict *infoDict, const char *key, GooString *s1; GBool isUnicode; Unicode u; - char buf[8]; + char buf[9]; int i, n; if (infoDict->lookup(key, &obj)->isString()) { @@ -463,7 +463,9 @@ static void printInfoString(FILE *f, Dict *infoDict, const char *key, ++i; } n = uMap->mapUnicode(u, buf, sizeof(buf)); - fwrite(buf, 1, n, f); + buf[n] = '\0'; + const std::string myString = myXmlTokenReplace(buf); + fputs(myString.c_str(), f); } fputs(text2, f); } |