[poppler] 2 commits - poppler/Lexer.cc poppler/Object.cc poppler/Object.h poppler/PDFDoc.cc poppler/PSOutputDev.cc poppler/SecurityHandler.cc poppler/StructElement.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Thu Dec 1 23:12:07 UTC 2016


 poppler/Lexer.cc           |    3 +--
 poppler/Object.cc          |   15 ++-------------
 poppler/Object.h           |   16 +++-------------
 poppler/PDFDoc.cc          |   22 ++++++----------------
 poppler/PSOutputDev.cc     |    5 ++---
 poppler/SecurityHandler.cc |    3 +--
 poppler/StructElement.cc   |    5 ++---
 7 files changed, 17 insertions(+), 52 deletions(-)

New commits:
commit b5f3e935c3a1f4824fcd681e291c35852966bb45
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Dec 2 00:09:38 2016 +0100

    Revert "introduced hex string as a new Object type and used it for file identifier"
    
    This reverts commit debd1361f4a4cb7811677ab7a8f241b8b6fca5f9.

diff --git a/poppler/Lexer.cc b/poppler/Lexer.cc
index a908edf..952967a 100644
--- a/poppler/Lexer.cc
+++ b/poppler/Lexer.cc
@@ -18,7 +18,6 @@
 // Copyright (C) 2010 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2012, 2013 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
-// Copyright (C) 2016 Jakub Alba <jakubalba at gmail.com>
 //
 // 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
@@ -527,7 +526,7 @@ Object *Lexer::getObj(Object *obj, int objNum) {
 	s->append(tokBuf, n);
       if (m == 1)
 	s->append((char)(c2 << 4));
-      obj->initHexString(s);
+      obj->initString(s);
     }
     break;
 
diff --git a/poppler/Object.cc b/poppler/Object.cc
index 0966e0d..d06bb39 100644
--- a/poppler/Object.cc
+++ b/poppler/Object.cc
@@ -15,7 +15,6 @@
 //
 // Copyright (C) 2008, 2010, 2012 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2013 Adrian Johnson <ajohnson at redneon.com>
-// Copyright (C) 2016 Jakub Alba <jakubalba at gmail.com>
 //
 // 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
@@ -55,13 +54,12 @@ static const char *objTypeNames[numObjTypes] = {
   "error",
   "eof",
   "none",
-  "integer64",
-  "hexstring"
+  "integer64"
 };
 
 #ifdef DEBUG_MEM
 int Object::numAlloc[numObjTypes] =
-  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 #endif
 
 Object *Object::initArray(XRef *xref) {
@@ -93,7 +91,6 @@ Object *Object::copy(Object *obj) {
   *obj = *this;
   switch (type) {
   case objString:
-  case objHexString:
     obj->string = string->copy();
     break;
   case objName:
@@ -128,7 +125,6 @@ Object *Object::fetch(XRef *xref, Object *obj, int recursion) {
 void Object::free() {
   switch (type) {
   case objString:
-  case objHexString:
     delete string;
     break;
   case objName:
@@ -184,13 +180,6 @@ void Object::print(FILE *f) {
     fwrite(string->getCString(), 1, string->getLength(), f);
     fprintf(f, ")");
     break;
-  case objHexString:
-    fprintf(f, "<");
-    for (i = 0; i < string->getLength(); i++) {
-      fprintf(f, "%02x", string->getChar(i) & 0xff);
-    }
-    fprintf(f, ">");
-    break;
   case objName:
     fprintf(f, "/%s", name);
     break;
diff --git a/poppler/Object.h b/poppler/Object.h
index 21b9030..e3f8f37 100644
--- a/poppler/Object.h
+++ b/poppler/Object.h
@@ -105,12 +105,10 @@ enum ObjType {
   objNone,			// uninitialized object
 
   // poppler-only objects
-  objInt64,			// integer with at least 64-bits
-
-  objHexString			// hex string
+  objInt64			// integer with at least 64-bits
 };
 
-#define numObjTypes 16		// total number of object types
+#define numObjTypes 15		// total number of object types
 
 //------------------------------------------------------------------------
 // Object
@@ -140,8 +138,6 @@ public:
     { initObj(objReal); real = realA; return this; }
   Object *initString(GooString *stringA)
     { initObj(objString); string = stringA; return this; }
-  Object *initHexString(GooString *hexA)
-    { initObj(objHexString); string = hexA; return this; }
   Object *initName(const char *nameA)
     { initObj(objName); name = copyString(nameA); return this; }
   Object *initNull()
@@ -182,7 +178,6 @@ public:
   GBool isReal() { return type == objReal; }
   GBool isNum() { return type == objInt || type == objReal || type == objInt64; }
   GBool isString() { return type == objString; }
-  GBool isHexString() { return type == objHexString; }
   GBool isName() { return type == objName; }
   GBool isNull() { return type == objNull; }
   GBool isArray() { return type == objArray; }
@@ -218,11 +213,6 @@ public:
   // because the object it's not expected to have a NULL string.
   GooString *takeString() {
     OBJECT_TYPE_CHECK(objString); GooString *s = string; string = NULL; return s; }
-  GooString *getHexString() { OBJECT_TYPE_CHECK(objHexString); return string; }
-  // After takeHexString() the only method that should be called for the object is free()
-  // because the object it's not expected to have a NULL hex string.
-  GooString *takeHexString() {
-    OBJECT_TYPE_CHECK(objHexString); GooString *s = string; string = NULL; return s; }
   char *getName() { OBJECT_TYPE_CHECK(objName); return name; }
   Array *getArray() { OBJECT_TYPE_CHECK(objArray); return array; }
   Dict *getDict() { OBJECT_TYPE_CHECK(objDict); return dict; }
@@ -281,7 +271,7 @@ private:
     int intg;			//   integer
     long long int64g;           //   64-bit integer
     double real;		//   real
-    GooString *string;		//   (hex) string
+    GooString *string;		//   string
     char *name;			//   name
     Array *array;		//   array
     Dict *dict;			//   dictionary
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 5f05388..f28bdec 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -1272,16 +1272,6 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO
     case objString:
       writeString(obj->getString(), outStr, fileKey, encAlgorithm, keyLength, objNum, objGen);
       break;
-    case objHexString:
-    {
-      GooString *s = obj->getHexString();
-      outStr->printf("<");
-      for (int i = 0; i < s->getLength(); i++) {
-        outStr->printf("%02x", s->getChar(i) & 0xff);
-      }
-      outStr->printf(">");
-      break;
-    }
     case objName:
     {
       GooString name(obj->getName());
commit 3a260ba8b3db99b4c0a956cc615704168db30e56
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Dec 2 00:09:31 2016 +0100

    Revert "treat file identifier as a hex string, not a basic string"
    
    This reverts commit 628299bc02ef825609e1ade539f967bbf052be0c.

diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 9c09283..5f05388 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -703,8 +703,8 @@ GBool PDFDoc::getID(GooString *permanent_id, GooString *update_id) {
     Object obj2;
 
     if (permanent_id) {
-      if (obj.arrayGet(0, &obj2)->isHexString()) {
-        if (!get_id (obj2.getHexString(), permanent_id)) {
+      if (obj.arrayGet(0, &obj2)->isString()) {
+        if (!get_id (obj2.getString(), permanent_id)) {
 	  obj2.free();
 	  return gFalse;
 	}
@@ -717,8 +717,8 @@ GBool PDFDoc::getID(GooString *permanent_id, GooString *update_id) {
     }
 
     if (update_id) {
-      if (obj.arrayGet(1, &obj2)->isHexString()) {
-        if (!get_id (obj2.getHexString(), update_id)) {
+      if (obj.arrayGet(1, &obj2)->isString()) {
+        if (!get_id (obj2.getString(), update_id)) {
 	  obj2.free();
 	  return gFalse;
 	}
@@ -1467,7 +1467,7 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Goffset startxR
   //calculate md5 digest
   Guchar digest[16];
   md5((Guchar*)message.getCString(), message.getLength(), digest);
-  obj1.initHexString(new GooString((const char*)digest, 16));
+  obj1.initString(new GooString((const char*)digest, 16));
 
   //create ID array
   Object obj2,obj3,obj5;
@@ -1492,7 +1492,7 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Goffset startxR
   } else {
     //new file => same values for the two identifiers
     obj2.arrayAdd(&obj1);
-    obj1.initHexString(new GooString((const char*)digest, 16));
+    obj1.initString(new GooString((const char*)digest, 16));
     obj2.arrayAdd(&obj1);
     trailerDict->set("ID", &obj2);
   }
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 195616a..ea0b043 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -31,7 +31,6 @@
 // Copyright (C) 2014 Till Kamppeter <till.kamppeter at gmail.com>
 // Copyright (C) 2015 Marek Kasik <mkasik at redhat.com>
 // Copyright (C) 2016 Caolán McNamara <caolanm at redhat.com>
-// Copyright (C) 2016 Jakub Alba <jakubalba at gmail.com>
 //
 // 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
@@ -7095,8 +7094,8 @@ void PSOutputDev::opiBegin13(GfxState *state, Dict *dict) {
   obj1.free();
 
   dict->lookup("ID", &obj1);
-  if (obj1.isHexString()) {
-    writePSFmt("%ALDImageID: {0:t}\n", obj1.getHexString());
+  if (obj1.isString()) {
+    writePSFmt("%ALDImageID: {0:t}\n", obj1.getString());
   }
   obj1.free();
 
diff --git a/poppler/SecurityHandler.cc b/poppler/SecurityHandler.cc
index 2e165b6..9e0546e 100644
--- a/poppler/SecurityHandler.cc
+++ b/poppler/SecurityHandler.cc
@@ -17,7 +17,6 @@
 // Copyright (C) 2013 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2014 Fabio D'Urso <fabiodurso at hotmail.it>
 // Copyright (C) 2016 Alok Anand <alok4nand at gmail.com>
-// Copyright (C) 2016 Jakub Alba <jakubalba at gmail.com>
 //
 // 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
@@ -276,7 +275,7 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA,
 	  encRevision >= 2 && encRevision <= 3) {
 	if (fileIDObj.isArray()) {
 	  if (fileIDObj.arrayGet(0, &fileIDObj1)->isString()) {
-	    fileID = fileIDObj1.getHexString()->copy();
+	    fileID = fileIDObj1.getString()->copy();
 	  } else {
 	    fileID = new GooString();
 	  }
diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc
index a890465..c668820 100644
--- a/poppler/StructElement.cc
+++ b/poppler/StructElement.cc
@@ -8,7 +8,6 @@
 // Copyright 2014 Luigi Scarso <luigi.scarso at gmail.com>
 // Copyright 2014 Albert Astals Cid <aacid at kde.org>
 // Copyright 2015 Dmytro Morgun <lztoad at gmail.com>
-// Copyright 2016 Jakub Alba <jakubalba at gmail.com>
 //
 //========================================================================
 
@@ -1123,8 +1122,8 @@ void StructElement::parse(Dict *element)
   obj.free();
 
   // Object ID (optional), to be looked at the IDTree in the tree root.
-  if (element->lookup("ID", &obj)->isHexString()) {
-    s->id = obj.takeHexString();
+  if (element->lookup("ID", &obj)->isString()) {
+    s->id = obj.takeString();
   }
   obj.free();
 


More information about the poppler mailing list