[Libreoffice-commits] core.git: tools/source

2023-11-29 Thread Stephan Bergmann (via logerrit)
 tools/source/inet/inetmsg.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 3bc5f0a38ac1708817d3e61a74fa40a22c099664
Author: Stephan Bergmann 
AuthorDate: Wed Nov 29 14:37:58 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Nov 29 16:40:53 2023 +0100

Extended loplugin:ostr: tools

Change-Id: I7a585370b7d2a8021b733984e605cae8cc92c774
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160097
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx
index b2e7f70b40d4..a5c6838176a1 100644
--- a/tools/source/inet/inetmsg.cxx
+++ b/tools/source/inet/inetmsg.cxx
@@ -269,7 +269,7 @@ void INetMIMEMessage::EnableAttachMultipartFormDataChild()
 o3tl::sprintf (sTail, "%08X%08X",
  static_cast< unsigned int >(aCurTime.GetTime()),
  static_cast< unsigned int >(nThis));
-m_aBoundary = "_4D48";
+m_aBoundary = "_4D48"_ostr;
 m_aBoundary += sTail;
 
 // Set header fields.


[Libreoffice-commits] core.git: tools/source

2023-10-23 Thread sahil (via logerrit)
 tools/source/stream/strmunx.cxx |   16 
 1 file changed, 4 insertions(+), 12 deletions(-)

New commits:
commit d56b61975330329c5dc1e99cc7750a690d3206ed
Author: sahil 
AuthorDate: Wed Sep 13 03:43:07 2023 +0530
Commit: Hossein 
CommitDate: Mon Oct 23 15:50:09 2023 +0200

tdf#130924 replace '*printf' with 'SAL_*' logging macros in tools

Change-Id: I9721bfd3783fd6c5d41b2d9a0e8468c583ede0c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156864
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index c19d5b00b4b2..881d7a28c0af 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -321,10 +321,7 @@ bool SvFileStream::LockFile()
 
 if( !lockFile( this ) )
 {
-#if OSL_DEBUG_LEVEL > 1
-fprintf( stderr, "InternalLock on %s failed\n",
- OUStringToOString(aFilename, 
osl_getThreadTextEncoding()).getStr() );
-#endif
+SAL_WARN("tools.stream", "InternalLock on " << aFilename << "failed");
 return false;
 }
 
@@ -403,14 +400,9 @@ void SvFileStream::Open( const OUString& rFilename, 
StreamMode nOpenMode )
 if (osl::File::remove( aFileURL ) == osl::FileBase::E_None )
 {
 File::copy( aStatus.getLinkTargetURL(), aFileURL );
-#if OSL_DEBUG_LEVEL > 0
-fprintf( stderr,
- "Removing link and replacing with file contents 
(%s) -> (%s).\n",
- OUStringToOString( aStatus.getLinkTargetURL(),
- 
RTL_TEXTENCODING_UTF8).getStr(),
- OUStringToOString( aFileURL,
- 
RTL_TEXTENCODING_UTF8).getStr() );
-#endif
+SAL_INFO("tools.stream",
+"Removing link and replacing with file contents (" <<
+aStatus.getLinkTargetURL() << ") -> (" << aFileURL << 
").");
 }
 }
 }


[Libreoffice-commits] core.git: tools/source

2023-10-20 Thread Stephan Bergmann (via logerrit)
 tools/source/fsys/urlobj.cxx |   56 +--
 1 file changed, 28 insertions(+), 28 deletions(-)

New commits:
commit 5f69ffb27a09e094c5ba9da214c769b5ec2ce406
Author: Stephan Bergmann 
AuthorDate: Thu Oct 19 10:30:36 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Oct 20 21:51:02 2023 +0200

Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: tools

Change-Id: I930c794c6f93531ef8d2b91c5e6ad62b486966dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158245
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 897d1c47ebd1..3c54eea3d664 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -318,34 +318,34 @@ struct INetURLObject::PrefixInfo
 inline INetURLObject::SchemeInfo const &
 INetURLObject::getSchemeInfo(INetProtocol eTheScheme)
 {
-static constexpr OUStringLiteral EMPTY = u"";
-static constexpr OUStringLiteral FTP = u"ftp";
-static constexpr OUStringLiteral HTTP = u"http";
-static constexpr OUStringLiteral FILE1 = u"file"; // because FILE is 
already defined
-static constexpr OUStringLiteral MAILTO = u"mailto";
-static constexpr OUStringLiteral VND_WEBDAV = u"vnd.sun.star.webdav";
-static constexpr OUStringLiteral PRIVATE = u"private";
-static constexpr OUStringLiteral VND_HELP = u"vnd.sun.star.help";
-static constexpr OUStringLiteral HTTPS = u"https";
-static constexpr OUStringLiteral SLOT = u"slot";
-static constexpr OUStringLiteral MACRO = u"macro";
-static constexpr OUStringLiteral JAVASCRIPT = u"javascript";
-static constexpr OUStringLiteral DATA = u"data";
-static constexpr OUStringLiteral CID = u"cid";
-static constexpr OUStringLiteral VND_HIER = u"vnd.sun.star.hier";
-static constexpr OUStringLiteral UNO = u".uno";
-static constexpr OUStringLiteral COMPONENT = u".component";
-static constexpr OUStringLiteral VND_PKG = u"vnd.sun.star.pkg";
-static constexpr OUStringLiteral LDAP = u"ldap";
-static constexpr OUStringLiteral DB = u"db";
-static constexpr OUStringLiteral VND_CMD = u"vnd.sun.star.cmd";
-static constexpr OUStringLiteral TELNET = u"telnet";
-static constexpr OUStringLiteral VND_EXPAND = u"vnd.sun.star.expand";
-static constexpr OUStringLiteral VND_TDOC = u"vnd.sun.star.tdoc";
-static constexpr OUStringLiteral SMB = u"smb";
-static constexpr OUStringLiteral HID = u"hid";
-static constexpr OUStringLiteral SFTP = u"sftp";
-static constexpr OUStringLiteral VND_CMIS = u"vnd.libreoffice.cmis";
+static constexpr OUString EMPTY = u""_ustr;
+static constexpr OUString FTP = u"ftp"_ustr;
+static constexpr OUString HTTP = u"http"_ustr;
+static constexpr OUString FILE1 = u"file"_ustr; // because FILE is already 
defined
+static constexpr OUString MAILTO = u"mailto"_ustr;
+static constexpr OUString VND_WEBDAV = u"vnd.sun.star.webdav"_ustr;
+static constexpr OUString PRIVATE = u"private"_ustr;
+static constexpr OUString VND_HELP = u"vnd.sun.star.help"_ustr;
+static constexpr OUString HTTPS = u"https"_ustr;
+static constexpr OUString SLOT = u"slot"_ustr;
+static constexpr OUString MACRO = u"macro"_ustr;
+static constexpr OUString JAVASCRIPT = u"javascript"_ustr;
+static constexpr OUString DATA = u"data"_ustr;
+static constexpr OUString CID = u"cid"_ustr;
+static constexpr OUString VND_HIER = u"vnd.sun.star.hier"_ustr;
+static constexpr OUString UNO = u".uno"_ustr;
+static constexpr OUString COMPONENT = u".component"_ustr;
+static constexpr OUString VND_PKG = u"vnd.sun.star.pkg"_ustr;
+static constexpr OUString LDAP = u"ldap"_ustr;
+static constexpr OUString DB = u"db"_ustr;
+static constexpr OUString VND_CMD = u"vnd.sun.star.cmd"_ustr;
+static constexpr OUString TELNET = u"telnet"_ustr;
+static constexpr OUString VND_EXPAND = u"vnd.sun.star.expand"_ustr;
+static constexpr OUString VND_TDOC = u"vnd.sun.star.tdoc"_ustr;
+static constexpr OUString SMB = u"smb"_ustr;
+static constexpr OUString HID = u"hid"_ustr;
+static constexpr OUString SFTP = u"sftp"_ustr;
+static constexpr OUString VND_CMIS = u"vnd.libreoffice.cmis"_ustr;
 
 static o3tl::enumarray constexpr map = {
 // [-loplugin:redundantfcast]:


[Libreoffice-commits] core.git: tools/source

2023-07-27 Thread Mike Kaganski (via logerrit)
 tools/source/generic/fract.cxx |   22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

New commits:
commit a7ffd469fb125f92da9848c2cfb09991862599c5
Author: Mike Kaganski 
AuthorDate: Thu Jul 27 14:49:50 2023 +0200
Commit: Mike Kaganski 
CommitDate: Thu Jul 27 15:49:17 2023 +0200

Check / adjust the correct variables

mnNumerator / mnDenominator are sal_Int32, so after they were assigned,
they can't be out of range.

Introduce a gcd initial step to avoid precision loss sometimes.

Negative denominator is used quite some time, so drop the obsolete
comment, while here.

Change-Id: I66b77fb3d69cfd2265ac2ed88344af9cfade405b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154957
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index a583e75a7cac..abe8ee41b206 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -55,21 +55,25 @@ static constexpr bool isOutOfRange(sal_Int64 nNum)
 || nNum > std::numeric_limits::max();
 }
 
-// Initialized by setting nNum as nominator and nDen as denominator
-// Negative values in the denominator are invalid and cause the
-// inversion of both nominator and denominator signs
-// in order to return the correct value.
 Fraction::Fraction( sal_Int64 nNum, sal_Int64 nDen ) : mnNumerator(nNum), 
mnDenominator(nDen)
 {
 if ( isOutOfRange(nNum) || isOutOfRange(nDen) )
 {
 // tdf#143200
-SAL_WARN("tools.fraction", "values outside of range we can represent, 
doing reduction, which will reduce precision");
-do
+if (const auto gcd = std::gcd(nNum, nDen); gcd > 1)
 {
-mnNumerator /= 2;
-mnDenominator /= 2;
-} while (isOutOfRange(mnNumerator) || isOutOfRange(mnDenominator));
+nNum /= gcd;
+nDen /= gcd;
+}
+SAL_WARN_IF(isOutOfRange(nNum) || isOutOfRange(nDen),
+"tools.fraction", "values outside of range we can 
represent, doing reduction, which will reduce precision");
+while (isOutOfRange(nNum) || isOutOfRange(nDen))
+{
+nNum /= 2;
+nDen /= 2;
+}
+mnNumerator = nNum;
+mnDenominator = nDen;
 }
 if ( mnDenominator == 0 )
 {


[Libreoffice-commits] core.git: tools/source

2023-07-22 Thread Noel Grandin (via logerrit)
 tools/source/xml/XmlWriter.cxx |   31 ++-
 1 file changed, 10 insertions(+), 21 deletions(-)

New commits:
commit 60d7b73d6d92eeb331cfe48734094330546477db
Author: Noel Grandin 
AuthorDate: Sat Jul 22 14:33:40 2023 +0200
Commit: Noel Grandin 
CommitDate: Sat Jul 22 16:57:26 2023 +0200

avoid some unnecessary string copies in tools::XmlWriter

Change-Id: I5844a878f3e1d85956eae828e9093b2fd1f5a275
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154757
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/xml/XmlWriter.cxx b/tools/source/xml/XmlWriter.cxx
index 85fbbf99544e..a13190ecf9d2 100644
--- a/tools/source/xml/XmlWriter.cxx
+++ b/tools/source/xml/XmlWriter.cxx
@@ -82,28 +82,21 @@ void XmlWriter::endDocument()
 void XmlWriter::startElement(const OString& sPrefix, const OString& sName,
  const OString& sNamespaceUri)
 {
-xmlChar* xmlName = xmlCharStrdup(sName.getStr());
+xmlChar* xmlName = BAD_CAST(sName.getStr());
 xmlChar* xmlPrefix = nullptr;
 xmlChar* xmlNamespaceUri = nullptr;
 if (!sPrefix.isEmpty())
-xmlPrefix = xmlCharStrdup(sPrefix.getStr());
+xmlPrefix = BAD_CAST(sPrefix.getStr());
 if (!sNamespaceUri.isEmpty())
-xmlNamespaceUri = xmlCharStrdup(sNamespaceUri.getStr());
+xmlNamespaceUri = BAD_CAST(sNamespaceUri.getStr());
 
 (void)xmlTextWriterStartElementNS(mpImpl->mpWriter, xmlPrefix, xmlName, 
xmlNamespaceUri);
-
-xmlFree(xmlName);
-if (!sPrefix.isEmpty())
-xmlFree(xmlPrefix);
-if (!sNamespaceUri.isEmpty())
-xmlFree(xmlNamespaceUri);
 }
 
 void XmlWriter::startElement(const OString& sName)
 {
-xmlChar* xmlName = xmlCharStrdup(sName.getStr());
+xmlChar* xmlName = BAD_CAST(sName.getStr());
 (void)xmlTextWriterStartElement(mpImpl->mpWriter, xmlName);
-xmlFree(xmlName);
 }
 
 void XmlWriter::endElement() { 
(void)xmlTextWriterEndElement(mpImpl->mpWriter); }
@@ -116,20 +109,17 @@ void XmlWriter::attributeBase64(const OString& rsName, 
std::vector co
 
 void XmlWriter::attributeBase64(const OString& rsName, std::vector 
const& rValueInBytes)
 {
-xmlChar* xmlName = xmlCharStrdup(rsName.getStr());
+xmlChar* xmlName = BAD_CAST(rsName.getStr());
 (void)xmlTextWriterStartAttribute(mpImpl->mpWriter, xmlName);
 (void)xmlTextWriterWriteBase64(mpImpl->mpWriter, rValueInBytes.data(), 0, 
rValueInBytes.size());
 (void)xmlTextWriterEndAttribute(mpImpl->mpWriter);
-xmlFree(xmlName);
 }
 
 void XmlWriter::attribute(const OString& name, const OString& value)
 {
-xmlChar* xmlName = xmlCharStrdup(name.getStr());
-xmlChar* xmlValue = xmlCharStrdup(value.getStr());
+xmlChar* xmlName = BAD_CAST(name.getStr());
+xmlChar* xmlValue = BAD_CAST(value.getStr());
 (void)xmlTextWriterWriteAttribute(mpImpl->mpWriter, xmlName, xmlValue);
-xmlFree(xmlValue);
-xmlFree(xmlName);
 }
 
 void XmlWriter::attribute(const OString& name, std::u16string_view value)
@@ -139,19 +129,18 @@ void XmlWriter::attribute(const OString& name, 
std::u16string_view value)
 
 void XmlWriter::attribute(const OString& name, const sal_Int32 aNumber)
 {
-attribute(name, OUString::number(aNumber));
+attribute(name, OString::number(aNumber));
 }
 
 void XmlWriter::attributeDouble(const OString& name, const double aNumber)
 {
-attribute(name, OUString::number(aNumber));
+attribute(name, OString::number(aNumber));
 }
 
 void XmlWriter::content(const OString& sValue)
 {
-xmlChar* xmlValue = xmlCharStrdup(sValue.getStr());
+xmlChar* xmlValue = BAD_CAST(sValue.getStr());
 (void)xmlTextWriterWriteString(mpImpl->mpWriter, xmlValue);
-xmlFree(xmlValue);
 }
 
 void XmlWriter::content(std::u16string_view sValue)


[Libreoffice-commits] core.git: tools/source

2023-07-16 Thread Julien Nabet (via logerrit)
 tools/source/misc/json_writer.cxx |5 -
 1 file changed, 5 deletions(-)

New commits:
commit 5ae47ac0a750dd7220c74daa4bdcd5a3e92924f7
Author: Julien Nabet 
AuthorDate: Sat Jul 15 21:52:10 2023 +0200
Commit: Julien Nabet 
CommitDate: Sun Jul 16 12:07:17 2023 +0200

cid#1537992 deadcode

since 16b0da38515467bf1819ccd88027934481cc5727
jsdialog: encode properly control characters

Change-Id: Ic447a819d3d0b3f9ff66e00f0b05a037ec53a9cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154488
Reviewed-by: Julien Nabet 
Tested-by: Julien Nabet 

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index 6e8cd7eafe86..e3e27bf756b4 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -146,11 +146,6 @@ static bool writeEscapedSequence(sal_uInt32 ch, char*& pos)
 
 switch (ch)
 {
-case '\b':
-case '\t':
-case '\n':
-case '\f':
-case '\r':
 case '"':
 case '/':
 case '\\':


[Libreoffice-commits] core.git: tools/source

2023-06-27 Thread Andrea Gelmini (via logerrit)
 tools/source/datetime/duration.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 858dfb53598ed379a2e72c887a7f77909b550ca0
Author: Andrea Gelmini 
AuthorDate: Sat Jun 17 18:10:33 2023 +0200
Commit: Julien Nabet 
CommitDate: Tue Jun 27 18:52:23 2023 +0200

Fix typo

Change-Id: I8dee1f762a39b21e88609d1d108846623d0b8bc2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153207
Tested-by: Julien Nabet 
Reviewed-by: Julien Nabet 

diff --git a/tools/source/datetime/duration.cxx 
b/tools/source/datetime/duration.cxx
index 42ce2a8a6cc4..a7b2762fff49 100644
--- a/tools/source/datetime/duration.cxx
+++ b/tools/source/datetime/duration.cxx
@@ -236,7 +236,7 @@ Duration Duration::Mult(sal_Int32 nMult, bool& rbOverflow) 
const
 }
 if (bBadNS)
 {
-// Simple calculation in overall nanoseconds overflew, try with
+// Simple calculation in overall nanoseconds overflowed, try with
 // individual components.
 const sal_uInt64 nMult64 = (nMult < 0) ? -nMult : nMult;
 do


[Libreoffice-commits] core.git: tools/source

2023-06-23 Thread Eike Rathke (via logerrit)
 tools/source/datetime/ttime.cxx |   12 
 1 file changed, 12 insertions(+)

New commits:
commit b07d72c6c1075efa6b64c67758566426c22c5225
Author: Eike Rathke 
AuthorDate: Wed Jun 21 21:46:17 2023 +0200
Commit: Eike Rathke 
CommitDate: Fri Jun 23 14:27:05 2023 +0200

Clamp and assert maximum hours value in Time::init()

Change-Id: Ia777222f3c797b90663b55499a57025e410b1d70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153407
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index 148bf0cbecc6..fcfa2e080e99 100644
--- a/tools/source/datetime/ttime.cxx
+++ b/tools/source/datetime/ttime.cxx
@@ -125,6 +125,18 @@ void tools::Time::init( sal_uInt32 nHour, sal_uInt32 nMin, 
sal_uInt32 nSec, sal_
 nHour+= nMin / minInHour;
 nMin %= minInHour;
 
+// 922337 * HOUR_MASK = 9223370 largest possible value, 922338
+// would be -9223364073709551616.
+assert(HOUR_MASK * nHour >= 0 && "use tools::Duration with days instead!");
+if (HOUR_MASK * nHour < 0)
+nHour = 922337;
+
+// But as is, GetHour() retrieves only sal_uInt16. Though retrieving in
+// nanoseconds or milliseconds might be possible this is all crap.
+assert(nHour <= SAL_MAX_UINT16 && "use tools::Duration with days 
instead!");
+if (nHour > SAL_MAX_UINT16)
+nHour = SAL_MAX_UINT16;
+
 // construct time
 nTime = nNanoSec +
 nSec  * SEC_MASK +


[Libreoffice-commits] core.git: tools/source

2023-06-21 Thread Eike Rathke (via logerrit)
 tools/source/datetime/duration.cxx |1 -
 1 file changed, 1 deletion(-)

New commits:
commit c7b2277f57cf72b7dc6e4cbd179ce40951fbae8c
Author: Eike Rathke 
AuthorDate: Wed Jun 21 14:32:55 2023 +0200
Commit: Eike Rathke 
CommitDate: Wed Jun 21 16:34:46 2023 +0200

rbOverflow was already set for bBadNS, unnecessary to set it again

Change-Id: I26e32b25b53be590bc24646803c7442385ec4d3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153393
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/tools/source/datetime/duration.cxx 
b/tools/source/datetime/duration.cxx
index be51a6e95e0f..3aa195cfbda5 100644
--- a/tools/source/datetime/duration.cxx
+++ b/tools/source/datetime/duration.cxx
@@ -173,7 +173,6 @@ Duration Duration::Mult(sal_Int32 nMult, bool& rbOverflow) 
const
 const sal_uInt64 nMult64 = (nMult < 0) ? -nMult : nMult;
 do
 {
-rbOverflow = true;
 sal_uInt64 nN;
 if 
(o3tl::checked_multiply(static_cast(maTime.GetNanoSec()), nMult64, 
nN))
 break;


[Libreoffice-commits] core.git: tools/source

2023-06-20 Thread Eike Rathke (via logerrit)
 tools/source/datetime/datetime.cxx |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

New commits:
commit d3d77d99e3e6f05b232923edc2ea23e513a721d5
Author: Eike Rathke 
AuthorDate: Tue Jun 20 15:07:59 2023 +0200
Commit: Eike Rathke 
CommitDate: Tue Jun 20 16:52:23 2023 +0200

Use tools::Duration in friend double operator-() if DateTime has Time set

Change-Id: Iff3e2aad596fdfd1530c46cdeff28b44e5142517
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153327
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/tools/source/datetime/datetime.cxx 
b/tools/source/datetime/datetime.cxx
index ec2c53673b17..bb4c1ff173a5 100644
--- a/tools/source/datetime/datetime.cxx
+++ b/tools/source/datetime/datetime.cxx
@@ -196,18 +196,13 @@ DateTime operator +( const DateTime& rDateTime, double 
fTimeInDays )
 
 double operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 )
 {
-sal_Int32 nDays = static_cast(rDateTime1)
-- static_cast(rDateTime2);
-sal_Int64 nTime = rDateTime1.GetNSFromTime() - rDateTime2.GetNSFromTime();
-if ( nTime )
+if (static_cast(rDateTime1) != static_cast(rDateTime2))
 {
-double fTime = double(nTime);
-fTime /= ::tools::Time::nanoSecPerDay; // convert from nanoseconds to 
fraction
-if ( nDays < 0 && fTime > 0.0 )
-fTime = 1.0 - fTime;
-return double(nDays) + fTime;
+// Use Duration to diminish floating point accuracy errors.
+const tools::Duration aDuration( rDateTime2, rDateTime1);
+return aDuration.GetInDays();
 }
-return double(nDays);
+return static_cast(rDateTime1) - static_cast(rDateTime2);
 }
 
 void DateTime::GetWin32FileDateTime( sal_uInt32 & rLower, sal_uInt32 & rUpper 
) const


[Libreoffice-commits] core.git: tools/source

2023-06-19 Thread Julien Nabet (via logerrit)
 tools/source/datetime/duration.cxx |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 99d01ff26fe69ccc66f49b3ddd43b258c3687f2c
Author: Julien Nabet 
AuthorDate: Mon Jun 19 10:10:42 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Mon Jun 19 13:56:21 2023 +0200

Fix TB Jenkins_Linux_Ubsan (duration.cxx)

/tools/source/datetime/duration.cxx:190:77: runtime error: negation of 
-2147483648 cannot be represented in type 'sal_Int32' (aka 'int'); cast to an 
unsigned type to negate this value to itself
0 0x7f08bd84936d in tools::Duration::Mult(int, bool&) const 
/tools/source/datetime/duration.cxx:190:77
1 0x7f08c1c1d27a in tools::DurationTest::testDuration() 
/tools/qa/cppunit/test_duration.cxx:219:26

Detected thanks to eac63ab120a181a1dff6317ee3d223327080e992
Related: tdf#153517 Introduce class tools::Duration

Change-Id: I3804cc4ff4011a7f3b393b82b27f0c805682fbb4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153254
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/tools/source/datetime/duration.cxx 
b/tools/source/datetime/duration.cxx
index c8cb4616eb08..be51a6e95e0f 100644
--- a/tools/source/datetime/duration.cxx
+++ b/tools/source/datetime/duration.cxx
@@ -187,8 +187,10 @@ Duration Duration::Mult(sal_Int32 nMult, bool& rbOverflow) 
const
 if 
(o3tl::checked_multiply(static_cast(maTime.GetHour()), nMult64, nH))
 break;
 sal_uInt64 nD;
-if (o3tl::checked_multiply(static_cast(mnDays < 0 ? 
-mnDays : mnDays),
-   nMult64, nD))
+if (o3tl::checked_multiply(
+mnDays < 0 ? 
static_cast(-static_cast(mnDays))
+   : static_cast(mnDays),
+nMult64, nD))
 break;
 if (nN > Time::nanoSecPerSec)
 {


[Libreoffice-commits] core.git: tools/source

2023-06-17 Thread Andrea Gelmini (via logerrit)
 tools/source/datetime/duration.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c041b5a3bc3301f137b141e1731b711178d536d2
Author: Andrea Gelmini 
AuthorDate: Sat Jun 17 18:09:17 2023 +0200
Commit: Julien Nabet 
CommitDate: Sat Jun 17 20:50:14 2023 +0200

Fix typo

Change-Id: I1d7b271eed63dd0272bd92431eaac3e2dfbfe2b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153206
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/tools/source/datetime/duration.cxx 
b/tools/source/datetime/duration.cxx
index 07f79929177f..c8cb4616eb08 100644
--- a/tools/source/datetime/duration.cxx
+++ b/tools/source/datetime/duration.cxx
@@ -67,7 +67,7 @@ Duration::Duration(double fTimeInDays)
 fFrac = ::rtl::math::approxFloor(fFrac);
 sal_Int64 nNS = static_cast(fFrac);
 // Round by 1 nanosecond if it's just 1 off to a second, i.e.
-// 09 or 01. This could be losened to rounding by 2 or
+// 09 or 01. This could be loosened to rounding by 2 or
 // such if necessary.
 const sal_Int64 nN = nNS % Time::nanoSecPerSec;
 if (std::abs(nN) == 1)


[Libreoffice-commits] core.git: tools/source

2023-05-18 Thread Eike Rathke (via logerrit)
 tools/source/datetime/datetime.cxx |   30 --
 1 file changed, 16 insertions(+), 14 deletions(-)

New commits:
commit 261063e69e80193ad563e086c515fd6e22e48464
Author: Eike Rathke 
AuthorDate: Thu May 18 23:30:51 2023 +0200
Commit: Eike Rathke 
CommitDate: Fri May 19 02:29:18 2023 +0200

Eliminate 24h loops in DateTime::operator+=/-=(tools::Time&)

... and repeated Date::operator++/--() that each calculate
lcl_DaysToDate( GetAsNormalizedDays() + 1 )
where Date::AddDays() does it once.

Also, that probably never worked correctly with negative time results >=24h

Change-Id: Ic67aaa3d93e0d6533501d52671acf765e2d9bbdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151984
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/tools/source/datetime/datetime.cxx 
b/tools/source/datetime/datetime.cxx
index 00790ff78dd4..efdb928986c3 100644
--- a/tools/source/datetime/datetime.cxx
+++ b/tools/source/datetime/datetime.cxx
@@ -101,19 +101,20 @@ DateTime& DateTime::operator +=( const tools::Time& rTime 
)
 sal_uInt16 nHours = aTime.GetHour();
 if ( aTime.GetTime() > 0 )
 {
-while ( nHours >= 24 )
+if (nHours >= 24)
 {
-Date::operator++();
-nHours -= 24;
+AddDays( nHours / 24 );
+nHours %= 24;
+aTime.SetHour( nHours );
 }
-aTime.SetHour( nHours );
 }
 else if ( aTime.GetTime() != 0 )
 {
-while ( nHours >= 24 )
+if (nHours >= 24)
 {
-Date::operator--();
-nHours -= 24;
+AddDays( -static_cast(nHours) / 24 );
+nHours %= 24;
+aTime.SetHour( nHours );
 }
 Date::operator--();
 aTime = Time( 24, 0, 0 )+aTime;
@@ -130,19 +131,20 @@ DateTime& DateTime::operator -=( const tools::Time& rTime 
)
 sal_uInt16 nHours = aTime.GetHour();
 if ( aTime.GetTime() > 0 )
 {
-while ( nHours >= 24 )
+if (nHours >= 24)
 {
-Date::operator++();
-nHours -= 24;
+AddDays( nHours / 24 );
+nHours %= 24;
+aTime.SetHour( nHours );
 }
-aTime.SetHour( nHours );
 }
 else if ( aTime.GetTime() != 0 )
 {
-while ( nHours >= 24 )
+if (nHours >= 24)
 {
-Date::operator--();
-nHours -= 24;
+AddDays( -static_cast(nHours) / 24 );
+nHours %= 24;
+aTime.SetHour( nHours );
 }
 Date::operator--();
 aTime = Time( 24, 0, 0 )+aTime;


[Libreoffice-commits] core.git: tools/source

2023-04-27 Thread Jaume Pujantell (via logerrit)
 tools/source/misc/json_writer.cxx |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 2fe581d916b76d613742c983731fb4a10b4ee95f
Author: Jaume Pujantell 
AuthorDate: Tue Apr 18 10:34:47 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Apr 27 12:13:37 2023 +0200

fix bug in json_writer

Ruler stores null-terminated strings in fixed length char arrays, so when 
creating a JSON
a string might end earlier that it's size sugsests.

Change-Id: Icdcaf35f9ce54c24dcd36368dc49bb688a2a65ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150542
Reviewed-by: Michael Meeks 
Tested-by: Jenkins

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index e7a0f55fd6c2..3111cac2f816 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -236,7 +236,8 @@ void JsonWriter::put(std::string_view pPropName, 
std::string_view rPropVal)
 ++mPos;
 
 // copy and perform escaping
-for (size_t i = 0; i < rPropVal.size(); ++i)
+bool bReachedEnd = false;
+for (size_t i = 0; i < rPropVal.size() && !bReachedEnd; ++i)
 {
 char ch = rPropVal[i];
 switch (ch)
@@ -251,6 +252,9 @@ void JsonWriter::put(std::string_view pPropName, 
std::string_view rPropVal)
 case '\\':
 writeEscapedSequence(ch, mPos);
 break;
+case 0:
+bReachedEnd = true;
+break;
 case '\xE2': // Special processing of U+2028 and U+2029
 if (i + 2 < rPropVal.size() && rPropVal[i + 1] == '\x80'
 && (rPropVal[i + 2] == '\xA8' || rPropVal[i + 2] == 
'\xA9'))


[Libreoffice-commits] core.git: tools/source

2023-04-17 Thread Noel Grandin (via logerrit)
 tools/source/generic/fract.cxx |   44 -
 1 file changed, 22 insertions(+), 22 deletions(-)

New commits:
commit b1684730ccbbca83df4dcb07d4759eebebbc4d66
Author: Noel Grandin 
AuthorDate: Mon Apr 17 13:24:25 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Apr 18 07:51:38 2023 +0200

tdf#143200 assert when pasting a cell to a large-height range

The values are unfortunately genuinely outside the range that our
Fraction class can work with.
So do the least-bad thing for now, and reduce the magnitude of the
values until they fit.

Change-Id: Iedc34e9767b3d4a502f5d84efcdebc96c6514cac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150493
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 4acd46cec404..a583e75a7cac 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -49,24 +49,36 @@ static boost::rational toRational(sal_Int32 n, 
sal_Int32 d)
 return boost::rational(n, d);
 }
 
+static constexpr bool isOutOfRange(sal_Int64 nNum)
+{
+return nNum < std::numeric_limits::min()
+|| nNum > std::numeric_limits::max();
+}
+
 // Initialized by setting nNum as nominator and nDen as denominator
 // Negative values in the denominator are invalid and cause the
 // inversion of both nominator and denominator signs
 // in order to return the correct value.
 Fraction::Fraction( sal_Int64 nNum, sal_Int64 nDen ) : mnNumerator(nNum), 
mnDenominator(nDen)
 {
-assert( nNum >= std::numeric_limits::min() );
-assert( nNum <= std::numeric_limits::max( ));
-assert( nDen >= std::numeric_limits::min() );
-assert( nDen <= std::numeric_limits::max( ));
-if ( nDen == 0 )
+if ( isOutOfRange(nNum) || isOutOfRange(nDen) )
+{
+// tdf#143200
+SAL_WARN("tools.fraction", "values outside of range we can represent, 
doing reduction, which will reduce precision");
+do
+{
+mnNumerator /= 2;
+mnDenominator /= 2;
+} while (isOutOfRange(mnNumerator) || isOutOfRange(mnDenominator));
+}
+if ( mnDenominator == 0 )
 {
 mbValid = false;
 SAL_WARN( "tools.fraction", "'Fraction(" << nNum << ",0)' invalid 
fraction created" );
 return;
 }
-if ((nDen == -1 && nNum == std::numeric_limits::min()) ||
-(nNum == -1 && nDen == std::numeric_limits::min()))
+else if ((nDen == -1 && nNum == std::numeric_limits::min()) ||
+(nNum == -1 && nDen == std::numeric_limits::min()))
 {
 mbValid = false;
 SAL_WARN("tools.fraction", "'Fraction(" << nNum << "," << nDen << ")' 
invalid fraction created");
@@ -77,21 +89,9 @@ Fraction::Fraction( sal_Int64 nNum, sal_Int64 nDen ) : 
mnNumerator(nNum), mnDeno
 /**
  * only here to prevent passing of NaN
  */
-Fraction::Fraction( double nNum, double nDen ) : mnNumerator(sal_Int64(nNum)), 
mnDenominator(sal_Int64(nDen))
-{
-assert( !std::isnan(nNum) );
-assert( !std::isnan(nDen) );
-assert( nNum >= std::numeric_limits::min() );
-assert( nNum <= std::numeric_limits::max( ));
-assert( nDen >= std::numeric_limits::min() );
-assert( nDen <= std::numeric_limits::max( ));
-if ( nDen == 0 )
-{
-mbValid = false;
-SAL_WARN( "tools.fraction", "'Fraction(" << nNum << ",0)' invalid 
fraction created" );
-return;
-}
-}
+Fraction::Fraction( double nNum, double nDen )
+: Fraction(sal_Int64(nNum), sal_Int64(nDen))
+{}
 
 Fraction::Fraction( double dVal )
 {


[Libreoffice-commits] core.git: tools/source vcl/source

2023-02-27 Thread Noel Grandin (via logerrit)
 tools/source/stream/GenericTypeSerializer.cxx |   12 
 vcl/source/filter/svm/SvmReader.cxx   |   19 ---
 2 files changed, 12 insertions(+), 19 deletions(-)

New commits:
commit 3d7b0a6ebbf5154933bc4a450613362052167791
Author: Noel Grandin 
AuthorDate: Mon Feb 27 14:06:47 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Feb 28 07:23:23 2023 +

move sanitizing of Size inside GenericTypeSerializer

I cannot see a useful application of a Size that is negative
(at least not in a file format).

Change-Id: I0c5bd8c7d3987a5c7803af2a6ae0543c4a6d7754
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147884
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/stream/GenericTypeSerializer.cxx 
b/tools/source/stream/GenericTypeSerializer.cxx
index 8abe23237d85..3eefb008ea67 100644
--- a/tools/source/stream/GenericTypeSerializer.cxx
+++ b/tools/source/stream/GenericTypeSerializer.cxx
@@ -130,6 +130,18 @@ void GenericTypeSerializer::readSize(Size& rSize)
 
 rSize.setWidth(nWidth);
 rSize.setHeight(nHeight);
+
+// sanitize negative size dimensions
+if (rSize.Width() < 0)
+{
+SAL_WARN("tools", "negative width");
+rSize.setWidth(0);
+}
+if (rSize.Height() < 0)
+{
+SAL_WARN("tools", "negative height");
+rSize.setHeight(0);
+}
 }
 
 void GenericTypeSerializer::writeSize(const Size& rSize)
diff --git a/vcl/source/filter/svm/SvmReader.cxx 
b/vcl/source/filter/svm/SvmReader.cxx
index a7a4dcbd7817..6d84d44d879f 100644
--- a/vcl/source/filter/svm/SvmReader.cxx
+++ b/vcl/source/filter/svm/SvmReader.cxx
@@ -55,21 +55,6 @@ public:
 m_rData.meActualCharSet = m_eOrigCharSet;
 }
 };
-
-void sanitizeNegativeSizeDimensions(Size& rSize)
-{
-if (rSize.Width() < 0)
-{
-SAL_WARN("vcl.gdi", "sanitizeNegativeSizeDimensions: negative width");
-rSize.setWidth(0);
-}
-
-if (rSize.Height() < 0)
-{
-SAL_WARN("vcl.gdi", "sanitizeNegativeSizeDimensions: negative height");
-rSize.setHeight(0);
-}
-}
 }
 
 SvmReader::SvmReader(SvStream& rIStm)
@@ -110,7 +95,6 @@ SvStream& SvmReader::Read(GDIMetaFile& rMetaFile, 
ImplMetaReadData* pData)
 rMetaFile.SetPrefMapMode(aMapMode);
 Size aSize;
 aSerializer.readSize(aSize);
-sanitizeNegativeSizeDimensions(aSize);
 rMetaFile.SetPrefSize(aSize);
 mrStream.ReadUInt32(nCount);
 
@@ -884,7 +868,6 @@ rtl::Reference SvmReader::BmpScaleHandler()
 
 Size aSz;
 aSerializer.readSize(aSz);
-sanitizeNegativeSizeDimensions(aSz);
 
 pAction->SetBitmap(aBmp);
 pAction->SetPoint(aPoint);
@@ -949,7 +932,6 @@ rtl::Reference SvmReader::BmpExScaleHandler()
 
 Size aSize;
 aSerializer.readSize(aSize);
-sanitizeNegativeSizeDimensions(aSize);
 
 pAction->SetBitmapEx(aBmpEx);
 pAction->SetPoint(aPoint);
@@ -1340,7 +1322,6 @@ rtl::Reference 
SvmReader::FloatTransparentHandler(ImplMetaReadData*
 
 Size aSize;
 aSerializer.readSize(aSize);
-sanitizeNegativeSizeDimensions(aSize);
 
 Gradient aGradient;
 aSerializer.readGradient(aGradient);


[Libreoffice-commits] core.git: tools/source

2022-12-30 Thread Tor Lillqvist (via logerrit)
 tools/source/misc/extendapplicationenvironment.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit af560f84efc5e48f122a468450f51dfff8359c8e
Author: Tor Lillqvist 
AuthorDate: Fri Dec 30 12:55:31 2022 +0200
Commit: Tor Lillqvist 
CommitDate: Fri Dec 30 12:15:06 2022 +

I get "warning: unsupported syscall: __sys_prlimit64" in WASM so avoid that

Change-Id: I8a9a19d3c7757e1b7e1d194c439280a9d4824c3a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144876
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/tools/source/misc/extendapplicationenvironment.cxx 
b/tools/source/misc/extendapplicationenvironment.cxx
index ce2237a88c70..07f9779ccc26 100644
--- a/tools/source/misc/extendapplicationenvironment.cxx
+++ b/tools/source/misc/extendapplicationenvironment.cxx
@@ -38,7 +38,7 @@ namespace tools
 {
 void extendApplicationEnvironment()
 {
-#if defined UNX
+#if defined UNX && !defined EMSCRIPTEN
 // Try to set RLIMIT_NOFILE as large as possible (failure is harmless):
 rlimit lim;
 if (getrlimit(RLIMIT_NOFILE, ) == 0)


[Libreoffice-commits] core.git: tools/source

2022-11-22 Thread Eike Rathke (via logerrit)
 tools/source/datetime/tdate.cxx |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit c4d169eb7f0b2abb96e6a210fbaae506eb354b4b
Author: Eike Rathke 
AuthorDate: Tue Nov 22 18:53:44 2022 +0100
Commit: Eike Rathke 
CommitDate: Tue Nov 22 19:47:09 2022 +0100

Avoid second null-date check of convertDateToDaysNormalizing()

This is micro-optimization, but..

Change-Id: Ic5d43bc0ce9343cf194e189777109636d3b587c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143126
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/tools/source/datetime/tdate.cxx b/tools/source/datetime/tdate.cxx
index 6c33dca13558..4b135fc3008a 100644
--- a/tools/source/datetime/tdate.cxx
+++ b/tools/source/datetime/tdate.cxx
@@ -75,7 +75,13 @@ sal_Int32 Date::GetAsNormalizedDays() const
 assert(DateToDays( GetDay(), GetMonth(), GetYear() ) == 693594);
 return 693594;
 }
-return DateToDays( GetDay(), GetMonth(), GetYear() );
+// Not calling comphelper::date::convertDateToDaysNormalizing() here just
+// avoids a second check on null-date handling like above.
+sal_uInt16 nDay = GetDay();
+sal_uInt16 nMonth = GetMonth();
+sal_Int16 nYear = GetYear();
+comphelper::date::normalize( nDay, nMonth, nYear);
+return comphelper::date::convertDateToDays( nDay, nMonth, nYear);
 }
 
 sal_Int32 Date::DateToDays( sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 
nYear )


[Libreoffice-commits] core.git: tools/source

2022-11-18 Thread Caolán McNamara (via logerrit)
 tools/source/generic/poly.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit f017eaf5d615faaf36f784b65005329ec29d16fb
Author: Caolán McNamara 
AuthorDate: Fri Nov 18 10:32:35 2022 +
Commit: Caolán McNamara 
CommitDate: Fri Nov 18 14:54:35 2022 +0100

ofz#53450 Integer-overflow

Change-Id: Iccabfb8991a4dca6ec05565f01f6cff82c642d27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142934
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index ae3465a2ce22..2665b0381571 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1433,7 +1433,7 @@ void Polygon::Rotate( const Point& rCenter, double fSin, 
double fCos )
 const tools::Long nX = rPt.X() - nCenterX;
 const tools::Long nY = rPt.Y() - nCenterY;
 rPt.setX( FRound(fCos * nX + fSin * nY + nCenterX) );
-rPt.setY( - FRound(fSin * nX - fCos * nY - nCenterY) );
+rPt.setY( FRound(-(fSin * nX - fCos * nY - nCenterY)) );
 }
 }
 


[Libreoffice-commits] core.git: tools/source

2022-11-05 Thread Stephan Bergmann (via logerrit)
 tools/source/inet/inetmsg.cxx |3 ++-
 tools/source/misc/json_writer.cxx |4 
 tools/source/ref/globname.cxx |4 ++--
 tools/source/stream/stream.cxx|   12 +---
 4 files changed, 13 insertions(+), 10 deletions(-)

New commits:
commit 4280a3257948e57cdf194a6e23718b46d907bbd6
Author: Stephan Bergmann 
AuthorDate: Sat Nov 5 16:08:39 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Sun Nov 6 01:13:45 2022 +0100

-Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): tools

(The "clang-format off" in tools/source/misc/json_writer.cxx is necessary
because otherwise the code between the 
SAL_WNODEPRECATED_DECLARATIONS_PUSH/POP
macros would be ill-formatted in a way that would trigger 
loplugin:indentation.)

Change-Id: Ic96787865d4c96be07c41f4939893420dfa04046
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142339
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx
index d58581e74200..b2e7f70b40d4 100644
--- a/tools/source/inet/inetmsg.cxx
+++ b/tools/source/inet/inetmsg.cxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -265,7 +266,7 @@ void INetMIMEMessage::EnableAttachMultipartFormDataChild()
 tools::Time aCurTime( tools::Time::SYSTEM );
 sal_uInt64 nThis = reinterpret_cast< sal_uIntPtr >( this ); // we can be 
on a 64bit architecture
 nThis = ( ( nThis >> 32 ) ^ nThis ) & SAL_MAX_UINT32;
-sprintf (sTail, "%08X%08X",
+o3tl::sprintf (sTail, "%08X%08X",
  static_cast< unsigned int >(aCurTime.GetTime()),
  static_cast< unsigned int >(nThis));
 m_aBoundary = "_4D48";
diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index fbb29bb2472c..3d78f82e08e6 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -326,7 +326,11 @@ void JsonWriter::put(const char* pPropName, sal_Int64 
nPropVal)
 memcpy(mPos, "\": ", 3);
 mPos += 3;
 
+// clang-format off
+SAL_WNODEPRECATED_DECLARATIONS_PUSH // sprintf (macOS 13 SDK)
 mPos += sprintf(mPos, "%" SAL_PRIdINT64, nPropVal);
+SAL_WNODEPRECATED_DECLARATIONS_POP
+// clang-format on
 
 validate();
 }
diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index a41b29bba6d3..df8ff10943ea 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -17,10 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include 
 #include 
 
 #include 
+#include 
 #include 
 
 #include 
@@ -153,7 +153,7 @@ bool SvGlobalName::MakeId( std::u16string_view rIdStr )
 OUString SvGlobalName::GetHexName() const
 {
 char buf[ 37 ];
-int n = sprintf(buf,
+int n = o3tl::sprintf(buf,
 "%8.8" SAL_PRIXUINT32 
"-%4.4X-%4.4X-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
 m_aData.Data1, m_aData.Data2, m_aData.Data3,
 m_aData.Data4[0], m_aData.Data4[1], m_aData.Data4[2], 
m_aData.Data4[3],
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index f6d703423828..d5abf5e2d9e2 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -26,12 +26,12 @@
 #include 
 
 #include 
-#include 
 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1361,17 +1361,15 @@ void SvStream::RefreshBuffer()
 
 SvStream& SvStream::WriteInt32AsString(sal_Int32 nInt32)
 {
-char buffer[12];
-std::size_t nLen = sprintf(buffer, "%" SAL_PRIdINT32, nInt32);
-WriteBytes(buffer, nLen);
+auto const buffer = OString::number(nInt32);
+WriteBytes(buffer.getStr(), buffer.length);
 return *this;
 }
 
 SvStream& SvStream::WriteUInt32AsString(sal_uInt32 nUInt32)
 {
-char buffer[11];
-std::size_t nLen = sprintf(buffer, "%" SAL_PRIuUINT32, nUInt32);
-WriteBytes(buffer, nLen);
+auto const buffer = OString::number(nUInt32);
+WriteBytes(buffer.getStr(), buffer.length);
 return *this;
 }
 


[Libreoffice-commits] core.git: tools/source

2022-10-27 Thread Noel Grandin (via logerrit)
 tools/source/generic/fract.cxx |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit b9ec72ff4d2fb89002ab81e363712fbfd4cbfd98
Author: Noel Grandin 
AuthorDate: Thu Oct 27 14:30:20 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Oct 27 15:24:35 2022 +0200

add some more asserts in Fraction::MakeFraction

which I missed when inlining code in

commit 8ac4dd510bd5f41882db0b647797674b06339f4e
Author: Noel Grandin 
Date:   Thu Oct 27 08:48:25 2022 +0200
tdf#123419 optimise ImplMakeFraction

Change-Id: Ifd271ce89cea29a22d41b8e143e27df118f8df3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141906
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 8c8b91d0f857..4acd46cec404 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -499,11 +499,19 @@ Fraction Fraction::MakeFraction( tools::Long nN1, 
tools::Long nN2, tools::Long n
 if ( nD2 < 0 ) { i = -i; nD2 = -nD2; }
 // all positive; i sign
 
+assert( nN1 >= std::numeric_limits::min() );
+assert( nN1 <= std::numeric_limits::max( ));
+assert( nD1 >= std::numeric_limits::min() );
+assert( nD1 <= std::numeric_limits::max( ));
+assert( nN2 >= std::numeric_limits::min() );
+assert( nN2 <= std::numeric_limits::max( ));
+assert( nD2 >= std::numeric_limits::min() );
+assert( nD2 <= std::numeric_limits::max( ));
+
 boost::rational a = toRational(i*nN1, nD1);
 boost::rational b = toRational(nN2, nD2);
 bool bFail = checked_multiply_by(a, b);
 
-
 while ( bFail ) {
 if ( nN1 > nN2 )
 nN1 = (nN1 + 1) / 2;


[Libreoffice-commits] core.git: tools/source

2022-10-27 Thread Noel Grandin (via logerrit)
 tools/source/generic/fract.cxx |1 -
 1 file changed, 1 deletion(-)

New commits:
commit eeaac9cfdea6d8660ac72e63df3c9a1b8623db7c
Author: Noel Grandin 
AuthorDate: Thu Oct 27 12:05:08 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Oct 27 13:39:53 2022 +0200

rational_ReduceInaccurate unnecessary here

as pointed out by mike kaganski, since we are already dealing with
32-bit values

Change-Id: Ic621757f2d9a689e54c47f36cc6ba85a322c500e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141904
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index b6ae743764df..8c8b91d0f857 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -519,7 +519,6 @@ Fraction Fraction::MakeFraction( tools::Long nN1, 
tools::Long nN2, tools::Long n
 bFail = checked_multiply_by(a, b);
 }
 
-rational_ReduceInaccurate(a, /*nSignificantBits*/32);
 return Fraction(a.numerator(), a.denominator());
 }
 


[Libreoffice-commits] core.git: tools/source

2022-10-16 Thread Mike Kaganski (via logerrit)
 tools/source/stream/stream.cxx |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

New commits:
commit f4e7738112eb4a374186a99953a74a5288bee4b0
Author: Mike Kaganski 
AuthorDate: Sun Oct 16 11:54:44 2022 +0200
Commit: Mike Kaganski 
CommitDate: Sun Oct 16 13:13:15 2022 +0200

Simplify a bit

Change-Id: Ia983d24c539ab37bcc6457630634142cd5826056
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141399
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 1c6bf5e32dcc..f2aed5da6174 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -362,13 +362,10 @@ void SvStream::SetError( ErrCode nErrorCode )
 void SvStream::SetEndian( SvStreamEndian nNewFormat )
 {
 m_nEndian = nNewFormat;
-m_isSwap = false;
 #ifdef OSL_BIGENDIAN
-if (m_nEndian == SvStreamEndian::LITTLE)
-m_isSwap = true;
+m_isSwap = m_nEndian == SvStreamEndian::LITTLE;
 #else
-if (m_nEndian == SvStreamEndian::BIG)
-m_isSwap = true;
+m_isSwap = m_nEndian == SvStreamEndian::BIG;
 #endif
 }
 


[Libreoffice-commits] core.git: tools/source

2022-10-07 Thread Caolán McNamara (via logerrit)
 tools/source/generic/line.cxx |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

New commits:
commit f59911c4381ca066facd0dcc6b1037077f4fc90a
Author: Caolán McNamara 
AuthorDate: Fri Oct 7 09:20:01 2022 +0100
Commit: Caolán McNamara 
CommitDate: Fri Oct 7 15:49:16 2022 +0200

ofz#52191 Integer-overflow

Change-Id: I97daf9327c55229fe7da546164d398353e0696a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141046
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/line.cxx b/tools/source/generic/line.cxx
index 1112da9863c2..ee9ad979793c 100644
--- a/tools/source/generic/line.cxx
+++ b/tools/source/generic/line.cxx
@@ -104,13 +104,13 @@ double Line::GetDistance( const double& rPtX, const 
double& rPtY ) const
 
 if( maStart != maEnd )
 {
-const doublefDistX = maEnd.X() - maStart.X();
-const doublefDistY = maEnd.Y() - maStart.Y();
-const doublefACX = maStart.X() - rPtX;
-const doublefACY = maStart.Y() - rPtY;
-const doublefL2 = fDistX * fDistX + fDistY * fDistY;
-const doublefR = ( fACY * -fDistY - fACX * fDistX ) / fL2;
-const doublefS = ( fACY * fDistX - fACX * fDistY ) / fL2;
+const double fDistX = static_cast(maEnd.X()) - maStart.X();
+const double fDistY = static_cast(maEnd.Y()) - maStart.Y();
+const double fACX = static_cast(maStart.X()) - rPtX;
+const double fACY = static_cast(maStart.Y()) - rPtY;
+const double fL2 = fDistX * fDistX + fDistY * fDistY;
+const double fR = ( fACY * -fDistY - fACX * fDistX ) / fL2;
+const double fS = ( fACY * fDistX - fACX * fDistY ) / fL2;
 
 if( fR < 0.0 )
 {


[Libreoffice-commits] core.git: tools/source

2022-08-30 Thread Caolán McNamara (via logerrit)
 tools/source/generic/line.cxx |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 70e0b2ab2cfb45f7eaa08337a42546f9c9f94542
Author: Caolán McNamara 
AuthorDate: Tue Aug 30 09:49:21 2022 +0100
Commit: Caolán McNamara 
CommitDate: Tue Aug 30 11:52:00 2022 +0200

ofz#50761 Integer-overflow

Change-Id: I8681e7b1b128e7ca33142b7120ad2d4bb3227493
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139019
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/line.cxx b/tools/source/generic/line.cxx
index 26465c5c85d6..1112da9863c2 100644
--- a/tools/source/generic/line.cxx
+++ b/tools/source/generic/line.cxx
@@ -49,17 +49,17 @@ bool Line::Intersection( const Line& rLine, Point& 
rIntersection ) const
 
 bool Line::Intersection( const tools::Line& rLine, double& rIntersectionX, 
double& rIntersectionY ) const
 {
-const doublefAx = maEnd.X() - maStart.X();
-const doublefAy = maEnd.Y() - maStart.Y();
-const doublefBx = rLine.maStart.X() - rLine.maEnd.X();
-const doublefBy = rLine.maStart.Y() - rLine.maEnd.Y();
+const doublefAx = static_cast(maEnd.X()) - maStart.X();
+const doublefAy = static_cast(maEnd.Y()) - maStart.Y();
+const doublefBx = static_cast(rLine.maStart.X()) - 
rLine.maEnd.X();
+const doublefBy = static_cast(rLine.maStart.Y()) - 
rLine.maEnd.Y();
 const doublefDen = fAy * fBx - fAx * fBy;
 boolbOk = false;
 
 if( fDen != 0. )
 {
-const doublefCx = maStart.X() - rLine.maStart.X();
-const doublefCy = maStart.Y() - rLine.maStart.Y();
+const doublefCx = static_cast(maStart.X()) - 
rLine.maStart.X();
+const doublefCy = static_cast(maStart.Y()) - 
rLine.maStart.Y();
 const doublefA = fBy * fCx - fBx * fCy;
 const bool  bGreater = ( fDen > 0. );
 


[Libreoffice-commits] core.git: tools/source

2022-08-28 Thread Caolán McNamara (via logerrit)
 tools/source/stream/stream.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 1ad7fe75cccafed2be3cd6628b931762067a56e8
Author: Caolán McNamara 
AuthorDate: Sun Aug 28 14:40:05 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sun Aug 28 17:32:30 2022 +0200

cid#1500491 silence Untrusted loop bound

Change-Id: I508337b8a8482b5aaa056a564a0dfa39cbbb4b56
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138943
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index fd4ce602ca99..1c6bf5e32dcc 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1868,6 +1868,7 @@ OUString read_uInt16s_ToOUString(SvStream& rStrm, 
std::size_t nLen)
 }
 
 // take ownership of buffer and return, otherwise return empty string
+// coverity[tainted_data] - unhelpful untrusted loop bound
 return pStr ? OUString(pStr, SAL_NO_ACQUIRE) : OUString();
 }
 


[Libreoffice-commits] core.git: tools/source

2022-08-24 Thread Caolán McNamara (via logerrit)
 tools/source/datetime/ttime.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit da46f3db22814c03fbc303275342f7182ea288b4
Author: Caolán McNamara 
AuthorDate: Tue Aug 16 00:14:42 2022 +0100
Commit: Caolán McNamara 
CommitDate: Tue Aug 16 09:52:55 2022 +0200

cid#1509285 Use of 32-bit time_t

Change-Id: I5aea4aaa6da8cd974234ab3f0c36212d436e11df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138332
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index ee9e427205ef..148bf0cbecc6 100644
--- a/tools/source/datetime/ttime.cxx
+++ b/tools/source/datetime/ttime.cxx
@@ -412,17 +412,17 @@ Time tools::Time::GetUTCOffset()
 {
 nTime = time( nullptr );
 localtime_r( ,  );
-sal_Int32 nLocalTime = mktime(  );
+auto nLocalTime = mktime(  );
 #if defined(__sun)
 // Solaris gmtime_r() seems not to handle daylight saving time
 // flags correctly
-nUTC = nLocalTime + ( aTM.tm_isdst == 0 ? timezone : altzone );
+auto nUTC = nLocalTime + ( aTM.tm_isdst == 0 ? timezone : altzone );
 #elif defined( LINUX )
 // Linux mktime() seems not to handle tm_isdst correctly
-sal_Int32 nUTC = nLocalTime - aTM.tm_gmtoff;
+auto nUTC = nLocalTime - aTM.tm_gmtoff;
 #else
 gmtime_r( ,  );
-sal_Int32 nUTC = mktime(  );
+auto nUTC = mktime(  );
 #endif
 nCacheTicks = nTicks;
 nCacheSecOffset = (nLocalTime-nUTC) / 60;


[Libreoffice-commits] core.git: tools/source

2022-08-24 Thread ehsan (via logerrit)
 tools/source/generic/poly.cxx |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 9b5f0234da27a674a939941d89975bc5a365f7ae
Author: ehsan 
AuthorDate: Sun Jul 10 19:05:56 2022 +0430
Commit: Hossein 
CommitDate: Sat Aug 13 12:09:17 2022 +0200

tdf#145614 Convert #define to constexpr

Change-Id: If783e2fbb65cae8e9c79ad9718f344dedf9dfe4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135074
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 166803b38f04..25f15d5fd00a 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -44,13 +44,13 @@
 #include 
 #include 
 
-#define EDGE_LEFT   1
-#define EDGE_TOP2
-#define EDGE_RIGHT  4
-#define EDGE_BOTTOM 8
-#define EDGE_HORZ   (EDGE_RIGHT | EDGE_LEFT)
-#define EDGE_VERT   (EDGE_TOP | EDGE_BOTTOM)
-#define SMALL_DVALUE0.001
+constexpr int EDGE_LEFT   = 1;
+constexpr int EDGE_TOP= 2;
+constexpr int EDGE_RIGHT  = 4;
+constexpr int EDGE_BOTTOM = 8;
+constexpr int EDGE_HORZ   = EDGE_RIGHT | EDGE_LEFT;
+constexpr int EDGE_VERT   = EDGE_TOP | EDGE_BOTTOM;
+constexpr double SMALL_DVALUE = 0.001;
 #define FSQRT2  1.4142135623730950488016887242097
 
 static double ImplGetParameter( const Point& rCenter, const Point& rPt, double 
fWR, double fHR )


[Libreoffice-commits] core.git: tools/source

2022-07-18 Thread Michael Stahl (via logerrit)
 tools/source/fsys/fileutil.cxx |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 54aebc2c8ff25f17a4083fe6c60c38c4f391af12
Author: Michael Stahl 
AuthorDate: Thu Jul 14 17:57:18 2022 +0200
Commit: Michael Stahl 
CommitDate: Mon Jul 18 16:42:34 2022 +0200

tools: try to work around DavGetHTTPFromUNCPath() not URL-encoding path

This was added in commit 20b1e6440aacab043753e93be4499e939a80b05b
"tdf#126121: WebDAV redirection detection" and it works fine when i test
it on my local Windows 10, returning an URL with encoded path.

The logs from the customer system however show a http URL containing an
unencoded ' ' in the path, which curl_url_set chokes on.

Try to encode the returned URL with rtl_UriEncodeKeepEscapes, which
should hopefully work in either situation.

Change-Id: I6862fe0828307a13b0004b192153747d85bb3a42
(cherry picked from commit 66e25aad35cf538da86bdd0157428f4bed95258d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137173
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/tools/source/fsys/fileutil.cxx b/tools/source/fsys/fileutil.cxx
index ec20e0a513bf..0e3512e5a160 100644
--- a/tools/source/fsys/fileutil.cxx
+++ b/tools/source/fsys/fileutil.cxx
@@ -10,6 +10,7 @@
 #include 
 #if defined _WIN32
 #include 
+#include 
 #include 
 #define WIN32_LEAN_AND_MEAN
 #include 
@@ -29,7 +30,11 @@ OUString UNCToDavURL(LPCWSTR sUNC)
 bufURL = std::make_unique(nSize);
 nResult = DavGetHTTPFromUNCPath(sUNC, bufURL.get(), );
 }
-return nResult == ERROR_SUCCESS ? OUString(o3tl::toU(bufURL.get())) : 
OUString();
+// looks like on different Windowses this may or may not be URL encoded?
+return nResult == ERROR_SUCCESS
+   ? ::rtl::Uri::encode(OUString(o3tl::toU(bufURL.get())), 
rtl_UriCharClassUric,
+rtl_UriEncodeKeepEscapes, 
RTL_TEXTENCODING_UTF8)
+   : OUString();
 }
 #endif
 }


[Libreoffice-commits] core.git: tools/source

2022-06-20 Thread Noel Grandin (via logerrit)
 tools/source/fsys/urlobj.cxx   |2 +-
 tools/source/memtools/multisel.cxx |4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 6623d5196467c489585130725866e8993bc8dde2
Author: Noel Grandin 
AuthorDate: Mon Jun 20 16:50:29 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon Jun 20 18:51:17 2022 +0200

elide some makeStringAndClear() calls

Change-Id: I4420042f7c8fdf743b888d6f7c1c0d2d3e0b877e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136184
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 12a1a797fba0..2b5a191d67c3 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -1898,7 +1898,7 @@ bool INetURLObject::convertRelToAbs(OUString const & 
rTheRelURIRef,
 }
 }
 
-INetURLObject aNewURI(aSynAbsURIRef.makeStringAndClear());
+INetURLObject aNewURI(aSynAbsURIRef);
 if (aNewURI.HasError())
 {
 // Detect cases where a relative input could not be made absolute
diff --git a/tools/source/memtools/multisel.cxx 
b/tools/source/memtools/multisel.cxx
index ff81f6c14ccc..739d2874875a 100644
--- a/tools/source/memtools/multisel.cxx
+++ b/tools/source/memtools/multisel.cxx
@@ -21,6 +21,7 @@
 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -586,7 +587,8 @@ bool StringRangeEnumerator::setRange( std::u16string_view 
aNewRange )
 aNumberBuf.append( *pInput++ );
 if( !aNumberBuf.isEmpty() )
 {
-sal_Int32 nNumber = aNumberBuf.makeStringAndClear().toInt32() + 
mnOffset;
+sal_Int32 nNumber = o3tl::toInt32(aNumberBuf) + mnOffset;
+aNumberBuf.setLength(0);
 aNumbers.push_back( nNumber );
 bSequence = false;
 }


[Libreoffice-commits] core.git: tools/source

2022-06-18 Thread Caolán McNamara (via logerrit)
 tools/source/zcodec/zcodec.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 97324e7e506273b425d5bca12961d9f3d58712b8
Author: Caolán McNamara 
AuthorDate: Sat Jun 18 12:39:01 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sat Jun 18 15:20:13 2022 +0200

cid#1506306 Uninitialized scalar field

Change-Id: I2daf370dc68dff19f1be538744d7241c080d8149
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136077
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index 16248939f3d6..c925ecde8a2d 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -47,6 +47,9 @@ ZCodec::ZCodec( size_t nInBufSize, size_t nOutBufSize )
 , mnInToRead(0)
 , mpOStm(nullptr)
 , mnOutBufSize(nOutBufSize)
+, mnUncompressedSize(0)
+, mnInBufCRC32(0)
+, mnLastModifiedTime(0)
 , mnCompressLevel(0)
 , mbGzLib(false)
 {


[Libreoffice-commits] core.git: tools/source

2022-05-30 Thread Roman Kuznetsov (via logerrit)
 tools/source/reversemap/bestreversemap.cxx |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 81aad6d53fa792dd95732e401ecb298714f699f4
Author: Roman Kuznetsov 
AuthorDate: Sun May 29 15:27:29 2022 +0200
Commit: Roman Kuznetsov 
CommitDate: Mon May 30 12:24:17 2022 +0200

tdf#147021 Use std::size() instead SAL_N_ELEMENTS macro

Change-Id: Id91ca2d7002b3743ecaed7b40edda3f85e080884
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135061
Tested-by: Jenkins
Reviewed-by: Roman Kuznetsov 

diff --git a/tools/source/reversemap/bestreversemap.cxx 
b/tools/source/reversemap/bestreversemap.cxx
index 02a81932b3f2..f124140c1918 100644
--- a/tools/source/reversemap/bestreversemap.cxx
+++ b/tools/source/reversemap/bestreversemap.cxx
@@ -11,6 +11,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 namespace {
@@ -91,7 +92,7 @@ int main()
 sal_Unicode c = 0;
 while (c < 0x)
 {
-for (size_t i = 0; i < SAL_N_ELEMENTS(aConverters); ++i)
+for (size_t i = 0; i < std::size(aConverters); ++i)
 aConverters[i].reset();
 
 int nMostCapable = -1;
@@ -99,7 +100,7 @@ int main()
 while(c < 0x)
 {
 bool bSomethingCapable = false;
-for (size_t i = 0; i < SAL_N_ELEMENTS(aConverters); ++i)
+for (size_t i = 0; i < std::size(aConverters); ++i)
 {
 if (aConverters[i].isOK())
 aConverters[i].checkSupports(c);
@@ -119,7 +120,7 @@ int main()
 while(c < 0x)
 {
 bool bNothingCapable = true;
-for (size_t i = 0; i < SAL_N_ELEMENTS(aConverters); ++i)
+for (size_t i = 0; i < std::size(aConverters); ++i)
 {
 aConverters[i].checkSupports(c);
 if (aConverters[i].isOK())


[Libreoffice-commits] core.git: tools/source

2022-05-24 Thread Noel Grandin (via logerrit)
 tools/source/fsys/urlobj.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 4bd8b4e469a4084eee0ec467721704ae51f82301
Author: Noel Grandin 
AuthorDate: Tue May 24 14:08:03 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue May 24 21:21:17 2022 +0200

no need to call makeStringAndClear here

we are passing it to a u16string_view arg

Change-Id: Ieef467fde2acccedf41381e97e93034fffceca22
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134873
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index ad96d1eecf10..00e3207b2d3b 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -3360,7 +3360,7 @@ bool INetURLObject::insertName(std::u16string_view 
rTheName,
 }
 aNewPath.append(pSuffixBegin, pPathEnd - pSuffixBegin);
 
-return setPath(aNewPath.makeStringAndClear(), 
EncodeMechanism::NotCanonical,
+return setPath(aNewPath, EncodeMechanism::NotCanonical,
 RTL_TEXTENCODING_UTF8);
 }
 
@@ -4053,7 +4053,7 @@ bool INetURLObject::removeSegment(sal_Int32 nIndex, bool 
bIgnoreFinalSlash)
 aNewPath.append('/');
 }
 
-return setPath(aNewPath.makeStringAndClear(), 
EncodeMechanism::NotCanonical,
+return setPath(aNewPath, EncodeMechanism::NotCanonical,
 RTL_TEXTENCODING_UTF8);
 }
 


[Libreoffice-commits] core.git: tools/source

2022-05-24 Thread Noel Grandin (via logerrit)
 tools/source/fsys/urlobj.cxx |   33 +
 1 file changed, 13 insertions(+), 20 deletions(-)

New commits:
commit 967fa3b5e50968237d1734a158c209f47cf36295
Author: Noel Grandin 
AuthorDate: Mon May 23 17:20:01 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue May 24 08:07:10 2022 +0200

no need to call makeStringAndClear here

we are passing the OUStringBuffer to a method that takes a
u16string_view, which means makeStringAndClear() is wasted effort

Change-Id: Ib8012f06f18508351d04d5f61cdc032a051faa84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134840
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 78c6d22af504..ad96d1eecf10 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -957,7 +957,7 @@ bool INetURLObject::setAbsURIRef(std::u16string_view 
rTheAbsURIRef,
PART_AUTHORITY, eCharset, false);
 }
 m_aHost.set(m_aAbsURIRef,
-aSynAuthority.makeStringAndClear(),
+aSynAuthority,
 m_aAbsURIRef.getLength());
 // misusing m_aHost to store the authority
 break;
@@ -993,7 +993,7 @@ bool INetURLObject::setAbsURIRef(std::u16string_view 
rTheAbsURIRef,
 return false;
 }
 m_aHost.set(m_aAbsURIRef,
-aSynAuthority.makeStringAndClear(),
+aSynAuthority,
 m_aAbsURIRef.getLength());
 // misusing m_aHost to store the authority
 }
@@ -1034,7 +1034,7 @@ bool INetURLObject::setAbsURIRef(std::u16string_view 
rTheAbsURIRef,
 else
 {
 m_aUser.set(m_aAbsURIRef,
-aSynUser.makeStringAndClear(),
+aSynUser,
 m_aAbsURIRef.getLength());
 m_aAbsURIRef.append("@");
 ++pPos;
@@ -1057,7 +1057,7 @@ bool INetURLObject::setAbsURIRef(std::u16string_view 
rTheAbsURIRef,
 return false;
 }
 m_aHost.set(m_aAbsURIRef,
-aSynAuthority.makeStringAndClear(),
+aSynAuthority,
 m_aAbsURIRef.getLength());
 // misusing m_aHost to store the authority
 break;
@@ -1341,8 +1341,7 @@ bool INetURLObject::setAbsURIRef(std::u16string_view 
rTheAbsURIRef,
 appendUCS4(aSynUser, nUTF32, eEscapeType, ePart,
eCharset, false);
 }
-m_aUser.set(m_aAbsURIRef, aSynUser.makeStringAndClear(),
-m_aAbsURIRef.getLength());
+m_aUser.set(m_aAbsURIRef, aSynUser, m_aAbsURIRef.getLength());
 if (bHasAuth)
 {
 if (bSupportsPassword)
@@ -1358,8 +1357,7 @@ bool INetURLObject::setAbsURIRef(std::u16string_view 
rTheAbsURIRef,
 appendUCS4(aSynAuth, nUTF32, eEscapeType,
ePart, eCharset, false);
 }
-m_aAuth.set(m_aAbsURIRef, aSynAuth.makeStringAndClear(),
-m_aAbsURIRef.getLength());
+m_aAuth.set(m_aAbsURIRef, aSynAuth, 
m_aAbsURIRef.getLength());
 }
 else
 {
@@ -1379,8 +1377,7 @@ bool INetURLObject::setAbsURIRef(std::u16string_view 
rTheAbsURIRef,
 appendUCS4(aSynAuth, nUTF32, eEscapeType,
ePart, eCharset, false);
 }
-m_aAuth.set(m_aAbsURIRef, aSynAuth.makeStringAndClear(),
-m_aAbsURIRef.getLength());
+m_aAuth.set(m_aAbsURIRef, aSynAuth, 
m_aAbsURIRef.getLength());
 }
 }
 if (pHostPortBegin)
@@ -1471,8 +1468,7 @@ bool INetURLObject::setAbsURIRef(std::u16string_view 
rTheAbsURIRef,
 appendUCS4(aSynQuery, nUTF32, eEscapeType,
PART_URIC, eCharset, true);
 }
-m_aQuery.set(m_aAbsURIRef, aSynQuery.makeStringAndClear(),
-m_aAbsURIRef.getLength());
+m_aQuery.set(m_aAbsURIRef, aSynQuery, m_aAbsURIRef.getLength());
 }
 
 // Parse #
@@ -1488,8 +1484,7 @@ bool INetURLObject::setAbsURIRef(std::u16string_view 
rTheAbsURIRef,
 appendUCS4(aSynFragment, nUTF32, eEscapeType, PART_URIC,
eCharset, true);
 }
-m_aFragment.set(m_aAbsURIRef, aSynFragment.makeStringAndClear(),
-m_aAbsURIRef.getLength());
+m_aFragment.set(m_aAbsURIRef, aSynFragment, 

[Libreoffice-commits] core.git: tools/source

2022-05-16 Thread Noel Grandin (via logerrit)
 tools/source/stream/strmunx.cxx |   18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

New commits:
commit f23633aa0adf5048b283e7bedb08f67198cff591
Author: Noel Grandin 
AuthorDate: Sun May 15 21:21:05 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon May 16 17:51:02 2022 +0200

no need to stat a dir when opening a temporary file

it can never be a dir

Change-Id: Ib1c234cb20387cd075a19e13e6656738be88716b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134397
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index d01866476f51..5964529f34a1 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -372,14 +372,20 @@ void SvFileStream::Open( const OUString& rFilename, 
StreamMode nOpenMode )
 // FIXME: we really need to switch to a pure URL model ...
 if ( osl::File::getFileURLFromSystemPath( aFilename, aFileURL ) != 
osl::FileBase::E_None )
 aFileURL = aFilename;
-bool bStatValid = ( osl::DirectoryItem::get( aFileURL, aItem) == 
osl::FileBase::E_None &&
-aItem.getFileStatus( aStatus ) == 
osl::FileBase::E_None );
 
-// SvFileStream can't open a directory
-if( bStatValid && aStatus.getFileType() == osl::FileStatus::Directory )
+// don't both stat()ing a temporary file, unnecessary
+bool bStatValid = true;
+if (!(nOpenMode & StreamMode::TEMPORARY))
 {
-SetError( ::GetSvError( EISDIR ) );
-return;
+bStatValid = ( osl::DirectoryItem::get( aFileURL, aItem) == 
osl::FileBase::E_None &&
+aItem.getFileStatus( aStatus ) == 
osl::FileBase::E_None );
+
+// SvFileStream can't open a directory
+if( bStatValid && aStatus.getFileType() == osl::FileStatus::Directory )
+{
+SetError( ::GetSvError( EISDIR ) );
+return;
+}
 }
 
 if ( !( nOpenMode & StreamMode::WRITE ) )


[Libreoffice-commits] core.git: tools/source

2022-05-07 Thread Stephan Bergmann (via logerrit)
 tools/source/generic/poly.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 4e7f7a799e3973b8417f318bd4c0ce28ca48e87f
Author: Stephan Bergmann 
AuthorDate: Sat May 7 15:58:22 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Sat May 7 17:23:53 2022 +0200

This condition is apparently fatal

...as mnPoints is the size of mxPointAry (see also
323df76698be1e554ba3342f56a812517a25437a "Revert 'tdf#147919 PPTX export: 
fix
curved and bent connector shape'")

Change-Id: I10b9c6bd25bc88754d2d52e851c3871621b0d517
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133980
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index b0ec428d49f7..166803b38f04 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1578,7 +1579,7 @@ void Polygon::Insert( sal_uInt16 nPos, const 
tools::Polygon& rPoly )
 
 Point& Polygon::operator[]( sal_uInt16 nPos )
 {
-DBG_ASSERT( nPos < mpImplPolygon->mnPoints, "Polygon::[]: nPos >= nPoints" 
);
+assert( nPos < mpImplPolygon->mnPoints );
 
 return mpImplPolygon->mxPointAry[nPos];
 }


[Libreoffice-commits] core.git: tools/source

2022-03-12 Thread Noel Grandin (via logerrit)
 tools/source/fsys/wldcrd.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 3d48db236e5e12460999fa8554d58e08a8f0f6df
Author: Noel Grandin 
AuthorDate: Fri Mar 11 19:24:12 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat Mar 12 11:16:40 2022 +0100

no need to temporary OUString here

Change-Id: Iffd95fcf4fd1f9aac0ba77effc3c63eedce69adf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131412
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/fsys/wldcrd.cxx b/tools/source/fsys/wldcrd.cxx
index a9867c00ba51..8d314001627b 100644
--- a/tools/source/fsys/wldcrd.cxx
+++ b/tools/source/fsys/wldcrd.cxx
@@ -92,18 +92,18 @@ bool WildCard::ImpMatch( std::u16string_view aWild, 
std::u16string_view aStr )
 
 bool WildCard::Matches( std::u16string_view rString ) const
 {
-OUString aTmpWild = aWildString;
+std::u16string_view aTmpWild = aWildString;
 
-sal_Int32 nSepPos;
+size_t nSepPos;
 
 if ( cSepSymbol != '\0' )
 {
-while ( (nSepPos = aTmpWild.indexOf(cSepSymbol)) != -1 )
+while ( (nSepPos = aTmpWild.find(cSepSymbol)) != 
std::u16string_view::npos )
 {
 // Check all split wildcards
-if ( ImpMatch( aTmpWild.subView( 0, nSepPos ), rString ) )
+if ( ImpMatch( aTmpWild.substr( 0, nSepPos ), rString ) )
 return true;
-aTmpWild = aTmpWild.copy(nSepPos + 1); // remove separator
+aTmpWild = aTmpWild.substr(nSepPos + 1); // remove separator
 }
 }
 


[Libreoffice-commits] core.git: tools/source

2022-03-06 Thread Caolán McNamara (via logerrit)
 tools/source/stream/GenericTypeSerializer.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 08bbd27e1cb6106e48489b2ca787201ca88da74a
Author: Caolán McNamara 
AuthorDate: Sun Mar 6 12:52:37 2022 +
Commit: Caolán McNamara 
CommitDate: Sun Mar 6 15:23:19 2022 +0100

ofz: Use-of-uninitialized-value

Change-Id: I41554dec3819efcd8e28f82bb732141c85414e9f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131074
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/stream/GenericTypeSerializer.cxx 
b/tools/source/stream/GenericTypeSerializer.cxx
index 7bba06d97aba..8abe23237d85 100644
--- a/tools/source/stream/GenericTypeSerializer.cxx
+++ b/tools/source/stream/GenericTypeSerializer.cxx
@@ -36,9 +36,9 @@ void GenericTypeSerializer::readColor(Color& rColor)
 
 if (nColorNameID & COL_NAME_USER)
 {
-sal_uInt16 nRed;
-sal_uInt16 nGreen;
-sal_uInt16 nBlue;
+sal_uInt16 nRed(0);
+sal_uInt16 nGreen(0);
+sal_uInt16 nBlue(0);
 
 mrStream.ReadUInt16(nRed);
 mrStream.ReadUInt16(nGreen);


[Libreoffice-commits] core.git: tools/source

2022-03-05 Thread Caolán McNamara (via logerrit)
 tools/source/generic/poly.cxx |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 80d99a387fa0d5b8764dab720c20e2d3754e610b
Author: Caolán McNamara 
AuthorDate: Sat Mar 5 10:29:15 2022 +
Commit: Caolán McNamara 
CommitDate: Sat Mar 5 14:51:31 2022 +0100

ofz: Use-of-uninitialized-value

Change-Id: If75e11dc26aae51d658464135dd8a4f965ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131054
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 13d2df0e47ef..6e5b2d778fa7 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1663,7 +1663,12 @@ void Polygon::ImplRead( SvStream& rIStream )
 if ( bHasPolyFlags )
 {
 mpImplPolygon->mxFlagAry.reset(new PolyFlags[mpImplPolygon->mnPoints]);
-rIStream.ReadBytes(mpImplPolygon->mxFlagAry.get(), 
mpImplPolygon->mnPoints);
+auto nRead = rIStream.ReadBytes(mpImplPolygon->mxFlagAry.get(), 
mpImplPolygon->mnPoints);
+if (nRead != mpImplPolygon->mnPoints)
+{
+SAL_WARN("tools", "Short read");
+memset(mpImplPolygon->mxFlagAry.get() + nRead, 0, 
mpImplPolygon->mnPoints - nRead);
+}
 }
 }
 


[Libreoffice-commits] core.git: tools/source

2022-02-28 Thread Caolán McNamara (via logerrit)
 tools/source/stream/stream.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit a0b6883f06d16892b571655764852c4d6d3200f1
Author: Caolán McNamara 
AuthorDate: Mon Feb 28 12:29:52 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Feb 28 16:25:13 2022 +0100

cid#1500555 try +taint_sanitize instead of -taint_source

Change-Id: I2a0f9ef243c3f17717afed8809b1e3fbc033c6f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130706
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 62c9be957c83..c69b2d053231 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1788,7 +1788,7 @@ void SvMemoryStream::SetSize(sal_uInt64 const nNewSize)
 }
 
 // Create an OString of nLen bytes from rStream
-// coverity[ -taint_source ]
+// coverity[ +taint_sanitize ]
 OString read_uInt8s_ToOString(SvStream& rStrm, std::size_t nLen)
 {
 rtl_String *pStr = nullptr;
@@ -1820,7 +1820,7 @@ OString read_uInt8s_ToOString(SvStream& rStrm, 
std::size_t nLen)
 }
 
 // Create an OUString of nLen sal_Unicode code units from rStream
-// coverity[ -taint_source ]
+// coverity[ +taint_sanitize ]
 OUString read_uInt16s_ToOUString(SvStream& rStrm, std::size_t nLen)
 {
 rtl_uString *pStr = nullptr;


[Libreoffice-commits] core.git: tools/source

2022-02-09 Thread Mike Kaganski (via logerrit)
 tools/source/ref/globname.cxx |  100 +++---
 1 file changed, 46 insertions(+), 54 deletions(-)

New commits:
commit a3e8bacbdb8d50ca5eb4917462cc9806be4879a2
Author: Mike Kaganski 
AuthorDate: Wed Feb 9 11:11:21 2022 +0300
Commit: Mike Kaganski 
CommitDate: Wed Feb 9 15:24:21 2022 +0100

Flatten SvGlobalName::MakeId

Change-Id: I5b592162d0fad3e57cfe9ad6d4b2252e7f7596d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129709
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index 87bb46d50c2b..7784f3fc722a 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -100,63 +100,55 @@ void SvGlobalName::MakeFromMemory( void const * pData )
 bool SvGlobalName::MakeId( const OUString & rIdStr )
 {
 const sal_Unicode *pStr = rIdStr.getStr();
-if( rIdStr.getLength() == 36
-  && '-' == pStr[ 8 ]  && '-' == pStr[ 13 ]
-  && '-' == pStr[ 18 ] && '-' == pStr[ 23 ] )
+if( rIdStr.getLength() != 36
+  || '-' != pStr[ 8 ]  || '-' != pStr[ 13 ]
+  || '-' != pStr[ 18 ] || '-' != pStr[ 23 ] )
+return false;
+
+SvGUID aGuid = {};
+auto asciiHexDigitToNumber = [](sal_Unicode c) -> sal_uInt8
 {
-SvGUID aGuid = {};
-auto asciiHexDigitToNumber = [](sal_Unicode c) -> sal_uInt8
-{
-if (rtl::isAsciiDigit(c))
-return c - '0';
-else
-return rtl::toAsciiUpperCase(c) - 'A' + 10;
-};
-for( int i = 0; i < 8; i++ )
-{
-if( rtl::isAsciiHexDigit( *pStr ) )
-aGuid.Data1 = aGuid.Data1 * 16 + asciiHexDigitToNumber( *pStr 
);
-else
-return false;
-pStr++;
-}
-
-pStr++;
-for( int i = 0; i < 4; i++ )
-{
-if( rtl::isAsciiHexDigit( *pStr ) )
-aGuid.Data2 = aGuid.Data2 * 16 + asciiHexDigitToNumber( *pStr 
);
-else
-return false;
-pStr++;
-}
-
-pStr++;
-for( int i = 0; i < 4; i++ )
-{
-if( rtl::isAsciiHexDigit( *pStr ) )
-aGuid.Data3 = aGuid.Data3 * 16 + asciiHexDigitToNumber( *pStr 
);
-else
-return false;
-pStr++;
-}
-
-pStr++;
-for( int i = 0; i < 16; i++ )
-{
-if( rtl::isAsciiHexDigit( *pStr ) )
-aGuid.Data4[i/2] = aGuid.Data4[i/2] * 16 + 
asciiHexDigitToNumber( *pStr );
-else
-return false;
-pStr++;
-if( i == 3 )
-pStr++;
-}
+if (rtl::isAsciiDigit(c))
+return c - '0';
+else
+return rtl::toAsciiUpperCase(c) - 'A' + 10;
+};
 
-m_aData = aGuid;
-return true;
+for( int i = 0; i < 8; i++ )
+{
+if( !rtl::isAsciiHexDigit( *pStr ) )
+return false;
+aGuid.Data1 = aGuid.Data1 * 16 + asciiHexDigitToNumber( *pStr++ );
 }
-return false;
+
+pStr++;
+for( int i = 0; i < 4; i++ )
+{
+if( !rtl::isAsciiHexDigit( *pStr ) )
+return false;
+aGuid.Data2 = aGuid.Data2 * 16 + asciiHexDigitToNumber( *pStr++ );
+}
+
+pStr++;
+for( int i = 0; i < 4; i++ )
+{
+if( !rtl::isAsciiHexDigit( *pStr ) )
+return false;
+aGuid.Data3 = aGuid.Data3 * 16 + asciiHexDigitToNumber( *pStr++ );
+}
+
+pStr++;
+for( int i = 0; i < 16; i++ )
+{
+if( !rtl::isAsciiHexDigit( *pStr ) )
+return false;
+aGuid.Data4[i/2] = aGuid.Data4[i/2] * 16 + asciiHexDigitToNumber( 
*pStr++ );
+if( i == 3 )
+pStr++;
+}
+
+m_aData = aGuid;
+return true;
 }
 
 OUString SvGlobalName::GetHexName() const


[Libreoffice-commits] core.git: tools/source

2022-02-03 Thread Caolán McNamara (via logerrit)
 tools/source/generic/fract.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 297f000c4968da9a61846d1b336d4fb77e01610c
Author: Caolán McNamara 
AuthorDate: Thu Feb 3 09:35:25 2022 +
Commit: Caolán McNamara 
CommitDate: Thu Feb 3 15:54:51 2022 +0100

cid#1497939 Division or modulo by zero

and

cid#1497937 Division or modulo by zero

Change-Id: I24f939e19791d811845a476c68125f40bb78f9c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129400
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 93a92fb3a12a..078ffd87f387 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -182,6 +182,9 @@ namespace
 sal_Int32 gcd1 = std::gcd(i.numerator(), den);
 sal_Int32 gcd2 = std::gcd(num, i.denominator());
 
+if (!gcd1 || !gcd2)
+return true;
+
 bool fail = false;
 fail |= o3tl::checked_multiply(i.numerator() / gcd1, num / gcd2, num);
 fail |= o3tl::checked_multiply(i.denominator() / gcd2, den / gcd1, 
den);


[Libreoffice-commits] core.git: tools/source

2021-12-27 Thread Noel Grandin (via logerrit)
 tools/source/stream/strmunx.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 64aa0e462f189bf3962c3ab4ae5d5e9b0cd177bd
Author: Noel Grandin 
AuthorDate: Wed Dec 22 20:54:39 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Dec 27 20:21:41 2021 +0100

osl::Mutex->std::mutex in lockFile

Change-Id: I5ebd56741568ecd25677af57e8c91389c69ddaad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127596
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index 853389266ac3..9beade27e92e 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -24,7 +24,7 @@
 #include 
 #include 
 
-#include 
+#include 
 #include 
 #include 
 
@@ -37,9 +37,9 @@ using namespace osl;
 
 namespace {
 
-osl::Mutex& LockMutex()
+std::mutex& LockMutex()
 {
-static osl::Mutex SINGLETON;
+static std::mutex SINGLETON;
 return SINGLETON;
 }
 
@@ -63,7 +63,7 @@ bool lockFile( const SvFileStream* pStream )
 if( aStatus.getFileType() == osl::FileStatus::Directory )
 return true;
 
-osl::MutexGuard aGuard( LockMutex() );
+std::unique_lock aGuard( LockMutex() );
 for( const auto& [rLockStream, rLockItem] : gLocks )
 {
 if( aItem.isIdenticalTo( rLockItem ) )
@@ -86,7 +86,7 @@ bool lockFile( const SvFileStream* pStream )
 
 void unlockFile( SvFileStream const * pStream )
 {
-osl::MutexGuard aGuard( LockMutex() );
+std::unique_lock aGuard( LockMutex() );
 gLocks.erase(pStream);
 }
 


[Libreoffice-commits] core.git: tools/source

2021-12-25 Thread Mike Kaganski (via logerrit)
 tools/source/fsys/urlobj.cxx |   20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

New commits:
commit be5f70e2b8498345f2301598cba325d5524513f2
Author: Mike Kaganski 
AuthorDate: Sat Dec 25 12:51:53 2021 +0300
Commit: Mike Kaganski 
CommitDate: Sat Dec 25 18:44:09 2021 +0100

Simplify INetURLObject::parseHostOrNetBiosName a bit more

Change-Id: Ie22e7a142aabd2c0f12c34945ad0858f5bd868a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127451
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 67cb1f1cd024..1d08a5590eaa 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -2843,9 +2843,16 @@ bool INetURLObject::parseHostOrNetBiosName(
 while (pBegin < pEnd)
 {
 EscapeType eEscapeType;
-sal_uInt32 nUTF32 = getUTF32(pBegin, pEnd, eMechanism, eCharset, 
eEscapeType);
-switch (nUTF32)
+switch (sal_uInt32 nUTF32 = getUTF32(pBegin, pEnd, eMechanism, 
eCharset, eEscapeType))
 {
+default:
+if (INetMIME::isVisible(nUTF32))
+{
+if (pCanonic)
+appendUCS4(*pCanonic, nUTF32, eEscapeType, PART_URIC, 
eCharset, true);
+break;
+}
+[[fallthrough]];
 case '"':
 case '*':
 case '+':
@@ -2865,16 +2872,7 @@ bool INetURLObject::parseHostOrNetBiosName(
 if (pCanonic)
 pCanonic->setLength(nOriginalCanonicLength);
 return false;
-default:
-if (!INetMIME::isVisible(nUTF32))
-{
-if (pCanonic)
-pCanonic->setLength(nOriginalCanonicLength);
-return false;
-}
 }
-if (pCanonic)
-appendUCS4(*pCanonic, nUTF32, eEscapeType, PART_URIC, eCharset, 
true);
 }
 return true;
 }


[Libreoffice-commits] core.git: tools/source

2021-12-24 Thread Mike Kaganski (via logerrit)
 tools/source/fsys/urlobj.cxx |   91 +--
 1 file changed, 37 insertions(+), 54 deletions(-)

New commits:
commit 132d652ad1af4ec067fe08e388e8ddba963ddc2b
Author: Mike Kaganski 
AuthorDate: Fri Dec 24 21:37:17 2021 +0100
Commit: Mike Kaganski 
CommitDate: Fri Dec 24 23:09:14 2021 +0100

Simplify INetURLObject::parseHostOrNetBiosName

Change-Id: I18818e89b2e6f0ef203caa51ba554c281753d3f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127383
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 7b86fe0f5261..67cb1f1cd024 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -2831,67 +2831,50 @@ bool INetURLObject::parseHostOrNetBiosName(
 EncodeMechanism eMechanism, rtl_TextEncoding eCharset, bool bNetBiosName,
 OUStringBuffer* pCanonic)
 {
+if (pBegin >= pEnd)
+return true;
 sal_Int32 nOriginalCanonicLength = pCanonic ? pCanonic->getLength() : 0;
-if (pBegin < pEnd)
+if (sal_Unicode const* p = pBegin; parseHost(p, pEnd, pCanonic) && p == 
pEnd)
+return true;
+if (pCanonic)
+pCanonic->setLength(nOriginalCanonicLength); // discard parseHost 
results
+if (!bNetBiosName)
+return false;
+while (pBegin < pEnd)
 {
-sal_Unicode const * p = pBegin;
-if (!parseHost(p, pEnd, pCanonic) || p != pEnd)
+EscapeType eEscapeType;
+sal_uInt32 nUTF32 = getUTF32(pBegin, pEnd, eMechanism, eCharset, 
eEscapeType);
+switch (nUTF32)
 {
-if (bNetBiosName)
-{
-OUStringBuffer buf;
-while (pBegin < pEnd)
-{
-EscapeType eEscapeType;
-sal_uInt32 nUTF32 = getUTF32(pBegin, pEnd,
- eMechanism, eCharset,
- eEscapeType);
-if (!INetMIME::isVisible(nUTF32))
-{
-if (pCanonic)
-pCanonic->setLength(nOriginalCanonicLength);
-return false;
-}
-if (!rtl::isAsciiAlphanumeric(nUTF32))
-switch (nUTF32)
-{
-case '"':
-case '*':
-case '+':
-case ',':
-case '/':
-case ':':
-case ';':
-case '<':
-case '=':
-case '>':
-case '?':
-case '[':
-case '\\':
-case ']':
-case '`':
-case '|':
-return false;
-}
-if (pCanonic != nullptr) {
-appendUCS4(
-buf, nUTF32, eEscapeType, PART_URIC,
-eCharset, true);
-}
-}
-if (pCanonic)
-{
-pCanonic->setLength(nOriginalCanonicLength);
-pCanonic->append(buf);
-}
-}
-else
-{
+case '"':
+case '*':
+case '+':
+case ',':
+case '/':
+case ':':
+case ';':
+case '<':
+case '=':
+case '>':
+case '?':
+case '[':
+case '\\':
+case ']':
+case '`':
+case '|':
 if (pCanonic)
 pCanonic->setLength(nOriginalCanonicLength);
 return false;
-}
+default:
+if (!INetMIME::isVisible(nUTF32))
+{
+if (pCanonic)
+pCanonic->setLength(nOriginalCanonicLength);
+return false;
+}
 }
+if (pCanonic)
+appendUCS4(*pCanonic, nUTF32, eEscapeType, PART_URIC, eCharset, 
true);
 }
 return true;
 }


[Libreoffice-commits] core.git: tools/source

2021-12-10 Thread Mike Kaganski (via logerrit)
 tools/source/stream/stream.cxx |   66 +
 1 file changed, 34 insertions(+), 32 deletions(-)

New commits:
commit 1f1ce06a185abcbf0c533cb3aa288418ecaa5ef4
Author: Mike Kaganski 
AuthorDate: Fri Dec 10 12:01:19 2021 +0200
Commit: Mike Kaganski 
CommitDate: Fri Dec 10 14:18:30 2021 +0100

Make BOM detection slightly more straightforward

Without taking system endianness and current stream endianness
into account - just read and check single bytes.

Change-Id: I9273d8f403caad7adb5e11cecc04e326919dad1f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126595
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index d42cefdf63cf..016c8b67e891 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -718,52 +718,54 @@ void SvStream::StartReadingUnicodeText( rtl_TextEncoding 
eReadBomCharSet )
 eReadBomCharSet == RTL_TEXTENCODING_UTF8))
 return;// nothing to read
 
-bool bTryUtf8 = false;
-sal_uInt16 nFlag(0);
-sal_sSize nBack = sizeof(nFlag);
-ReadUInt16( nFlag );
+const sal_uInt64 nOldPos = Tell();
+bool bGetBack = true;
+unsigned char nFlag(0);
+ReadUChar( nFlag );
 switch ( nFlag )
 {
-case 0xfeff :
-// native UTF-16
+case 0xfe: // UTF-16BE?
 if (eReadBomCharSet == RTL_TEXTENCODING_DONTKNOW ||
 eReadBomCharSet == RTL_TEXTENCODING_UNICODE)
-nBack = 0;
+{
+ReadUChar(nFlag);
+if (nFlag == 0xff)
+{
+SetEndian(SvStreamEndian::BIG);
+bGetBack = false;
+}
+}
 break;
-case 0xfffe :
-// swapped UTF-16
+case 0xff: // UTF-16LE?
 if (eReadBomCharSet == RTL_TEXTENCODING_DONTKNOW ||
 eReadBomCharSet == RTL_TEXTENCODING_UNICODE)
 {
-SetEndian( m_nEndian == SvStreamEndian::BIG ? 
SvStreamEndian::LITTLE : SvStreamEndian::BIG );
-nBack = 0;
+ReadUChar(nFlag);
+if (nFlag == 0xfe)
+{
+SetEndian(SvStreamEndian::LITTLE);
+bGetBack = false;
+}
 }
 break;
-case 0xefbb :
-if (m_nEndian == SvStreamEndian::BIG &&
-(eReadBomCharSet == RTL_TEXTENCODING_DONTKNOW ||
- eReadBomCharSet == RTL_TEXTENCODING_UTF8))
-bTryUtf8 = true;
-break;
-case 0xbbef :
-if (m_nEndian == SvStreamEndian::LITTLE &&
-(eReadBomCharSet == RTL_TEXTENCODING_DONTKNOW ||
- eReadBomCharSet == RTL_TEXTENCODING_UTF8))
-bTryUtf8 = true;
+case 0xef: // UTF-8?
+if (eReadBomCharSet == RTL_TEXTENCODING_DONTKNOW ||
+eReadBomCharSet == RTL_TEXTENCODING_UTF8)
+{
+ReadUChar(nFlag);
+if (nFlag == 0xbb)
+{
+ReadUChar(nFlag);
+if (nFlag == 0xbf)
+bGetBack = false; // it is UTF-8
+}
+}
 break;
 default:
 ;   // nothing
 }
-if (bTryUtf8)
-{
-unsigned char nChar(0);
-nBack += sizeof(nChar);
-ReadUChar( nChar );
-if (nChar == 0xbf)
-nBack = 0;  // it is UTF-8
-}
-if (nBack)
-SeekRel( -nBack );  // no BOM, pure data
+if (bGetBack)
+Seek(nOldPos);  // no BOM, pure data
 }
 
 sal_uInt64 SvStream::SeekRel(sal_Int64 const nPos)


[Libreoffice-commits] core.git: tools/source

2021-12-06 Thread Urja Rannikko (via logerrit)
 tools/source/datetime/ttime.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 7fa9b09bc271d91792fe78c5cb03430bf38155a8
Author: Urja Rannikko 
AuthorDate: Sun Dec 5 14:29:09 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Mon Dec 6 11:58:09 2021 +0100

tdf#128715 fix tools::Time::GetMonotonicTicks() on 32-bit linux

Since time_t and thus tv_sec is (still, for now) 32-bit on these
architechtures, the multiplication of seconds to microseconds
happened in 32-bit thus causing a rollover roughly every 4295 seconds.
Fix by casting tv_sec to sal_uInt64 before the multiplication.

Also fixes tdf#144975.

Change-Id: I829d3406208545a816979cb58daaeb99ec2d5294
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126379
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index c6c89c934886..ee9e427205ef 100644
--- a/tools/source/datetime/ttime.cxx
+++ b/tools/source/datetime/ttime.cxx
@@ -477,11 +477,12 @@ sal_uInt64 tools::Time::GetMonotonicTicks()
 #if defined(_POSIX_TIMERS)
 struct timespec currentTime;
 clock_gettime( CLOCK_MONOTONIC,  );
-nMicroSeconds = currentTime.tv_sec * 1000 * 1000 + currentTime.tv_nsec / 
1000;
+nMicroSeconds
+= static_cast(currentTime.tv_sec) * 1000 * 1000 + 
currentTime.tv_nsec / 1000;
 #else
 struct timeval currentTime;
 gettimeofday( , nullptr );
-nMicroSeconds = currentTime.tv_sec * 1000 * 1000 + currentTime.tv_usec;
+nMicroSeconds = static_cast(currentTime.tv_sec) * 1000 * 1000 
+ currentTime.tv_usec;
 #endif
 #endif // __MACH__
 return nMicroSeconds;


[Libreoffice-commits] core.git: tools/source

2021-11-26 Thread Noel Grandin (via logerrit)
 tools/source/generic/fract.cxx |   21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 05766922e7e4262b98e9c3f8d83cdfdaa49d3f7a
Author: Noel Grandin 
AuthorDate: Fri Nov 26 13:55:03 2021 +0200
Commit: Noel Grandin 
CommitDate: Fri Nov 26 17:30:10 2021 +0100

speed up Fraction::operator*= a little

for my test spreadsheet this reduced the time spent
in Fraction by 30%

Change-Id: Ib14a93284dbd6c6ea2349c1754979135463ca61b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125878
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 1b3c95a6cdda..93a92fb3a12a 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -35,8 +35,8 @@
 #endif
 
 static boost::rational rational_FromDouble(double dVal);
-
 static void rational_ReduceInaccurate(boost::rational& rRational, 
unsigned nSignificantBits);
+static int impl_NumberOfBits( sal_uInt32 nNum );
 
 static boost::rational toRational(sal_Int32 n, sal_Int32 d)
 {
@@ -163,15 +163,24 @@ Fraction& Fraction::operator -= ( const Fraction& rVal )
 
 namespace
 {
-template bool checked_multiply_by(boost::rational& i, const 
boost::rational& r)
+bool checked_multiply_by(boost::rational& i, const 
boost::rational& r)
 {
 // Protect against self-modification
-T num = r.numerator();
-T den = r.denominator();
+sal_Int32 num = r.numerator();
+sal_Int32 den = r.denominator();
+
+// Fast-path if the number of bits in input is < the number of bits in 
the output, overflow cannot happen
+// This is considerably faster than repeated std::gcd() operations
+if ((impl_NumberOfBits(std::abs(i.numerator())) + 
impl_NumberOfBits(std::abs(r.numerator( < 32 &&
+(impl_NumberOfBits(std::abs(i.denominator())) + 
impl_NumberOfBits(std::abs(r.denominator( < 32)
+{
+i *= r;
+return false;
+}
 
 // Avoid overflow and preserve normalization
-T gcd1 = std::gcd(i.numerator(), den);
-T gcd2 = std::gcd(num, i.denominator());
+sal_Int32 gcd1 = std::gcd(i.numerator(), den);
+sal_Int32 gcd2 = std::gcd(num, i.denominator());
 
 bool fail = false;
 fail |= o3tl::checked_multiply(i.numerator() / gcd1, num / gcd2, num);


[Libreoffice-commits] core.git: tools/source

2021-11-23 Thread Stephan Bergmann (via logerrit)
 tools/source/fsys/urlobj.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit a884f0596cf4d519f2e8e75737a108d134185f9b
Author: Stephan Bergmann 
AuthorDate: Tue Nov 23 12:18:23 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Tue Nov 23 16:07:15 2021 +0100

Use proper type for OUString length variables

Change-Id: Id116ed42c553bb6524876288ca0066be4a4a1820
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125694
Reviewed-by: Stephan Bergmann 
Tested-by: Jenkins

diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index dee820474a73..7e29adc7d1c7 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -1476,7 +1476,7 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 }
 
 void INetURLObject::changeScheme(INetProtocol eTargetScheme) {
-int oldSchemeLen = 0;
+sal_Int32 oldSchemeLen = 0;
 const OUString& rOldSchemeName = getSchemeInfo().m_sScheme;
 if (m_eScheme == INetProtocol::Generic)
 oldSchemeLen = m_aScheme.getLength();
@@ -1484,10 +1484,10 @@ void INetURLObject::changeScheme(INetProtocol 
eTargetScheme) {
 oldSchemeLen = rOldSchemeName.getLength();
 m_eScheme=eTargetScheme;
 const OUString& rNewSchemeName = getSchemeInfo().m_sScheme;
-int newSchemeLen = rNewSchemeName.getLength();
+sal_Int32 newSchemeLen = rNewSchemeName.getLength();
 m_aAbsURIRef.remove(0, oldSchemeLen);
 m_aAbsURIRef.insert(0, rNewSchemeName);
-int delta=newSchemeLen-oldSchemeLen;
+sal_Int32 delta=newSchemeLen-oldSchemeLen;
 m_aUser+=delta;
 m_aAuth+=delta;
 m_aHost+=delta;


[Libreoffice-commits] core.git: tools/source

2021-11-23 Thread Noel Grandin (via logerrit)
 tools/source/fsys/urlobj.cxx |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

New commits:
commit da6ac377c6a4bb84ba4bdcc41e73c9079b009039
Author: Noel Grandin 
AuthorDate: Tue Nov 23 12:15:42 2021 +0200
Commit: Noel Grandin 
CommitDate: Tue Nov 23 13:47:16 2021 +0100

avoid OUString temporary in INetURLObject::changeScheme

Change-Id: I8a97c1d89770fe2c0ba0d3f75ce9f3fec0df2e53
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125692
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 085c6d2846f0..6f4dfd068304 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -1476,8 +1476,6 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 }
 
 void INetURLObject::changeScheme(INetProtocol eTargetScheme) {
-OUString aTmpStr=m_aAbsURIRef.toString();
-m_aAbsURIRef.setLength(0);
 int oldSchemeLen = 0;
 const OUString& rOldSchemeName = getSchemeInfo().m_sScheme;
 if (m_eScheme == INetProtocol::Generic)
@@ -1487,8 +1485,8 @@ void INetURLObject::changeScheme(INetProtocol 
eTargetScheme) {
 m_eScheme=eTargetScheme;
 const OUString& rNewSchemeName = getSchemeInfo().m_sScheme;
 int newSchemeLen = rNewSchemeName.getLength();
-m_aAbsURIRef.append(rNewSchemeName);
-m_aAbsURIRef.append(aTmpStr.getStr()+oldSchemeLen);
+m_aAbsURIRef.remove(0, oldSchemeLen);
+m_aAbsURIRef.insert(0, rNewSchemeName);
 int delta=newSchemeLen-oldSchemeLen;
 m_aUser+=delta;
 m_aAuth+=delta;


[Libreoffice-commits] core.git: tools/source

2021-11-22 Thread Michael Stahl (via logerrit)
 tools/source/fsys/urlobj.cxx |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 6c9d853edcb1f76468bc96b2e8d7e60dcfa72c7e
Author: Michael Stahl 
AuthorDate: Mon Nov 22 18:57:50 2021 +0100
Commit: Noel Grandin 
CommitDate: Tue Nov 23 07:40:04 2021 +0100

tools: fix INetURLObject::changeScheme()

(regression from dc2010964fb8d18d5c4fe96172ee082276a1e587
 which broke JunitTest_ucb_unoapi)

Change-Id: I14a79c3b7d1161234da64822186bcf97d4022264
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125671
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index adc73849b5f0..085c6d2846f0 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -1479,14 +1479,15 @@ void INetURLObject::changeScheme(INetProtocol 
eTargetScheme) {
 OUString aTmpStr=m_aAbsURIRef.toString();
 m_aAbsURIRef.setLength(0);
 int oldSchemeLen = 0;
-const OUString& aSchemeName = getSchemeInfo().m_sScheme;
+const OUString& rOldSchemeName = getSchemeInfo().m_sScheme;
 if (m_eScheme == INetProtocol::Generic)
 oldSchemeLen = m_aScheme.getLength();
 else
-oldSchemeLen = aSchemeName.getLength();
+oldSchemeLen = rOldSchemeName.getLength();
 m_eScheme=eTargetScheme;
-int newSchemeLen = aSchemeName.getLength();
-m_aAbsURIRef.append(aSchemeName);
+const OUString& rNewSchemeName = getSchemeInfo().m_sScheme;
+int newSchemeLen = rNewSchemeName.getLength();
+m_aAbsURIRef.append(rNewSchemeName);
 m_aAbsURIRef.append(aTmpStr.getStr()+oldSchemeLen);
 int delta=newSchemeLen-oldSchemeLen;
 m_aUser+=delta;


[Libreoffice-commits] core.git: tools/source

2021-11-19 Thread Noel Grandin (via logerrit)
 tools/source/fsys/urlobj.cxx |   66 ---
 1 file changed, 32 insertions(+), 34 deletions(-)

New commits:
commit 2aa7aa564f8c8f7d1cd520b3e2d198a17e423a37
Author: Noel Grandin 
AuthorDate: Fri Nov 19 16:02:21 2021 +0200
Commit: Noel Grandin 
CommitDate: Sat Nov 20 08:10:25 2021 +0100

tdf#133835 speedup calc autofilter (3)

Tweak INetURLObject::parsePath to avoid an OUStringBuffer copy,
saves 5%

Change-Id: I49eff3443f34971b8ce15f4c1ab6c9395ee0690f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125565
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 93e12e965261..6b074180f6df 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -1391,7 +1391,7 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 }
 
 // Parse 
-OUStringBuffer aSynPath;
+OUStringBuffer aSynPath(256);
 if (!parsePath(m_eScheme, , pEnd, eMechanism, eCharset,
bSkippedInitialSlash, nSegmentDelimiter,
nAltSegmentDelimiter,
@@ -2880,7 +2880,6 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
 DBG_ASSERT(pBegin, "INetURLObject::parsePath(): Null output param");
 
 sal_Unicode const * pPos = *pBegin;
-OUStringBuffer aTheSynPath(256);
 
 switch (eScheme)
 {
@@ -2895,11 +2894,11 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
 EscapeType eEscapeType;
 sal_uInt32 nUTF32 = getUTF32(pPos, pEnd, eMechanism,
  eCharset, eEscapeType);
-appendUCS4(aTheSynPath, nUTF32, eEscapeType,
+appendUCS4(rSynPath, nUTF32, eEscapeType,
PART_HTTP_PATH, eCharset, true);
 }
-if (aTheSynPath.isEmpty())
-aTheSynPath.append('/');
+if (rSynPath.isEmpty())
+rSynPath.append('/');
 break;
 
 case INetProtocol::Http:
@@ -2915,17 +2914,17 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
 EscapeType eEscapeType;
 sal_uInt32 nUTF32 = getUTF32(pPos, pEnd, eMechanism,
  eCharset, eEscapeType);
-appendUCS4(aTheSynPath, nUTF32, eEscapeType,
+appendUCS4(rSynPath, nUTF32, eEscapeType,
PART_HTTP_PATH, eCharset, true);
 }
-if (aTheSynPath.isEmpty())
-aTheSynPath.append('/');
+if (rSynPath.isEmpty())
+rSynPath.append('/');
 break;
 
 case INetProtocol::File:
 {
 if (bSkippedInitialSlash)
-aTheSynPath.append('/');
+rSynPath.append('/');
 else if (pPos < pEnd
  && *pPos != nSegmentDelimiter
  && *pPos != nAltSegmentDelimiter)
@@ -2940,7 +2939,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
 if (nUTF32 == nSegmentDelimiter
 || nUTF32 == nAltSegmentDelimiter)
 {
-aTheSynPath.append('/');
+rSynPath.append('/');
 continue;
 }
 else if (nUTF32 == '|'
@@ -2948,20 +2947,20 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
  || *pPos == nFragmentDelimiter
  || *pPos == nSegmentDelimiter
  || *pPos == nAltSegmentDelimiter)
- && aTheSynPath.getLength() == 2
- && rtl::isAsciiAlpha(aTheSynPath[1]))
+ && rSynPath.getLength() == 2
+ && rtl::isAsciiAlpha(rSynPath[1]))
 {
 // A first segment of  is translated to
 // :
-aTheSynPath.append(':');
+rSynPath.append(':');
 continue;
 }
 }
-appendUCS4(aTheSynPath, nUTF32, eEscapeType,
+appendUCS4(rSynPath, nUTF32, eEscapeType,
PART_PCHAR, eCharset, true);
 }
-if (aTheSynPath.isEmpty())
-aTheSynPath.append('/');
+if (rSynPath.isEmpty())
+rSynPath.append('/');
 break;
 }
 
@@ -2972,7 +2971,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
 EscapeType eEscapeType;
 sal_uInt32 nUTF32 = getUTF32(pPos, pEnd, eMechanism,
  eCharset, eEscapeType);
-appendUCS4(aTheSynPath, nUTF32, eEscapeType,
+

[Libreoffice-commits] core.git: tools/source

2021-11-18 Thread Noel Grandin (via logerrit)
 tools/source/stream/strmunx.cxx |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 4d3e4c1cf3f117b8abd8dd67843864bb4c2e5a2f
Author: Noel Grandin 
AuthorDate: Thu Nov 18 20:13:51 2021 +0200
Commit: Noel Grandin 
CommitDate: Fri Nov 19 07:33:15 2021 +0100

rtl::Static->thread-safe static in tools

Change-Id: I6c45fc533ec6281d011282bf2e8d49f23e2c29e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125494
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index 6743993f112e..853389266ac3 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -30,7 +30,6 @@
 
 #include 
 #include 
-#include 
 
 using namespace osl;
 
@@ -38,7 +37,11 @@ using namespace osl;
 
 namespace {
 
-struct LockMutex : public rtl::Static< osl::Mutex, LockMutex > {};
+osl::Mutex& LockMutex()
+{
+static osl::Mutex SINGLETON;
+return SINGLETON;
+}
 
 std::map gLocks;
 
@@ -60,7 +63,7 @@ bool lockFile( const SvFileStream* pStream )
 if( aStatus.getFileType() == osl::FileStatus::Directory )
 return true;
 
-osl::MutexGuard aGuard( LockMutex::get() );
+osl::MutexGuard aGuard( LockMutex() );
 for( const auto& [rLockStream, rLockItem] : gLocks )
 {
 if( aItem.isIdenticalTo( rLockItem ) )
@@ -83,7 +86,7 @@ bool lockFile( const SvFileStream* pStream )
 
 void unlockFile( SvFileStream const * pStream )
 {
-osl::MutexGuard aGuard( LockMutex::get() );
+osl::MutexGuard aGuard( LockMutex() );
 gLocks.erase(pStream);
 }
 


[Libreoffice-commits] core.git: tools/source

2021-10-31 Thread Mike Kaganski (via logerrit)
 tools/source/ref/globname.cxx |   36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

New commits:
commit 20354bce87305a274c046cca39ffe8f16add2322
Author: Mike Kaganski 
AuthorDate: Fri Oct 29 10:19:16 2021 +0300
Commit: Mike Kaganski 
CommitDate: Sun Oct 31 18:41:42 2021 +0100

Prepare for removal of non-const operator[] from Sequence in tools

Change-Id: Ifff56df8da9b0b9e4d4e96d6b09f490807e96f52
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124402
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index b38bda02ab9c..fda6fafab53c 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -256,24 +256,24 @@ css::uno::Sequence < sal_Int8 > 
SvGlobalName::GetByteSequence() const
 {
 // platform independent representation of a "GlobalName"
 // maybe transported remotely
-css::uno::Sequence< sal_Int8 > aResult( 16 );
-
-aResult[ 0] = static_cast(pImp->szData.Data1 >> 24);
-aResult[ 1] = static_cast((pImp->szData.Data1 << 8 ) >> 24);
-aResult[ 2] = static_cast((pImp->szData.Data1 << 16 ) >> 24);
-aResult[ 3] = static_cast((pImp->szData.Data1 << 24 ) >> 24);
-aResult[ 4] = static_cast(pImp->szData.Data2 >> 8);
-aResult[ 5] = static_cast((pImp->szData.Data2 << 8 ) >> 8);
-aResult[ 6] = static_cast(pImp->szData.Data3 >> 8);
-aResult[ 7] = static_cast((pImp->szData.Data3 << 8 ) >> 8);
-aResult[ 8] = pImp->szData.Data4[ 0 ];
-aResult[ 9] = pImp->szData.Data4[ 1 ];
-aResult[10] = pImp->szData.Data4[ 2 ];
-aResult[11] = pImp->szData.Data4[ 3 ];
-aResult[12] = pImp->szData.Data4[ 4 ];
-aResult[13] = pImp->szData.Data4[ 5 ];
-aResult[14] = pImp->szData.Data4[ 6 ];
-aResult[15] = pImp->szData.Data4[ 7 ];
+css::uno::Sequence< sal_Int8 > aResult{
+/* [ 0] */ static_cast(pImp->szData.Data1 >> 24),
+/* [ 1] */ static_cast((pImp->szData.Data1 << 8 ) >> 24),
+/* [ 2] */ static_cast((pImp->szData.Data1 << 16 ) >> 24),
+/* [ 3] */ static_cast((pImp->szData.Data1 << 24 ) >> 24),
+/* [ 4] */ static_cast(pImp->szData.Data2 >> 8),
+/* [ 5] */ static_cast((pImp->szData.Data2 << 8 ) >> 8),
+/* [ 6] */ static_cast(pImp->szData.Data3 >> 8),
+/* [ 7] */ static_cast((pImp->szData.Data3 << 8 ) >> 8),
+/* [ 8] */ static_cast(pImp->szData.Data4[ 0 ]),
+/* [ 9] */ static_cast(pImp->szData.Data4[ 1 ]),
+/* [10] */ static_cast(pImp->szData.Data4[ 2 ]),
+/* [11] */ static_cast(pImp->szData.Data4[ 3 ]),
+/* [12] */ static_cast(pImp->szData.Data4[ 4 ]),
+/* [13] */ static_cast(pImp->szData.Data4[ 5 ]),
+/* [14] */ static_cast(pImp->szData.Data4[ 6 ]),
+/* [15] */ static_cast(pImp->szData.Data4[ 7 ])
+};
 
 return aResult;
 }


[Libreoffice-commits] core.git: tools/source

2021-10-29 Thread Tor Lillqvist (via logerrit)
 tools/source/generic/poly.cxx |2 --
 1 file changed, 2 deletions(-)

New commits:
commit 9dd38a0b4021aa942196babdd6406691c1638a2a
Author: Tor Lillqvist 
AuthorDate: Fri Oct 29 13:26:11 2021 +0300
Commit: Tor Lillqvist 
CommitDate: Fri Oct 29 16:14:41 2021 +0200

Let's assume this is a bogus warning

Change-Id: I3941d8b1811d34b2b7646b20bc7e91c9034770be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124427
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 8128491ac8cd..7c5eca59d4c0 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1030,8 +1030,6 @@ double Polygon::CalcDistance( sal_uInt16 nP1, sal_uInt16 
nP2 ) const
 
 void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags )
 {
-DBG_ASSERT( !mpImplPolygon->mxFlagAry, "Optimizing could fail with 
beziers!" );
-
 sal_uInt16 nSize = mpImplPolygon->mnPoints;
 
 if( !(bool(nOptimizeFlags) && nSize) )


[Libreoffice-commits] core.git: tools/source

2021-10-13 Thread Mike Kaganski (via logerrit)
 tools/source/misc/json_writer.cxx |  135 ++
 1 file changed, 79 insertions(+), 56 deletions(-)

New commits:
commit aff3ce8837e00db6e91d0deb6c4f2ccb0d520c54
Author: Mike Kaganski 
AuthorDate: Wed Oct 13 13:17:23 2021 +0200
Commit: Mike Kaganski 
CommitDate: Wed Oct 13 19:34:13 2021 +0200

Improve JsonWriter's escapement code

It should now be conformant to JSON spec; and additionally,
it escapes two characters that are valid in JSON, but invalid
in JavaScript (as described in [1]).

[1] 
http://web.archive.org/web/20201203234157/http://timelessrepo.com/json-isnt-a-javascript-subset

Change-Id: I1081ade89a57fefefde672f2b8fa08e97627fc50
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123510
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index 09f34c25c3c7..7024b580c7fd 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -119,6 +119,56 @@ void JsonWriter::endStruct()
 mbFirstFieldInNode = false;
 }
 
+static char getEscapementChar(char ch)
+{
+switch (ch)
+{
+case '\b':
+return 'b';
+case '\t':
+return 't';
+case '\n':
+return 'n';
+case '\f':
+return 'f';
+case '\r':
+return 'r';
+default:
+return ch;
+}
+}
+
+static bool writeEscapedSequence(sal_uInt32 ch, char*& pos)
+{
+switch (ch)
+{
+case '\b':
+case '\t':
+case '\n':
+case '\f':
+case '\r':
+case '"':
+case '/':
+case '\\':
+*pos++ = '\\';
+*pos++ = getEscapementChar(ch);
+return true;
+// Special processing of U+2028 and U+2029, which are valid JSON, but 
invalid JavaScript
+// Write them in escaped '\u2028' or '\u2029' form
+case 0x2028:
+case 0x2029:
+*pos++ = '\\';
+*pos++ = 'u';
+*pos++ = '2';
+*pos++ = '0';
+*pos++ = '2';
+*pos++ = ch == 0x2028 ? '8' : '9';
+return true;
+default:
+return false;
+}
+}
+
 void JsonWriter::writeEscapedOUString(const OUString& rPropVal)
 {
 // Convert from UTF-16 to UTF-8 and perform escaping
@@ -126,42 +176,9 @@ void JsonWriter::writeEscapedOUString(const OUString& 
rPropVal)
 while (i < rPropVal.getLength())
 {
 sal_uInt32 ch = rPropVal.iterateCodePoints();
-if (ch == '\\')
-{
-*mPos = static_cast(ch);
-++mPos;
-*mPos = static_cast(ch);
-++mPos;
-}
-else if (ch == '"')
-{
-*mPos = '\\';
-++mPos;
-*mPos = static_cast(ch);
-++mPos;
-}
-else if (ch == '\n')
-{
-*mPos = '\\';
-++mPos;
-*mPos = 'n';
-++mPos;
-}
-else if (ch == '\r')
-{
-*mPos = '\\';
-++mPos;
-*mPos = 'r';
-++mPos;
-}
-else if (ch == '\f')
-{
-*mPos = '\\';
-++mPos;
-*mPos = 'f';
-++mPos;
-}
-else if (ch <= 0x7F)
+if (writeEscapedSequence(ch, mPos))
+continue;
+if (ch <= 0x7F)
 {
 *mPos = static_cast(ch);
 ++mPos;
@@ -200,9 +217,8 @@ void JsonWriter::put(const char* pPropName, const OUString& 
rPropVal)
 {
 auto nPropNameLength = strlen(pPropName);
 // But values can be any UTF-8,
-// see rtl_ImplGetFastUTF8ByteLen in sal/rtl/string.cxx for why a factor 3
-// is the worst case
-auto nWorstCasePropValLength = rPropVal.getLength() * 3;
+// if the string only contains of 0x2028, it will be expanded 6 times (see 
writeEscapedSequence)
+auto nWorstCasePropValLength = rPropVal.getLength() * 6;
 ensureSpace(nPropNameLength + nWorstCasePropValLength + 8);
 
 addCommaBeforeField();
@@ -241,24 +257,31 @@ void JsonWriter::put(const char* pPropName, 
std::string_view rPropVal)
 for (size_t i = 0; i < rPropVal.size(); ++i)
 {
 char ch = rPropVal[i];
-if (ch == '\\')
-{
-*mPos = ch;
-++mPos;
-*mPos = ch;
-++mPos;
-}
-else if (ch == '"')
+switch (ch)
 {
-*mPos = '\\';
-++mPos;
-*mPos = ch;
-++mPos;
-}
-else
-{
-*mPos = ch;
-++mPos;
+case '\b':
+case '\t':
+case '\n':
+case '\f':
+case '\r':
+case '"':
+case '/':
+case '\\':
+writeEscapedSequence(ch, mPos);
+break;
+

[Libreoffice-commits] core.git: tools/source

2021-10-02 Thread Noel Grandin (via logerrit)
 tools/source/misc/json_writer.cxx |   11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 9946a2fef07840ff4ca842928afbeeb52ece3603
Author: Noel Grandin 
AuthorDate: Sat Oct 2 13:18:37 2021 +0200
Commit: Michael Meeks 
CommitDate: Sat Oct 2 22:36:17 2021 +0200

fix buffer overruns in JsonWriter::put with UTF-8 values

Change-Id: I694585a1a540bfefc0e59bd58d8033a96ca35acb
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122996
Tested-by: Jenkins

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index f002ddc391aa..30ad911f9754 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -200,7 +200,10 @@ void JsonWriter::writeEscapedOUString(const OUString& 
rPropVal)
 void JsonWriter::put(const char* pPropName, const OUString& rPropVal)
 {
 auto nPropNameLength = strlen(pPropName);
-auto nWorstCasePropValLength = rPropVal.getLength() * 2;
+// But values can be any UTF-8,
+// see rtl_ImplGetFastUTF8ByteLen in sal/rtl/string.cxx for why a factor 3
+// is the worst case
+auto nWorstCasePropValLength = rPropVal.getLength() * 3;
 ensureSpace(nPropNameLength + nWorstCasePropValLength + 8);
 
 addCommaBeforeField();
@@ -220,8 +223,10 @@ void JsonWriter::put(const char* pPropName, const 
OUString& rPropVal)
 
 void JsonWriter::put(const char* pPropName, const OString& rPropVal)
 {
+// we assume property names are ascii
 auto nPropNameLength = strlen(pPropName);
-auto nWorstCasePropValLength = rPropVal.getLength();
+// escaping can double the length
+auto nWorstCasePropValLength = rPropVal.getLength() * 2;
 ensureSpace(nPropNameLength + nWorstCasePropValLength + 8);
 
 addCommaBeforeField();
@@ -372,7 +377,7 @@ void JsonWriter::put(const char* pPropName, bool nPropVal)
 
 void JsonWriter::putSimpleValue(const OUString& rPropVal)
 {
-auto nWorstCasePropValLength = rPropVal.getLength() * 2;
+auto nWorstCasePropValLength = rPropVal.getLength() * 3;
 ensureSpace(nWorstCasePropValLength + 4);
 
 addCommaBeforeField();


[Libreoffice-commits] core.git: tools/source

2021-10-02 Thread Noel Grandin (via logerrit)
 tools/source/misc/json_writer.cxx |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

New commits:
commit 897192f07c1f7863a50e09cdd29e6631550b83ff
Author: Noel Grandin 
AuthorDate: Sat Oct 2 13:15:40 2021 +0200
Commit: Noel Grandin 
CommitDate: Sat Oct 2 19:15:00 2021 +0200

simplify JsonWriter::reallocBuffer by using realloc

instead of malloc and copy.

spotted by mmeeks

Change-Id: Ibac83be597cfaf61f783a265562c5102bbaf29d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122995
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index b6482329ea55..f002ddc391aa 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -413,10 +413,7 @@ void JsonWriter::reallocBuffer(int noMoreBytesRequired)
 {
 int currentUsed = mPos - mpBuffer;
 auto newSize = std::max(mSpaceAllocated * 2, (currentUsed + 
noMoreBytesRequired) * 2);
-char* pNew = static_cast(malloc(newSize));
-memcpy(pNew, mpBuffer, currentUsed);
-free(mpBuffer);
-mpBuffer = pNew;
+mpBuffer = static_cast(realloc(mpBuffer, newSize));
 mPos = mpBuffer + currentUsed;
 mSpaceAllocated = newSize;
 }


[Libreoffice-commits] core.git: tools/source

2021-09-30 Thread Noel Grandin (via logerrit)
 tools/source/xml/XmlWalker.cxx |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

New commits:
commit 8148a46c7878158c4b701e2a5c374129e6ffdffc
Author: Noel Grandin 
AuthorDate: Thu Sep 30 10:39:16 2021 +0200
Commit: Noel Grandin 
CommitDate: Thu Sep 30 13:58:19 2021 +0200

no need to copy the name in XmlWalker::attribute

sName and the parameter we pass to xmlGetProp are both null-terminated
char strings

Change-Id: Ia8cb036f33cada8fa59d1e4f05df318a9cf28115
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122875
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/xml/XmlWalker.cxx b/tools/source/xml/XmlWalker.cxx
index 34a3d8746f6b..73199b4b665d 100644
--- a/tools/source/xml/XmlWalker.cxx
+++ b/tools/source/xml/XmlWalker.cxx
@@ -98,12 +98,11 @@ void XmlWalker::parent()
 
 OString XmlWalker::attribute(const OString& sName)
 {
-xmlChar* xmlName = xmlCharStrdup(sName.getStr());
-xmlChar* xmlAttribute = xmlGetProp(mpImpl->mpCurrent, xmlName);
+xmlChar* xmlAttribute
+= xmlGetProp(mpImpl->mpCurrent, reinterpret_cast(sName.getStr()));
 OString aAttributeContent(
 xmlAttribute == nullptr ? "" : reinterpret_cast(xmlAttribute));
 xmlFree(xmlAttribute);
-xmlFree(xmlName);
 
 return aAttributeContent;
 }


[Libreoffice-commits] core.git: tools/source

2021-09-16 Thread Noel Grandin (via logerrit)
 tools/source/generic/fract.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit f2315daf701847a180a5759039b4951fb4da0653
Author: Noel Grandin 
AuthorDate: Thu Sep 16 11:59:08 2021 +0200
Commit: Noel Grandin 
CommitDate: Thu Sep 16 13:33:55 2021 +0200

Revert "speedup rational_FromDouble"

This reverts commit 67d83e40e2c4f3862c50e6abeabfc24a75119fc8.

because it causes less accuracy sometimes, eg. see
  https://gerrit.libreoffice.org/c/core/+/122186

Change-Id: I06eb4921359a8fe6689c6cfd3e2967e25b646fa3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122124
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 57dd4e79c138..1b3c95a6cdda 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -370,8 +370,8 @@ bool operator > ( const Fraction& rVal1, const Fraction& 
rVal2 )
 }
 
 // If dVal > LONG_MAX or dVal < LONG_MIN, the rational throws a 
boost::bad_rational.
-// Otherwise, dVal and denominator are multiplied by 8, until one of them
-// is larger than (LONG_MAX / 8).
+// Otherwise, dVal and denominator are multiplied by 10, until one of them
+// is larger than (LONG_MAX / 10).
 //
 // NOTE: here we use 'sal_Int32' due that only values in sal_Int32 range are 
valid.
 static boost::rational rational_FromDouble(double dVal)
@@ -381,11 +381,11 @@ static boost::rational 
rational_FromDouble(double dVal)
  std::isnan(dVal) )
 throw boost::bad_rational();
 
-const sal_Int32 nMAX = std::numeric_limits::max() / 8;
+const sal_Int32 nMAX = std::numeric_limits::max() / 10;
 sal_Int32 nDen = 1;
 while ( std::abs( dVal ) < nMAX && nDen < nMAX ) {
-dVal *= 8;
-nDen *= 8;
+dVal *= 10;
+nDen *= 10;
 }
 return boost::rational( sal_Int32(dVal), nDen );
 }


[Libreoffice-commits] core.git: tools/source

2021-09-15 Thread Mike Kaganski (via logerrit)
 tools/source/generic/poly.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 6419ecb40a025f1b4f7df5d059bfca3579dab4d7
Author: Mike Kaganski 
AuthorDate: Wed Sep 15 12:34:12 2021 +0200
Commit: Mike Kaganski 
CommitDate: Wed Sep 15 16:54:19 2021 +0200

No need to check if nDX is 0 for atan2

We rely on IEEE floating-point arithmetic anyway, and then even both
arguments equal to 0 do not result in an error.

Even if it was different, it would be better to check id both nDX and
nDY are 0, and return 0 early.

It was so ever since "MWS_SRX644: migrate branch mws_srx644 -> HEAD"
commit fd2cf3dc7cd9c73070fa4d70c8ca99c9fc1ce135.

Change-Id: I5b8e2a359374dd1500b149d74eba4c0b0e5cd8d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122115
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 70bafc824404..ab33eb61021b 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -58,7 +58,7 @@ static double ImplGetParameter( const Point& rCenter, const 
Point& rPt, double f
 {
 const double nDX = static_cast(rPt.X()) - rCenter.X();
 const double nDY = static_cast(rCenter.Y()) - rPt.Y();
-double fAngle = atan2(nDY, (nDX == 0) ? 0.1 : nDX);
+double fAngle = atan2(nDY, nDX);
 
 return atan2(fWR*sin(fAngle), fHR*cos(fAngle));
 }


[Libreoffice-commits] core.git: tools/source

2021-09-06 Thread Noel Grandin (via logerrit)
 tools/source/generic/fract.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit f8cf0d2cb4e5e18f48d6b3bfbc7d0e72e7ed5190
Author: Noel Grandin 
AuthorDate: Mon Sep 6 13:25:45 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Sep 6 20:51:48 2021 +0200

tdf#144319 fix formula load

regression from
commit 67d83e40e2c4f3862c50e6abeabfc24a75119fc8
Author: Noel Grandin 
Date:   Sat Dec 19 13:25:53 2020 +0200
speedup rational_FromDouble

Change-Id: Icb728b63f950e827f1492087114f927c2f85ddb9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121719
Tested-by: Jenkins
Tested-by: Xisco Fauli 
Reviewed-by: Xisco Fauli 
Reviewed-by: Noel Grandin 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 7c0e850db8d7..57dd4e79c138 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -43,6 +43,9 @@ static boost::rational toRational(sal_Int32 n, 
sal_Int32 d)
 // https://github.com/boostorg/boost/issues/335 when these are 
std::numeric_limits::min
 if (n == d)
 return 1;
+// tdf#144319 avoid boost::bad_rational e.g. if numerator=-476741369, 
denominator=-2147483648
+if (d < -std::numeric_limits::max())
+return 0;
 return boost::rational(n, d);
 }
 


[Libreoffice-commits] core.git: tools/source

2021-07-06 Thread Noel Grandin (via logerrit)
 tools/source/datetime/ttime.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit ccf88845752a978ff3536c4bf66658993939caad
Author: Noel Grandin 
AuthorDate: Tue Jul 6 10:23:55 2021 +0200
Commit: Noel Grandin 
CommitDate: Tue Jul 6 22:07:59 2021 +0200

actually use CLOCK_MONOTONIC in tools::time

some of the code was not copied from sal/ correctly

Change-Id: I0a84b61eeab6a1b51eaa8ad303909373c52a6bb8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118529
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index 0049c33efd9d..c6c89c934886 100644
--- a/tools/source/datetime/ttime.cxx
+++ b/tools/source/datetime/ttime.cxx
@@ -29,6 +29,7 @@
 #include 
 #elif defined UNX
 #include 
+#include 
 #endif
 
 #include 
@@ -473,7 +474,7 @@ sal_uInt64 tools::Time::GetMonotonicTicks()
 mach_timebase_info(  );
 nMicroSeconds = mach_absolute_time() * static_cast(info.numer / 
info.denom) / 1000;
 #else
-#if defined(USE_CLOCK_GETTIME)
+#if defined(_POSIX_TIMERS)
 struct timespec currentTime;
 clock_gettime( CLOCK_MONOTONIC,  );
 nMicroSeconds = currentTime.tv_sec * 1000 * 1000 + currentTime.tv_nsec / 
1000;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-06-28 Thread Caolán McNamara (via logerrit)
 tools/source/generic/poly.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 228cb26a6a1afe668dd17471bedf0ab52f133d5a
Author: Caolán McNamara 
AuthorDate: Sun Jun 27 19:08:36 2021 +0100
Commit: Caolán McNamara 
CommitDate: Mon Jun 28 09:53:10 2021 +0200

ofz#35504 Integer-overflow

Change-Id: I7a462b821f286411d759b5259461fcdbf1741859
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117955
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 1f60337cffa1..2575d262a68a 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -255,7 +255,7 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, 
const Point& rStart, c
 }
 
 
-if( ( nRadX > 32 ) && ( nRadY > 32 ) && ( nRadX + nRadY ) < 8192 )
+if (nRadX > 32 && nRadY > 32 && o3tl::saturating_add(nRadX, nRadY) < 
8192)
 nPoints >>= 1;
 
 // compute threshold
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-06-23 Thread Caolán McNamara (via logerrit)
 tools/source/generic/poly.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 623b633f1145466e8d60fff3255f476e6001297b
Author: Caolán McNamara 
AuthorDate: Wed Jun 23 14:04:39 2021 +0100
Commit: Caolán McNamara 
CommitDate: Wed Jun 23 17:48:37 2021 +0200

ofz#35504 Integer-overflow

Change-Id: If8c460a4890ad23c2656c3b677b6c2ad8d46fb2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117734
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 9d5f63fc65e9..1f60337cffa1 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -236,8 +236,8 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, 
const Point& rStart, c
 // tdf#142268 Get Top Left corner of rectangle (the rectangle is not 
always correctly created)
 const auto aBoundLeft = rBound.Left() < aCenter.X() ? rBound.Left() : 
rBound.Right();
 const auto aBoundTop = rBound.Top() < aCenter.Y() ? rBound.Top() : 
rBound.Bottom();
-const auto nRadX = aCenter.X() - aBoundLeft;
-const auto nRadY = aCenter.Y() - aBoundTop;
+const auto nRadX = o3tl::saturating_sub(aCenter.X(), aBoundLeft);
+const auto nRadY = o3tl::saturating_sub(aCenter.Y(), aBoundTop);
 sal_uInt16  nPoints;
 
 tools::Long nRadXY;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-06-21 Thread Noel Grandin (via logerrit)
 tools/source/stream/strmunx.cxx |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit c8644ab3fcc9a911a9182a1b6a24a17610a2105d
Author: Noel Grandin 
AuthorDate: Mon Jun 21 11:30:06 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Jun 21 12:44:46 2021 +0200

make SvFileStream::FlushData __actually__ flush to disk

which I noticed while debugging another change where I need
the flush to actually do something useful.

Change-Id: I61621cbfe68a404c7fae851760154b398997fe61
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117548
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index 40cbe382213a..0b745e69b140 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -288,8 +288,10 @@ sal_uInt64 SvFileStream::SeekPos(sal_uInt64 const nPos)
 
 void SvFileStream::FlushData()
 {
-// does not exist locally
-}
+auto rc = osl_syncFile(pInstanceData->rHandle);
+if (rc != osl_File_E_None)
+SetError( ::GetSvError( rc ));
+ }
 
 bool SvFileStream::LockFile()
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-06-20 Thread Caolán McNamara (via logerrit)
 tools/source/generic/poly.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 6a1dea1d7a1c7ede887c66e6fd2ddecedf5404b9
Author: Caolán McNamara 
AuthorDate: Sun Jun 20 14:22:35 2021 +0100
Commit: Caolán McNamara 
CommitDate: Sun Jun 20 16:27:08 2021 +0200

Revert "ofz#33769 Integer-overflow"

now fixed at an earlier stage so NaN isn't imported from dxf

This reverts commit 71fe0aeee20640c57816dc45010d32dac9afeaaf.

Change-Id: Id2689e33f89deb08e1bcd39a6d4ba38fb4663681
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117511
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 857a1a8e7cbb..9d5f63fc65e9 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -57,7 +57,7 @@
 static double ImplGetParameter( const Point& rCenter, const Point& rPt, double 
fWR, double fHR )
 {
 const tools::Long nDX = rPt.X() - rCenter.X();
-double fAngle = atan2( o3tl::saturating_toggle_sign(rPt.Y()) + 
rCenter.Y(), ( ( nDX == 0 ) ? 0.1 : nDX ) );
+double fAngle = atan2( -rPt.Y() + rCenter.Y(), ( ( nDX == 0 ) ? 
0.1 : nDX ) );
 
 return atan2(fWR*sin(fAngle), fHR*cos(fAngle));
 }
@@ -236,8 +236,8 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, 
const Point& rStart, c
 // tdf#142268 Get Top Left corner of rectangle (the rectangle is not 
always correctly created)
 const auto aBoundLeft = rBound.Left() < aCenter.X() ? rBound.Left() : 
rBound.Right();
 const auto aBoundTop = rBound.Top() < aCenter.Y() ? rBound.Top() : 
rBound.Bottom();
-const auto nRadX = o3tl::saturating_sub(aCenter.X(), aBoundLeft);
-const auto nRadY = o3tl::saturating_sub(aCenter.Y(), aBoundTop);
+const auto nRadX = aCenter.X() - aBoundLeft;
+const auto nRadY = aCenter.Y() - aBoundTop;
 sal_uInt16  nPoints;
 
 tools::Long nRadXY;
@@ -255,7 +255,7 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, 
const Point& rStart, c
 }
 
 
-if (nRadX > 32 && nRadY > 32 && o3tl::saturating_add(nRadX, nRadY) < 
8192)
+if( ( nRadX > 32 ) && ( nRadY > 32 ) && ( nRadX + nRadY ) < 8192 )
 nPoints >>= 1;
 
 // compute threshold
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-06-03 Thread Caolán McNamara (via logerrit)
 tools/source/generic/poly.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 71fe0aeee20640c57816dc45010d32dac9afeaaf
Author: Caolán McNamara 
AuthorDate: Thu Jun 3 11:10:23 2021 +0100
Commit: Caolán McNamara 
CommitDate: Thu Jun 3 13:37:36 2021 +0200

ofz#33769 Integer-overflow

Change-Id: I2f158b1f7c3fdaea00c4334cf3889e0f38674e8a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116650
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index f0a0a7388b06..857a1a8e7cbb 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -255,7 +255,7 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, 
const Point& rStart, c
 }
 
 
-if( ( nRadX > 32 ) && ( nRadY > 32 ) && ( nRadX + nRadY ) < 8192 )
+if (nRadX > 32 && nRadY > 32 && o3tl::saturating_add(nRadX, nRadY) < 
8192)
 nPoints >>= 1;
 
 // compute threshold
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source ucb/source

2021-05-28 Thread Noel Grandin (via logerrit)
 tools/source/generic/poly.cxx|8 
 ucb/source/cacher/cachedcontentresultset.cxx |8 
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 3e0c39f9aeaa5c8791df94418ab8b4b78e005ac1
Author: Noel Grandin 
AuthorDate: Thu May 27 15:55:18 2021 +0200
Commit: Noel Grandin 
CommitDate: Fri May 28 13:28:31 2021 +0200

no need to allocate these on the heap

Change-Id: I0f477edb666ff2c6dc9def45ec68c4ce1a34634a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116289
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 210764086743..f0a0a7388b06 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -141,12 +141,12 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rRect, 
sal_uInt32 nHorzRound,
 const Point aTR( aRect.Right() - nHorzRound, aRect.Top() + 
nVertRound );
 const Point aBR( aRect.Right() - nHorzRound, aRect.Bottom() - 
nVertRound );
 const Point aBL( aRect.Left() + nHorzRound, aRect.Bottom() - 
nVertRound );
-std::unique_ptr pEllipsePoly( new tools::Polygon( 
Point(), nHorzRound, nVertRound ) );
-sal_uInt16 i, nEnd, nSize4 = pEllipsePoly->GetSize() >> 2;
+tools::Polygon aEllipsePoly( Point(), nHorzRound, nVertRound );
+sal_uInt16 i, nEnd, nSize4 = aEllipsePoly.GetSize() >> 2;
 
-ImplInitSize(pEllipsePoly->GetSize() + 1);
+ImplInitSize(aEllipsePoly.GetSize() + 1);
 
-const Point* pSrcAry = pEllipsePoly->GetConstPointAry();
+const Point* pSrcAry = aEllipsePoly.GetConstPointAry();
 Point* pDstAry = mxPointAry.get();
 
 for( i = 0, nEnd = nSize4; i < nEnd; i++ )
diff --git a/ucb/source/cacher/cachedcontentresultset.cxx 
b/ucb/source/cacher/cachedcontentresultset.cxx
index 297453f1540c..9d1b8d8c7a0d 100644
--- a/ucb/source/cacher/cachedcontentresultset.cxx
+++ b/ucb/source/cacher/cachedcontentresultset.cxx
@@ -446,8 +446,8 @@ CCRS_PropertySetInfo::CCRS_PropertySetInfo(
 if( nFetchDirection != -1 )
 nDeleted++;
 
-std::unique_ptr > pOrigProps(new Sequence ( 
*m_pProperties ));
-sal_Int32 nOrigProps = pOrigProps->getLength();
+Sequence< Property > aOrigProps( *m_pProperties );
+sal_Int32 nOrigProps = aOrigProps.getLength();
 
 m_pProperties->realloc( nOrigProps + 2 - nDeleted );//note that nDeleted 
is <= 2
 for( sal_Int32 n = 0, m = 0; n < nOrigProps; n++, m++ )
@@ -455,7 +455,7 @@ CCRS_PropertySetInfo::CCRS_PropertySetInfo(
 if( n == nFetchSize || n == nFetchDirection )
 m--;
 else
-(*m_pProperties)[ m ] = (*pOrigProps)[ n ];
+(*m_pProperties)[ m ] = aOrigProps[ n ];
 }
 {
 Property& rMyProp = (*m_pProperties)[ nOrigProps - nDeleted ];
@@ -464,7 +464,7 @@ CCRS_PropertySetInfo::CCRS_PropertySetInfo(
 rMyProp.Attributes = PropertyAttribute::BOUND | 
PropertyAttribute::MAYBEDEFAULT;
 
 if( nFetchSize != -1 )
-m_nFetchSizePropertyHandle = (*pOrigProps)[nFetchSize].Handle;
+m_nFetchSizePropertyHandle = aOrigProps[nFetchSize].Handle;
 else
 m_nFetchSizePropertyHandle = impl_getRemainedHandle();
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-05-20 Thread Mike Kaganski (via logerrit)
 tools/source/generic/gen.cxx |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

New commits:
commit 256c834c30c400034ce35744b74dfea7cf70069c
Author: Mike Kaganski 
AuthorDate: Thu May 20 14:13:17 2021 +0200
Commit: Mike Kaganski 
CommitDate: Thu May 20 15:09:32 2021 +0200

Simplify a bit: use one minmax in place of 3 min + 3 max calls

Change-Id: Ief2d8d049d2e05ee762e6855514f75be2f053836
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115835
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 78025c459d07..34c9fbdfd649 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -103,10 +103,8 @@ tools::Rectangle& tools::Rectangle::Union( const 
tools::Rectangle& rRect )
 *this = rRect;
 else
 {
-nLeft  =  std::min( std::min( nLeft, rRect.nLeft ), std::min( nRight, 
rRect.nRight )   );
-nRight  = std::max( std::max( nLeft, rRect.nLeft ), std::max( nRight, 
rRect.nRight )   );
-nTop= std::min( std::min( nTop, rRect.nTop ),   std::min( nBottom, 
rRect.nBottom ) );
-nBottom = std::max( std::max( nTop, rRect.nTop ),   std::max( nBottom, 
rRect.nBottom ) );
+std::tie(nLeft, nRight) = std::minmax({ nLeft, rRect.nLeft, nRight, 
rRect.nRight });
+std::tie(nTop, nBottom) = std::minmax({ nTop, rRect.nTop, nBottom, 
rRect.nBottom });
 }
 
 return *this;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-04-28 Thread Caolán McNamara (via logerrit)
 tools/source/generic/poly.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit bc7c37f2f67ace27196a46c62c2d568501e9f796
Author: Caolán McNamara 
AuthorDate: Wed Apr 28 09:02:16 2021 +0100
Commit: Caolán McNamara 
CommitDate: Wed Apr 28 16:17:17 2021 +0200

ofz#33769 Integer-overflow

Change-Id: I067db0452650cf3e8bc887abac74c4ff796d4ad2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114768
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index e482528b9ab1..05d35f7d1385 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -227,14 +227,14 @@ ImplPolygon::ImplPolygon( const Point& rCenter, 
tools::Long nRadX, tools::Long n
 ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, 
const Point& rEnd,
 PolyStyle eStyle )
 {
-const tools::Long  nWidth = rBound.GetWidth();
-const tools::Long  nHeight = rBound.GetHeight();
+const auto nWidth = rBound.GetWidth();
+const auto nHeight = rBound.GetHeight();
 
 if( ( nWidth > 1 ) && ( nHeight > 1 ) )
 {
 const Point aCenter( rBound.Center() );
-const tools::Long  nRadX = aCenter.X() - rBound.Left();
-const tools::Long  nRadY = aCenter.Y() - rBound.Top();
+const auto nRadX = o3tl::saturating_sub(aCenter.X(), rBound.Left());
+const auto nRadY = o3tl::saturating_sub(aCenter.Y(), rBound.Top());
 sal_uInt16  nPoints;
 
 tools::Long nRadXY;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-04-14 Thread Caolán McNamara (via logerrit)
 tools/source/generic/poly.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2f752afbb075c4caa67697d9e8b249ae29824bbe
Author: Caolán McNamara 
AuthorDate: Wed Apr 14 15:31:04 2021 +0100
Commit: Caolán McNamara 
CommitDate: Wed Apr 14 18:33:16 2021 +0200

ofz#33235 Integer-overflow

Change-Id: I7a717a5bfdd58f22de3dcd61fe4aad67d1463a42
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114099
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 9d06055150b4..e482528b9ab1 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -57,7 +57,7 @@
 static double ImplGetParameter( const Point& rCenter, const Point& rPt, double 
fWR, double fHR )
 {
 const tools::Long nDX = rPt.X() - rCenter.X();
-double fAngle = atan2( -rPt.Y() + rCenter.Y(), ( ( nDX == 0 ) ? 
0.1 : nDX ) );
+double fAngle = atan2( o3tl::saturating_toggle_sign(rPt.Y()) + 
rCenter.Y(), ( ( nDX == 0 ) ? 0.1 : nDX ) );
 
 return atan2(fWR*sin(fAngle), fHR*cos(fAngle));
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-04-10 Thread Caolán McNamara (via logerrit)
 tools/source/generic/fract.cxx |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit db00a6d4d9935f4905c70d826b27139221e4a1c7
Author: Caolán McNamara 
AuthorDate: Sat Apr 10 16:17:01 2021 +0100
Commit: Caolán McNamara 
CommitDate: Sat Apr 10 20:19:23 2021 +0200

ofz#32973 Integer-overflow

Change-Id: Ib290468b4c7388b80da627138435b98feaed354b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113921
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index d4c4fe11c319..7c0e850db8d7 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -427,8 +427,15 @@ static void 
rational_ReduceInaccurate(boost::rational& rRational, uns
 return;
 
 // 
http://www.boost.org/doc/libs/release/libs/rational/rational.html#Internal%20representation
-const bool bNeg = ( rRational.numerator() < 0 );
-sal_Int32 nMul = bNeg? -rRational.numerator(): rRational.numerator();
+sal_Int32 nMul = rRational.numerator();
+if (nMul == std::numeric_limits::min())
+{
+// ofz#32973 Integer-overflow
+return;
+}
+const bool bNeg = nMul < 0;
+if (bNeg)
+nMul = -nMul;
 sal_Int32 nDiv = rRational.denominator();
 
 DBG_ASSERT(nSignificantBits<65, "More than 64 bit of significance is 
overkill!");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-04-09 Thread Caolán McNamara (via logerrit)
 tools/source/generic/fract.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit ce9f23c6196b17985d14e441aa93175b31650f34
Author: Caolán McNamara 
AuthorDate: Thu Apr 8 20:16:35 2021 +0100
Commit: Caolán McNamara 
CommitDate: Fri Apr 9 10:06:47 2021 +0200

ofz#33038 Floating-point-exception

Change-Id: Ibe4a6667f5a14b5d94f2dbb92ad611ecba4984f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113821
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 648c91b20550..d4c4fe11c319 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -62,7 +62,8 @@ Fraction::Fraction( sal_Int64 nNum, sal_Int64 nDen ) : 
mnNumerator(nNum), mnDeno
 SAL_WARN( "tools.fraction", "'Fraction(" << nNum << ",0)' invalid 
fraction created" );
 return;
 }
-if (nDen == -1 && nNum == std::numeric_limits::min())
+if ((nDen == -1 && nNum == std::numeric_limits::min()) ||
+(nNum == -1 && nDen == std::numeric_limits::min()))
 {
 mbValid = false;
 SAL_WARN("tools.fraction", "'Fraction(" << nNum << "," << nDen << ")' 
invalid fraction created");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-04-07 Thread Caolán McNamara (via logerrit)
 tools/source/generic/fract.cxx |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

New commits:
commit 6b46b053c78eb99d5fa4f296d25c8101ef4552d3
Author: Caolán McNamara 
AuthorDate: Tue Apr 6 20:42:14 2021 +0100
Commit: Caolán McNamara 
CommitDate: Wed Apr 7 10:05:08 2021 +0200

ofz#32965 move fpe fix of ofz#17212 into toRational

Change-Id: Ica301357f45fd289c41234b8a7059ab0ff264321
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113703
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 6e245530281a..648c91b20550 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -40,6 +40,9 @@ static void 
rational_ReduceInaccurate(boost::rational& rRational, uns
 
 static boost::rational toRational(sal_Int32 n, sal_Int32 d)
 {
+// https://github.com/boostorg/boost/issues/335 when these are 
std::numeric_limits::min
+if (n == d)
+return 1;
 return boost::rational(n, d);
 }
 
@@ -109,10 +112,6 @@ Fraction::operator double() const
 return 0.0;
 }
 
-// https://github.com/boostorg/boost/issues/335 when these are 
std::numeric_limits::min
-if (mnNumerator == mnDenominator)
-return 1.0;
-
 return boost::rational_cast(toRational(mnNumerator, 
mnDenominator));
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-04-05 Thread Mike Kaganski (via logerrit)
 tools/source/generic/fract.cxx |   16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

New commits:
commit d266373bbb48f1c4c481fac74727c7b17440f7bd
Author: Mike Kaganski 
AuthorDate: Mon Apr 5 13:43:28 2021 +0300
Commit: Mike Kaganski 
CommitDate: Mon Apr 5 13:43:55 2021 +0200

Use std::gcd instead of boost version

Change-Id: Iba3bd7cbab01a99f46e7b2f5632fd3b11e70458d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113598
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index a76ce01e1f81..6e245530281a 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -26,13 +26,8 @@
 
 #include 
 #include 
+#include 
 
-#include 
-#if BOOST_VERSION >= 106700
-#include 
-#else
-#include 
-#endif
 #include 
 
 #ifdef _MSC_VER
@@ -172,13 +167,8 @@ namespace
 T den = r.denominator();
 
 // Avoid overflow and preserve normalization
-#if BOOST_VERSION >= 106700
-T gcd1 = boost::integer::gcd(i.numerator(), den);
-T gcd2 = boost::integer::gcd(num, i.denominator());
-#else
-T gcd1 = boost::math::gcd(i.numerator(), den);
-T gcd2 = boost::math::gcd(num, i.denominator());
-#endif
+T gcd1 = std::gcd(i.numerator(), den);
+T gcd2 = std::gcd(num, i.denominator());
 
 bool fail = false;
 fail |= o3tl::checked_multiply(i.numerator() / gcd1, num / gcd2, num);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source vcl/qa

2021-04-05 Thread Caolán McNamara (via logerrit)
 tools/source/generic/fract.cxx|6 ++
 vcl/qa/cppunit/graphicfilter/data/svm/pass/ofz32885-1.svm |binary
 2 files changed, 6 insertions(+)

New commits:
commit b4613a30fed86aa8eed45e1ecee13947a33ea81c
Author: Caolán McNamara 
AuthorDate: Sun Apr 4 20:34:30 2021 +0100
Commit: Caolán McNamara 
CommitDate: Mon Apr 5 12:18:31 2021 +0200

ofz#32885 regard as invalid fractions that will FPE boost::integer::gcd

Change-Id: I59befe0cd21be54d1c94bb28e3d9c01f1483c104
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113574
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index b525d1de9896..a76ce01e1f81 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -64,6 +64,12 @@ Fraction::Fraction( sal_Int64 nNum, sal_Int64 nDen ) : 
mnNumerator(nNum), mnDeno
 SAL_WARN( "tools.fraction", "'Fraction(" << nNum << ",0)' invalid 
fraction created" );
 return;
 }
+if (nDen == -1 && nNum == std::numeric_limits::min())
+{
+mbValid = false;
+SAL_WARN("tools.fraction", "'Fraction(" << nNum << "," << nDen << ")' 
invalid fraction created");
+return;
+}
 }
 
 /**
diff --git a/vcl/qa/cppunit/graphicfilter/data/svm/pass/ofz32885-1.svm 
b/vcl/qa/cppunit/graphicfilter/data/svm/pass/ofz32885-1.svm
new file mode 100644
index ..b4d5126b95cf
Binary files /dev/null and 
b/vcl/qa/cppunit/graphicfilter/data/svm/pass/ofz32885-1.svm differ
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-01-14 Thread Tor Lillqvist (via logerrit)
 tools/source/misc/json_writer.cxx |   18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

New commits:
commit 5aee16cf09f9d4ba50feaf804b2a7a649af276bc
Author: Tor Lillqvist 
AuthorDate: Fri Jan 15 03:03:41 2021 +0200
Commit: Tor Lillqvist 
CommitDate: Fri Jan 15 08:54:12 2021 +0100

Make JsonWriter::writeEscapedOUString() handle surrogate pairs properly

It is wrong to iterate over UTF-16 code units one by one. We have
OUString::iterateCodePoints() to iterate over Unicode code points.

The two UTF-16 code units of a surrogate pair (for a non-BMP code
point) should not be encoded separately to UTF-8 bytes. It is the code
point that should be encoded (to four bytes).

Change-Id: Ica4341308deb6618c9c2da8dcee8a11ef4e8238d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109318
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
Reviewed-by: Tor Lillqvist 

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index a50e2ada967f..c326201eb9e5 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -123,9 +123,10 @@ void JsonWriter::endStruct()
 void JsonWriter::writeEscapedOUString(const OUString& rPropVal)
 {
 // Convert from UTF-16 to UTF-8 and perform escaping
-for (int i = 0; i < rPropVal.getLength(); ++i)
+sal_Int32 i = 0;
+while (i < rPropVal.getLength())
 {
-sal_Unicode ch = rPropVal[i];
+sal_uInt32 ch = rPropVal.iterateCodePoints();
 if (ch == '\\')
 {
 *mPos = static_cast(ch);
@@ -173,7 +174,7 @@ void JsonWriter::writeEscapedOUString(const OUString& 
rPropVal)
 *mPos = 0x80 | (ch & 0x3F); /* 10xx */
 ++mPos;
 }
-else
+else if (ch <= 0x)
 {
 *mPos = 0xE0 | (ch >> 12); /* 1110 */
 ++mPos;
@@ -182,6 +183,17 @@ void JsonWriter::writeEscapedOUString(const OUString& 
rPropVal)
 *mPos = 0x80 | (ch & 0x3F); /* 10xx */
 ++mPos;
 }
+else
+{
+*mPos = 0xF0 | (ch >> 18); /* 0xxx */
+++mPos;
+*mPos = 0x80 | ((ch >> 12) & 0x3F); /* 10xx */
+++mPos;
+*mPos = 0x80 | ((ch >> 6) & 0x3F); /* 10xx */
+++mPos;
+*mPos = 0x80 | (ch & 0x3F); /* 10xx */
+++mPos;
+}
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2021-01-14 Thread Noel Grandin (via logerrit)
 tools/source/generic/bigint.cxx |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 61a3aaae61dfb6d9538d4721d44293d737f4
Author: Noel Grandin 
AuthorDate: Thu Jan 14 14:31:22 2021 +0200
Commit: Noel Grandin 
CommitDate: Fri Jan 15 08:08:40 2021 +0100

cid#1471704 workaround

Coverity complaints that
"nVal = nNum[0] in bigint.cxx:84 is an assignment of overlapping memory"
But this is essentially a tagged union, so it's actually fine.
Workaround the warning by using a temporary (which the compiler
will optimise away anyhow)

Change-Id: I0fda945f831b1cdd7b33f7cb671a744150990bf6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109294
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx
index 5c8c7771a2c5..f6627200a61c 100644
--- a/tools/source/generic/bigint.cxx
+++ b/tools/source/generic/bigint.cxx
@@ -80,14 +80,16 @@ void BigInt::Normalize()
 
 if ( nLen < 3 )
 {
+sal_Int32 newVal;
 if ( nLen < 2 )
-nVal = nNum[0];
+newVal = nNum[0];
 else if ( nNum[1] & 0x8000 )
 return;
 else
-nVal = (static_cast(nNum[1]) << 16) + nNum[0];
+newVal = (static_cast(nNum[1]) << 16) + nNum[0];
 
 nLen = 0;
+nVal = newVal;
 
 if ( bIsNeg )
 nVal = -nVal;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-12-28 Thread Henry Castro (via logerrit)
 tools/source/misc/json_writer.cxx |   21 +
 1 file changed, 21 insertions(+)

New commits:
commit 6002ff0354c95c3dffbf4f933833695f3f47b73b
Author: Henry Castro 
AuthorDate: Fri Dec 25 12:55:49 2020 -0400
Commit: Henry Castro 
CommitDate: Mon Dec 28 13:26:46 2020 +0100

tools: json: fix missing escaped chars

When client side tries to show the "Macro Security Warning"
message dialog, it fails to parse the JSON objects

Change-Id: Id73c291ddd9cf739d63d69f06094eacb7b43a2f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108287
Tested-by: Jenkins
Reviewed-by: Henry Castro 

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index 1246f0578fca..a50e2ada967f 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -140,6 +140,27 @@ void JsonWriter::writeEscapedOUString(const OUString& 
rPropVal)
 *mPos = static_cast(ch);
 ++mPos;
 }
+else if (ch == '\n')
+{
+*mPos = '\\';
+++mPos;
+*mPos = 'n';
+++mPos;
+}
+else if (ch == '\r')
+{
+*mPos = '\\';
+++mPos;
+*mPos = 'r';
+++mPos;
+}
+else if (ch == '\f')
+{
+*mPos = '\\';
+++mPos;
+*mPos = 'f';
+++mPos;
+}
 else if (ch <= 0x7F)
 {
 *mPos = static_cast(ch);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-12-19 Thread Noel Grandin (via logerrit)
 tools/source/generic/fract.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 67d83e40e2c4f3862c50e6abeabfc24a75119fc8
Author: Noel Grandin 
AuthorDate: Sat Dec 19 13:25:53 2020 +0200
Commit: Noel Grandin 
CommitDate: Sat Dec 19 16:05:20 2020 +0100

speedup rational_FromDouble

multiplying/dividing by a power of 2 is much cheaper than
the equivalent operation on a factor of 10.

Change-Id: I31a7196a07649336378be867c67eb8a89fe6765f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108019
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 8ec17b94a477..f5d2c88f4af8 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -400,8 +400,8 @@ SvStream& WriteFraction( SvStream& rOStream, const 
Fraction& rFract )
 }
 
 // If dVal > LONG_MAX or dVal < LONG_MIN, the rational throws a 
boost::bad_rational.
-// Otherwise, dVal and denominator are multiplied by 10, until one of them
-// is larger than (LONG_MAX / 10).
+// Otherwise, dVal and denominator are multiplied by 8, until one of them
+// is larger than (LONG_MAX / 8).
 //
 // NOTE: here we use 'sal_Int32' due that only values in sal_Int32 range are 
valid.
 static boost::rational rational_FromDouble(double dVal)
@@ -411,11 +411,11 @@ static boost::rational 
rational_FromDouble(double dVal)
  std::isnan(dVal) )
 throw boost::bad_rational();
 
-const sal_Int32 nMAX = std::numeric_limits::max() / 10;
+const sal_Int32 nMAX = std::numeric_limits::max() / 8;
 sal_Int32 nDen = 1;
 while ( std::abs( dVal ) < nMAX && nDen < nMAX ) {
-dVal *= 10;
-nDen *= 10;
+dVal *= 8;
+nDen *= 8;
 }
 return boost::rational( sal_Int32(dVal), nDen );
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-12-17 Thread Noel Grandin (via logerrit)
 tools/source/stream/stream.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d5b20f44a9911534dd1796d3bfa8cbca4619e075
Author: Noel Grandin 
AuthorDate: Wed Dec 16 12:29:17 2020 +0200
Commit: Noel Grandin 
CommitDate: Thu Dec 17 14:02:11 2020 +0100

simplify checkSeek()

Change-Id: Ie6e016aa9fe630691ed71154489c63a182a3f8cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107827
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index a7021d2b22aa..f807a56cf52f 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1411,7 +1411,7 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos)
 
 bool checkSeek(SvStream , sal_uInt64 nOffset)
 {
-const sal_uInt64 nMaxSeek(rSt.Tell() + rSt.remainingSize());
+const sal_uInt64 nMaxSeek = rSt.TellEnd();
 return (nOffset <= nMaxSeek && rSt.Seek(nOffset) == nOffset);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-12-14 Thread Noel (via logerrit)
 tools/source/stream/stream.cxx |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 0651fa8352116a58463c036c196b6caede5c9616
Author: Noel 
AuthorDate: Mon Dec 14 14:42:19 2020 +0200
Commit: Noel Grandin 
CommitDate: Mon Dec 14 21:14:54 2020 +0100

remove Seek(nCurr) in SvStream::remainingSize()

which slows down some operations,
and is unnecessary, since TellEnd()
already resets the file pointer.

Change-Id: I71a0d7f45074039b890997a730afa1cd1c160886
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107689
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 8448f5144af9..a7021d2b22aa 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1442,7 +1442,6 @@ sal_uInt64 SvStream::remainingSize()
 sal_uInt64 const nCurr = Tell();
 sal_uInt64 const nEnd = TellEnd();
 sal_uInt64 nMaxAvailable = nEnd > nCurr ? (nEnd-nCurr) : 0;
-Seek(nCurr);
 return nMaxAvailable;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-11-17 Thread Mike Kaganski (via logerrit)
 tools/source/generic/poly.cxx |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

New commits:
commit c70b00820ec46035e50c7922876c5423c2f5f936
Author: Mike Kaganski 
AuthorDate: Wed Nov 18 08:59:57 2020 +0300
Commit: Mike Kaganski 
CommitDate: Wed Nov 18 07:54:20 2020 +0100

Reduce variable scope

Change-Id: Ie1adad9228c4eadbe0d314c0dc27057e84cd721a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106037
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index a88a9fd9ec00..73531236f522 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1606,7 +1606,6 @@ bool Polygon::IsEqual( const tools::Polygon& rPoly ) const
 
 SvStream& ReadPolygon( SvStream& rIStream, tools::Polygon& rPoly )
 {
-sal_uInt16  i;
 sal_uInt16  nPoints(0);
 
 // read all points and create array
@@ -1621,7 +1620,7 @@ SvStream& ReadPolygon( SvStream& rIStream, 
tools::Polygon& rPoly )
 
 rPoly.mpImplPolygon->ImplSetSize( nPoints, false );
 
-for (i = 0; i < nPoints; i++)
+for (sal_uInt16 i = 0; i < nPoints; i++)
 {
 sal_Int32 nTmpX(0), nTmpY(0);
 rIStream.ReadInt32(nTmpX).ReadInt32(nTmpY);
@@ -1634,13 +1633,12 @@ SvStream& ReadPolygon( SvStream& rIStream, 
tools::Polygon& rPoly )
 
 SvStream& WritePolygon( SvStream& rOStream, const tools::Polygon& rPoly )
 {
-sal_uInt16  i;
 sal_uInt16  nPoints = rPoly.GetSize();
 
 // Write number of points
 rOStream.WriteUInt16( nPoints );
 
-for (i = 0; i < nPoints; i++)
+for (sal_uInt16 i = 0; i < nPoints; i++)
 {
 rOStream.WriteInt32(rPoly.mpImplPolygon->mxPointAry[i].X())
 .WriteInt32(rPoly.mpImplPolygon->mxPointAry[i].Y());
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-11-17 Thread Mike Kaganski (via logerrit)
 tools/source/generic/poly.cxx |   43 +++---
 1 file changed, 8 insertions(+), 35 deletions(-)

New commits:
commit 97f084b10caa971ee08730c80a3c3cde85c9475e
Author: Mike Kaganski 
AuthorDate: Tue Nov 17 15:00:53 2020 +0300
Commit: Mike Kaganski 
CommitDate: Tue Nov 17 17:54:56 2020 +0100

Fix vcl_svm_test after making tools::Long 64-bit on _WIN64

Just don't rely on details of Point implementation.

Change-Id: I0cd0d6b7cacbf2751803a854d78e4b099ccf197f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105978
Reviewed-by: Noel Grandin 
Reviewed-by: Mike Kaganski 
Tested-by: Jenkins

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 5a4a79be984c..a88a9fd9ec00 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1621,24 +1621,12 @@ SvStream& ReadPolygon( SvStream& rIStream, 
tools::Polygon& rPoly )
 
 rPoly.mpImplPolygon->ImplSetSize( nPoints, false );
 
-// Determine whether we need to write through operators
-#if (SAL_TYPES_SIZEOFLONG) == 4
-#ifdef OSL_BIGENDIAN
-if ( rIStream.GetEndian() == SvStreamEndian::BIG )
-#else
-if ( rIStream.GetEndian() == SvStreamEndian::LITTLE )
-#endif
-   rIStream.ReadBytes(rPoly.mpImplPolygon->mxPointAry.get(), 
nPoints*sizeof(Point));
-else
-#endif
+for (i = 0; i < nPoints; i++)
 {
-for( i = 0; i < nPoints; i++ )
-{
-sal_Int32 nTmpX(0), nTmpY(0);
-rIStream.ReadInt32( nTmpX ).ReadInt32( nTmpY );
-rPoly.mpImplPolygon->mxPointAry[i].setX( nTmpX );
-rPoly.mpImplPolygon->mxPointAry[i].setY( nTmpY );
-}
+sal_Int32 nTmpX(0), nTmpY(0);
+rIStream.ReadInt32(nTmpX).ReadInt32(nTmpY);
+rPoly.mpImplPolygon->mxPointAry[i].setX(nTmpX);
+rPoly.mpImplPolygon->mxPointAry[i].setY(nTmpY);
 }
 
 return rIStream;
@@ -1652,25 +1640,10 @@ SvStream& WritePolygon( SvStream& rOStream, const 
tools::Polygon& rPoly )
 // Write number of points
 rOStream.WriteUInt16( nPoints );
 
-// Determine whether we need to write through operators
-#if (SAL_TYPES_SIZEOFLONG) == 4
-#ifdef OSL_BIGENDIAN
-if ( rOStream.GetEndian() == SvStreamEndian::BIG )
-#else
-if ( rOStream.GetEndian() == SvStreamEndian::LITTLE )
-#endif
-{
-if ( nPoints )
-rOStream.WriteBytes(rPoly.mpImplPolygon->mxPointAry.get(), 
nPoints*sizeof(Point));
-}
-else
-#endif
+for (i = 0; i < nPoints; i++)
 {
-for( i = 0; i < nPoints; i++ )
-{
-rOStream.WriteInt32( rPoly.mpImplPolygon->mxPointAry[i].X() )
-.WriteInt32( rPoly.mpImplPolygon->mxPointAry[i].Y() );
-}
+rOStream.WriteInt32(rPoly.mpImplPolygon->mxPointAry[i].X())
+.WriteInt32(rPoly.mpImplPolygon->mxPointAry[i].Y());
 }
 
 return rOStream;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source vcl/workben

2020-09-01 Thread Andrea Gelmini (via logerrit)
 tools/source/misc/extendapplicationenvironment.cxx |6 +++---
 vcl/workben/commonfuzzer.hxx   |6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit b866b71e2419c8011d969f316a28bd820c56fb5a
Author: Andrea Gelmini 
AuthorDate: Mon Aug 31 15:59:50 2020 +0200
Commit: Julien Nabet 
CommitDate: Tue Sep 1 08:49:07 2020 +0200

Fix typo in code

It passed "make check" on Linux

Change-Id: I4db1681869907f050ea224ed24dcb7469a50eb20
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101792
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/tools/source/misc/extendapplicationenvironment.cxx 
b/tools/source/misc/extendapplicationenvironment.cxx
index 0324a7d0d380..13171d8e70ff 100644
--- a/tools/source/misc/extendapplicationenvironment.cxx
+++ b/tools/source/misc/extendapplicationenvironment.cxx
@@ -61,9 +61,9 @@ void extendApplicationEnvironment() {
 if (osl_getExecutableFile() != osl_Process_E_None) {
 abort();
 }
-sal_Int32 lastDirSeperatorPos = uri.lastIndexOf('/');
-if (lastDirSeperatorPos >= 0) {
-uri = uri.copy(0, lastDirSeperatorPos + 1);
+sal_Int32 lastDirSeparatorPos = uri.lastIndexOf('/');
+if (lastDirSeparatorPos >= 0) {
+uri = uri.copy(0, lastDirSeparatorPos + 1);
 }
 env.append(rtl::Bootstrap::encode(uri));
 #ifdef MACOSX
diff --git a/vcl/workben/commonfuzzer.hxx b/vcl/workben/commonfuzzer.hxx
index d6c8d5cae634..85808c346f78 100644
--- a/vcl/workben/commonfuzzer.hxx
+++ b/vcl/workben/commonfuzzer.hxx
@@ -42,9 +42,9 @@ namespace
 if (osl_getExecutableFile() != osl_Process_E_None) {
 abort();
 }
-sal_Int32 lastDirSeperatorPos = uri.lastIndexOf('/');
-if (lastDirSeperatorPos >= 0) {
-uri = uri.copy(0, lastDirSeperatorPos + 1);
+sal_Int32 lastDirSeparatorPos = uri.lastIndexOf('/');
+if (lastDirSeparatorPos >= 0) {
+uri = uri.copy(0, lastDirSeparatorPos + 1);
 }
 return uri;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-08-06 Thread Noel Grandin (via logerrit)
 tools/source/generic/config.cxx |  140 +++---
 tools/source/generic/poly.cxx   |  182 
 tools/source/generic/poly2.cxx  |   74 
 tools/source/stream/vcompat.cxx |   28 +++---
 4 files changed, 212 insertions(+), 212 deletions(-)

New commits:
commit 987c96d8a976338dcb8b5b8c4d1258b8fddb0093
Author: Noel Grandin 
AuthorDate: Wed Aug 5 20:31:06 2020 +0200
Commit: Noel Grandin 
CommitDate: Thu Aug 6 08:39:29 2020 +0200

loplugin:flatten in tools

Change-Id: I6e5c07f4e63b949afb8c259d623a0711a86db021
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100188
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/generic/config.cxx b/tools/source/generic/config.cxx
index 6808bc4a132a..0f2e13acea21 100644
--- a/tools/source/generic/config.cxx
+++ b/tools/source/generic/config.cxx
@@ -667,31 +667,31 @@ void Config::DeleteGroup(const OString& rGroup)
 pGroup = pGroup->mpNext;
 }
 
-if ( pGroup )
+if ( !pGroup )
+return;
+
+// Remove all keys
+ImplKeyData* pTempKey;
+ImplKeyData* pKey = pGroup->mpFirstKey;
+while ( pKey )
 {
-// Remove all keys
-ImplKeyData* pTempKey;
-ImplKeyData* pKey = pGroup->mpFirstKey;
-while ( pKey )
-{
-pTempKey = pKey->mpNext;
-delete pKey;
-pKey = pTempKey;
-}
+pTempKey = pKey->mpNext;
+delete pKey;
+pKey = pTempKey;
+}
 
-// Rewire pointers and remove group
-if ( pPrevGroup )
-pPrevGroup->mpNext = pGroup->mpNext;
-else
-mpData->mpFirstGroup = pGroup->mpNext;
-delete pGroup;
+// Rewire pointers and remove group
+if ( pPrevGroup )
+pPrevGroup->mpNext = pGroup->mpNext;
+else
+mpData->mpFirstGroup = pGroup->mpNext;
+delete pGroup;
 
-// Rewrite config data
-mpData->mbModified = true;
+// Rewrite config data
+mpData->mbModified = true;
 
-mnDataUpdateId = mpData->mnDataUpdateId;
-mpData->mnDataUpdateId++;
-}
+mnDataUpdateId = mpData->mnDataUpdateId;
+mpData->mnDataUpdateId++;
 }
 
 OString Config::GetGroupName(sal_uInt16 nGroup) const
@@ -787,41 +787,41 @@ void Config::WriteKey(const OString& rKey, const OString& 
rStr)
 
 // Search key and update value if found
 ImplGroupData* pGroup = ImplGetGroup();
-if ( pGroup )
+if ( !pGroup )
+return;
+
+ImplKeyData* pPrevKey = nullptr;
+ImplKeyData* pKey = pGroup->mpFirstKey;
+while ( pKey )
 {
-ImplKeyData* pPrevKey = nullptr;
-ImplKeyData* pKey = pGroup->mpFirstKey;
-while ( pKey )
-{
-if ( !pKey->mbIsComment && pKey->maKey.equalsIgnoreAsciiCase(rKey) 
)
-break;
+if ( !pKey->mbIsComment && pKey->maKey.equalsIgnoreAsciiCase(rKey) )
+break;
 
-pPrevKey = pKey;
-pKey = pKey->mpNext;
-}
+pPrevKey = pKey;
+pKey = pKey->mpNext;
+}
 
-bool bNewValue;
-if ( !pKey )
-{
-pKey  = new ImplKeyData;
-pKey->mpNext  = nullptr;
-pKey->maKey   = rKey;
-pKey->mbIsComment = false;
-if ( pPrevKey )
-pPrevKey->mpNext = pKey;
-else
-pGroup->mpFirstKey = pKey;
-bNewValue = true;
-}
+bool bNewValue;
+if ( !pKey )
+{
+pKey  = new ImplKeyData;
+pKey->mpNext  = nullptr;
+pKey->maKey   = rKey;
+pKey->mbIsComment = false;
+if ( pPrevKey )
+pPrevKey->mpNext = pKey;
 else
-bNewValue = pKey->maValue != rStr;
+pGroup->mpFirstKey = pKey;
+bNewValue = true;
+}
+else
+bNewValue = pKey->maValue != rStr;
 
-if ( bNewValue )
-{
-pKey->maValue = rStr;
+if ( bNewValue )
+{
+pKey->maValue = rStr;
 
-mpData->mbModified = true;
-}
+mpData->mbModified = true;
 }
 }
 
@@ -836,30 +836,30 @@ void Config::DeleteKey(const OString& rKey)
 
 // Search key and update value
 ImplGroupData* pGroup = ImplGetGroup();
-if ( pGroup )
+if ( !pGroup )
+return;
+
+ImplKeyData* pPrevKey = nullptr;
+ImplKeyData* pKey = pGroup->mpFirstKey;
+while ( pKey )
 {
-ImplKeyData* pPrevKey = nullptr;
-ImplKeyData* pKey = pGroup->mpFirstKey;
-while ( pKey )
-{
-if ( !pKey->mbIsComment && pKey->maKey.equalsIgnoreAsciiCase(rKey) 
)
-break;
+if ( !pKey->mbIsComment && pKey->maKey.equalsIgnoreAsciiCase(rKey) )
+break;
 
-pPrevKey = pKey;
-pKey = pKey->mpNext;
-}
+pPrevKey = pKey;
+pKey = 

[Libreoffice-commits] core.git: tools/source

2020-08-03 Thread Stephan Bergmann (via logerrit)
 tools/source/misc/json_writer.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 4ad4468675069312902feaefb862d0a288ede23c
Author: Stephan Bergmann 
AuthorDate: Mon Aug 3 15:11:52 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Mon Aug 3 17:11:42 2020 +0200

Missing include (std::max; Windows --disable-pch)

Change-Id: I31d44c0a1791c58c0fc348fb2ec42fe2e2ec4323
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/13
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index e815a0b6b173..1ccee8569480 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -9,6 +9,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-07-02 Thread Stephan Bergmann (via logerrit)
 tools/source/datetime/tdate.cxx   |6 +++---
 tools/source/fsys/urlobj.cxx  |2 +-
 tools/source/generic/b3dtrans.cxx |4 ++--
 tools/source/generic/bigint.cxx   |4 ++--
 tools/source/inet/inetmime.cxx|2 +-
 tools/source/inet/inetmsg.cxx |2 +-
 tools/source/zcodec/zcodec.cxx|2 +-
 7 files changed, 11 insertions(+), 11 deletions(-)

New commits:
commit 445537bbc2971b970bed244db40f35c9caf43ef4
Author: Stephan Bergmann 
AuthorDate: Thu Jul 2 09:31:24 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Jul 2 11:29:01 2020 +0200

Upcoming improved loplugin:staticanonymous -> redundantstatic: tools

Change-Id: I832fbcde277a87ab873ce3477a6886c7002e24ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97709
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/tools/source/datetime/tdate.cxx b/tools/source/datetime/tdate.cxx
index e3fd7eff5bbe..a38fb8e986c3 100644
--- a/tools/source/datetime/tdate.cxx
+++ b/tools/source/datetime/tdate.cxx
@@ -22,7 +22,7 @@
 
 #include 
 
-static const sal_uInt16 aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30,
+const sal_uInt16 aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30,
  31, 31, 30, 31, 30, 31 };
 
 // Once upon a time the number of days we internally handled was limited to
@@ -38,8 +38,8 @@ static const sal_uInt16 aDaysInMonth[12] = { 31, 28, 31, 30, 
31, 30,
 /* XXX can that dbconversion cope with years >  or negative years at all?
  * Database fields may be limited to positive 4 digits. */
 
-static const sal_Int32 MIN_DAYS = -11968265; // -32768-01-01
-static const sal_Int32 MAX_DAYS =  11967900; //  32767-12-31
+const sal_Int32 MIN_DAYS = -11968265; // -32768-01-01
+const sal_Int32 MAX_DAYS =  11967900; //  32767-12-31
 
 namespace
 {
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 8818f548da29..2478a2bd5d55 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -453,7 +453,7 @@ enum
 PR = INetURLObject::PART_HTTP_QUERY,
 };
 
-static sal_uInt32 const aMustEncodeMap[128]
+sal_uInt32 const aMustEncodeMap[128]
 = { 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, 0, 0, 0,
 /*   */  PP,
diff --git a/tools/source/generic/b3dtrans.cxx 
b/tools/source/generic/b3dtrans.cxx
index b8e29be31d4a..1f63cc2e381d 100644
--- a/tools/source/generic/b3dtrans.cxx
+++ b/tools/source/generic/b3dtrans.cxx
@@ -22,8 +22,8 @@
 #include 
 
 // Near and far clipping planes
-static constexpr double gfNearBound = 0.001;
-static constexpr double gfFarBound = 1.001;
+constexpr double gfNearBound = 0.001;
+constexpr double gfFarBound = 1.001;
 
 
 // B3dTransformationSet 

diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx
index 903cf826f44a..4a1ddfff391e 100644
--- a/tools/source/generic/bigint.cxx
+++ b/tools/source/generic/bigint.cxx
@@ -28,8 +28,8 @@
 /**
  * The range in which we can perform add/sub without fear of overflow
  */
-static const sal_Int32 MY_MAXLONG  = 0x3fff;
-static const sal_Int32 MY_MINLONG  = -MY_MAXLONG;
+const sal_Int32 MY_MAXLONG  = 0x3fff;
+const sal_Int32 MY_MINLONG  = -MY_MAXLONG;
 
 /*
  * The algorithms for Addition, Subtraction, Multiplication and Division
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index fd00fe3a4603..d92a02790ee0 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -747,7 +747,7 @@ struct EncodingEntry
 // The source for the following table is  as of Jan, 21 2000 12:46:00, unless  otherwise
 // noted:
-static EncodingEntry const aEncodingMap[]
+EncodingEntry const aEncodingMap[]
 = { { "US-ASCII", RTL_TEXTENCODING_ASCII_US },
 { "ANSI_X3.4-1968", RTL_TEXTENCODING_ASCII_US },
 { "ISO-IR-6", RTL_TEXTENCODING_ASCII_US },
diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx
index f8912bb9d231..3adf1ebd4487 100644
--- a/tools/source/inet/inetmsg.cxx
+++ b/tools/source/inet/inetmsg.cxx
@@ -190,7 +190,7 @@ bool INetMIMEMessage::ParseDateField (
   (rDateTime.GetHour() > 23)));
 }
 
-static const std::map 
ImplINetMIMEMessageHeaderData =
+const std::map ImplINetMIMEMessageHeaderData =
 {
 { InetMessageMime::VERSION, "MIME-Version"},
 { InetMessageMime::CONTENT_DISPOSITION, "Content-Disposition"},
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index b6b1b2112b32..525834681ef8 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -35,7 +35,7 @@
 #define GZ_COMMENT  0x10 /* bit 4 set: file comment present */
 #define GZ_RESERVED 0xE0 /* bits 5..7: reserved */
 
-static const int gz_magic[2] = { 0x1f, 0x8b }; /* 

[Libreoffice-commits] core.git: tools/source

2020-06-29 Thread Miklos Vajna (via logerrit)
 tools/source/misc/json_writer.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 51a4c85bf9228a3750b61cb54e64c8134314a35e
Author: Miklos Vajna 
AuthorDate: Mon Jun 29 09:59:53 2020 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jun 29 12:31:52 2020 +0200

tools: fix 32bit Android build

tools/source/misc/json_writer.cxx:289:34: error: format specifies type 
'long' but the argument has type 'sal_Int64' (aka 'long long') 
[-Werror,-Wformat]
mPos += sprintf(mPos, "%ld", nPropVal);
   ~~~   ^~~~
   %lld
1 error generated.

Change-Id: Ieacf2f521f77292d61fa714bf584c9e2045c2e1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97367
Reviewed-by: Noel Grandin 
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index aacf3f709c90..e815a0b6b173 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -286,7 +286,7 @@ void JsonWriter::put(const char* pPropName, sal_Int64 
nPropVal)
 memcpy(mPos, "\": ", 3);
 mPos += 3;
 
-mPos += sprintf(mPos, "%ld", nPropVal);
+mPos += sprintf(mPos, "%" SAL_PRIdINT64, nPropVal);
 }
 
 void JsonWriter::put(const char* pPropName, double fPropVal)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-06-24 Thread Noel Grandin (via logerrit)
 tools/source/misc/json_writer.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 3fb5c11ac69e6687e579d4129cb892c5ae746a5e
Author: Noel Grandin 
AuthorDate: Wed Jun 24 18:24:37 2020 +0200
Commit: Noel Grandin 
CommitDate: Wed Jun 24 22:16:45 2020 +0200

fix JsonWriter::reallocBuffer

was not updating mSpaceAllocated

Change-Id: Ie5404e58c6520d32b72c19ddfa58b2ab2b895199
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97049
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index 95c8b59e5d02..be891ef18423 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -320,6 +320,7 @@ void JsonWriter::reallocBuffer(int noMoreBytesRequired)
 free(mpBuffer);
 mpBuffer = pNew;
 mPos = mpBuffer + currentUsed;
+mSpaceAllocated = newSize;
 }
 
 /** Hands ownership of the underlying storage buffer to the caller,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-06-21 Thread Stephan Bergmann (via logerrit)
 tools/source/misc/json_writer.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 18b9f927a00b1cafecd450bbe276bbbfe009b7f3
Author: Stephan Bergmann 
AuthorDate: Sun Jun 21 23:09:35 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Sun Jun 21 23:55:10 2020 +0200

Avoid one more unhelpful -Werror=stringop-truncation

...after cb95276e6e6bf12a1c06d5c252551e55c788fcb2 "use JsonWriter for the 
rest
of ITiledRenderable", similar to de32eb539bbcf291f9968ae12696e1317fdb855d 
"Avoid
unhelpful -Werror=stringop-truncation"

Change-Id: I8782a8a936a5ff0351b6e6d171a00cb8f4a1b2d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96820
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index 251c44c0246f..95c8b59e5d02 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -76,7 +76,7 @@ ScopedJsonWriterArray JsonWriter::startArray(const char* 
pNodeName)
 ++mPos;
 memcpy(mPos, pNodeName, len);
 mPos += len;
-strncpy(mPos, "\": [ ", 5);
+memcpy(mPos, "\": [ ", 5);
 mPos += 5;
 mStartNodeCount++;
 mbFirstFieldInNode = true;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-06-18 Thread Stephan Bergmann (via logerrit)
 tools/source/misc/json_writer.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit de32eb539bbcf291f9968ae12696e1317fdb855d
Author: Stephan Bergmann 
AuthorDate: Thu Jun 18 11:29:41 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Jun 18 15:08:26 2020 +0200

Avoid unhelpful -Werror=stringop-truncation

...emitted at least by recent GCC 11 trunk (even with --disable-optimized, 
where
optimization level traditionally has some impact on what warnings of this 
kind
are emitted exactly):

> tools/source/misc/json_writer.cxx: In member function 
‘tools::ScopedJsonWriterNode tools::JsonWriter::startNode(const char*)’:
> tools/source/misc/json_writer.cxx:42:12: error: ‘char* strncpy(char*, 
const char*, size_t)’ output truncated before terminating nul copying 5 bytes 
from a string of the same length [-Werror=stringop-truncation]
>42 | strncpy(mPos, "\": { ", 5);
>   | ~~~^~~

etc.

Change-Id: Id96964b178b61879cf2373c5b418f5c9df4a226f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96593
Reviewed-by: Noel Grandin 
Reviewed-by: Justin Luth 
Reviewed-by: Stephan Bergmann 
Tested-by: Jenkins

diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index a233381038c4..12ff5eb37641 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -39,7 +39,7 @@ ScopedJsonWriterNode JsonWriter::startNode(const char* 
pNodeName)
 ++mPos;
 memcpy(mPos, pNodeName, len);
 mPos += len;
-strncpy(mPos, "\": { ", 5);
+memcpy(mPos, "\": { ", 5);
 mPos += 5;
 mStartNodeCount++;
 mbFirstFieldInNode = true;
@@ -66,7 +66,7 @@ void JsonWriter::put(const char* pPropName, const OUString& 
rPropVal)
 ++mPos;
 memcpy(mPos, pPropName, nPropNameLength);
 mPos += nPropNameLength;
-strncpy(mPos, "\": \"", 4);
+memcpy(mPos, "\": \"", 4);
 mPos += 4;
 
 // Convert from UTF-16 to UTF-8 and perform escaping
@@ -125,7 +125,7 @@ void JsonWriter::put(const char* pPropName, const OString& 
rPropVal)
 ++mPos;
 memcpy(mPos, pPropName, nPropNameLength);
 mPos += nPropNameLength;
-strncpy(mPos, "\": \"", 4);
+memcpy(mPos, "\": \"", 4);
 mPos += 4;
 
 // copy and perform escaping
@@ -169,7 +169,7 @@ void JsonWriter::put(const char* pPropName, const char* 
pPropVal)
 ++mPos;
 memcpy(mPos, pPropName, nPropNameLength);
 mPos += nPropNameLength;
-strncpy(mPos, "\": \"", 4);
+memcpy(mPos, "\": \"", 4);
 mPos += 4;
 
 // copy and perform escaping
@@ -215,7 +215,7 @@ void JsonWriter::put(const char* pPropName, int nPropVal)
 ++mPos;
 memcpy(mPos, pPropName, nPropNameLength);
 mPos += nPropNameLength;
-strncpy(mPos, "\": ", 3);
+memcpy(mPos, "\": ", 3);
 mPos += 3;
 
 mPos += sprintf(mPos, "%d", nPropVal);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source ucb/source unotools/source unoxml/source writerfilter/source xmlhelp/source xmloff/source

2020-04-17 Thread Noel Grandin (via logerrit)
 tools/source/generic/poly.cxx |   16 +
 tools/source/memtools/multisel.cxx|   23 +-
 tools/source/zcodec/zcodec.cxx|   10 -
 ucb/source/ucp/file/filrset.cxx   |3 
 ucb/source/ucp/file/filtask.cxx   |5 
 ucb/source/ucp/ftp/ftpurl.cxx |   12 -
 unotools/source/config/bootstrap.cxx  |3 
 unotools/source/misc/datetime.cxx |  165 +-
 unoxml/source/rdf/CURI.cxx|   12 -
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   18 +
 writerfilter/source/dmapper/NumberingManager.cxx  |4 
 xmlhelp/source/cxxhelp/provider/databases.cxx |   22 +-
 xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx |5 
 xmlhelp/source/treeview/tvread.cxx|5 
 xmloff/source/forms/formattributes.cxx|3 
 xmloff/source/style/xmlnumfe.cxx  |7 
 16 files changed, 193 insertions(+), 120 deletions(-)

New commits:
commit 0b2ddcda730897cb5b2801731f03191d77409273
Author: Noel Grandin 
AuthorDate: Fri Apr 17 11:39:49 2020 +0200
Commit: Noel Grandin 
CommitDate: Fri Apr 17 12:44:46 2020 +0200

loplugin:buriedassign in tools..xmloff

Change-Id: I31df6c4fd82c6f6d15bbe5228e92e5171cacba51
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92410
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index fba7a80bd23d..72e7532874ad 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -332,10 +332,12 @@ ImplPolygon::ImplPolygon( const Point& rBezPt1, const 
Point& rCtrlPt1,
 Point& rPt = mxPointAry[i];
 
 fK_2 = fK_1;
-fK_3 = ( fK_2 *= fK_1 );
+fK_2 *= fK_1;
+fK_3 = fK_2;
 fK_3 *= fK_1;
 fK1_2 = fK1_1;
-fK1_3 = ( fK1_2 *= fK1_1 );
+fK1_2 *= fK1_1;
+fK1_3 = fK1_2;
 fK1_3 *= fK1_1;
 double fK12 = fK_1 * fK1_2;
 double fK21 = fK_2 * fK1_1;
@@ -1250,10 +1252,14 @@ Vector2D& Vector2D::Normalize()
 {
 double fLen = Scalar( *this );
 
-if( ( fLen != 0.0 ) && ( fLen != 1.0 ) && ( ( fLen = sqrt( fLen ) ) != 0.0 
) )
+if( ( fLen != 0.0 ) && ( fLen != 1.0 ) )
 {
-mfX /= fLen;
-mfY /= fLen;
+fLen = sqrt( fLen );
+if( fLen != 0.0 )
+{
+mfX /= fLen;
+mfY /= fLen;
+}
 }
 
 return *this;
diff --git a/tools/source/memtools/multisel.cxx 
b/tools/source/memtools/multisel.cxx
index 8fd0c61aeb27..7a8df48d0049 100644
--- a/tools/source/memtools/multisel.cxx
+++ b/tools/source/memtools/multisel.cxx
@@ -379,10 +379,11 @@ sal_Int32 MultiSelection::FirstSelected()
 nCurSubSel = 0;
 
 bCurValid = !aSels.empty();
-if ( bCurValid )
-return nCurIndex = aSels[ 0 ].Min();
+if ( !bCurValid )
+return SFX_ENDOFSELECTION;
 
-return SFX_ENDOFSELECTION;
+nCurIndex = aSels[ 0 ].Min();
+return nCurIndex;
 }
 
 sal_Int32 MultiSelection::LastSelected()
@@ -390,10 +391,11 @@ sal_Int32 MultiSelection::LastSelected()
 nCurSubSel = aSels.size() - 1;
 bCurValid = !aSels.empty();
 
-if ( bCurValid )
-return nCurIndex = aSels[ nCurSubSel ].Max();
+if ( !bCurValid )
+return SFX_ENDOFSELECTION;
 
-return SFX_ENDOFSELECTION;
+nCurIndex = aSels[ nCurSubSel ].Max();
+return nCurIndex;
 }
 
 sal_Int32 MultiSelection::NextSelected()
@@ -406,11 +408,12 @@ sal_Int32 MultiSelection::NextSelected()
 return ++nCurIndex;
 
 // are there further sub selections?
-if ( ++nCurSubSel < sal_Int32(aSels.size()) )
-return nCurIndex = aSels[ nCurSubSel ].Min();
+if ( ++nCurSubSel >= sal_Int32(aSels.size()) )
+// we are at the end!
+return SFX_ENDOFSELECTION;
 
-// we are at the end!
-return SFX_ENDOFSELECTION;
+nCurIndex = aSels[ nCurSubSel ].Min();
+return nCurIndex;
 }
 
 void MultiSelection::SetTotalRange( const Range& rTotRange )
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index a29127be7232..b6b1b2112b32 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -119,9 +119,12 @@ void ZCodec::Compress( SvStream& rIStm, SvStream& rOStm )
 InitCompress();
 mpInBuf = new sal_uInt8[ mnInBufSize ];
 auto pStream = static_cast(mpsC_Stream);
-while ((pStream->avail_in = rIStm.ReadBytes(
-pStream->next_in = mpInBuf, mnInBufSize )) != 0)
+for (;;)
 {
+pStream->next_in = mpInBuf;
+pStream->avail_in = rIStm.ReadBytes( pStream->next_in, mnInBufSize );
+if (pStream->avail_in == 0)
+break;
 if ( pStream->avail_out == 0 )
 ImplWriteBack();
 if ( deflate( pStream, Z_NO_FLUSH ) < 0 )
@@ 

[Libreoffice-commits] core.git: tools/source

2020-01-22 Thread Noel Grandin (via logerrit)
 tools/source/datetime/tdate.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit ce43004ca4234010c5b7243e7bb90daa6a9b7f56
Author: Noel Grandin 
AuthorDate: Wed Jan 22 15:55:41 2020 +0200
Commit: Noel Grandin 
CommitDate: Wed Jan 22 15:40:26 2020 +0100

 don't warn about 0/0/0 year, commonly used as a default-value/no-value

Change-Id: I2f6dc371f99d6963753ffaf5365a7d69ca866ca8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87190
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/tools/source/datetime/tdate.cxx b/tools/source/datetime/tdate.cxx
index 1fdebaac55bb..e3fd7eff5bbe 100644
--- a/tools/source/datetime/tdate.cxx
+++ b/tools/source/datetime/tdate.cxx
@@ -99,7 +99,9 @@ sal_uInt16 ImplDaysInMonth( sal_uInt16 nMonth, sal_Int16 
nYear )
 
 void Date::setDateFromDMY( sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear 
)
 {
-SAL_WARN_IF( nYear == 0, "tools.datetime", "Date::setDateFromDMY - sure 
about 0 year? It's not in the calendar.");
+// don't warn about 0/0/0, commonly used as a default-value/no-value
+SAL_WARN_IF( nYear == 0 && !(nYear == 0 && nMonth == 0 && nDay == 0),
+"tools.datetime", "Date::setDateFromDMY - sure about 0 year? It's not 
in the calendar.");
 assert( nMonth < 100 && "nMonth % 100 not representable" );
 assert(   nDay < 100 && "nDay % 100 not representable" );
 if (nYear < 0)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2020-01-17 Thread Stephan Bergmann (via logerrit)
 tools/source/stream/stream.cxx |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit bb32e871e9e5926004381029866df694a0c89dbb
Author: Stephan Bergmann 
AuthorDate: Fri Jan 17 18:30:20 2020 +0100
Commit: Stephan Bergmann 
CommitDate: Fri Jan 17 23:58:28 2020 +0100

loplugin:redundantcast (size_t vs. std::size_t)

...which happen to be found by 6efffbbfce9c27439f54970f7a569b069ce46eba 
"Improve
loplugin:redundantcast for sal_Int... vs. ::sal_Int..." only on macOS, not 
on
Linux:  At least for my Linux builds, size_t is a typedef in my local LLVM
installation's lib/clang/11.0.0/include/stddef.h while std::size_t is an
unrelated typedef (but to the same type) in
/usr/include/c++/9/x86_64-redhat-linux/bits/c++config.h.

Change-Id: I98dd605cb7b4ba5fb9bd3902bd9b1ae960a804e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86994
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index c39d6787e134..8c38d862b3df 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1248,7 +1248,7 @@ std::size_t SvStream::ReadBytes( void* pData, std::size_t 
nCount )
 {
 // => yes
 if (nCount != 0)
-memcpy(pData, m_pBufPos, static_cast(nCount));
+memcpy(pData, m_pBufPos, nCount);
 m_nBufActualPos = m_nBufActualPos + 
static_cast(nCount);
 m_pBufPos += nCount;
 m_nBufFree = m_nBufFree - static_cast(nCount);
@@ -1291,7 +1291,7 @@ std::size_t SvStream::ReadBytes( void* pData, std::size_t 
nCount )
 {
 nCount = nCountTmp;  // trim count back, EOF see below
 }
-memcpy( pData, m_pRWBuf.get(), static_cast(nCount) );
+memcpy( pData, m_pRWBuf.get(), nCount );
 m_nBufActualPos = static_cast(nCount);
 m_pBufPos = m_pRWBuf.get() + nCount;
 }
@@ -1331,7 +1331,7 @@ std::size_t SvStream::WriteBytes( const void* pData, 
std::size_t nCount )
 m_isIoWrite = true;
 if (nCount <= static_cast(m_nBufSize - m_nBufActualPos))
 {
-memcpy( m_pBufPos, pData, static_cast(nCount) );
+memcpy( m_pBufPos, pData, nCount );
 m_nBufActualPos = m_nBufActualPos + static_cast(nCount);
 // Update length if buffer was updated
 if (m_nBufActualPos > m_nBufActualLen)
@@ -1362,7 +1362,7 @@ std::size_t SvStream::WriteBytes( const void* pData, 
std::size_t nCount )
 else
 {
 // Copy block to buffer
-memcpy( m_pRWBuf.get(), pData, static_cast(nCount) );
+memcpy( m_pRWBuf.get(), pData, nCount );
 
 // Mind the order!
 m_nBufFilePos += m_nBufActualPos;
@@ -1693,7 +1693,7 @@ std::size_t SvMemoryStream::GetData( void* pData, 
std::size_t nCount )
 nCount = nMaxCount;
 if (nCount != 0)
 {
-memcpy( pData, pBuf+nPos, static_cast(nCount) );
+memcpy( pData, pBuf+nPos, nCount );
 }
 nPos += nCount;
 return nCount;
@@ -1746,7 +1746,7 @@ std::size_t SvMemoryStream::PutData( const void* pData, 
std::size_t nCount )
 }
 }
 assert(pBuf && "Possibly Reallocate failed");
-memcpy( pBuf+nPos, pData, static_cast(nCount));
+memcpy( pBuf+nPos, pData, nCount);
 
 nPos += nCount;
 if( nPos > nEndOfData )
@@ -1824,7 +1824,7 @@ bool SvMemoryStream::ReAllocateMemory( long nDiff )
 bRetVal = true; // Success!
 if( nNewSize < nSize )  // Are we shrinking?
 {
-memcpy( pNewBuf, pBuf, static_cast(nNewSize) );
+memcpy( pNewBuf, pBuf, nNewSize );
 if( nPos > nNewSize )
 nPos = 0;
 if( nEndOfData >= nNewSize )
@@ -1834,7 +1834,7 @@ bool SvMemoryStream::ReAllocateMemory( long nDiff )
 {
 if (nSize != 0)
 {
-memcpy( pNewBuf, pBuf, static_cast(nSize) );
+memcpy( pNewBuf, pBuf, nSize );
 }
 memset(pNewBuf + nSize, 0x00, nNewSize - nSize);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: tools/source

2019-11-21 Thread Julien Nabet (via logerrit)
 tools/source/debug/debug.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit c5f0e89ee5b1d13416987ddceaccc4d8a0816986
Author: Julien Nabet 
AuthorDate: Tue Nov 19 23:02:20 2019 +0100
Commit: Julien Nabet 
CommitDate: Thu Nov 21 22:16:21 2019 +0100

tdf#128862: fix HSQLDB odb-files with apostrophe crash

see bt:
0  0x7209866a in std::type_info::name() const (this=0x0) at 
/usr/include/c++/9/typeinfo:100
1  0x720966e1 in exceptionToStringImpl(rtl::OStringBuffer&, 
com::sun::star::uno::Any const&)
(sMessage="DBG_UNHANDLED_EXCEPTION in bool 
connectivity::hsqldb::OHsqlConnection::impl_isTextTable_nothrow(const 
rtl::OUString&) exception: com.sun.star.sdbc.SQLException message: Unexpected 
token: S in statemen"..., caught=
  uno::Any("com.sun.star.sdbc.SQLException": 
{ = {Message = "Unexpected token: S in 
statement [s]", Context = uno::Reference to (com::sun::star::uno::XInterface *) 
0x59269238}, SQLState = "37000", ErrorCode = -11, NextException = 
uno::Any(void)})) at 
/home/julien/lo/libreoffice/tools/source/debug/debug.cxx:113
2  0x7209855d in DbgUnhandledException(com::sun::star::uno::Any 
const&, char const*, char const*, char const*, char const*) (caught=
  uno::Any("com.sun.star.sdbc.SQLException": 
{ = {Message = "Unexpected token: S in 
statement [s]", Context = uno::Reference to (com::sun::star::uno::XInterface *) 
0x59269238}, SQLState = "37000", ErrorCode = -11, NextException = 
uno::Any(void)}), currentFunction=0x7fffdb5ca340 "bool 
connectivity::hsqldb::OHsqlConnection::impl_isTextTable_nothrow(const 
rtl::OUString&)", fileAndLineNo=0x7fffdb5ca2e8 
"/home/julien/lo/libreoffice/connectivity/source/drivers/hsqldb/HConnection.cxx:301:
 ", area=0x7fffdb5c9f49 "connectivity.hsqldb", explanatory=0x0)
at /home/julien/lo/libreoffice/tools/source/debug/debug.cxx:418
3  0x7fffdb58a16a in 
connectivity::hsqldb::OHsqlConnection::impl_isTextTable_nothrow(rtl::OUString 
const&) (this=0x58a43de0, _rTableName="William Kidwell's Address Book")
at 
/home/julien/lo/libreoffice/connectivity/source/drivers/hsqldb/HConnection.cxx:301
https://bugs.documentfoundation.org/attachment.cgi?id=155952

Change-Id: I2bc744164b1470d8f09bcb126b02e48af180e886
Reviewed-on: https://gerrit.libreoffice.org/83245
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index 6bfb9a42612f..de4a14015044 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -108,6 +108,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, 
const css::uno::Any &
 sMessage.append(" message: ");
 sMessage.append(toOString(exception.Message));
 }
+/*  TODO FIXME (see https://gerrit.libreoffice.org/#/c/83245/)
 if ( exception.Context.is() )
 {
 const char* pContext = typeid( *exception.Context ).name();
@@ -122,6 +123,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, 
const css::uno::Any &
 std::free(const_cast(pContext));
 #endif
 }
+*/
 {
 css::configuration::CorruptedConfigurationException specialized;
 if ( caught >>= specialized )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: tools/source

2019-10-21 Thread Stephan Bergmann (via logerrit)
 tools/source/stream/stream.cxx |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit b25fd58a1ecba62f7967dd118194f5994fcd5c23
Author: Stephan Bergmann 
AuthorDate: Mon Oct 21 15:34:44 2019 +0200
Commit: Stephan Bergmann 
CommitDate: Mon Oct 21 19:18:25 2019 +0200

-fsanitize=nullptr-with-nonzero-offset

...(new with Clang 10 trunk), as seen during CppunitTest_emfio_wmf:

> tools/source/stream/stream.cxx:808:32: runtime error: applying non-zero 
offset 10 to null pointer
>  #0 in SvStream::SeekRel(long) at tools/source/stream/stream.cxx:808:32
>  #1 in (anonymous namespace)::ImplReadDIBFileHeader(SvStream&, unsigned 
long&) at vcl/source/gdi/dibtools.cxx:1085:19
>  #2 in (anonymous namespace)::ImplReadDIB(Bitmap&, AlphaMask*, SvStream&, 
bool, bool, bool) at vcl/source/gdi/dibtools.cxx:1656:12
>  #3 in ReadDIB(Bitmap&, SvStream&, bool, bool) at 
vcl/source/gdi/dibtools.cxx:1738:12
>  #4 in emfio::EmfReader::ReadEnhWMF() at 
emfio/source/reader/emfreader.cxx:1507:33
>  #5 in 
emfio::emfreader::XEmfParser::getDecomposition(com::sun::star::uno::Reference
 const&, rtl::OUString const&, 
com::sun::star::uno::Sequence const&) at 
emfio/source/emfuno/xemfparser.cxx:148:72
>  #6 in non-virtual thunk to 
emfio::emfreader::XEmfParser::getDecomposition(com::sun::star::uno::Reference
 const&, rtl::OUString const&, 
com::sun::star::uno::Sequence const&) at 
emfio/source/emfuno/xemfparser.cxx
>  #7 in VectorGraphicData::ensureSequenceAndRange() at 
vcl/source/gdi/vectorgraphicdata.cxx:172:137
>  #8 in VectorGraphicData::getPrimitive2DSequence() const at 
vcl/source/gdi/vectorgraphicdata.cxx:279:45
>  #9 in ImpGraphic::ImplGetGDIMetaFile() const at 
vcl/source/gdi/impgraph.cxx:844:110
>  #10 in Graphic::GetGDIMetaFile() const at vcl/source/gdi/graph.cxx:365:26
>  #11 in ReadWindowMetafile(SvStream&, GDIMetaFile&) at 
vcl/source/filter/wmf/wmf.cxx:62:25
>  #12 in WmfTest::testEmfProblem() at 
emfio/qa/cppunit/wmf/wmfimporttest.cxx:116:5

An invariant of SvStream appears to be that m_pRWBuf can be null and that
m_pBufPos is null iff m_pRWBuf is null.  So don't update m_pBufPos here when
m_pRWBuf is null.  (And assert the assumed invariant.)

Change-Id: Iad2eb2723394f5564d43dfa8a3a1a8b8de79158d
Reviewed-on: https://gerrit.libreoffice.org/81237
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 713d36504b6f..c10dad0457fa 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -19,6 +19,9 @@
 
 // TODO: Read->RefreshBuffer-> React to changes from m_nBufActualLen
 
+#include 
+
+#include 
 #include 
 #include 
 
@@ -805,7 +808,11 @@ sal_uInt64 SvStream::SeekRel(sal_Int64 const nPos)
 nActualPos -= nAbsPos;
 }
 
-m_pBufPos = m_pRWBuf.get() + nActualPos;
+assert((m_pBufPos != nullptr) == bool(m_pRWBuf));
+if (m_pRWBuf)
+{
+m_pBufPos = m_pRWBuf.get() + nActualPos;
+}
 return Seek( nActualPos );
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: tools/source

2019-10-11 Thread Caolán McNamara (via logerrit)
 tools/source/zcodec/zcodec.cxx |  130 ++---
 1 file changed, 70 insertions(+), 60 deletions(-)

New commits:
commit 732e02f80fceda3e3b6ee14c590d3632d0e369a5
Author: Caolán McNamara 
AuthorDate: Fri Oct 11 10:57:40 2019 +0100
Commit: Caolán McNamara 
CommitDate: Fri Oct 11 16:33:30 2019 +0200

drop PZSTREAM define

Change-Id: Ia0ac30fc8441f446977270c96dd2430647dfa2d7
Reviewed-on: https://gerrit.libreoffice.org/80647
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index 98be0dc08fcd..51e304fe3a67 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -27,8 +27,6 @@
 
 #include 
 
-#define PZSTREAM static_cast(mpsC_Stream)
-
 /* gzip flag byte */
 //  GZ_ASCII_FLAG   0x01 /* bit 0 set: file probably ascii text */
 #define GZ_HEAD_CRC 0x02 /* bit 1 set: header CRC present */
@@ -57,7 +55,8 @@ ZCodec::ZCodec( size_t nInBufSize, size_t nOutBufSize )
 
 ZCodec::~ZCodec()
 {
-delete static_cast(mpsC_Stream);
+auto pStream = static_cast(mpsC_Stream);
+delete pStream;
 }
 
 void ZCodec::BeginCompression( int nCompressLevel, bool gzLib )
@@ -68,18 +67,20 @@ void ZCodec::BeginCompression( int nCompressLevel, bool 
gzLib )
 mpOStm = nullptr;
 mnInToRead = 0x;
 mpInBuf = mpOutBuf = nullptr;
-PZSTREAM->total_out = PZSTREAM->total_in = 0;
+auto pStream = static_cast(mpsC_Stream);
+pStream->total_out = pStream->total_in = 0;
 mnCompressLevel = nCompressLevel;
 mbGzLib = gzLib;
-PZSTREAM->zalloc = nullptr;
-PZSTREAM->zfree = nullptr;
-PZSTREAM->opaque = nullptr;
-PZSTREAM->avail_out = PZSTREAM->avail_in = 0;
+pStream->zalloc = nullptr;
+pStream->zfree = nullptr;
+pStream->opaque = nullptr;
+pStream->avail_out = pStream->avail_in = 0;
 }
 
 long ZCodec::EndCompression()
 {
 long retvalue = 0;
+auto pStream = static_cast(mpsC_Stream);
 
 if (meState != STATE_INIT)
 {
@@ -91,18 +92,18 @@ long ZCodec::EndCompression()
 {
 ImplWriteBack();
 }
-while ( deflate( PZSTREAM, Z_FINISH ) != Z_STREAM_END );
+while ( deflate( pStream, Z_FINISH ) != Z_STREAM_END );
 
 ImplWriteBack();
 }
 
-retvalue = PZSTREAM->total_in;
-deflateEnd( PZSTREAM );
+retvalue = pStream->total_in;
+deflateEnd( pStream );
 }
 else
 {
-retvalue = PZSTREAM->total_out;
-inflateEnd( PZSTREAM );
+retvalue = pStream->total_out;
+inflateEnd( pStream );
 }
 delete[] mpOutBuf;
 delete[] mpInBuf;
@@ -117,12 +118,13 @@ void ZCodec::Compress( SvStream& rIStm, SvStream& rOStm )
 mpOStm = 
 InitCompress();
 mpInBuf = new sal_uInt8[ mnInBufSize ];
-while ((PZSTREAM->avail_in = rIStm.ReadBytes(
-PZSTREAM->next_in = mpInBuf, mnInBufSize )) != 0)
+auto pStream = static_cast(mpsC_Stream);
+while ((pStream->avail_in = rIStm.ReadBytes(
+pStream->next_in = mpInBuf, mnInBufSize )) != 0)
 {
-if ( PZSTREAM->avail_out == 0 )
+if ( pStream->avail_out == 0 )
 ImplWriteBack();
-if ( deflate( PZSTREAM, Z_NO_FLUSH ) < 0 )
+if ( deflate( pStream, Z_NO_FLUSH ) < 0 )
 {
 mbStatus = false;
 break;
@@ -134,23 +136,24 @@ long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm 
)
 {
 int err;
 size_t nInToRead;
-longnOldTotal_Out = PZSTREAM->total_out;
+auto pStream = static_cast(mpsC_Stream);
+longnOldTotal_Out = pStream->total_out;
 
 assert(meState == STATE_INIT);
 mpOStm = 
 InitDecompress(rIStm);
-PZSTREAM->next_out = mpOutBuf = new sal_uInt8[ PZSTREAM->avail_out = 
mnOutBufSize ];
+pStream->next_out = mpOutBuf = new sal_uInt8[ pStream->avail_out = 
mnOutBufSize ];
 do
 {
-if ( PZSTREAM->avail_out == 0 ) ImplWriteBack();
-if ( PZSTREAM->avail_in == 0 && mnInToRead )
+if ( pStream->avail_out == 0 ) ImplWriteBack();
+if ( pStream->avail_in == 0 && mnInToRead )
 {
 nInToRead = std::min( mnInBufSize, mnInToRead );
-PZSTREAM->next_in = mpInBuf;
-PZSTREAM->avail_in = rIStm.ReadBytes(mpInBuf, nInToRead);
+pStream->next_in = mpInBuf;
+pStream->avail_in = rIStm.ReadBytes(mpInBuf, nInToRead);
 mnInToRead -= nInToRead;
 }
-err = mbStatus ? inflate(PZSTREAM, Z_NO_FLUSH) : Z_ERRNO;
+err = mbStatus ? inflate(pStream, Z_NO_FLUSH) : Z_ERRNO;
 if ( err < 0 )
 {
 mbStatus = false;
@@ -158,10 +161,10 @@ long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm 
)
 }
 
 }
-

[Libreoffice-commits] core.git: tools/source

2019-10-09 Thread Michael Stahl (via logerrit)
 tools/source/stream/stream.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit 0c1033a08eff36699d4ec1e8eea76a7d8b621cdf
Author: Michael Stahl 
AuthorDate: Tue Oct 8 16:23:31 2019 +0200
Commit: Michael Stahl 
CommitDate: Wed Oct 9 15:28:49 2019 +0200

tools: don't leave SvStream::m_nBufFilePos pointing beyond the end

... of the stream in SvStream::SetStreamSize(); this caused
SvMemoryStream with SetStreamSize(0) and subsequent write to be
pre-filled with 0 bytes.

Change-Id: I0de704b319f5087bc6c1914881e38018212afbf2
Reviewed-on: https://gerrit.libreoffice.org/80478
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index a793446ce738..713d36504b6f 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1561,6 +1561,10 @@ bool SvStream::SetStreamSize(sal_uInt64 const nSize)
 sal_uInt16 nBuf = m_nBufSize;
 SetBufferSize( 0 );
 SetSize( nSize );
+if (nSize < m_nBufFilePos)
+{
+m_nBufFilePos = nSize;
+}
 SetBufferSize( nBuf );
 #ifdef DBG_UTIL
 DBG_ASSERT(Tell()==nFPos,"SetStreamSize failed");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

  1   2   3   >