[poppler] cpp/poppler-private.cpp glib/poppler-document.cc goo/GooString.cc goo/GooString.h poppler/Annot.cc poppler/Form.cc qt4/src qt5/src
Albert Astals Cid
aacid at kemper.freedesktop.org
Sat Sep 16 15:46:02 UTC 2017
cpp/poppler-private.cpp | 4 ++--
glib/poppler-document.cc | 3 +--
goo/GooString.cc | 6 ++++++
goo/GooString.h | 1 +
poppler/Annot.cc | 9 +++------
poppler/Form.cc | 13 +++++--------
qt4/src/poppler-private.cc | 4 ++--
qt5/src/poppler-private.cc | 4 ++--
8 files changed, 22 insertions(+), 22 deletions(-)
New commits:
commit a0ed20f3fb8025706ad9a580f6a692316bf6df66
Author: Albert Astals Cid <aacid at kde.org>
Date: Sat Sep 16 17:45:42 2017 +0200
-Woverflow fixes
diff --git a/cpp/poppler-private.cpp b/cpp/poppler-private.cpp
index 60dff144..62940c07 100644
--- a/cpp/poppler-private.cpp
+++ b/cpp/poppler-private.cpp
@@ -106,8 +106,8 @@ GooString* detail::ustring_to_unicode_GooString(const ustring &str)
const size_t len = str.size() * 2 + 2;
const ustring::value_type *me = str.data();
byte_array ba(len);
- ba[0] = 0xfe;
- ba[1] = 0xff;
+ ba[0] = (char)0xfe;
+ ba[1] = (char)0xff;
for (size_t i = 0; i < str.size(); ++i, ++me) {
ba[i * 2 + 2] = ((*me >> 8) & 0xff);
ba[i * 2 + 3] = (*me & 0xff);
diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index 157a0484..41b6a04b 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -758,8 +758,7 @@ _poppler_goo_string_from_utf8(const gchar *src)
g_free (utf16);
if (!result->hasUnicodeMarker()) {
- result->insert(0, 0xff);
- result->insert(0, 0xfe);
+ result->prependUnicodeMarker();
}
return result;
diff --git a/goo/GooString.cc b/goo/GooString.cc
index 12592e49..f76e7d14 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -917,6 +917,12 @@ GBool GooString::hasUnicodeMarker(void) const
return length > 1 && (s[0] & 0xff) == 0xfe && (s[1] & 0xff) == 0xff;
}
+void GooString::prependUnicodeMarker()
+{
+ insert(0, (char)0xff);
+ insert(0, (char)0xfe);
+}
+
GooString *GooString::sanitizedName(GBool psmode)
{
GooString *name;
diff --git a/goo/GooString.h b/goo/GooString.h
index de704971..5d17ec80 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -161,6 +161,7 @@ public:
GBool endsWith(const char *suffix) const;
GBool hasUnicodeMarker(void) const;
+ void prependUnicodeMarker();
GBool hasJustUnicodeMarker(void) const { return length == 2 && hasUnicodeMarker(); }
// Sanitizes the string so that it does
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 87985675..83261038 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1398,8 +1398,7 @@ void Annot::setContents(GooString *new_content) {
contents = new GooString(new_content);
//append the unicode marker <FE FF> if needed
if (!contents->hasUnicodeMarker()) {
- contents->insert(0, 0xff);
- contents->insert(0, 0xfe);
+ contents->prependUnicodeMarker();
}
} else {
contents = new GooString();
@@ -1987,8 +1986,7 @@ void AnnotMarkup::setLabel(GooString *new_label) {
label = new GooString(new_label);
//append the unicode marker <FE FF> if needed
if (!label->hasUnicodeMarker()) {
- label->insert(0, 0xff);
- label->insert(0, 0xfe);
+ label->prependUnicodeMarker();
}
} else {
label = new GooString();
@@ -2764,8 +2762,7 @@ void AnnotFreeText::setStyleString(GooString *new_string) {
styleString = new GooString(new_string);
//append the unicode marker <FE FF> if needed
if (!styleString->hasUnicodeMarker()) {
- styleString->insert(0, 0xff);
- styleString->insert(0, 0xfe);
+ styleString->prependUnicodeMarker();
}
} else {
styleString = new GooString();
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 15c31e67..83bceb20 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -60,8 +60,8 @@ char* pdfDocEncodingToUTF16 (GooString* orig, int* length)
char *result = new char[(*length)];
char *cstring = orig->getCString();
//unicode marker
- result[0] = 0xfe;
- result[1] = 0xff;
+ result[0] = (char)0xfe;
+ result[1] = (char)0xff;
//convert to utf16
for(int i=2,j=0; i<(*length); i+=2,j++) {
Unicode u = pdfDocEncoding[(unsigned int)((unsigned char)cstring[j])]&0xffff;
@@ -918,8 +918,7 @@ GooString* FormField::getFullyQualifiedName() {
}
if (unicode_encoded) {
- full_name->insert(0, 0xff);
- full_name->insert(0, 0xfe);
+ full_name->prependUnicodeMarker();
}
fullyQualifiedName = full_name;
@@ -1182,8 +1181,7 @@ void FormFieldText::setContentCopy (GooString* new_content)
//append the unicode marker <FE FF> if needed
if (!content->hasUnicodeMarker()) {
- content->insert(0, 0xff);
- content->insert(0, 0xfe);
+ content->prependUnicodeMarker();
}
}
@@ -1539,8 +1537,7 @@ void FormFieldChoice::setEditChoice (GooString* new_content)
//append the unicode marker <FE FF> if needed
if (!editedChoice->hasUnicodeMarker()) {
- editedChoice->insert(0, 0xff);
- editedChoice->insert(0, 0xfe);
+ editedChoice->prependUnicodeMarker();
}
}
updateSelection();
diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index 6c4d782e..4ff68f94 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -132,8 +132,8 @@ namespace Debug {
GooString *QStringToUnicodeGooString(const QString &s) {
int len = s.length() * 2 + 2;
char *cstring = (char *)gmallocn(len, sizeof(char));
- cstring[0] = 0xfe;
- cstring[1] = 0xff;
+ cstring[0] = (char)0xfe;
+ cstring[1] = (char)0xff;
for (int i = 0; i < s.length(); ++i)
{
cstring[2+i*2] = s.at(i).row();
diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc
index dced8b9a..1540a66f 100644
--- a/qt5/src/poppler-private.cc
+++ b/qt5/src/poppler-private.cc
@@ -132,8 +132,8 @@ namespace Debug {
GooString *QStringToUnicodeGooString(const QString &s) {
int len = s.length() * 2 + 2;
char *cstring = (char *)gmallocn(len, sizeof(char));
- cstring[0] = 0xfe;
- cstring[1] = 0xff;
+ cstring[0] = (char)0xfe;
+ cstring[1] = (char)0xff;
for (int i = 0; i < s.length(); ++i)
{
cstring[2+i*2] = s.at(i).row();
More information about the poppler
mailing list