[poppler] poppler/poppler: CharCodeToUnicode.cc, 1.2, 1.3 CharCodeToUnicode.h, 1.1.1.1, 1.2

Marco Pesenti Gritti marco at freedesktop.org
Fri Sep 16 11:39:00 PDT 2005


Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv5858/poppler

Modified Files:
	CharCodeToUnicode.cc CharCodeToUnicode.h 
Log Message:
2005-09-16  Marco Pesenti Gritti  <mpg at redhat.com>

        * poppler/CharCodeToUnicode.cc:
        * poppler/CharCodeToUnicode.h:

        Improvements from xpdf 3.01



Index: CharCodeToUnicode.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CharCodeToUnicode.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CharCodeToUnicode.cc	27 Aug 2005 08:43:43 -0000	1.2
+++ CharCodeToUnicode.cc	16 Sep 2005 18:38:58 -0000	1.3
@@ -251,7 +251,7 @@
 	  error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
 	  continue;
 	}
-	addMapping(code1, tok2 + 1, n2 - 1, 0);
+	addMapping(code1, tok2 + 1, n2 - 2, 0);
       }
       pst->getToken(tok1, sizeof(tok1), &n1);
     } else if (!strcmp(tok2, "beginbfrange")) {
@@ -433,23 +433,30 @@
 }
 
 void CharCodeToUnicode::setMapping(CharCode c, Unicode *u, int len) {
-  int i;
+  int i, j;
 
   if (len == 1) {
     map[c] = u[0];
   } else {
-    map[c] = 0;
-    if (sMapLen == sMapSize) {
-      sMapSize += 8;
-      sMap = (CharCodeToUnicodeString *)
-	       greallocn(sMap, sMapSize, sizeof(CharCodeToUnicodeString));
+    for (i = 0; i < sMapLen; ++i) {
+      if (sMap[i].c == c) {
+	break;
+      }
     }
-    sMap[sMapLen].c = c;
-    sMap[sMapLen].len = len;
-    for (i = 0; i < len && i < maxUnicodeString; ++i) {
-      sMap[sMapLen].u[i] = u[i];
+    if (i == sMapLen) {
+      if (sMapLen == sMapSize) {
+	sMapSize += 8;
+	sMap = (CharCodeToUnicodeString *)
+	         greallocn(sMap, sMapSize, sizeof(CharCodeToUnicodeString));
+      }
+      ++sMapLen;
+    }
+    map[c] = 0;
+    sMap[i].c = c;
+    sMap[i].len = len;
+    for (j = 0; j < len && j < maxUnicodeString; ++j) {
+      sMap[i].u[j] = u[j];
     }
-    ++sMapLen;
   }
 }
 

Index: CharCodeToUnicode.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CharCodeToUnicode.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- CharCodeToUnicode.h	3 Mar 2005 19:46:00 -0000	1.1.1.1
+++ CharCodeToUnicode.h	16 Sep 2005 18:38:58 -0000	1.2
@@ -66,6 +66,10 @@
   // Map a CharCode to Unicode.
   int mapToUnicode(CharCode c, Unicode *u, int size);
 
+  // Return the mapping's length, i.e., one more than the max char
+  // code supported by the mapping.
+  CharCode getLength() { return mapLen; }
+
 private:
 
   void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);



More information about the poppler mailing list