[poppler] goo/GooString.cc goo/GooString.h poppler/PDFDoc.cc poppler/PDFDoc.h

2022-09-15 Thread GitLab Mirror
 goo/GooString.cc  |2 +-
 goo/GooString.h   |2 +-
 poppler/PDFDoc.cc |2 +-
 poppler/PDFDoc.h  |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 098b8622cc804c9fd41e2a56fbb2e116226b22b3
Author: Albert Astals Cid 
Date:   Thu Sep 15 23:32:48 2022 +0200

Update (C)

diff --git a/goo/GooString.cc b/goo/GooString.cc
index 19a913a8..010058f3 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -29,7 +29,7 @@
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2018 Adam Reichold 
 // Copyright (C) 2018 Greg Knight 
-// Copyright (C) 2019 Oliver Sander 
+// Copyright (C) 2019, 2022 Oliver Sander 
 //
 // 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
diff --git a/goo/GooString.h b/goo/GooString.h
index 053c65f3..5af12d0c 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -26,7 +26,7 @@
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2019 Christophe Fergeau 
 // Copyright (C) 2019 Tomoyuki Kubota 
-// Copyright (C) 2019, 2020 Oliver Sander 
+// Copyright (C) 2019, 2020, 2022 Oliver Sander 
 // Copyright (C) 2019 Hans-Ulrich Jüttner 
 // Copyright (C) 2020 Thorsten Behrens 
 // Copyright (C) 2022 Even Rouault 
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 1840a3f5..a3c01e62 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -46,7 +46,7 @@
 // Copyright (C) 2020 Nelson Benítez León 
 // Copyright (C) 2020 Thorsten Behrens 
 // Copyright (C) 2020 Adam Sampson 
-// Copyright (C) 2021 Oliver Sander 
+// Copyright (C) 2021, 2022 Oliver Sander 
 // Copyright (C) 2021 Mahmoud Khalil 
 // Copyright (C) 2021 RM 
 // Copyright (C) 2021 Georgiy Sgibnev . Work sponsored by 
lab50.net.
diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h
index 7fe5f469..01592e0c 100644
--- a/poppler/PDFDoc.h
+++ b/poppler/PDFDoc.h
@@ -32,7 +32,7 @@
 // Copyright (C) 2016 Jakub Alba 
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2018 Evangelos Rigas 
-// Copyright (C) 2020, 2021 Oliver Sander 
+// Copyright (C) 2020-2022 Oliver Sander 
 // Copyright (C) 2020 Nelson Benítez León 
 // Copyright (C) 2021 Mahmoud Khalil 
 // Copyright (C) 2021 Georgiy Sgibnev . Work sponsored by 
lab50.net.


[poppler] goo/GooString.cc goo/GooString.h poppler/PDFDoc.cc

2022-09-15 Thread GitLab Mirror
 goo/GooString.cc  |   12 +---
 goo/GooString.h   |3 +--
 poppler/PDFDoc.cc |4 ++--
 3 files changed, 4 insertions(+), 15 deletions(-)

New commits:
commit d6b7ef8794bad35366257e2644843f686326f4df
Author: Oliver Sander 
Date:   Thu Sep 15 16:19:19 2022 +0200

Remove the psmode argument from GooString::sanitizedName

It is always 'false'.

diff --git a/goo/GooString.cc b/goo/GooString.cc
index f2fb3031..19a913a8 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -625,20 +625,10 @@ bool GooString::endsWith(const char *suffix) const
 return endsWith(toStr(), suffix);
 }
 
