[Libreoffice-commits] core.git: sal/osl sal/qa

2023-11-19 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/file.cxx|2 
 sal/osl/unx/pipe.cxx|2 
 sal/qa/OStringBuffer/rtl_OStringBuffer.cxx  | 1346 ++--
 sal/qa/osl/file/osl_File.cxx|  172 +--
 sal/qa/osl/process/osl_process.cxx  |6 
 sal/qa/rtl/cipher/rtl_cipher.cxx|   16 
 sal/qa/rtl/digest/rtl_digest.cxx|  136 +-
 sal/qa/rtl/ostring/rtl_str.cxx  |  112 +-
 sal/qa/rtl/oustring/rtl_OUString2.cxx   |   56 -
 sal/qa/rtl/oustring/rtl_ustr.cxx|   22 
 sal/qa/rtl/strings/nonconstarray.cxx|4 
 sal/qa/rtl/strings/test_ostring.cxx |   42 
 sal/qa/rtl/strings/test_ostring_concat.cxx  |   86 -
 sal/qa/rtl/strings/test_oustring_concat.cxx |2 
 sal/qa/rtl/strings/test_strings_replace.cxx |   30 
 15 files changed, 1017 insertions(+), 1017 deletions(-)

New commits:
commit 95ffa27c593a7fa31309b5e72a55d966862db9a0
Author: Stephan Bergmann 
AuthorDate: Sun Nov 19 17:32:08 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Sun Nov 19 21:19:40 2023 +0100

Extended loplugin:ostr: sal

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

diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index a831221a3c36..7c803fd8 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -110,7 +110,7 @@ struct FileHandle_Impl
 rtl_String*  m_memstreambuf; /*< used for in-memory streams */
 #endif
 
-explicit FileHandle_Impl(int fd, Kind kind = KIND_FD, OString path = 
"");
+explicit FileHandle_Impl(int fd, Kind kind = KIND_FD, OString path = 
""_ostr);
 ~FileHandle_Impl();
 
 static size_t getpagesize();
diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx
index 43f577ba8f44..4dfd75ddf662 100644
--- a/sal/osl/unx/pipe.cxx
+++ b/sal/osl/unx/pipe.cxx
@@ -136,7 +136,7 @@ getBootstrapSocketPath()
 {
 return OUStringToOString(pValue, RTL_TEXTENCODING_UTF8);
 }
-return "";
+return ""_ostr;
 }
 
 static oslPipe osl_psz_createPipe(const char *pszPipeName, oslPipeOptions 
Options,
diff --git a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx 
b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
index 0543db0112b3..9692d9fb2910 100644
--- a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
+++ b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
@@ -457,9 +457,9 @@ namespace rtl_OStringBuffer
 void setUp() override
 {
 arrOUS[0] = OString( kTestStr1 );
-arrOUS[1] = OString( "1" );
+arrOUS[1] = "1"_ostr;
 arrOUS[2] = OString( );
-arrOUS[3] = OString( "" );
+arrOUS[3] = ""_ostr;
 arrOUS[4] = OString( "\0", 1 );
 arrOUS[5] = OString( kTestStr2 );
 
@@ -582,9 +582,9 @@ namespace rtl_OStringBuffer
 void setUp() override
 {
 arrOUS[0] = OString( kTestStr1 );
-arrOUS[1] = OString( "1" );
+arrOUS[1] = "1"_ostr;
 arrOUS[2] = OString( );
-arrOUS[3] = OString( "" );
+arrOUS[3] = ""_ostr;
 arrOUS[4] = OString( "\0", 1 );
 arrOUS[5] = OString( kTestStr2 );
 
@@ -943,9 +943,9 @@ namespace rtl_OStringBuffer
 void setUp() override
 {
 arrOUS[0] = OString( kTestStr1 );
-arrOUS[1] = OString( "1" );
+arrOUS[1] = "1"_ostr;
 arrOUS[2] = OString( );
-arrOUS[3] = OString( "" );
+arrOUS[3] = ""_ostr;
 arrOUS[4] = OString( "\0", 1 );
 arrOUS[5] = OString( kTestStr2 );
 
@@ -1679,7 +1679,7 @@ namespace rtl_OStringBuffer
 arrOUS[0] = OString( kTestStr7 );
 arrOUS[1] = OString(  );
 arrOUS[2] = OString( kTestStr25 );
-arrOUS[3] = OString( "" );
+arrOUS[3] = ""_ostr;
 arrOUS[4] = OString( kTestStr28 );
 
 }
@@ -2167,7 +2167,7 @@ namespace rtl_OStringBuffer
 arrOUS[0] = OString( kTestStr7 );
 arrOUS[1] = OString(  );
 arrOUS[2] = OString( kTestStr25 );
-arrOUS[3] = OString( "" );
+arrOUS[3] = ""_ostr;
 arrOUS[4] = OString( kTestStr28 );
 
 }
@@ -2647,7 +2647,7 @@ namespace rtl_OStringBuffer
 arrOUS[0] = OString( kTestStr7 );
 arrOUS[1] = OString(  );
 arrOUS[2] = OString( kTestStr25 );
-arrOUS[3] = OString( "" );
+arrOUS[3] = ""_ostr;
 arrOUS[4] = OString( kTestStr28 );
 
 }
@@ -3126,7 +3126,7 @@ namespace rtl_OStringBuffer
 arrOUS[0] = OString( kTestStr7 );
 arrOUS[1] = OString(  );
 arrOUS[2] = OString( kTestStr25 );
-arrOUS[3] = OString( "" );
+arrOUS[3] = ""_ostr;
 arrOUS[4] = OString( kTestStr28 );
 
 }
@@ -3405,7 

[Libreoffice-commits] core.git: sal/osl sal/qa

2021-10-16 Thread Julien Nabet (via logerrit)
 sal/osl/unx/backtraceapi.cxx   |8 +---
 sal/qa/osl/process/osl_process.cxx |   10 ++
 2 files changed, 11 insertions(+), 7 deletions(-)

New commits:
commit 8546cdb2ad25b03ac152615357cab0006340d92f
Author: Julien Nabet 
AuthorDate: Sat Oct 16 10:16:25 2021 +0200
Commit: Julien Nabet 
CommitDate: Sat Oct 16 18:12:29 2021 +0200

Simplify vector initialization in sal

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

diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx
index e98d8d663f39..b372a500f7f0 100644
--- a/sal/osl/unx/backtraceapi.cxx
+++ b/sal/osl/unx/backtraceapi.cxx
@@ -79,10 +79,12 @@ void process_file_addr2line( const char* file, 
std::vector& frameData
 OUString arg1("-Cfe");
 OUString arg2 = OUString::fromUtf8(file);
 std::vector addrs;
-std::vector args;
+std::vector args
+{
+arg1.pData,
+arg2.pData
+};
 args.reserve(frameData.size() + 2);
-args.push_back( arg1.pData );
-args.push_back( arg2.pData );
 for( FrameData& frame : frameData )
 {
 if( frame.file != nullptr && strcmp( file, frame.file ) == 0 )
diff --git a/sal/qa/osl/process/osl_process.cxx 
b/sal/qa/osl/process/osl_process.cxx
index 58510e3a1e08..c396a06b5782 100644
--- a/sal/qa/osl/process/osl_process.cxx
+++ b/sal/qa/osl/process/osl_process.cxx
@@ -382,10 +382,12 @@ public:
 
 osl_freeProcessHandle(process);
 
-std::vector different_child_env_vars;
-different_child_env_vars.push_back(ENV1);
-different_child_env_vars.push_back(ENV2);
-different_child_env_vars.push_back(ENV4);
+std::vector different_child_env_vars
+{
+ENV1,
+ENV2,
+ENV4
+};
 
 CPPUNIT_ASSERT_MESSAGE
 (


[Libreoffice-commits] core.git: sal/osl sal/qa

2021-05-31 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/socket.cxx |   11 +++
 sal/qa/osl/socket.cxx  |   22 +++---
 2 files changed, 26 insertions(+), 7 deletions(-)

New commits:
commit 1fef071c01caf6c293dd941ee7c8340e6894afc3
Author: Stephan Bergmann 
AuthorDate: Mon May 31 11:29:48 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Mon May 31 15:22:33 2021 +0200

Replace inet_addr with inet_pton

...as inet_addr is deprecated (it does not allow to distinguish successful
return for "255.255.255.255" from -1 error return); and update tests

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

diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx
index c78e43a9de93..cc1798e4eb1d 100644
--- a/sal/osl/unx/socket.cxx
+++ b/sal/osl/unx/socket.cxx
@@ -426,7 +426,10 @@ oslSocketAddr SAL_CALL osl_createInetBroadcastAddr (
 , strDottedAddr->buffer, strDottedAddr->length,
 RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS);
 
-nAddr = inet_addr (pDottedAddr->buffer);
+in_addr buf;
+if (inet_pton (AF_INET, pDottedAddr->buffer, ) == 1) {
+nAddr = buf.s_addr;
+}
 rtl_string_release (pDottedAddr);
 }
 
@@ -494,11 +497,11 @@ oslSocketAddr osl_psz_createInetSocketAddr (
 sal_Int32   Port)
 {
 oslSocketAddr pAddr = nullptr;
-sal_Int32 Addr = inet_addr(pszDottedAddr);
-if(Addr != -1)
+in_addr buf;
+if(inet_pton(AF_INET, pszDottedAddr, ) == 1)
 {
 /* valid dotted addr */
-pAddr = createSocketAddrWithFamily( osl_Socket_FamilyInet, htons(Port) 
, Addr );
+pAddr = createSocketAddrWithFamily( osl_Socket_FamilyInet, htons(Port) 
, buf.s_addr );
 }
 return pAddr;
 }
diff --git a/sal/qa/osl/socket.cxx b/sal/qa/osl/socket.cxx
index dab2621f2293..813702f4ca21 100644
--- a/sal/qa/osl/socket.cxx
+++ b/sal/qa/osl/socket.cxx
@@ -19,18 +19,34 @@ namespace
 class SocketTest : public CppUnit::TestFixture
 {
 CPPUNIT_TEST_SUITE(SocketTest);
-CPPUNIT_TEST(test_getDottedInetAddrOfSocketAddr);
+CPPUNIT_TEST(test_createInetSocketAddr);
+CPPUNIT_TEST(test_createInetBroadcastAddr);
 CPPUNIT_TEST_SUITE_END();
 
-void test_getDottedInetAddrOfSocketAddr()
+void test_createInetSocketAddr()
 {
 OUString const in("123.4.56.78");
-auto const addr = osl_createInetSocketAddr(in.pData, 0);
+auto const addr = osl_createInetSocketAddr(in.pData, 100);
 CPPUNIT_ASSERT(addr != nullptr);
+CPPUNIT_ASSERT_EQUAL(osl_Socket_FamilyInet, 
osl_getFamilyOfSocketAddr(addr));
 OUString out;
 auto const res = osl_getDottedInetAddrOfSocketAddr(addr, );
 CPPUNIT_ASSERT_EQUAL(osl_Socket_Ok, res);
 CPPUNIT_ASSERT_EQUAL(in, out);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(100), 
osl_getInetPortOfSocketAddr(addr));
+}
+
+void test_createInetBroadcastAddr()
+{
+OUString const in("123.4.56.78");
+auto const addr = osl_createInetBroadcastAddr(in.pData, 100);
+CPPUNIT_ASSERT(addr != nullptr);
+CPPUNIT_ASSERT_EQUAL(osl_Socket_FamilyInet, 
osl_getFamilyOfSocketAddr(addr));
+OUString out;
+auto const res = osl_getDottedInetAddrOfSocketAddr(addr, );
+CPPUNIT_ASSERT_EQUAL(osl_Socket_Ok, res);
+CPPUNIT_ASSERT_EQUAL(OUString("123.255.255.255"), out);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(100), 
osl_getInetPortOfSocketAddr(addr));
 }
 };
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sal/osl sal/qa

2021-02-01 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/file_url.cxx  |  210 +++---
 sal/qa/osl/file/osl_old_test_file.cxx |   85 -
 2 files changed, 199 insertions(+), 96 deletions(-)

New commits:
commit 41eaf2d389277a8198974a78d9c70df2f6be8e89
Author: Mike Kaganski 
AuthorDate: Mon Feb 1 19:39:47 2021 +0300
Commit: Mike Kaganski 
CommitDate: Tue Feb 2 05:13:35 2021 +0100

Do not forget to remove "." and ".." path parts in osl_getAbsoluteFileURL

A follow-up to commit 6e0fa7d4c7b45c98418c289d1d4715eb9eb133f7. Also enables
corresponding unit tests on Windows.

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

diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index b0b266e0d40e..fde2bb92b82e 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -21,6 +21,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -30,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -41,6 +43,150 @@
 
 // FileURL functions
 
+namespace
+{
+// Internal functions that expect only backslashes as path separators
+
+bool startsWithDriveColon(const sal_Unicode* p) { return 
rtl::isAsciiAlpha(p[0]) && p[1] == ':'; }
+
+bool startsWithDriveColon(const rtl_uString* p) { return 
startsWithDriveColon(p->buffer); }
+
+bool startsWithDriveColonSlash(const rtl_uString* p)
+{
+return startsWithDriveColon(p) && p->buffer[2] == '\\';
+}
+
+bool startsWithSlashSlash(const sal_Unicode* p) { return p[0] == '\\' && p[1] 
== '\\'; }
+
+bool startsWithSlashSlash(const rtl_uString* p) { return 
startsWithSlashSlash(p->buffer); }
+
+// An absolute path starts either with \\ (an UNC or device path like \\.\ or 
\\?\)
+// or with a ASCII alpha character followed by colon followed by backslash.
+bool isAbsolute(const rtl_uString* p)
+{
+return startsWithSlashSlash(p) || startsWithDriveColonSlash(p);
+}
+
+bool onSameDrive(const rtl_uString* p1, const rtl_uString* p2)
+{
+return rtl::toAsciiUpperCase(p1->buffer[0]) == 
rtl::toAsciiUpperCase(p2->buffer[0])
+   && rtl::toAsciiUpperCase(p1->buffer[1]) == 
rtl::toAsciiUpperCase(p2->buffer[1]);
+}
+
+sal_Int32 getRootLength(const rtl_uString* path)
+{
+assert(isAbsolute(path));
+const sal_Unicode* p = path->buffer;
+sal_Int32 nResult = 0;
+if (startsWithSlashSlash(p))
+{
+// Cases:
+//   1. Device UNC: \\?\UNC\server\share or \\.\UNC\server\share
+//   2. Non-device UNC: \\server\share
+//   3. Device non-UNC: \\?\C: or \\.\C:
+bool bUNC = false;
+if ((p[2] == '.' || p[2] == '?') && p[3] == '\\')
+{
+if (p[4] == 'U' && p[5] == 'N' && p[6] == 'C' && p[7] == '\\')
+{
+// \\?\UNC\server\share or \\.\UNC\server\share
+nResult = 8;
+bUNC = true;
+}
+else
+{
+// \\?\C: or \\.\C:
+assert(startsWithDriveColon(p + 4));
+nResult = 6;
+}
+}
+else
+{
+// \\server\share
+nResult = 2;
+bUNC = true;
+}
+if (bUNC)
+{
+// \\?\UNC\server\share or \\.\UNC\server\share or \\server\share
+assert(nResult < path->length && p[nResult] != '\\');
+// Skip server name and share name
+for (int nSlashes = 0; nResult < path->length; ++nResult)
+{
+if (p[nResult] == '\\' && ++nSlashes == 2)
+break;
+}
+}
+}
+else
+{
+// C:
+assert(startsWithDriveColon(p));
+nResult = 2;
+}
+return std::min(nResult, path->length);
+}
+
+std::u16string_view pathView(const rtl_uString* path, bool bOnlyRoot)
+{
+return std::u16string_view(path->buffer, bOnlyRoot ? getRootLength(path) : 
path->length);
+}
+
+OUString combinePath(std::u16string_view basePath, const sal_Unicode* relPath)
+{
+const bool needSep = basePath.back() != '\\' && relPath[0] != '\\';
+const auto sSeparator = needSep ? std::u16string_view(u"\\") : 
std::u16string_view();
+if (basePath.back() == '\\' && relPath[0] == '\\')
+++relPath; // avoid two adjacent backslashes
+return OUString::Concat(basePath) + sSeparator + relPath;
+}
+
+OUString removeRelativeParts(const OUString& p)
+{
+const sal_Int32 rootPos = getRootLength(p.pData);
+OUStringBuffer buf(p.getLength());
+buf.append(p.subView(0, rootPos));
+std::stack partPositions;
+bool bAfterSlash = false;
+for (sal_Int32 i = rootPos; i < p.getLength(); ++i)
+{
+sal_Unicode c = p[i];
+if (c == '\\')
+{
+if (i + 1 < p.getLength() && p[i + 1] == '.')
+{
+if (i + 2 == p.getLength() || p[i + 2] == '\\')

[Libreoffice-commits] core.git: sal/osl sal/qa sal/rtl sal/textenc

2020-07-01 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/nlsupport.cxx   |2 
 sal/osl/unx/pipe.cxx|2 
 sal/osl/unx/process.cxx |4 
 sal/osl/unx/socket.cxx  |   16 
 sal/osl/unx/tempfile.cxx|4 
 sal/osl/unx/thread.cxx  |2 
 sal/qa/OStringBuffer/rtl_String_Const.h |  598 
 sal/rtl/bootstrap.cxx   |2 
 sal/rtl/cipher.cxx  |2 
 sal/rtl/crc.cxx |2 
 sal/rtl/digest.cxx  |   14 
 sal/rtl/math.cxx|4 
 sal/rtl/string.cxx  |2 
 sal/rtl/ustring.cxx |2 
 sal/textenc/convertbig5hkscs.tab|4 
 sal/textenc/converteuctw.tab|4 
 sal/textenc/convertgb18030.tab  |4 
 sal/textenc/convertisciidevangari.cxx   |2 
 sal/textenc/convertisciidevangari.tab   |2 
 sal/textenc/convertiso2022cn.tab|4 
 sal/textenc/convertiso2022jp.tab|4 
 sal/textenc/convertiso2022kr.tab|4 
 sal/textenc/convertsimple.cxx   |4 
 sal/textenc/generate/big5hkscs2001.tab  |   10 
 sal/textenc/generate/cns116431992.tab   |   12 
 sal/textenc/generate/gb180302000.tab|8 
 sal/textenc/tables.cxx  |6 
 sal/textenc/tcvtarb1.tab|   60 +--
 sal/textenc/tcvteas1.tab|   24 -
 sal/textenc/tcvtest1.tab|  284 +++
 sal/textenc/tcvtjp1.tab |  100 ++---
 sal/textenc/tcvtjp2.tab |  216 +--
 sal/textenc/tcvtjp3.tab |  292 +++
 sal/textenc/tcvtjp4.tab |  192 +-
 sal/textenc/tcvtjp5.tab |  176 -
 sal/textenc/tcvtjp6.tab |   52 +-
 sal/textenc/tcvtkr1.tab |  248 ++---
 sal/textenc/tcvtkr2.tab |  290 +++
 sal/textenc/tcvtkr4.tab |  224 +--
 sal/textenc/tcvtkr5.tab |  290 +++
 sal/textenc/tcvtkr6.tab |   26 -
 sal/textenc/tcvtlat1.tab|  100 ++---
 sal/textenc/tcvtscn1.tab|  252 ++---
 sal/textenc/tcvtscn2.tab|  264 +++---
 sal/textenc/tcvtscn3.tab|  148 +++
 sal/textenc/tcvtscn4.tab|  162 
 sal/textenc/tcvtscn5.tab|  164 
 sal/textenc/tcvtscn6.tab|   44 +-
 sal/textenc/tcvtsym1.tab|2 
 sal/textenc/tcvttcn1.tab|  178 -
 sal/textenc/tcvttcn2.tab|  204 +-
 sal/textenc/tcvttcn6.tab|   26 -
 sal/textenc/tcvtuni1.tab|2 
 sal/textenc/tcvtutf7.cxx|6 
 sal/textenc/textenc.cxx |   28 -
 55 files changed, 2389 insertions(+), 2389 deletions(-)

New commits:
commit d563b9a5960e9bfe7077ee5aca44966d0bb3e2f1
Author: Stephan Bergmann 
AuthorDate: Wed Jul 1 19:53:00 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Jul 2 07:09:56 2020 +0200

Upcoming improved loplugin:staticanonymous -> redundantstatic: sal

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

diff --git a/sal/osl/unx/nlsupport.cxx b/sal/osl/unx/nlsupport.cxx
index a4c7c807c201..3a0b1021e726 100644
--- a/sal/osl/unx/nlsupport.cxx
+++ b/sal/osl/unx/nlsupport.cxx
@@ -294,7 +294,7 @@ static const Pair nl_language_list[] = {
 
 #elif defined(LINUX)
 
-static const Pair nl_language_list[] = {
+const Pair nl_language_list[] = {
 { "ANSI_X3.110-1983",   RTL_TEXTENCODING_DONTKNOW   },  /* 
ISO-IR-99 NAPLPS */
 { "ANSI_X3.4-1968", RTL_TEXTENCODING_ISO_8859_1 },  /* fake: 
ASCII_US */
 { "ASMO_449",   RTL_TEXTENCODING_DONTKNOW },/* 
ISO_9036 ARABIC7 */
diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx
index ec9fe4b9d5ca..034979ba0e4e 100644
--- a/sal/osl/unx/pipe.cxx
+++ b/sal/osl/unx/pipe.cxx
@@ -41,7 +41,7 @@
 
 static oslPipe osl_psz_createPipe(const char *pszPipeName, oslPipeOptions 
Options, oslSecurity Security);
 
-static struct
+struct
 {
 interrcode;
 oslPipeError   error;
diff --git a/sal/osl/unx/process.cxx b/sal/osl/unx/process.cxx
index 39db4936fa3f..861324963dec 100644
--- a/sal/osl/unx/process.cxx
+++ b/sal/osl/unx/process.cxx
@@ -92,8 +92,8 @@ struct ProcessData
 oslFileHandle*m_pErrorRead;
 };
 
-static oslProcessImpl* ChildList;
-static oslMutexChildListMutex;
+oslProcessImpl* ChildList;
+oslMutexChildListMutex;
 
 } //Anonymous namespace
 
diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx
index 4f67795a60ee..56a8f6cd63ac 100644
--- a/sal/osl/unx/socket.cxx
+++ b/sal/osl/unx/socket.cxx
@@ 

[Libreoffice-commits] core.git: sal/osl sal/qa

2019-12-03 Thread Jan-Marek Glogowski (via logerrit)
 sal/osl/w32/file_error.cxx   |2 +-
 sal/qa/osl/file/osl_File.cxx |2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

New commits:
commit c6553564a858a65a74c8727f08ae737c35b81a08
Author: Jan-Marek Glogowski 
AuthorDate: Fri Nov 29 16:07:55 2019 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Tue Dec 3 09:08:59 2019 +0100

WIN map ERROR_DIRECTORY to osl_File_E_NOTDIR

The open_004 unit test fails on Windows with E_NOENT. I think the
assert is correct, and it's better change the ERROR_DIRECTORY
mapping, as FindFirstFileW returns ERROR_PATH_NOT_FOUND, if the
path doesn't exists at all.

The description of that error code in the MS API docs is "The
directory name is invalid.". And obviously there is no way to
tell, if this is actually a better mapping.

Change-Id: Id122ce39e90f3562e70c96a06752e5b32ed55b41
Reviewed-on: https://gerrit.libreoffice.org/84070
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/sal/osl/w32/file_error.cxx b/sal/osl/w32/file_error.cxx
index 5336c17fd970..27b0f90cbd2d 100644
--- a/sal/osl/w32/file_error.cxx
+++ b/sal/osl/w32/file_error.cxx
@@ -77,7 +77,7 @@ static const struct osl_file_error_entry errtable[] = {
   {  ERROR_FILENAME_EXCED_RANGE,   osl_File_E_NOENT},  /* 206 */
   {  ERROR_NESTING_NOT_ALLOWED,osl_File_E_AGAIN},  /* 215 */
   {  ERROR_FILE_CHECKED_OUT,   osl_File_E_ACCES},  /* 220 */
-  {  ERROR_DIRECTORY,  osl_File_E_NOENT},  /* 267 */
+  {  ERROR_DIRECTORY,  osl_File_E_NOTDIR   },  /* 267 */
   {  ERROR_NOT_ENOUGH_QUOTA,   osl_File_E_NOMEM},  /* 1816 */
   {  ERROR_CANT_ACCESS_FILE,   osl_File_E_ACCES},  /* 1920 */
   {  ERROR_UNEXP_NET_ERR,  osl_File_E_NETWORK  }   /* 59 */
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 28f63b3055c3..31f15bc6a41f 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -4142,10 +4142,8 @@ namespace osl_Directory
 CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, nError2);
 }
 
-#ifndef _WIN32 // returns E_NOENT on Windows
 CPPUNIT_ASSERT_MESSAGE("test for open function: open a file 
instead of a directory",
  (osl::FileBase::E_NOTDIR == nError1) || 
(osl::FileBase::E_ACCES == nError1));
-#endif
 }
 
 CPPUNIT_TEST_SUITE(open);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: sal/osl sal/qa sax/source sc/inc sc/source

2019-08-24 Thread Noel Grandin (via logerrit)
 sal/osl/unx/file_path_helper.cxx |   17 +++--
 sal/qa/rtl/doublelock/rtl_doublelocking.cxx  |2 -
 sax/source/fastparser/legacyfastparser.cxx   |8 ++--
 sc/inc/document.hxx  |   12 +++---
 sc/inc/textuno.hxx   |2 -
 sc/source/core/data/documen3.cxx |8 ++--
 sc/source/core/data/document.cxx |2 -
 sc/source/filter/excel/tokstack.cxx  |   24 ++---
 sc/source/filter/inc/tokstack.hxx|   34 +--
 sc/source/ui/StatisticsDialogs/CorrelationDialog.cxx |4 +-
 sc/source/ui/StatisticsDialogs/CovarianceDialog.cxx  |4 +-
 sc/source/ui/inc/CorrelationDialog.hxx   |4 +-
 sc/source/ui/inc/CovarianceDialog.hxx|4 +-
 sc/source/ui/inc/MatrixComparisonGenerator.hxx   |4 +-
 sc/source/ui/inc/tabvwsh.hxx |2 -
 sc/source/ui/view/tabvwshc.cxx   |2 -
 16 files changed, 65 insertions(+), 68 deletions(-)

New commits:
commit e0adee8341e89d478511d7b3e784941f2fd9b504
Author: Noel Grandin 
AuthorDate: Sat Aug 24 20:32:19 2019 +0200
Commit: Noel Grandin 
CommitDate: Sat Aug 24 22:11:15 2019 +0200

loplugin:returnconstval in sal..sc

Change-Id: I300d14d580d450ec338129918955651b9d40d5d2
Reviewed-on: https://gerrit.libreoffice.org/78059
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sal/osl/unx/file_path_helper.cxx b/sal/osl/unx/file_path_helper.cxx
index 584279cff841..a89e00bf76ed 100644
--- a/sal/osl/unx/file_path_helper.cxx
+++ b/sal/osl/unx/file_path_helper.cxx
@@ -28,14 +28,11 @@ const sal_Unicode FPH_CHAR_PATH_SEPARATOR = '/';
 const sal_Unicode FPH_CHAR_DOT= '.';
 const sal_Unicode FPH_CHAR_COLON  = ':';
 
-static const OUString FPH_PATH_SEPARATOR()
-{ return OUString(FPH_CHAR_PATH_SEPARATOR); }
+static const OUStringLiteral FPH_PATH_SEPARATOR("/");
 
-static const OUString FPH_LOCAL_DIR_ENTRY()
-{ return OUString(FPH_CHAR_DOT); }
+static const OUStringLiteral FPH_LOCAL_DIR_ENTRY(".");
 
-static const OUString FPH_PARENT_DIR_ENTRY()
-{ return ".."; }
+static const OUStringLiteral FPH_PARENT_DIR_ENTRY("..");
 
 void osl_systemPathRemoveSeparator(rtl_uString* pustrPath)
 {
@@ -68,11 +65,11 @@ void osl_systemPathEnsureSeparator(rtl_uString** ppustrPath)
 
 if ((lp > 1 && i != (lp - 1)) || ((lp < 2) && i < 0))
 {
-path += FPH_PATH_SEPARATOR();
+path += FPH_PATH_SEPARATOR;
 rtl_uString_assign(ppustrPath, path.pData);
 }
 
-SAL_WARN_IF( !path.endsWith(FPH_PATH_SEPARATOR()),
+SAL_WARN_IF( !path.endsWith(FPH_PATH_SEPARATOR),
  "sal.osl",
  "osl_systemPathEnsureSeparator: Post condition failed");
 }
@@ -147,8 +144,8 @@ bool osl_systemPathIsLocalOrParentDirectoryEntry(
 
 osl_systemPathGetFileNameOrLastDirectoryPart(pustrPath, );
 
-return (dirent == FPH_LOCAL_DIR_ENTRY() ||
-dirent == FPH_PARENT_DIR_ENTRY());
+return (dirent == FPH_LOCAL_DIR_ENTRY ||
+dirent == FPH_PARENT_DIR_ENTRY);
 }
 
 /** Simple iterator for a path list separated by the specified character
diff --git a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx 
b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
index 384b8f59392a..d2e094d19c12 100644
--- a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
+++ b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
@@ -46,7 +46,7 @@
 
 namespace {
 struct Gregorian : public rtl::StaticWithInit {
-const OUString operator () () {
+OUString operator () () {
 return CONST_TEST_STRING;
 }
 };
diff --git a/sax/source/fastparser/legacyfastparser.cxx 
b/sax/source/fastparser/legacyfastparser.cxx
index 994835acc666..f5a4a433f8df 100644
--- a/sax/source/fastparser/legacyfastparser.cxx
+++ b/sax/source/fastparser/legacyfastparser.cxx
@@ -130,8 +130,8 @@ private:
 Reference< XDocumentHandler > m_xDocumentHandler;
 Reference< XFastTokenHandler > m_xTokenHandler;
 rtl::Reference< NamespaceHandler > m_aNamespaceHandler;
-const OUString getNamespacePrefixFromToken( sal_Int32 nToken );
-const OUString getNameFromToken( sal_Int32 nToken );
+OUString getNamespacePrefixFromToken( sal_Int32 nToken );
+OUString getNameFromToken( sal_Int32 nToken );
 
 static const OUString aDefaultNamespace;
 static const OUString aNamespaceSeparator;
@@ -161,7 +161,7 @@ public:
 const OUString CallbackDocumentHandler::aDefaultNamespace = OUString("");
 const OUString CallbackDocumentHandler::aNamespaceSeparator = OUString(":");
 
-const OUString CallbackDocumentHandler::getNamespacePrefixFromToken( sal_Int32 
nToken )
+OUString CallbackDocumentHandler::getNamespacePrefixFromToken( sal_Int32 
nToken )
 {
 if ( ( nToken & 0x ) != 0 )
 {
@@ -173,7 +173,7 @@ const OUString 

[Libreoffice-commits] core.git: sal/osl sal/qa sal/rtl

2018-11-22 Thread Libreoffice Gerrit user
 sal/osl/unx/profile.cxx  |   14 +-
 sal/osl/w32/module.cxx   |5 +
 sal/osl/w32/time.cxx |   12 
 sal/qa/osl/file/osl_File.cxx |   11 ++-
 sal/rtl/bootstrap.cxx|   17 -
 sal/rtl/hash.cxx |7 +--
 6 files changed, 21 insertions(+), 45 deletions(-)

New commits:
commit 85acc270fc670443cd700c471d9b495e12d4e6dc
Author: Noel Grandin 
AuthorDate: Thu Nov 22 08:52:59 2018 +0200
Commit: Noel Grandin 
CommitDate: Thu Nov 22 12:07:54 2018 +0100

improve function-local statics in sal

Change-Id: I0853cf13162bae44cf8a5c44a4546a73f05772d9
Reviewed-on: https://gerrit.libreoffice.org/63780
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index a986dfd0d41f..589662b9b62a 100644
--- a/sal/osl/unx/profile.cxx
+++ b/sal/osl/unx/profile.cxx
@@ -879,19 +879,7 @@ static osl_TStamp OslProfile_getFileStamp(osl_TFile* pFile)
 static bool OslProfile_lockFile(const osl_TFile* pFile, osl_TLockMode eMode)
 {
 struct flock lock;
-/* boring hack, but initializers for static vars must be constant */
-static bool bIsInitialized = false;
-static bool bLockingDisabled;
-
-if ( !bIsInitialized )
-{
-sal_Char* pEnvValue;
-pEnvValue = getenv( "STAR_PROFILE_LOCKING_DISABLED" );
-
-bLockingDisabled = pEnvValue != nullptr;
-
-bIsInitialized = true;
-}
+static bool const bLockingDisabled = getenv( 
"STAR_PROFILE_LOCKING_DISABLED" ) != nullptr;
 
 if (pFile->m_Handle < 0)
 {
diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx
index de9ce4db421b..8de791a7a8e1 100644
--- a/sal/osl/w32/module.cxx
+++ b/sal/osl/w32/module.cxx
@@ -327,10 +327,7 @@ typedef BOOL (WINAPI *GetModuleInformation_PROC)(
 static bool osl_addressGetModuleURL_NT_( void *pv, rtl_uString **pustrURL )
 {
 boolbSuccess= false;/* Assume failure */
-static HMODULE  hModPsapi = nullptr;
-
-if ( !hModPsapi )
-hModPsapi = LoadLibraryW( L"PSAPI.DLL" );
+static HMODULE hModPsapi = LoadLibraryW( L"PSAPI.DLL" );
 
 if ( hModPsapi )
 {
diff --git a/sal/osl/w32/time.cxx b/sal/osl/w32/time.cxx
index d1284b663fae..135aab368fc8 100644
--- a/sal/osl/w32/time.cxx
+++ b/sal/osl/w32/time.cxx
@@ -35,18 +35,14 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal)
 
 typedef VOID (WINAPI *GetSystemTimePreciseAsFileTime_PROC)(LPFILETIME);
 
-static HMODULE hModule = nullptr;
-static GetSystemTimePreciseAsFileTime_PROC pGetSystemTimePreciseAsFileTime 
= nullptr;
-
 OSL_ASSERT(pTimeVal != nullptr);
 
-if ( !hModule )
+static GetSystemTimePreciseAsFileTime_PROC pGetSystemTimePreciseAsFileTime 
= [&]()
 {
-hModule = GetModuleHandleW( L"Kernel32.dll" );
-if ( hModule )
-pGetSystemTimePreciseAsFileTime = 
reinterpret_cast(
+HMODULE hModule = GetModuleHandleW( L"Kernel32.dll" );
+return reinterpret_cast(
 GetProcAddress(hModule, "GetSystemTimePreciseAsFileTime"));
-}
+}();
 
 // use ~1 microsecond resolution if available
 if (pGetSystemTimePreciseAsFileTime)
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index fcc8c41cf4ab..ecb65ae8cd3f 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -4922,8 +4922,7 @@ namespace osl_Directory
 
 static OUString const & get_test_path()
 {
-static OUString test_path;
-if (test_path.isEmpty())
+static OUString test_path = [&]()
 {
 OUString tmp;
 osl::FileBase::RC rc = osl::FileBase::getTempDirURL(tmp);
@@ -4962,14 +4961,16 @@ namespace osl_Directory
 #endif
 tmp_x += OString(TEST_PATH_POSTFIX);
 
-rc = 
osl::FileBase::getFileURLFromSystemPath(OStringToOUString(tmp_x, 
RTL_TEXTENCODING_UTF8), test_path);
+OUString tmpTestPath;
+rc = 
osl::FileBase::getFileURLFromSystemPath(OStringToOUString(tmp_x, 
RTL_TEXTENCODING_UTF8), tmpTestPath);
 
 CPPUNIT_ASSERT_EQUAL_MESSAGE
 (
  "Cannot convert the system path back to an URL",
  osl::FileBase::E_None, rc
-  );
-}
+);
+return tmpTestPath;
+}();
 return test_path;
 }
 
diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx
index 897de890d890..9c6675586ef9 100644
--- a/sal/rtl/bootstrap.cxx
+++ b/sal/rtl/bootstrap.cxx
@@ -155,10 +155,9 @@ static bool getFromCommandLineArgs(
 {
 OSL_ASSERT(value);
 
-static NameValueVector *pNameValueVector = nullptr;
-if (!pNameValueVector)
+static NameValueVector nameValueVector = [&]()
 {
-static NameValueVector nameValueVector;
+NameValueVector tmp;
 
 sal_Int32 nArgCount = osl_getCommandArgCount();
 for(sal_Int32 i = 0; i < nArgCount; ++ i)
@@ -189,18 

[Libreoffice-commits] core.git: sal/osl sal/qa

2018-08-29 Thread Libreoffice Gerrit user
 sal/osl/w32/security.cxx |   58 +++
 sal/qa/osl/security/osl_Security.cxx |   52 +++
 2 files changed, 19 insertions(+), 91 deletions(-)

New commits:
commit d8d310dcac8ddfdb16756cc863552ef788cfc393
Author: Mike Kaganski 
AuthorDate: Tue Aug 28 23:22:29 2018 +0300
Commit: Mike Kaganski 
CommitDate: Wed Aug 29 08:40:01 2018 +0200

Use ConvertSidToStringSidW instead of composing SID string manually

Change-Id: I0dc22130b5dec5eb2250c9625773b6c9720182a9
Reviewed-on: https://gerrit.libreoffice.org/59740
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sal/osl/w32/security.cxx b/sal/osl/w32/security.cxx
index 8192dbbb6ded..c70ad92f2931 100644
--- a/sal/osl/w32/security.cxx
+++ b/sal/osl/w32/security.cxx
@@ -24,7 +24,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include "secimpl.hxx"
 
@@ -305,60 +307,26 @@ sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, 
rtl_uString **strIdent)
 if (pInfoBuffer)
 {
 PSID pSid = 
reinterpret_cast(pInfoBuffer)->User.Sid;
-PSID_IDENTIFIER_AUTHORITY psia;
-DWORD dwSubAuthorities;
-DWORD dwCounter;
-DWORD dwSidSize;
-PUCHAR pSSACount;
 
-/* obtain SidIdentifierAuthority */
-psia=GetSidIdentifierAuthority(pSid);
-
-/* obtain sidsubauthority count */
-pSSACount = GetSidSubAuthorityCount(pSid);
-dwSubAuthorities = (*pSSACount < 5) ? *pSSACount : 5;
-
-/* buffer length: S-SID_REVISION- + identifierauthority- + 
subauthorities- + NULL */
-sal_Unicode *Ident=static_cast(malloc(88*sizeof(sal_Unicode)));
-
-/* prepare S-SID_REVISION- */
-dwSidSize=wsprintfW(o3tl::toW(Ident), L"S-%lu-", SID_REVISION);
-
-/* prepare SidIdentifierAuthority */
-if ((psia->Value[0] != 0) || (psia->Value[1] != 0))
+LPWSTR pSidStr = nullptr;
+BOOL bResult = ConvertSidToStringSidW(pSid, );
+if (bResult)
 {
-dwSidSize+=wsprintfW(o3tl::toW(Ident) + 
wcslen(o3tl::toW(Ident)),
-L"0x%02hx%02hx%02hx%02hx%02hx%02hx",
-static_cast(psia->Value[0]),
-static_cast(psia->Value[1]),
-static_cast(psia->Value[2]),
-static_cast(psia->Value[3]),
-static_cast(psia->Value[4]),
-static_cast(psia->Value[5]));
+rtl_uString_newFromStr(strIdent, o3tl::toU(pSidStr));
+LocalFree(pSidStr);
 }
 else
 {
-dwSidSize+=wsprintfW(o3tl::toW(Ident) + 
wcslen(o3tl::toW(Ident)),
-L"%lu",
-static_cast(psia->Value[5]  )   +
-static_cast(psia->Value[4] <<  8)   +
-static_cast(psia->Value[3] << 16)   +
-static_cast(psia->Value[2] << 24)   );
+const DWORD dwError = GetLastError();
+char sBuf[100];
+sprintf(sBuf, "ConvertSidToStringSidW failed. GetLastError 
returned: %d",
+dwError);
+SAL_WARN("sal.osl", sBuf);
 }
 
-/* loop through SidSubAuthorities */
-for (dwCounter=0; dwCounter < dwSubAuthorities; dwCounter++)
-{
-dwSidSize+=wsprintfW(o3tl::toW(Ident) + dwSidSize, L"-%lu",
-*GetSidSubAuthority(pSid, dwCounter) );
-}
-
-rtl_uString_newFromStr( strIdent, Ident );
-
 free(pInfoBuffer);
-free(Ident);
 
-return true;
+return bResult;
 }
 }
 else
diff --git a/sal/qa/osl/security/osl_Security.cxx 
b/sal/qa/osl/security/osl_Security.cxx
index 5c24b8260c4c..a1dff025ce70 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -23,6 +23,7 @@
 # define WIN32_LEAN_AND_MEAN
 #endif
 #include 
+#include 
 #undef min
 #endif
 #include "osl_Security_Const.h"
@@ -477,58 +478,17 @@ void MyTestPlugInImpl::initialize( 
CPPUNIT_NS::TestFactoryRegistry *,
 }
 }
 
-// now got SID successfully, only need to compare SID, so I copied the 
rest lines from source to convert SID to OUString.
-PSID_IDENTIFIER_AUTHORITY psia;
-DWORD dwSubAuthorities;
-DWORD dwSidRev=SID_REVISION;
-DWORD dwCounter;
-DWORD dwSidSize;
-wchar_t *Ident;
-
-/* 

[Libreoffice-commits] core.git: sal/osl sal/qa

2018-06-05 Thread Thorsten Behrens
 sal/osl/all/log.cxx  |   10 +-
 sal/qa/osl/file/osl_File.cxx |2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 92ed91610d30246e671226da081da748f6b16aae
Author: Thorsten Behrens 
Date:   Tue Jun 5 14:23:08 2018 +0200

sal: WNT -> _WIN32

Still some holdouts from that bad old habit it seems.

Change-Id: Ib0fe2c7eb006649b121668c549ff8e0bb060e120
Reviewed-on: https://gerrit.libreoffice.org/55331
Tested-by: Jenkins 
Reviewed-by: Thorsten Behrens 

diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 4b6016e00951..d5c77dfb5750 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -32,7 +32,7 @@
 
 #if defined ANDROID
 #include 
-#elif defined WNT
+#elif defined _WIN32
 #include 
 #include 
 #define OSL_DETAIL_GETPID _getpid()
@@ -101,7 +101,7 @@ char const * getEnvironmentVariable(const char* env) {
 return p2;
 }
 
-#ifdef WNT
+#ifdef _WIN32
 # define INI_STRINGBUF_SIZE 1024
 
 bool getValueFromLoggingIniFile(const char* key, char* value) {
@@ -144,7 +144,7 @@ char const * getLogLevel() {
 if (env != nullptr)
 return env;
 
-#ifdef WNT
+#ifdef _WIN32
 static char logLevel[INI_STRINGBUF_SIZE];
 if (getValueFromLoggingIniFile("LogLevel", logLevel))
 return logLevel;
@@ -159,7 +159,7 @@ std::ofstream * getLogFile() {
 
 if (!logFile)
 {
-#ifdef WNT
+#ifdef _WIN32
 static char logFilePath[INI_STRINGBUF_SIZE];
 if (getValueFromLoggingIniFile("LogFilePath", logFilePath))
 logFile = logFilePath;
@@ -331,7 +331,7 @@ void sal_detail_log(
 *logFile << s.str() << std::endl;
 }
 else {
-#ifdef WNT
+#ifdef _WIN32
 // write to Windows debugger console, too
 OutputDebugStringA(s.str().c_str());
 #endif
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 78868fec3de1..5261cb6511f2 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -5105,7 +5105,7 @@ namespace osl_Directory
 rc != osl::FileBase::E_None
   );
 }
-#endif /* WNT */
+#endif /* _WIN32 */
 
 CPPUNIT_TEST_SUITE(createPath);
 CPPUNIT_TEST(with_relative_path);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sal/osl sal/qa sal/rtl

2017-09-26 Thread Mike Kaganski
 sal/osl/w32/conditn.cxx  |   10 +-
 sal/osl/w32/dllentry.cxx |   12 +--
 sal/osl/w32/file_dirvol.cxx  |4 -
 sal/osl/w32/file_url.cxx |8 +-
 sal/osl/w32/module.cxx   |   47 ++---
 sal/osl/w32/nlsupport.cxx|2 
 sal/osl/w32/pipe.cxx |6 -
 sal/osl/w32/process.cxx  |   18 ++---
 sal/osl/w32/procimpl.cxx |4 -
 sal/osl/w32/profile.cxx  |  119 +++
 sal/osl/w32/socket.cxx   |5 -
 sal/osl/w32/tempfile.cxx |8 +-
 sal/qa/osl/security/osl_Security.cxx |   54 ---
 sal/rtl/alloc_cache.cxx  |2 
 14 files changed, 183 insertions(+), 116 deletions(-)

New commits:
commit 48db718042d32bffe95ec058d636ed935d98ec4d
Author: Mike Kaganski 
Date:   Tue Sep 26 22:05:15 2017 +0300

SAL: use more Unicode on Windows

Change-Id: I9f54c8e8c4e617cc1ed6b436ca8c162d381ecab3
Reviewed-on: https://gerrit.libreoffice.org/42828
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 

diff --git a/sal/osl/w32/conditn.cxx b/sal/osl/w32/conditn.cxx
index 9807eaa95863..6bc6d9d3ed3a 100644
--- a/sal/osl/w32/conditn.cxx
+++ b/sal/osl/w32/conditn.cxx
@@ -32,10 +32,10 @@ oslCondition SAL_CALL osl_createCondition(void)
 {
 oslCondition Condition;
 
-Condition= reinterpret_cast(CreateEvent(nullptr,  /* 
no security */
- true,  /* manual reset */
- false, /* initial state not 
signaled */
- nullptr)); /* automatic name 
*/
+Condition= reinterpret_cast(CreateEventW(nullptr,   /* no 
security */
+   true,  /* 
manual reset */
+   false, /* 
initial state not signaled */
+   nullptr)); /* 
automatic name */
 
 return Condition;
 
@@ -88,7 +88,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition 
Condition,
 /* We Must not dispatch the message. PM_NOREMOVE leaves the 
message queue untouched
  but dispatches SendMessage calls automatically */
 
-PeekMessage( , nullptr, 0, 0, PM_NOREMOVE );
+PeekMessageW( , nullptr, 0, 0, PM_NOREMOVE );
 }
 break;
 
diff --git a/sal/osl/w32/dllentry.cxx b/sal/osl/w32/dllentry.cxx
index bc575ac5b7d8..52159853eb3e 100644
--- a/sal/osl/w32/dllentry.cxx
+++ b/sal/osl/w32/dllentry.cxx
@@ -66,8 +66,8 @@ static BOOL WINAPI RawDllMain( HINSTANCE, DWORD fdwReason, 
LPVOID )
 {
 #ifdef _DEBUG
 WCHAR buf[64];
-DWORD const res = 
GetEnvironmentVariableW(L"SAL_NO_ASSERT_DIALOGS", buf, sizeof(buf));
-if (res && res < sizeof(buf))
+DWORD const res = 
GetEnvironmentVariableW(L"SAL_NO_ASSERT_DIALOGS", buf, SAL_N_ELEMENTS(buf));
+if (res && res < SAL_N_ELEMENTS(buf))
 {
 // disable the dialog on abort()
 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
@@ -203,20 +203,20 @@ BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID )
 {
 case DLL_PROCESS_ATTACH:
 {
-TCHAR   szBuffer[64];
+WCHAR szBuffer[64];
 
 // This code will attach the process to its parent process
 // if the parent process had set the environment variable.
 // The corresponding code (setting the environment variable)
 // is desktop/win32/source/officeloader.cxx
 
-DWORD   dwResult = GetEnvironmentVariable( 
"ATTACHED_PARENT_PROCESSID", szBuffer, sizeof(szBuffer) );
+DWORD dwResult = GetEnvironmentVariableW( 
L"ATTACHED_PARENT_PROCESSID", szBuffer, SAL_N_ELEMENTS(szBuffer) );
 
-if ( dwResult && dwResult < sizeof(szBuffer) )
+if ( dwResult && dwResult < SAL_N_ELEMENTS(szBuffer) )
 {
 DWORD   dwThreadId = 0;
 
-DWORD_PTR   dwParentProcessId = (DWORD_PTR)atol( szBuffer );
+DWORD_PTR dwParentProcessId = (DWORD_PTR)_wtol( szBuffer );
 
 if ( dwParentProcessId && GetParentProcessId() == 
dwParentProcessId )
 {
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index 46f185d0554e..446654f98759 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -257,9 +257,9 @@ static HANDLE WINAPI OpenLogicalDrivesEnum()
 LPDRIVEENUM pEnum = static_cast(HeapAlloc( GetProcessHeap(), 
0, sizeof(DRIVEENUM) ));
 if ( pEnum )
 {
-DWORD dwNumCopied = GetLogicalDriveStringsW( (sizeof(pEnum->cBuffer) 

[Libreoffice-commits] core.git: sal/osl sal/qa

2017-05-20 Thread Chris Sherlock
 sal/osl/unx/file_url.cxx |4 ++--
 sal/qa/osl/file/osl_File.cxx |9 +
 2 files changed, 11 insertions(+), 2 deletions(-)

New commits:
commit 0a72b799718a17b0ea49dc36d974da28000fc952
Author: Chris Sherlock 
Date:   Sat May 20 18:17:13 2017 +1000

tdf#107968 - double slash handling misleading; add unit test

Change-Id: Ide52926eff56065e7368615338ea33dcb2f87c62
Reviewed-on: https://gerrit.libreoffice.org/37850
Tested-by: Jenkins 
Reviewed-by: Chris Sherlock 

diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index b47f94192833..e6c0ecc2a02f 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -281,7 +281,7 @@ oslFileError SAL_CALL osl_getFileURLFromSystemPath( 
rtl_uString *ustrSystemPath,
 }
 }
 
-/* check if initial string contains double instances of '/' */
+/* check if initial string contains repeated '/' characters */
 nIndex = rtl_ustr_indexOfStr_WithLength( ustrSystemPath->buffer, 
ustrSystemPath->length, pDoubleSlash, 2 );
 if( nIndex != -1 )
 {
@@ -295,7 +295,7 @@ oslFileError SAL_CALL osl_getFileURLFromSystemPath( 
rtl_uString *ustrSystemPath,
 /* adapt index to pTmp */
 nIndex += pTmp->length - ustrSystemPath->length;
 
-/* remove all occurrences of '//' */
+/* replace repeated '/' characters with a single '/' */
 for( nSrcIndex = nIndex + 1; nSrcIndex < pTmp->length; nSrcIndex++ )
 {
 if( (pTmp->buffer[nSrcIndex] == '/') && (pTmp->buffer[nIndex] == 
'/') )
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 4e635a1d559f..7176885dbbae 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -611,6 +611,7 @@ namespace osl_FileBase
 void getFileURLFromSystemPath_002();
 void getFileURLFromSystemPath_003();
 void getFileURLFromSystemPath_004();
+void getFileURLFromSystemPath_004_1();
 void getFileURLFromSystemPath_005();
 
 CPPUNIT_TEST_SUITE(SystemPath_FileURL);
@@ -641,6 +642,7 @@ namespace osl_FileBase
 CPPUNIT_TEST(getFileURLFromSystemPath_002);
 CPPUNIT_TEST(getFileURLFromSystemPath_003);
 CPPUNIT_TEST(getFileURLFromSystemPath_004);
+CPPUNIT_TEST(getFileURLFromSystemPath_004_1);
 CPPUNIT_TEST(getFileURLFromSystemPath_005);
 CPPUNIT_TEST_SUITE_END();
 
@@ -1017,6 +1019,13 @@ namespace osl_FileBase
 checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, 
osl::FileBase::E_INVAL, "");
 }
 
+void SystemPath_FileURL::getFileURLFromSystemPath_004_1()
+{
+OString sSysPath("/tmp///first start");
+checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, 
osl::FileBase::E_None, "file:///tmp/first%20start");
+checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, 
osl::FileBase::E_INVAL, "");
+}
+
 void SystemPath_FileURL::getFileURLFromSystemPath_005()
 {
 OString sSysPath("");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sal/osl sal/qa

2015-11-02 Thread Noel Grandin
 sal/osl/unx/file_url.cxx |2 +-
 sal/qa/osl/file/osl_File.cxx |2 +-
 sal/qa/osl/module/osl_Module.cxx |6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 253081247628923d53eccc2d027594add4e40b1f
Author: Noel Grandin 
Date:   Mon Nov 2 12:41:26 2015 +0200

loplugin:stringconstant

Change-Id: Id051dd984c24fb34dcc89060ed11955fed61fd48

diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index ee5f038..45e96e7 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -693,7 +693,7 @@ oslFileError osl_searchFileURL(rtl_uString* ustrFilePath, 
rtl_uString* ustrSearc
 rtl::OUString file_path;
 
 // try to interpret search path as file url else assume it's a system path 
list
-rc = FileBase::getSystemPathFromFileURL(rtl::OUString(ustrFilePath), 
file_path);
+rc = FileBase::getSystemPathFromFileURL(ustrFilePath, file_path);
 if (FileBase::E_INVAL == rc)
 file_path = ustrFilePath;
 else if (FileBase::E_None != rc)
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 7f5b848..7a03a69 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -4918,7 +4918,7 @@ namespace osl_Directory
 
 void with_relative_path()
 {
-FileBase::RC rc = Directory::createPath( 
OUString(TEST_PATH_POSTFIX));
+FileBase::RC rc = Directory::createPath(TEST_PATH_POSTFIX);
 
 CPPUNIT_ASSERT_MESSAGE
 (
diff --git a/sal/qa/osl/module/osl_Module.cxx b/sal/qa/osl/module/osl_Module.cxx
index 9f6e8ae..171e9d6 100644
--- a/sal/qa/osl/module/osl_Module.cxx
+++ b/sal/qa/osl/module/osl_Module.cxx
@@ -135,7 +135,7 @@ namespace osl_Module
 #if !defined( MACOSX )
 // TODO: Find out why this fails on Mac OS X
 ::osl::Module aMod( getDllURL( ) );
-FuncPtr pFunc = reinterpret_cast(aMod.getSymbol( 
rtl::OUString("firstfunc") ));
+FuncPtr pFunc = reinterpret_cast(aMod.getSymbol( 
"firstfunc" ));
 
 OUString aFileURL;
 bRes = osl::Module::getUrlFromAddress(
@@ -258,7 +258,7 @@ namespace osl_Module
 #if !defined( MACOSX )
 // TODO: Find out why this fails on Mac OS X
 ::osl::Module aMod( getDllURL( ) );
-FuncPtr pFunc = reinterpret_cast(aMod.getSymbol( 
rtl::OUString("firstfunc") ));
+FuncPtr pFunc = reinterpret_cast(aMod.getSymbol( 
"firstfunc" ));
 bRes = false;
 if ( pFunc )
 bRes = pFunc( bRes );
@@ -337,7 +337,7 @@ namespace osl_Module
 #if !defined( MACOSX )
 // TODO: Find out why this fails on Mac OS X
 ::osl::Module aMod( getDllURL( ) );
-oslGenericFunction oslFunc = aMod.getFunctionSymbol( 
rtl::OUString("firstfunc") );
+oslGenericFunction oslFunc = aMod.getFunctionSymbol( "firstfunc" );
 ::rtl::OUString aLibraryURL;
 bRes = ::osl::Module::getUrlFromAddress( oslFunc, aLibraryURL);
 aMod.unload();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sal/osl sal/qa

2014-05-20 Thread Stephan Bergmann
 sal/osl/unx/socket.c   |4 ++--
 sal/qa/rtl/ostring/rtl_str.cxx |   10 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit fe39041f98b1abb3a23b43f399963487fe5b66b9
Author: Stephan Bergmann sberg...@redhat.com
Date:   Tue May 20 10:03:18 2014 +0200

Remove unnecessary casts

Change-Id: Iafc7727a22d657dfb6bc97ed767907cce3679364

diff --git a/sal/osl/unx/socket.c b/sal/osl/unx/socket.c
index 052ace9..d11297f 100644
--- a/sal/osl/unx/socket.c
+++ b/sal/osl/unx/socket.c
@@ -790,7 +790,7 @@ static oslHostAddr _osl_hostentToHostAddr (const struct 
hostent *he)
 
 if (_osl_isFullQualifiedDomainName(he-h_name))
 {
-cn= (sal_Char *)strdup(he-h_name);
+cn= strdup(he-h_name);
 OSL_ASSERT(cn);
 if (cn == NULL)
 return ((oslHostAddr)NULL);
@@ -887,7 +887,7 @@ oslHostAddr SAL_CALL osl_psz_createHostAddr (
 if ((pszHostname == NULL) || (pAddr == NULL))
 return ((oslHostAddr)NULL);
 
-cn = (sal_Char *) strdup(pszHostname);
+cn = strdup(pszHostname);
 OSL_ASSERT(cn);
 if (cn == NULL)
 return ((oslHostAddr)NULL);
diff --git a/sal/qa/rtl/ostring/rtl_str.cxx b/sal/qa/rtl/ostring/rtl_str.cxx
index 759d30e..4ba2962 100644
--- a/sal/qa/rtl/ostring/rtl_str.cxx
+++ b/sal/qa/rtl/ostring/rtl_str.cxx
@@ -711,7 +711,7 @@ namespace rtl_str
 void trim_WithLength_001()
 {
 char const *pStr =   trim this;
-sal_Char *pStr2 = (sal_Char*)strdup(pStr);
+sal_Char *pStr2 = strdup(pStr);
 if (pStr2)
 {
 rtl_str_trim_WithLength( pStr2, 2 );
@@ -724,7 +724,7 @@ namespace rtl_str
 void trim_WithLength_002()
 {
 char const *pStr = trim this;
-sal_Char *pStr2 = (sal_Char*)strdup(pStr);
+sal_Char *pStr2 = strdup(pStr);
 if (pStr2)
 {
 rtl_str_trim_WithLength( pStr2, 5 );
@@ -737,7 +737,7 @@ namespace rtl_str
 void trim_WithLength_003()
 {
 char const *pStr =  trim   this;
-sal_Char *pStr2 = (sal_Char*)strdup(pStr);
+sal_Char *pStr2 = strdup(pStr);
 if (pStr2)
 {
 strcpy(pStr2, pStr);
@@ -751,7 +751,7 @@ namespace rtl_str
 void trim_WithLength_004()
 {
 char const *pStr = \r\n\t \n\rtrim  \n this;
-sal_Char *pStr2 = (sal_Char*)strdup(pStr);
+sal_Char *pStr2 = strdup(pStr);
 if (pStr2)
 {
 rtl_str_trim_WithLength( pStr2, 17 );
@@ -764,7 +764,7 @@ namespace rtl_str
 void trim_WithLength_005()
 {
 char const *pStr = \r\n\t \n\rtrim \t this \n\r\t\t ;
-sal_Char *pStr2 = (sal_Char*)strdup(pStr);
+sal_Char *pStr2 = strdup(pStr);
 if (pStr2)
 {
 rtl_str_trim_WithLength( pStr2, strlen(pStr2) );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sal/osl sal/qa sal/rtl sal/textenc

2013-02-22 Thread Tor Lillqvist
 sal/osl/unx/file_url.cxx  |2 +-
 sal/osl/unx/process.cxx   |2 +-
 sal/osl/unx/salinit.cxx   |2 +-
 sal/osl/w32/file_dirvol.cxx   |4 ++--
 sal/osl/w32/file_url.cxx  |2 +-
 sal/osl/w32/module.cxx|2 +-
 sal/osl/w32/process.cxx   |2 +-
 sal/osl/w32/profile.cxx   |2 +-
 sal/qa/osl/file/osl_File.cxx  |   14 +++---
 sal/qa/osl/mutex/osl_Mutex.cxx|   14 +++---
 sal/qa/osl/pipe/osl_Pipe.cxx  |6 +++---
 sal/qa/osl/socket/osl_ConnectorSocket.cxx |2 +-
 sal/qa/osl/socket/osl_Socket.cxx  |8 
 sal/qa/osl/socket/osl_SocketAddr.cxx  |4 ++--
 sal/qa/osl/socket/osl_StreamSocket.cxx|8 
 sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx|2 +-
 sal/qa/rtl_strings/rtl_OUString.cxx   |2 +-
 sal/rtl/source/unload.cxx |2 +-
 sal/textenc/tcvtmb.cxx|2 +-
 sal/textenc/tcvtutf8.cxx  |2 +-
 20 files changed, 42 insertions(+), 42 deletions(-)

New commits:
commit fc090acf829d0053c0a611acd73f08b51128031d
Author: Tor Lillqvist t...@iki.fi
Date:   Fri Feb 22 11:13:56 2013 +0200

Fix misspellings detected by https://github.com/lyda/misspell-check

Just as a test to check the usefulness of that tool. It needs some 
improvement
before really usable.

Change-Id: I875e79c1992ed5f3b695736b0d49938ad0ba2d55

diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index 7c28b8c..203d17f 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -182,7 +182,7 @@ oslFileError SAL_CALL osl_getSystemPathFromFileURL( 
rtl_uString *ustrFileURL, rt
 {
 nOffset += nIndex;
 
-/* break url down in '/' devided tokens tokens */
+/* break url down in '/' divided tokens tokens */
 nIndex = rtl_ustr_indexOfChar_WithLength( ustrFileURL-buffer + 
nOffset, ustrFileURL-length - nOffset, (sal_Unicode) '/' );
 
 /* copy token to new string */
diff --git a/sal/osl/unx/process.cxx b/sal/osl/unx/process.cxx
index cf246c5..aa71c36 100644
--- a/sal/osl/unx/process.cxx
+++ b/sal/osl/unx/process.cxx
@@ -1158,7 +1158,7 @@ static int is_timeout(const struct timeval* tend)
 }
 
 /**
- kill(pid, 0) is usefull for checking if a
+ kill(pid, 0) is useful for checking if a
  process is still alive, but remember that
  kill even returns 0 if the process is already
  a zombie.
diff --git a/sal/osl/unx/salinit.cxx b/sal/osl/unx/salinit.cxx
index 4211d08..49fddea 100644
--- a/sal/osl/unx/salinit.cxx
+++ b/sal/osl/unx/salinit.cxx
@@ -46,7 +46,7 @@ void sal_detail_initialize(int argc, char ** argv) {
 // https://bugs.freedesktop.org/show_bug.cgi?id=50603 Unable to update
 // LibreOffice without resetting user profile).  But closing fds in
 // restartOnMac before calling exec does not work, as additional threads
-// might still be running then, wich can still use those fds and cause
+// might still be running then, which can still use those fds and cause
 // crashes.  Therefore, the simples solution is to close fds at process
 // start (as early as possible, so that no other threads have been created
 // yet that might already have opened some fds); this is done for all kinds
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index 89d286b..5d8c3a5 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -491,7 +491,7 @@ static oslFileError osl_openLocalRoot(
 ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
 rtl_uString_newFromString( pDirImpl-m_pDirectoryPath, strSysPath );
 
-/* Append backslash if neccessary */
+/* Append backslash if necessary */
 
 /* @@@ToDo
use function ensure backslash
@@ -556,7 +556,7 @@ static oslFileError SAL_CALL osl_openFileDirectory(
 ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
 rtl_uString_newFromString( pDirImpl-m_pDirectoryPath, strDirectoryPath );
 
-/* Append backslash if neccessary */
+/* Append backslash if necessary */
 
 /* @@@ToDo
use function ensure backslash
diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index 2527cbd..324eca1 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -998,7 +998,7 @@ oslFileError SAL_CALL osl_searchFileURL(
 LPCTSTR lpszSearchFile = 
reinterpret_castLPCTSTR(ustrSysPath-buffer);
 
 /* Allocate space for buffer according to previous returned count 
of required chars */
-/* +1 is not neccessary if we follow MSDN documentation but for 
robustness we do so */
+/* +1 is not necessary if we follow MSDN documentation but for 
robustness we do so */
 nBufferLength = dwResult + 1;