[poppler] poppler/CharCodeToUnicode.cc poppler/CharCodeToUnicode.h
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Mar 30 14:39:27 UTC 2022
poppler/CharCodeToUnicode.cc | 24 +++++++++---------------
poppler/CharCodeToUnicode.h | 9 +++++----
2 files changed, 14 insertions(+), 19 deletions(-)
New commits:
commit 01c4d1a3a6535c46017ad71f9cc52171b1026e23
Author: Albert Astals Cid <aacid at kde.org>
Date: Wed Mar 30 16:05:20 2022 +0200
Convert CharCodeToUnicode tag to optional string
diff --git a/poppler/CharCodeToUnicode.cc b/poppler/CharCodeToUnicode.cc
index 86527f1a..cd009379 100644
--- a/poppler/CharCodeToUnicode.cc
+++ b/poppler/CharCodeToUnicode.cc
@@ -13,7 +13,7 @@
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
-// Copyright (C) 2006, 2008-2010, 2012, 2018-2021 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006, 2008-2010, 2012, 2018-2022 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2007 Julien Rebetez <julienr at svn.gnome.org>
// Copyright (C) 2007 Koji Otani <sho at bbr.jp>
// Copyright (C) 2008 Michael Vrable <mvrable at cs.ucsd.edu>
@@ -162,7 +162,7 @@ CharCodeToUnicode *CharCodeToUnicode::parseCIDToUnicode(const char *fileName, co
}
fclose(f);
- ctu = new CharCodeToUnicode(collection->copy(), mapA, mapLenA, true, nullptr, 0, 0);
+ ctu = new CharCodeToUnicode(collection->toStr(), mapA, mapLenA, true, nullptr, 0, 0);
gfree(mapA);
return ctu;
}
@@ -248,7 +248,7 @@ CharCodeToUnicode *CharCodeToUnicode::parseUnicodeToUnicode(const GooString *fil
}
fclose(f);
- ctu = new CharCodeToUnicode(fileName->copy(), mapA, len, true, sMapA, sMapLenA, sMapSizeA);
+ ctu = new CharCodeToUnicode(fileName->toStr(), mapA, len, true, sMapA, sMapLenA, sMapSizeA);
gfree(mapA);
gfree(uBuf);
return ctu;
@@ -256,14 +256,14 @@ CharCodeToUnicode *CharCodeToUnicode::parseUnicodeToUnicode(const GooString *fil
CharCodeToUnicode *CharCodeToUnicode::make8BitToUnicode(Unicode *toUnicode)
{
- return new CharCodeToUnicode(nullptr, toUnicode, 256, true, nullptr, 0, 0);
+ return new CharCodeToUnicode({}, toUnicode, 256, true, nullptr, 0, 0);
}
CharCodeToUnicode *CharCodeToUnicode::parseCMap(const GooString *buf, int nBits)
{
CharCodeToUnicode *ctu;
- ctu = new CharCodeToUnicode(nullptr);
+ ctu = new CharCodeToUnicode(std::optional<std::string>());
const char *p = buf->c_str();
if (!ctu->parseCMap1(&getCharFromString, &p, nBits)) {
delete ctu;
@@ -277,7 +277,7 @@ CharCodeToUnicode *CharCodeToUnicode::parseCMapFromFile(const GooString *fileNam
CharCodeToUnicode *ctu;
FILE *f;
- ctu = new CharCodeToUnicode(nullptr);
+ ctu = new CharCodeToUnicode(std::optional<std::string>());
if ((f = globalParams->findToUnicodeFile(fileName))) {
if (!ctu->parseCMap1(&getCharFromFile, f, nBits)) {
delete ctu;
@@ -559,7 +559,6 @@ void CharCodeToUnicode::addMappingInt(CharCode code, Unicode u)
CharCodeToUnicode::CharCodeToUnicode()
{
- tag = nullptr;
map = nullptr;
mapLen = 0;
sMap = nullptr;
@@ -568,11 +567,10 @@ CharCodeToUnicode::CharCodeToUnicode()
isIdentity = false;
}
-CharCodeToUnicode::CharCodeToUnicode(GooString *tagA)
+CharCodeToUnicode::CharCodeToUnicode(const std::optional<std::string> &tagA) : tag(tagA)
{
CharCode i;
- tag = tagA;
mapLen = 256;
map = (Unicode *)gmallocn(mapLen, sizeof(Unicode));
for (i = 0; i < mapLen; ++i) {
@@ -584,9 +582,8 @@ CharCodeToUnicode::CharCodeToUnicode(GooString *tagA)
isIdentity = false;
}
-CharCodeToUnicode::CharCodeToUnicode(GooString *tagA, Unicode *mapA, CharCode mapLenA, bool copyMap, CharCodeToUnicodeString *sMapA, int sMapLenA, int sMapSizeA)
+CharCodeToUnicode::CharCodeToUnicode(const std::optional<std::string> &tagA, Unicode *mapA, CharCode mapLenA, bool copyMap, CharCodeToUnicodeString *sMapA, int sMapLenA, int sMapSizeA) : tag(tagA)
{
- tag = tagA;
mapLen = mapLenA;
if (copyMap) {
map = (Unicode *)gmallocn(mapLen, sizeof(Unicode));
@@ -603,9 +600,6 @@ CharCodeToUnicode::CharCodeToUnicode(GooString *tagA, Unicode *mapA, CharCode ma
CharCodeToUnicode::~CharCodeToUnicode()
{
- if (tag) {
- delete tag;
- }
gfree(map);
if (sMap) {
for (int i = 0; i < sMapLen; ++i) {
@@ -629,7 +623,7 @@ void CharCodeToUnicode::decRefCnt()
bool CharCodeToUnicode::match(const GooString *tagA)
{
- return tag && !tag->cmp(tagA);
+ return tag && tag == tagA->toStr();
}
void CharCodeToUnicode::setMapping(CharCode c, Unicode *u, int len)
diff --git a/poppler/CharCodeToUnicode.h b/poppler/CharCodeToUnicode.h
index d1100538..596d44d1 100644
--- a/poppler/CharCodeToUnicode.h
+++ b/poppler/CharCodeToUnicode.h
@@ -17,7 +17,7 @@
//
// Copyright (C) 2007 Julien Rebetez <julienr at svn.gnome.org>
// Copyright (C) 2007 Koji Otani <sho at bbr.jp>
-// Copyright (C) 2008, 2011, 2012, 2018, 2019, 2021 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2008, 2011, 2012, 2018, 2019, 2021, 2022 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2017 Adrian Johnson <ajohnson at redneon.com>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
// Copyright (C) 2018 Adam Reichold <adam.reichold at t-online.de>
@@ -32,6 +32,7 @@
#define CHARCODETOUNICODE_H
#include <atomic>
+#include <optional>
#include "poppler-config.h"
#include "CharTypes.h"
@@ -103,10 +104,10 @@ private:
void addMapping(CharCode code, char *uStr, int n, int offset);
void addMappingInt(CharCode code, Unicode u);
CharCodeToUnicode();
- explicit CharCodeToUnicode(GooString *tagA);
- CharCodeToUnicode(GooString *tagA, Unicode *mapA, CharCode mapLenA, bool copyMap, CharCodeToUnicodeString *sMapA, int sMapLenA, int sMapSizeA);
+ explicit CharCodeToUnicode(const std::optional<std::string> &tagA);
+ CharCodeToUnicode(const std::optional<std::string> &tagA, Unicode *mapA, CharCode mapLenA, bool copyMap, CharCodeToUnicodeString *sMapA, int sMapLenA, int sMapSizeA);
- GooString *tag;
+ const std::optional<std::string> tag;
Unicode *map;
CharCode mapLen;
CharCodeToUnicodeString *sMap;
More information about the poppler
mailing list