-GooString *GooString::sanitizedName(bool psmode) const
+GooString *GooString::sanitizedName() const
 {
 auto *name = new GooString();
 
-if (psmode) {
-// ghostscript chokes on names that begin with out-of-limits
-// numbers, e.g., 1e4foo is handled correctly (as a name), but
-// 1e999foo generates a limitcheck error
-const auto c = getChar(0);
-if (c >= '0' && c <= '9') {
-name->append('f');
-}
-}
-
 for (const auto c : *this) {
 if (c <= (char)0x20 || c >= (char)0x7f || c == ' ' || c == '(' || c == 
')' || c == '<' || c == '>' || c == '[' || c == ']' || c == '{' || c == '}' || 
c == '/' || c == '%' || c == '#') {
 char buf[8];
diff --git a/goo/GooString.h b/goo/GooString.h
index 4535f7a6..053c65f3 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -259,9 +259,8 @@ public:
 
 // Sanitizes the string so that it does
 // not contain any ( ) < > [ ] { } / %
-// The postscript mode also has some more strict checks
 // The caller owns the return value
-POPPLER_PRIVATE_EXPORT GooString *sanitizedName(bool psmode) const;
+POPPLER_PRIVATE_EXPORT GooString *sanitizedName() const;
 };
 
 #endif
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 0e851ffd..1840a3f5 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -1221,7 +1221,7 @@ void PDFDoc::writeDictionary(Dict *dict, OutStream 
*outStr, XRef *xRef, unsigned
 outStr->printf("<<");
 for (int i = 0; i < dict->getLength(); i++) {
 GooString keyName(dict->getKey(i));
-GooString *keyNameToPrint = keyName.sanitizedName(false /* non ps mode 
*/);
+GooString *keyNameToPrint = keyName.sanitizedName();
 outStr->printf("/%s ", keyNameToPrint->c_str());
 delete keyNameToPrint;
 Object obj1 = dict->getValNF(i).copy();
@@ -1371,7 +1371,7 @@ void PDFDoc::writeObject(Object *obj, OutStream *outStr, 
XRef *xRef, unsigned in
 }
 case objName: {
 GooString name(obj->getName());
-GooString *nameToPrint = name.sanitizedName(false /* non ps mode */);
+GooString *nameToPrint = name.sanitizedName();
 outStr->printf("/%s ", nameToPrint->c_str());
 delete nameToPrint;
 break;


[poppler] goo/GooString.cc goo/GooString.h

2022-03-28 Thread GitLab Mirror
 goo/GooString.cc |   18 ++
 goo/GooString.h  |3 +++
 2 files changed, 5 insertions(+), 16 deletions(-)

New commits:
commit 5bebbe59a1e971dfd6b2f1f76d51dc544239ffb6
Author: Albert Astals Cid 
Date:   Tue Feb 22 16:01:19 2022 +0100

GooString: Introduce string_view ends/startsWith functions

diff --git a/goo/GooString.cc b/goo/GooString.cc
index 4f46b85d..470b79f5 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -617,26 +617,12 @@ void GooString::prependUnicodeMarker()
 
 bool GooString::startsWith(const char *prefix) const
 {
-const auto len = size();
-const auto prefixLen = std::strlen(prefix);
-
-if (len < prefixLen) {
-return false;
-}
-
-return static_cast(*this).compare(0, prefixLen, 
prefix) == 0;
+return startsWith(toStr(), prefix);
 }
 
 bool GooString::endsWith(const char *suffix) const
 {
-const auto len = size();
-const auto suffixLen = std::strlen(suffix);
-
-if (len < suffixLen) {
-return false;
-}
-
-return static_cast(*this).compare(len - suffixLen, 
suffixLen, suffix) == 0;
+return endsWith(toStr(), suffix);
 }
 
 GooString *GooString::sanitizedName(bool psmode) const
diff --git a/goo/GooString.h b/goo/GooString.h
index f2d01108..d83fcb95 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -239,6 +239,9 @@ public:
 // Return true if string ends with suffix
 POPPLER_PRIVATE_EXPORT bool endsWith(const char *suffix) const;
 
+static bool startsWith(std::string_view str, std::string_view prefix) { 
return str.size() >= prefix.size() && 0 == str.compare(0, prefix.size(), 
prefix); }
+static bool endsWith(std::string_view str, std::string_view suffix) { 
return str.size() >= suffix.size() && 0 == str.compare(str.size() - 
suffix.size(), suffix.size(), suffix); }
+
 bool hasUnicodeMarker() const { return hasUnicodeMarker(*this); }
 static bool hasUnicodeMarker(const std::string ) { return s.size() >= 2 
&& s[0] == '\xfe' && s[1] == '\xff'; }
 bool hasUnicodeMarkerLE() const { return hasUnicodeMarkerLE(*this); }


[poppler] goo/GooString.cc goo/GooString.h

2022-03-08 Thread GitLab Mirror
 goo/GooString.cc |   17 ++---
 goo/GooString.h  |6 +-
 2 files changed, 19 insertions(+), 4 deletions(-)

New commits:
commit 6e1fe42a6a3c3f7b7cfb259f7de3d8a1de279016
Author: Albert Astals Cid 
Date:   Mon Mar 7 16:24:06 2022 +0100

GooString: Add lowercase helpers for std::string

diff --git a/goo/GooString.cc b/goo/GooString.cc
index 54e8bc52..42436234 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -18,7 +18,7 @@
 // Copyright (C) 2006 Kristian Høgsberg 
 // Copyright (C) 2006 Krzysztof Kowalczyk 
 // Copyright (C) 2007 Jeff Muizelaar 
-// Copyright (C) 2008-2011, 2016-2018, 2021 Albert Astals Cid 
+// Copyright (C) 2008-2011, 2016-2018, 2022 Albert Astals Cid 
 // Copyright (C) 2011 Kenji Uno 
 // Copyright (C) 2012, 2013 Fabio D'Urso 
 // Copyright (C) 2012, 2017 Adrian Johnson 
@@ -589,13 +589,24 @@ void formatDoubleSmallAware(double x, char *buf, int 
bufSize, int prec, bool tri
 
 GooString *GooString::lowerCase()
 {
-for (auto  : *this) {
+lowerCase(*this);
+return this;
+}
+
+void GooString::lowerCase(std::string )
+{
+for (auto  : s) {
 if (std::isupper(c)) {
 c = std::tolower(c);
 }
 }
+}
 
-return this;
+std::string GooString::toLowerCase(const std::string )
+{
+std::string newString = s;
+lowerCase(newString);
+return s;
 }
 
 void GooString::prependUnicodeMarker()
diff --git a/goo/GooString.h b/goo/GooString.h
index aa68635c..d6747f90 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -17,7 +17,7 @@
 //
 // Copyright (C) 2006 Kristian Høgsberg 
 // Copyright (C) 2006 Krzysztof Kowalczyk 
-// Copyright (C) 2008-2010, 2012, 2014, 2017-2021 Albert Astals Cid 

+// Copyright (C) 2008-2010, 2012, 2014, 2017-2022 Albert Astals Cid 

 // Copyright (C) 2012-2014 Fabio D'Urso 
 // Copyright (C) 2013 Jason Crain 
 // Copyright (C) 2015, 2018 Adam Reichold 
@@ -222,6 +222,10 @@ public:
 
 // Convert string to all-lower case.
 GooString *lowerCase();
+static void lowerCase(std::string );
+
+// Returns a new string converted to all-lower case.
+static std::string toLowerCase(const std::string );
 
 // Compare two strings:  -1:<  0:=  +1:>
 int cmp(const GooString *str) const { return compare(*str); }


[poppler] goo/GooString.cc goo/GooString.h make-glib-api-docs qt5/demos

2019-11-24 Thread GitLab Mirror
 goo/GooString.cc|1 +
 goo/GooString.h |1 +
 make-glib-api-docs  |1 +
 qt5/demos/navigationtoolbar.cpp |1 +
 4 files changed, 4 insertions(+)

New commits:
commit c017531fdebdd8a9d56c86ba89e861cc067000a2
Author: Albert Astals Cid 
Date:   Sun Nov 24 09:52:54 2019 +0100

Update (C) of few past commits

diff --git a/goo/GooString.cc b/goo/GooString.cc
index 998c77ec..8120146a 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -29,6 +29,7 @@
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2018 Adam Reichold 
 // Copyright (C) 2018 Greg Knight 
+// Copyright (C) 2019 Oliver Sander 
 //
 // 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
diff --git a/goo/GooString.h b/goo/GooString.h
index 16e83a26..5d17c4e5 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -26,6 +26,7 @@
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2019 Christophe Fergeau 
 // Copyright (C) 2019 Tomoyuki Kubota 
+// Copyright (C) 2019 Oliver Sander 
 //
 // 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
diff --git a/make-glib-api-docs b/make-glib-api-docs
index fca9279b..ad9db87a 100755
--- a/make-glib-api-docs
+++ b/make-glib-api-docs
@@ -1,6 +1,7 @@
 #!/usr/bin/env python3
 #
 # Copyright (C) 2017 Carlos Garcia Campos 
+# Copyright (C) 2019 Albert Astals Cid 
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/qt5/demos/navigationtoolbar.cpp b/qt5/demos/navigationtoolbar.cpp
index 77a011f1..41603077 100644
--- a/qt5/demos/navigationtoolbar.cpp
+++ b/qt5/demos/navigationtoolbar.cpp
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2008-2009, Pino Toscano 
  * Copyright (C) 2013, Fabio D'Urso 
+ * Copyright (C) 2019, Albert Astals Cid 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler

[poppler] goo/GooString.cc goo/GooString.h qt5/tests utils/HtmlFonts.cc utils/HtmlOutputDev.cc

2019-11-18 Thread GitLab Mirror
 goo/GooString.cc  |9 -
 goo/GooString.h   |3 ---
 qt5/tests/check_goostring.cpp |   22 --
 utils/HtmlFonts.cc|8 
 utils/HtmlOutputDev.cc|8 
 5 files changed, 8 insertions(+), 42 deletions(-)

New commits:
commit 66fd6879eb647e8349e9ea67258e2da8cf2ecf91
Author: Oliver Sander 
Date:   Mon Nov 18 10:24:29 2019 +0100

Replace GooString::fromInt by std::to_string

diff --git a/goo/GooString.cc b/goo/GooString.cc
index 1fb622be..86fadf30 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -136,15 +136,6 @@ void formatDoubleSmallAware(double x, char *buf, int 
bufSize, int prec,
 
 //
 
-GooString *GooString::fromInt(int x) {
-  char buf[24]; // enough space for 64-bit ints plus a little extra
-  const char *p;
-  int len;
-  formatInt(x, buf, sizeof(buf), false, 0, 10, , );
-
-  return new GooString(p, len);
-}
-
 GooString *GooString::format(const char *fmt, ...) {
   auto *s = new GooString();
 
diff --git a/goo/GooString.h b/goo/GooString.h
index 38950aef..3bc8abbf 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -91,9 +91,6 @@ public:
 static_cast(*this).append(*str2);
   }
 
-  // Convert an integer to a string.
-  static GooString *fromInt(int x);
-
   // Create a formatted string.  Similar to printf, but without the
   // string overflow issues.  Formatting elements consist of:
   // {:[][.]}
diff --git a/qt5/tests/check_goostring.cpp b/qt5/tests/check_goostring.cpp
index 4a18ad1f..3bdfcf77 100644
--- a/qt5/tests/check_goostring.cpp
+++ b/qt5/tests/check_goostring.cpp
@@ -14,8 +14,6 @@ private slots:
 void testInsert();
 void testFormat();
 void testFromNullptr();
-void testFromInt_data();
-void testFromInt();
 };
 
 void TestGooString::testInsertData_data()
@@ -163,26 +161,6 @@ void TestGooString::testFromNullptr()
   }
 }
 
-void TestGooString::testFromInt_data()
-{
-QTest::addColumn("inty");
-QTest::addColumn("stringy");
-
-QTest::newRow("Natural") << 12345 << QByteArray("12345");
-QTest::newRow("Negative") << -1 << QByteArray("-1");
-QTest::newRow("Zero") << 0 << QByteArray("0");
-QTest::newRow("INT_MAX") << 0x7fff << QByteArray("2147483647");
-QTest::newRow("-INT_MAX-1") << (-0x7fff - 1) << 
QByteArray("-2147483648");
-}
-
-void TestGooString::testFromInt()
-{
-QFETCH(int, inty);
-QFETCH(QByteArray, stringy);
-QScopedPointer str(GooString::fromInt(inty));
-QCOMPARE(str->c_str(), stringy.constData());
-}
-
 QTEST_GUILESS_MAIN(TestGooString)
 #include "check_goostring.moc"
 
diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc
index 597c2624..08d0b967 100644
--- a/utils/HtmlFonts.cc
+++ b/utils/HtmlFonts.cc
@@ -275,13 +275,13 @@ int HtmlFontAccu::AddFont(const HtmlFont& font){
 // get CSS font definition for font #i 
 GooString* HtmlFontAccu::CSStyle(int i, int j){
GooString *tmp=new GooString();
-   GooString *iStr=GooString::fromInt(i);
-   GooString *jStr=GooString::fromInt(j);
+   GooString *iStr=new GooString(std::to_string(i));
+   GooString *jStr=new GooString(std::to_string(j));
 
std::vector::iterator g=accu->begin();
g+=i;
HtmlFont font=*g;
-   GooString *Size=GooString::fromInt(font.getSize());
+   GooString *Size=new GooString(std::to_string(font.getSize()));
GooString *colorStr=font.getColor().toString();
GooString *fontName=(fontFullName ? font.getFullName() : 
font.getFontName());
GooString *lSize;
@@ -294,7 +294,7 @@ GooString* HtmlFontAccu::CSStyle(int i, int j){
  tmp->append(Size);
  if( font.getLineSize() != -1 && font.getLineSize() != 0 )
  {
-lSize = GooString::fromInt(font.getLineSize());
+lSize = new GooString(std::to_string(font.getLineSize()));
 tmp->append("px;line-height:");
 tmp->append(lSize);
 delete lSize;
diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc
index 3f490ff6..306bb416 100644
--- a/utils/HtmlOutputDev.cc
+++ b/utils/HtmlOutputDev.cc
@@ -814,7 +814,7 @@ int HtmlPage::dumpComplexHeaders(FILE * const file, FILE *& 
pageFile, int page)
 
   if( !noframes )
   {
-  GooString* pgNum=GooString::fromInt(page);
+  GooString* pgNum=new GooString(std::to_string(page));
   tmp = new GooString(DocName);
   if (!singleHtml){
 tmp->append('-')->append(pgNum)->append(".html");
@@ -1577,7 +1577,7 @@ GooString* HtmlOutputDev::getLinkDest(AnnotLink *link){
 
  delete dest;
 
- GooString *str=GooString::fromInt(destPage);
+ GooString *str=new GooString(std::to_string(destPage));
  /*complex simple
frames  file-4.html files.html#4
noframesfile.html#4 file.html#4
@@ -1634,7 +1634,7 @@ GooString* HtmlOutputDev::getLinkDest(AnnotLink *link){
  

[poppler] goo/GooString.cc goo/GooString.h poppler/StructElement.cc poppler/StructElement.h

2018-10-29 Thread GitLab Mirror
 goo/GooString.cc |  368 +--
 goo/GooString.h  |  125 +++
 poppler/StructElement.cc |   15 -
 poppler/StructElement.h  |2 
 4 files changed, 135 insertions(+), 375 deletions(-)

New commits:
commit 48877b91db366293658a2561f08f110501872ce9
Author: Adam Reichold 
Date:   Sat Oct 6 12:04:04 2018 +0200

Replace the implementation of GooString by std::string but keep the exact 
interface intact.

The approach is slightly different to GooList as it reimplements GooString 
in terms of
std::string but keeps its interface intact and does expose any std::string 
functionality
as of now.

This is done since GooString has a significantly larger API surface and 
exposing both API
would be quite confusing with with some overloads from GooString and some 
from std::string
being visible. But it does mean we can align the API (they are already 
pretty close) and
expose new things like a reserve method piece by piece.

It also already helps in that the implementation of GooString is gone 
except for the
original parts, i.e. the formatting, and we have zero cost conversion 
from/to std::string
which should help in making more use of it elsewhere. It also gives us 
do-nothing-access
to optimizations done for the standard library, e.g. word-level 
implementations of
cmp and friends.

(Note that the resulting GooString.cc is a bit funny as the formatting 
helper are now
local to the translation unit, but I had to redeclare them to keep the diff 
small as
I did not change them at all. But if this is done, they could probably just 
be moved to
where the declarations are to make the source file more readable.)

diff --git a/goo/GooString.cc b/goo/GooString.cc
index b1a7ae86..7e502435 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -35,19 +35,21 @@
 
 #include 
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
 #include "gmem.h"
 #include "GooString.h"
 
-static const int MAXIMUM_DOUBLE_PREC = 16;
-
 //
 
+namespace
+{
+
 union GooStringFormatArg {
   int i;
   Guint ui;
@@ -101,7 +103,7 @@ enum GooStringFormatType {
   fmtSpace
 };
 
-static const char *formatStrings[] = {
+const char *const formatStrings[] = {
   "d", "x", "X", "o", "b", "ud", "ux", "uX", "uo", "ub",
   "ld", "lx", "lX", "lo", "lb", "uld", "ulx", "ulX", "ulo", "ulb",
   "lld", "llx", "llX", "llo", "llb",
@@ -114,176 +116,58 @@ static const char *formatStrings[] = {
   nullptr
 };
 
-//
-
-int inline GooString::roundedSize(int len) {
-  int delta;
-  if (len <= STR_STATIC_SIZE-1)
-  return STR_STATIC_SIZE;
-  delta = len < 256 ? 7 : 255;
-  return ((len + 1) + delta) & ~delta;
-}
-
-// Make sure that the buffer is big enough to contain  characters
-// plus terminating 0.
-// We assume that if this is being called from the constructor,  was set
-// to NULL and  was set to 0 to indicate unused string before calling 
us.
-void inline GooString::resize(int newLength) {
-  char *s1 = s;
-
-  if (!s || (roundedSize(length) != roundedSize(newLength))) {
-// requires re-allocating data for string
-if (newLength < STR_STATIC_SIZE) {
-  s1 = sStatic;
-} else {
-  // allocate a rounded amount
-  if (s == sStatic)
-   s1 = (char*)gmalloc(roundedSize(newLength));
-  else
-   s1 = (char*)grealloc(s, roundedSize(newLength));
-}
-if (s == sStatic || s1 == sStatic) {
-  // copy the minimum, we only need to if are moving to or
-  // from sStatic.
-  // assert(s != s1) the roundedSize condition ensures this
-  if (newLength < length) {
-   memcpy(s1, s, newLength);
-  } else if (length > 0) {
-   memcpy(s1, s, length);
-  }
-  if (s != sStatic)
-   gfree(s);
-}
+void formatInt(long long x, char *buf, int bufSize,
+  bool zeroFill, int width, int base,
+  const char **p, int *len, bool upperCase = false);
 
-  }
+void formatUInt(unsigned long long x, char *buf, int bufSize,
+   bool zeroFill, int width, int base,
+   const char **p, int *len, bool upperCase = false);
 
-  s = s1;
-  length = newLength;
-  s[length] = '\0';
-}
+void formatDouble(double x, char *buf, int bufSize, int prec,
+ bool trim, const char **p, int *len);
 
-GooString* GooString::Set(const char *newStr, int newLen)
-{
-if (!newStr) {
-clear();
-return this;
-}
-
-if (newLen == CALC_STRING_LEN) {
-newLen = strlen(newStr);
-} else {
-assert(newLen >= 0);
-}
-
-resize(newLen);
-memmove(s, newStr, newLen);
-
-return this;
-}
-
-GooString::GooString() {
-  s = nullptr;
-  length = 0;
-  Set(nullptr);
-
-#if 

[poppler] goo/GooString.cc goo/GooString.h

2018-09-22 Thread GitLab Mirror
 goo/GooString.cc |   12 ++--
 goo/GooString.h  |8 
 2 files changed, 10 insertions(+), 10 deletions(-)

New commits:
commit 8dc1e98b8e112ed48155920f5aa4e46b5d616e79
Author: Albert Astals Cid 
Date:   Sun Sep 23 02:14:51 2018 +0200

GooString: some more const

diff --git a/goo/GooString.cc b/goo/GooString.cc
index 0cf32a3a..7a75ef45 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -230,7 +230,7 @@ GooString::GooString(GooString *str1, GooString *str2) {
 
 GooString *GooString::fromInt(int x) {
   char buf[24]; // enough space for 64-bit ints plus a little extra
-  char *p;
+  const char *p;
   int len;
   formatInt(x, buf, sizeof(buf), gFalse, 0, 10, , );
   return new GooString(p, len);
@@ -301,7 +301,7 @@ GooString *GooString::appendfv(const char *fmt, va_list 
argList) {
   char buf[65];
   int len, i;
   const char *p0, *p1;
-  char *str;
+  const char *str;
   GooStringFormatArg argsBuf[ 8 ];
 
   argsLen = 0;
@@ -624,7 +624,7 @@ static const char upperCaseDigits[17] = "0123456789ABCDEF";
 
 void GooString::formatInt(long long x, char *buf, int bufSize,
   GBool zeroFill, int width, int base,
-  char **p, int *len, GBool upperCase) {
+  const char **p, int *len, GBool upperCase) {
   const char *vals = upperCase ? upperCaseDigits : lowerCaseDigits;
   GBool neg;
   int start, i, j;
@@ -659,7 +659,7 @@ void GooString::formatInt(long long x, char *buf, int 
bufSize,
 
 void GooString::formatUInt(unsigned long long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
-   char **p, int *len, GBool upperCase) {
+   const char **p, int *len, GBool upperCase) {
   const char *vals = upperCase ? upperCaseDigits : lowerCaseDigits;
   int i, j;
 
@@ -682,7 +682,7 @@ void GooString::formatUInt(unsigned long long x, char *buf, 
int bufSize,
 }
 
 void GooString::formatDouble(double x, char *buf, int bufSize, int prec,
-  GBool trim, char **p, int *len) {
+  GBool trim, const char **p, int *len) {
   GBool neg, started;
   double x2;
   int d, i, j;
@@ -721,7 +721,7 @@ void GooString::formatDouble(double x, char *buf, int 
bufSize, int prec,
 }
 
 void GooString::formatDoubleSmallAware(double x, char *buf, int bufSize, int 
prec,
- GBool trim, char **p, int *len)
+ GBool trim, const char **p, int *len)
 {
   double absX = fabs(x);
   if (absX >= 0.1) {
diff --git a/goo/GooString.h b/goo/GooString.h
index 78ebd85b..142fb684 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -195,14 +195,14 @@ private:
   void resize(int newLength);
   static void formatInt(long long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
-   char **p, int *len, GBool upperCase = gFalse);
+   const char **p, int *len, GBool upperCase = gFalse);
   static void formatUInt(unsigned long long x, char *buf, int bufSize,
 GBool zeroFill, int width, int base,
-char **p, int *len, GBool upperCase = gFalse);
+const char **p, int *len, GBool upperCase = gFalse);
   static void formatDouble(double x, char *buf, int bufSize, int prec,
-  GBool trim, char **p, int *len);
+  GBool trim, const char **p, int *len);
   static void formatDoubleSmallAware(double x, char *buf, int bufSize, int 
prec,
-GBool trim, char **p, int *len);
+GBool trim, const char **p, int *len);
 };
 
 #endif
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] goo/GooString.cc goo/GooString.h poppler/Array.cc poppler/Array.h poppler/Dict.cc poppler/Dict.h poppler/Object.cc poppler/Object.h

2017-09-21 Thread Albert Astals Cid
 goo/GooString.cc  |2 
 goo/GooString.h   |2 
 poppler/Array.cc  |8 +-
 poppler/Array.h   |   12 ++--
 poppler/Dict.cc   |   18 +++---
 poppler/Dict.h|   26 -
 poppler/Object.cc |4 -
 poppler/Object.h  |  152 +++---
 8 files changed, 112 insertions(+), 112 deletions(-)

New commits:
commit 1a33f60da2996ea64c1b903580885697940cf046
Author: Albert Astals Cid 
Date:   Thu Sep 21 20:32:25 2017 +0200

Add some constness to the basic classes

diff --git a/goo/GooString.cc b/goo/GooString.cc
index f76e7d14..10976e87 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -923,7 +923,7 @@ void GooString::prependUnicodeMarker()
 insert(0, (char)0xfe);
 }
 
-GooString *GooString::sanitizedName(GBool psmode)
+GooString *GooString::sanitizedName(GBool psmode) const
 {
   GooString *name;
   char buf[8];
diff --git a/goo/GooString.h b/goo/GooString.h
index 5d17ec80..a5418c3d 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -168,7 +168,7 @@ public:
   // not contain any ( ) < > [ ] { } / %
   // The postscript mode also has some more strict checks
   // The caller owns the return value
-  GooString *sanitizedName(GBool psmode);
+  GooString *sanitizedName(GBool psmode) const;
 
 private:
   GooString(const GooString );
diff --git a/poppler/Array.cc b/poppler/Array.cc
index c2c4040d..94b8d66a 100644
--- a/poppler/Array.cc
+++ b/poppler/Array.cc
@@ -65,7 +65,7 @@ Array::~Array() {
 #endif
 }
 
-Object Array::copy(XRef *xrefA) {
+Object Array::copy(XRef *xrefA) const {
   arrayLocker();
   Array *a = new Array(xrefA);
   for (int i = 0; i < length; ++i) {
@@ -114,7 +114,7 @@ void Array::remove(int i) {
   memmove( elems + i, elems + i + 1, sizeof(elems[0]) * (length - i) );
 }
 
-Object Array::get(int i, int recursion) {
+Object Array::get(int i, int recursion) const {
   if (i < 0 || i >= length) {
 #ifdef DEBUG_MEM
 abort();
@@ -125,7 +125,7 @@ Object Array::get(int i, int recursion) {
   return elems[i].fetch(xref, recursion);
 }
 
-Object Array::getNF(int i) {
+Object Array::getNF(int i) const {
   if (i < 0 || i >= length) {
 #ifdef DEBUG_MEM
 abort();
@@ -136,7 +136,7 @@ Object Array::getNF(int i) {
   return elems[i].copy();
 }
 
-GBool Array::getString(int i, GooString *string)
+GBool Array::getString(int i, GooString *string) const
 {
   Object obj = getNF(i);
   if (obj.isString()) {
diff --git a/poppler/Array.h b/poppler/Array.h
index 8043c830..d2cdf65f 100644
--- a/poppler/Array.h
+++ b/poppler/Array.h
@@ -50,10 +50,10 @@ public:
   ~Array();
 
   // Get number of elements.
-  int getLength() { return length; }
+  int getLength() const { return length; }
 
   // Copy array with new xref
-  Object copy(XRef *xrefA);
+  Object copy(XRef *xrefA) const;
 
   // Add an element
   // elem becomes a dead object after this call
@@ -63,9 +63,9 @@ public:
   void remove(int i);
 
   // Accessors.
-  Object get(int i, int resursion = 0);
-  Object getNF(int i);
-  GBool getString(int i, GooString *string);
+  Object get(int i, int resursion = 0) const;
+  Object getNF(int i) const;
+  GBool getString(int i, GooString *string) const;
 
 private:
   friend class Object; // for incRef/decRef
@@ -80,7 +80,7 @@ private:
   int length;  // number of elements in array
   int ref; // reference count
 #if MULTITHREADED
-  GooMutex mutex;
+  mutable GooMutex mutex;
 #endif
 };
 
diff --git a/poppler/Dict.cc b/poppler/Dict.cc
index 5c231d14..2bd86abf 100644
--- a/poppler/Dict.cc
+++ b/poppler/Dict.cc
@@ -163,7 +163,7 @@ void Dict::add(char *key, Object &) {
   ++length;
 }
 
-inline DictEntry *Dict::find(const char *key) {
+inline DictEntry *Dict::find(const char *key) const {
   if (!sorted && length >= SORT_LENGTH_LOWER_LIMIT)
   {
   dictLocker();
@@ -187,7 +187,7 @@ inline DictEntry *Dict::find(const char *key) {
   return NULL;
 }
 
-GBool Dict::hasKey(const char *key) {
+GBool Dict::hasKey(const char *key) const {
   return find(key) != NULL;
 }
 
@@ -247,25 +247,25 @@ void Dict::set(const char *key, Object &) {
 }
 
 
-GBool Dict::is(const char *type) {
+GBool Dict::is(const char *type) const {
   DictEntry *e;
 
   return (e = find("Type")) && e->val.isName(type);
 }
 
-Object Dict::lookup(const char *key, int recursion) {
+Object Dict::lookup(const char *key, int recursion) const {
   DictEntry *e;
 
   return (e = find(key)) ? e->val.fetch(xref, recursion) : Object(objNull);
 }
 
-Object Dict::lookupNF(const char *key) {
+Object Dict::lookupNF(const char *key) const {
   DictEntry *e;
 
   return (e = find(key)) ? e->val.copy() : Object(objNull);
 }
 
-GBool Dict::lookupInt(const char *key, const char *alt_key, int *value)
+GBool Dict::lookupInt(const char *key, const char *alt_key, int *value) const
 {
   GBool success = gFalse;
   Object obj1 = lookup ((char *) key);
@@ -283,14 +283,14 @@ GBool Dict::lookupInt(const char *key, const char 
*alt_key, int *value)
   return 

[poppler] goo/GooString.cc goo/GooString.h

2016-05-11 Thread Albert Astals Cid
 goo/GooString.cc |   40 ++--
 goo/GooString.h  |   10 +-
 2 files changed, 19 insertions(+), 31 deletions(-)

New commits:
commit 9c35dc79ec777d9495796124ac7a42bf2b4cf83f
Author: Jakub Kucharski 
Date:   Wed May 11 23:34:53 2016 +0200

goo: refactor GooString::Set()

it is used only once to concatenate strings and it is in a GooString 
constructor used specifically for that
so I think concatenation should take place in the constructor and 
GooString::Set
should do exactly what it says which is setting the string.

Bug #94201

diff --git a/goo/GooString.cc b/goo/GooString.cc
index 3f22f36..de9c93c 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -25,6 +25,7 @@
 // Copyright (C) 2012 Pino Toscano 
 // Copyright (C) 2013 Jason Crain 
 // Copyright (C) 2015 William Bader 
+// Copyright (C) 2016 Jakub Kucharski 
 //
 // 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
@@ -176,37 +177,22 @@ void inline GooString::resize(int newLength) {
   s[length] = '\0';
 }
 
-GooString* GooString::Set(const char *s1, int s1Len, const char *s2, int s2Len)
+GooString* GooString::Set(const char *newStr, int newLen)
 {
-int newLen = 0;
-char *p;
-
-if (s1) {
-if (CALC_STRING_LEN == s1Len) {
-s1Len = strlen(s1);
-} else
-assert(s1Len >= 0);
-newLen += s1Len;
+if (!newStr) {
+clear();
+return this;
 }
 
-if (s2) {
-if (CALC_STRING_LEN == s2Len) {
-s2Len = strlen(s2);
-} else
-assert(s2Len >= 0);
-newLen += s2Len;
+if (newLen == CALC_STRING_LEN) {
+newLen = strlen(newStr);
+} else {
+assert(newLen >= 0);
 }
 
 resize(newLen);
-p = s;
-if (s1) {
-memcpy(p, s1, s1Len);
-p += s1Len;
-}
-if (s2) {
-memcpy(p, s2, s2Len);
-p += s2Len;
-}
+memmove(s, newStr, newLen);
+
 return this;
 }
 
@@ -244,7 +230,9 @@ GooString::GooString(const GooString *str) {
 GooString::GooString(GooString *str1, GooString *str2) {
   s = NULL;
   length = 0;
-  Set(str1->getCString(), str1->length, str2->getCString(), str2->length);
+  resize(str1->length + str2->length);
+  memcpy(s, str1->getCString(), str1->length);
+  memcpy(s + str1->length, str2->getCString(), str2->length);
 }
 
 GooString *GooString::fromInt(int x) {
diff --git a/goo/GooString.h b/goo/GooString.h
index 776dd59..5ff01ef 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -21,6 +21,7 @@
 // Copyright (C) 2012-2014 Fabio D'Urso 
 // Copyright (C) 2013 Jason Crain 
 // Copyright (C) 2015 Adam Reichold 
+// Copyright (C) 2016 Jakub Kucharski 
 //
 // 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
@@ -65,11 +66,10 @@ public:
   // Create a string from  chars at  in .
   GooString(GooString *str, int idx, int lengthA);
 
-  // Set content of a string to concatination of  and . They can both
-  // be NULL. if  or  is CALC_STRING_LEN, then length of the 
string
-  // will be calculated with strlen(). Otherwise we assume they are a valid
-  // length of string (or its substring)
-  GooString* Set(const char *s1, int s1Len=CALC_STRING_LEN, const char 
*s2=NULL, int s2Len=CALC_STRING_LEN);
+  // Set content of a string to . If  is CALC_STRING_LEN, then
+  // length of the string will be calculated with strlen(). Otherwise we assume
+  // this is a valid length of  (or its substring)
+  GooString* Set(const char *newStr, int newLen=CALC_STRING_LEN);
 
   // Copy a string.
   explicit GooString(const GooString *str);
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] goo/GooString.cc goo/GooString.h

2008-12-27 Thread Albert Astals Cid
 goo/GooString.cc |9 +
 goo/GooString.h  |2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

New commits:
commit 0f10561f3b1c90acc030d973399316bfca5f495e
Author: Albert Astals Cid aa...@kde.org
Date:   Sun Dec 28 01:44:25 2008 +0100

Fix my last commit, copypaste is really evil

diff --git a/goo/GooString.cc b/goo/GooString.cc
index 74645aa..3cff060 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -744,7 +744,7 @@ GBool GooString::hasUnicodeMarker(void)
 return (s[0]  0xff) == 0xfe  (s[1]  0xff) == 0xff;
 }
 
-GooString *GooString::sanitizedName(GBool psmode) const
+GooString *GooString::sanitizedName(GBool psmode)
 {
   GooString *name;
   char buf[8];
@@ -758,15 +758,16 @@ GooString *GooString::sanitizedName(GBool psmode) const
 // ghostscript chokes on names that begin with out-of-limits
 // numbers, e.g., 1e4foo is handled correctly (as a name), but
 // 1e999foo generates a limitcheck error
-c = name-getChar(0);
+c = getChar(0);
 if (c = '0'  c = '9') {
   name-append('f');
 }
   }
 
-  for (i = 0; i  name-getLength(); ++i) {
-c = name-getChar(i);
+  for (i = 0; i  getLength(); ++i) {
+c = getChar(i);
 if ((psmode  (c = (char)0x20 || c = (char)0x7f)) ||
+   c == ' ' ||
c == '(' || c == ')' || c == '' || c == '' ||
c == '[' || c == ']' || c == '{' || c == '}' ||
c == '/' || c == '%') {
diff --git a/goo/GooString.h b/goo/GooString.h
index bd7b1ff..6194555 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -142,7 +142,7 @@ public:
   // not contain any ( )   [ ] { } / %
   // The postscript mode also has some more strict checks
   // The caller owns the return value
-  GooString *sanitizedName(GBool psmode) const;
+  GooString *sanitizedName(GBool psmode);
 
 private:
   // you can tweak this number for a different speed/memory usage tradeoffs.
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler