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

2023-12-06 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/nlsupport.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8b5bb37cc4116f74c2f533453936eb8cb84d9fc5
Author: Stephan Bergmann 
AuthorDate: Wed Dec 6 13:42:50 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Dec 6 16:38:22 2023 +0100

loplugin:ostr (macOS)

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

diff --git a/sal/osl/unx/nlsupport.cxx b/sal/osl/unx/nlsupport.cxx
index 4cd02fe0e594..7ba961968ab7 100644
--- a/sal/osl/unx/nlsupport.cxx
+++ b/sal/osl/unx/nlsupport.cxx
@@ -827,7 +827,7 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
 locale = getenv( "LANG" );
 
 if( locale.isEmpty() )
-locale = "C";
+locale = "C"_ostr;
 }
 
 /* return the locale */


[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

2023-11-08 Thread Stephan Bergmann (via logerrit)
 sal/osl/w32/file_dirvol.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c254acddbc5e45a7e70be3e7b688ed5dddca3c2d
Author: Stephan Bergmann 
AuthorDate: Wed Nov 8 14:15:10 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Nov 9 07:36:23 2023 +0100

loplugin:unnecessarygetstr (clang-cl)

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

diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index f0c03d0d0033..84ccd28de8c7 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -1300,7 +1300,7 @@ static bool path_get_parent(OUString& path)
 sal_Int32 i = path.lastIndexOf(BACKSLASH);
 if (-1 < i)
 {
-path = OUString(path.getStr(), i);
+path = path.copy(0, i);
 return true;
 }
 }


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

2023-11-08 Thread Stephan Bergmann (via logerrit)
 sal/osl/w32/signal.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 94dbf63dcd1843b4d7d0515d63998adb8032ac3c
Author: Stephan Bergmann 
AuthorDate: Wed Nov 8 14:12:22 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Nov 8 18:57:03 2023 +0100

-Werror,-Wmissing-field-initializers (clang-cl)

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

diff --git a/sal/osl/w32/signal.cxx b/sal/osl/w32/signal.cxx
index 52d47da86b6c..2d04e59269de 100644
--- a/sal/osl/w32/signal.cxx
+++ b/sal/osl/w32/signal.cxx
@@ -41,7 +41,8 @@ BOOL WINAPI CtrlHandlerFunction(DWORD dwCtrlType)
 case CTRL_C_EVENT:
 case CTRL_BREAK_EVENT:
 case CTRL_CLOSE_EVENT:
-switch (oslSignalInfo Info{ osl_Signal_Terminate }; 
callSignalHandler())
+switch (oslSignalInfo Info{ osl_Signal_Terminate, 0, nullptr };
+callSignalHandler())
 {
 case osl_Signal_ActCallNextHdl:
 break; // Fall through to call the next handler


[Libreoffice-commits] core.git: sal/osl vcl/inc vcl/ios

2023-10-01 Thread Patrick Luby (via logerrit)
 sal/osl/unx/process.cxx   |4 
 vcl/inc/ios/iosinst.hxx   |2 +-
 vcl/inc/quartz/SystemFontList.hxx |3 +++
 vcl/ios/iosinst.cxx   |9 +
 4 files changed, 13 insertions(+), 5 deletions(-)

New commits:
commit 53c27f66fcb5a624ef27d2480b0f3e584a1ba1ef
Author: Patrick Luby 
AuthorDate: Fri Sep 29 14:19:43 2023 -0400
Commit: Patrick Luby 
CommitDate: Sun Oct 1 15:55:55 2023 +0200

Fix iOS build breakages when building on macOS Sonoma

Change-Id: I347e48e9da69c8c9b15581a5afa5c61cdd1d380d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157411
Reviewed-by: Patrick Luby 
Reviewed-by: Andras Timar 
Tested-by: Patrick Luby 

diff --git a/sal/osl/unx/process.cxx b/sal/osl/unx/process.cxx
index d54864042465..cebdc6f35fdb 100644
--- a/sal/osl/unx/process.cxx
+++ b/sal/osl/unx/process.cxx
@@ -45,6 +45,10 @@
 #include 
 #endif
 
+#ifdef IOS
+#include 
+#endif
+
 #include "system.hxx"
 #include "unixerrnostring.hxx"
 #if defined(__sun)
diff --git a/vcl/inc/ios/iosinst.hxx b/vcl/inc/ios/iosinst.hxx
index 6ba433eed104..63182bcd0c0a 100644
--- a/vcl/inc/ios/iosinst.hxx
+++ b/vcl/inc/ios/iosinst.hxx
@@ -44,7 +44,7 @@ public:
 css::uno::Reference
 CreateClipboard(const css::uno::Sequence& i_rArguments) 
override;
 
-void GetWorkArea(tools::Rectangle& rRect);
+void GetWorkArea(AbsoluteScreenPixelRectangle& rRect);
 SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) 
override;
 SalFrame* CreateChildFrame(SystemParentData* pParent, SalFrameStyleFlags 
nStyle) override;
 };
diff --git a/vcl/inc/quartz/SystemFontList.hxx 
b/vcl/inc/quartz/SystemFontList.hxx
index f923b47998a7..4f623804702c 100644
--- a/vcl/inc/quartz/SystemFontList.hxx
+++ b/vcl/inc/quartz/SystemFontList.hxx
@@ -33,6 +33,9 @@
 #include 
 
 #include 
+#ifdef IOS
+#include 
+#endif
 
 #include 
 
diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx
index 533fef269a07..371d5c246ca1 100644
--- a/vcl/ios/iosinst.cxx
+++ b/vcl/ios/iosinst.cxx
@@ -26,16 +26,17 @@
 #include "headless/svpdata.hxx"
 #include "headless/svpdummies.hxx"
 #include "quartz/utils.h"
+#include "quartz/SystemFontList.hxx"
 #include 
 #include 
 
 // Totally wrong of course but doesn't seem to harm much in the iOS app.
 static int viewWidth = 1, viewHeight = 1;
 
-void IosSalInstance::GetWorkArea( tools::Rectangle& rRect )
+void IosSalInstance::GetWorkArea( AbsoluteScreenPixelRectangle& rRect )
 {
-rRect = tools::Rectangle( Point( 0, 0 ),
-   Size( viewWidth, viewHeight ) );
+rRect = AbsoluteScreenPixelRectangle( AbsoluteScreenPixelPoint( 0, 0 ),
+   AbsoluteScreenPixelSize( viewWidth, viewHeight ) );
 }
 
 IosSalInstance *IosSalInstance::getInstance()
@@ -80,7 +81,7 @@ public:
 SetPosSize(0, 0, viewWidth, viewHeight, SAL_FRAME_POSSIZE_WIDTH | 
SAL_FRAME_POSSIZE_HEIGHT);
 }
 
-virtual void GetWorkArea( tools::Rectangle& rRect ) override
+virtual void GetWorkArea( AbsoluteScreenPixelRectangle& rRect ) override
 {
 IosSalInstance::getInstance()->GetWorkArea( rRect );
 }


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

2023-09-26 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/file_dirvol.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit d724b51c7da391c9afe5e47476d432aecf1c4c67
Author: Mike Kaganski 
AuthorDate: Tue Sep 26 09:52:29 2023 +0300
Commit: Mike Kaganski 
CommitDate: Tue Sep 26 11:59:54 2023 +0200

tdf#157448: ignore FILE_ATTRIBUTE_READONLY when FILE_ATTRIBUTE_DIRECTORY is 
set

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

diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index f9d821605e86..f0c03d0d0033 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -1553,6 +1553,10 @@ oslFileError SAL_CALL osl_getFileStatus(
 pStatus->uValidFields |= osl_FileStatus_Mask_Type;
 
 pStatus->uAttributes = pItemImpl->FindData.dwFileAttributes;
+// tdf#157448: RO attribute is ignored for directories on Windows:
+// 
https://learn.microsoft.com/en-us/windows/desktop/FileIO/file-attribute-constants
+if (pStatus->uAttributes & FILE_ATTRIBUTE_DIRECTORY)
+pStatus->uAttributes &= ~sal_uInt64(FILE_ATTRIBUTE_READONLY);
 pStatus->uValidFields |= osl_FileStatus_Mask_Attributes;
 
 pStatus->uFileSize = 
static_cast(pItemImpl->FindData.nFileSizeLow) + 
(static_cast(pItemImpl->FindData.nFileSizeHigh) << 32);


[Libreoffice-commits] core.git: sal/osl sfx2/source ucbhelper/source vcl/inc vcl/source vcl/win

2023-08-09 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/dllentry.cxx |9 -
 sal/osl/w32/thread.cxx   |8 
 sfx2/source/appl/shutdowniconw32.cxx |6 +++---
 ucbhelper/source/client/proxydecider.cxx |6 --
 vcl/inc/win/dnd_target.hxx   |4 ++--
 vcl/source/app/svmain.cxx|7 +++
 vcl/win/dtrans/MtaOleClipb.cxx   |   13 ++---
 vcl/win/dtrans/MtaOleClipb.hxx   |6 +++---
 vcl/win/dtrans/source.cxx|8 
 vcl/win/dtrans/target.cxx|8 
 10 files changed, 37 insertions(+), 38 deletions(-)

New commits:
commit 8a0c43fa86bd32b4d47fd7e46d3ed414c9282ffa
Author: Mike Kaganski 
AuthorDate: Wed Aug 9 14:29:54 2023 +0300
Commit: Mike Kaganski 
CommitDate: Wed Aug 9 20:15:43 2023 +0200

Use _beginthreadex instead of CreateThread

The documentation for ExitThread [1] has this comment:

  A thread in an executable that calls the C run-time library (CRT) should 
use
  the _beginthreadex and _endthreadex functions for thread management rather
  than CreateThread and ExitThread; this requires the use of the 
multithreaded
  version of the CRT. If a thread created using CreateThread calls the CRT,
  the CRT may terminate the process in low-memory conditions.

Since ~all our code uses CRT, be safe and use _beginthreadex.

[1] 
https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread

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

diff --git a/sal/osl/w32/dllentry.cxx b/sal/osl/w32/dllentry.cxx
index 81139a05852b..5389c056d5a2 100644
--- a/sal/osl/w32/dllentry.cxx
+++ b/sal/osl/w32/dllentry.cxx
@@ -18,6 +18,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -159,7 +160,7 @@ static DWORD GetParentProcessId()
 return dwParentProcessId;
 }
 
-static DWORD WINAPI ParentMonitorThreadProc( LPVOID lpParam )
+static unsigned __stdcall ParentMonitorThreadProc(void* lpParam)
 {
 DWORD_PTR dwParentProcessId = reinterpret_cast(lpParam);
 
@@ -196,8 +197,6 @@ BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID )
 
 if ( dwResult && dwResult < SAL_N_ELEMENTS(szBuffer) )
 {
-DWORD   dwThreadId = 0;
-
 DWORD_PTR dwParentProcessId = static_cast(_wtol( 
szBuffer ));
 
 if ( dwParentProcessId && GetParentProcessId() == 
dwParentProcessId )
@@ -205,8 +204,8 @@ BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID )
 // No error check, it works or it does not
 // Thread should only be started for headless mode, see 
desktop/win32/source/officeloader.cxx
 HANDLE hThread
-= CreateThread(nullptr, 0, ParentMonitorThreadProc,
-   
reinterpret_cast(dwParentProcessId), 0, );
+= reinterpret_cast(_beginthreadex(nullptr, 0, 
ParentMonitorThreadProc,
+   
reinterpret_cast(dwParentProcessId), 0, nullptr));
 // Note: calling CreateThread in DllMain is discouraged
 // but this is only done in the headless mode and in
 // that case no other threads should be running at startup
diff --git a/sal/osl/w32/thread.cxx b/sal/osl/w32/thread.cxx
index f6b3109adfb9..3640d43b9992 100644
--- a/sal/osl/w32/thread.cxx
+++ b/sal/osl/w32/thread.cxx
@@ -43,7 +43,7 @@ namespace {
 typedef struct
 {
 HANDLE  m_hThread;  /* OS-handle used for all 
thread-functions */
-DWORD   m_ThreadId; /* identifier for this thread */
+unsignedm_ThreadId; /* identifier for this thread */
 sal_Int32   m_nTerminationRequested;
 oslWorkerFunction   m_WorkerFunction;
 void*   m_pData;
@@ -54,7 +54,7 @@ typedef struct
 
 static oslThread oslCreateThread(oslWorkerFunction pWorker, void* pThreadData, 
sal_uInt32 nFlags);
 
-static DWORD WINAPI oslWorkerWrapperFunction(_In_ LPVOID pData)
+static unsigned __stdcall oslWorkerWrapperFunction(void* pData)
 {
 osl_TThreadImpl* pThreadImpl= static_cast(pData);
 
@@ -89,13 +89,13 @@ static oslThread oslCreateThread(oslWorkerFunction pWorker,
 pThreadImpl->m_pData= pThreadData;
 pThreadImpl->m_nTerminationRequested= 0;
 
-pThreadImpl->m_hThread= CreateThread(
+pThreadImpl->m_hThread= reinterpret_cast(_beginthreadex(
nullptr, /* no security */
0,   /* default 
stack-size */
oslWorkerWrapperFunction,/* worker-function 
*/
pThreadImpl, /* provide 

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

2023-05-02 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/signal.cxx |   32 
 1 file changed, 32 insertions(+)

New commits:
commit d7823e0266d38dd83d7f824f6bafb3898ccbca75
Author: Mike Kaganski 
AuthorDate: Tue May 2 12:58:33 2023 +0300
Commit: Mike Kaganski 
CommitDate: Tue May 2 18:22:03 2023 +0200

tdf#155122: implement CtrlHandler on Windows

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

diff --git a/sal/osl/w32/signal.cxx b/sal/osl/w32/signal.cxx
index dcb05beae097..52d47da86b6c 100644
--- a/sal/osl/w32/signal.cxx
+++ b/sal/osl/w32/signal.cxx
@@ -33,12 +33,43 @@ namespace
 {
 long WINAPI signalHandlerFunction(LPEXCEPTION_POINTERS lpEP);
 
+// Similar to SIGINT handler in sal/osl/unx/signal.cxx
+BOOL WINAPI CtrlHandlerFunction(DWORD dwCtrlType)
+{
+switch (dwCtrlType)
+{
+case CTRL_C_EVENT:
+case CTRL_BREAK_EVENT:
+case CTRL_CLOSE_EVENT:
+switch (oslSignalInfo Info{ osl_Signal_Terminate }; 
callSignalHandler())
+{
+case osl_Signal_ActCallNextHdl:
+break; // Fall through to call the next handler
+
+case osl_Signal_ActAbortApp:
+abort();
+break;
+
+case osl_Signal_ActKillApp:
+_exit(255);
+break;
+
+default:
+return TRUE; // do not call the next handler
+}
+[[fallthrough]];
+default:
+return FALSE; // call the next handler
+}
+}
+
 LPTOP_LEVEL_EXCEPTION_FILTER pPreviousHandler = nullptr;
 }
 
 bool onInitSignal()
 {
 pPreviousHandler = SetUnhandledExceptionFilter(signalHandlerFunction);
+SetConsoleCtrlHandler(CtrlHandlerFunction, TRUE);
 
 WerAddExcludedApplication(L"SOFFICE.EXE", FALSE);
 
@@ -47,6 +78,7 @@ bool onInitSignal()
 
 bool onDeInitSignal()
 {
+SetConsoleCtrlHandler(CtrlHandlerFunction, FALSE);
 SetUnhandledExceptionFilter(pPreviousHandler);
 
 return false;


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

2023-05-02 Thread Noel Grandin (via logerrit)
 sal/osl/w32/backtrace.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit bcd233e45f1d793555e29522d1c30b67c574b628
Author: Noel Grandin 
AuthorDate: Tue May 2 09:52:43 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue May 2 10:37:53 2023 +0200

improve windows backtrace_to_string

I want to know the symbol address we actually capture, since
we seem to getting duplicates in the output of SymFromAddr, I
want to know if the fault is in SymFromAddr, or the backtrace
capture call.

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

diff --git a/sal/osl/w32/backtrace.cxx b/sal/osl/w32/backtrace.cxx
index 8d55c6485a12..0b38d1962bc1 100644
--- a/sal/osl/w32/backtrace.cxx
+++ b/sal/osl/w32/backtrace.cxx
@@ -74,10 +74,11 @@ OUString sal::backtrace_to_string(BacktraceState* 
backtraceState)
 OUStringBuffer aBuf;
 for( int i = 0; i < nFrames; i++ )
 {
-SymFromAddr( hProcess, 
reinterpret_cast(backtraceState->buffer[ i ]), nullptr, pSymbol );
+auto pSymAddr = reinterpret_cast(backtraceState->buffer[ i ]);
+SymFromAddr( hProcess, pSymAddr, nullptr, pSymbol );
 aBuf.append( OUString::number(nFrames - i - 1) + ": " );
 aBuf.appendAscii( pSymbol->Name );
-aBuf.append( " - 0x" + OUString::number(pSymbol->Address, 16) + "\n" );
+aBuf.append( " - 0x" + OUString::number(pSymAddr, 16) + "\n" );
 }
 
 free( pSymbol );


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

2023-04-17 Thread Stephan Bergmann (via logerrit)
 sal/osl/w32/backtrace.cxx |7 ++-
 sal/osl/w32/procimpl.cxx  |3 +--
 2 files changed, 3 insertions(+), 7 deletions(-)

New commits:
commit a0c08ce6cf5e0cd88238fefb3b819305daf4005e
Author: Stephan Bergmann 
AuthorDate: Mon Apr 17 09:20:53 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Mon Apr 17 17:16:29 2023 +0200

loplugin:stringadd

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

diff --git a/sal/osl/w32/backtrace.cxx b/sal/osl/w32/backtrace.cxx
index d9231de44517..8d55c6485a12 100644
--- a/sal/osl/w32/backtrace.cxx
+++ b/sal/osl/w32/backtrace.cxx
@@ -75,12 +75,9 @@ OUString sal::backtrace_to_string(BacktraceState* 
backtraceState)
 for( int i = 0; i < nFrames; i++ )
 {
 SymFromAddr( hProcess, 
reinterpret_cast(backtraceState->buffer[ i ]), nullptr, pSymbol );
-aBuf.append( static_cast(nFrames - i - 1) );
-aBuf.append( ": " );
+aBuf.append( OUString::number(nFrames - i - 1) + ": " );
 aBuf.appendAscii( pSymbol->Name );
-aBuf.append( " - 0x" );
-aBuf.append( static_cast(pSymbol->Address), 16 );
-aBuf.append( "\n" );
+aBuf.append( " - 0x" + OUString::number(pSymbol->Address, 16) + "\n" );
 }
 
 free( pSymbol );
diff --git a/sal/osl/w32/procimpl.cxx b/sal/osl/w32/procimpl.cxx
index 5fb9a46348b2..1689d6ac6be9 100644
--- a/sal/osl/w32/procimpl.cxx
+++ b/sal/osl/w32/procimpl.cxx
@@ -422,8 +422,7 @@ oslProcessError SAL_CALL 
osl_executeProcess_WithRedirectedIO(
 if (!(Options & osl_Process_WAIT) || (Options & 
osl_Process_DETACHED))
 flags |= CREATE_NEW_CONSOLE;
 
-command_line.append(batch_processor);
-command_line.append(" /c ");
+command_line.append(batch_processor + " /c ");
 }
 else
 // should we return here in case of error?


[Libreoffice-commits] core.git: sal/osl svx/source vcl/unx xmlhelp/source

2023-04-09 Thread Noel Grandin (via logerrit)
 sal/osl/w32/file_url.cxx |6 --
 svx/source/form/formcontroller.cxx   |2 +-
 vcl/unx/gtk3/gtkframe.cxx|4 ++--
 xmlhelp/source/cxxhelp/provider/urlparameter.hxx |2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

New commits:
commit d7910847fba1694c83dc57a1f27b8eaabb2a7d85
Author: Noel Grandin 
AuthorDate: Sun Apr 9 13:32:12 2023 +0200
Commit: Noel Grandin 
CommitDate: Sun Apr 9 19:27:44 2023 +0200

use more OStringToOUString

both because it is more obvious to read, and it takes a string_view,
which is handy

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

diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index 8c525042ddef..a14f8d4b9b39 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -502,8 +502,10 @@ static std::optional osl_decodeURL_(const 
OString& sUTF8)
 }
 }
 
-return bValidEncoded ? OUString(aBuffer.getStr(), aBuffer.getLength(), 
RTL_TEXTENCODING_UTF8)
- : std::optional();
+if (!bValidEncoded)
+return std::nullopt;
+
+return OStringToOUString(aBuffer, RTL_TEXTENCODING_UTF8);
 }
 
 static OUString osl_encodeURL_(std::u16string_view sURL)
diff --git a/svx/source/form/formcontroller.cxx 
b/svx/source/form/formcontroller.cxx
index b1063a46df2f..bf5306bc71c5 100644
--- a/svx/source/form/formcontroller.cxx
+++ b/svx/source/form/formcontroller.cxx
@@ -3082,7 +3082,7 @@ void 
FormController::setFilter(::std::vector& rFieldInfos)
 {
 OString aVal = 
m_pParser->getContext().getIntlKeywordAscii(IParseContext::InternationalKeyCode::And);
 OUString aCompText = aRow[rFieldInfo.xText] + " "  
+
-
OUString(aVal.getStr(),aVal.getLength(),RTL_TEXTENCODING_ASCII_US) + " " +
+OStringToOUString(aVal, 
RTL_TEXTENCODING_ASCII_US) + " " +
 ::comphelper::getString(rRefValue.Value);
 aRow[rFieldInfo.xText] = aCompText;
 }
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 824af112fa5d..1b1a1c0595b0 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -2713,7 +2713,7 @@ OUString GtkSalFrame::GetKeyName( sal_uInt16 nKeyCode )
 KeyCodeToGdkKey(nKeyCode, ,  );
 
 gchar* pName = gtk_accelerator_get_label(nGtkKeyCode, nGtkModifiers);
-OUString aRet(pName, rtl_str_getLength(pName), RTL_TEXTENCODING_UTF8);
+OUString aRet = OStringToOUString(pName, strlen(pName), 
RTL_TEXTENCODING_UTF8);
 g_free(pName);
 return aRet;
 }
@@ -4859,7 +4859,7 @@ public:
 OUString aStr;
 gchar *pText = 
reinterpret_cast(gtk_selection_data_get_text(m_pData));
 if (pText)
-aStr = OUString(pText, rtl_str_getLength(pText), 
RTL_TEXTENCODING_UTF8);
+aStr = OStringToOUString(pText, strlen(pText), 
RTL_TEXTENCODING_UTF8);
 g_free(pText);
 aRet <<= aStr.replaceAll("\r\n", "\n");
 }
diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.hxx 
b/xmlhelp/source/cxxhelp/provider/urlparameter.hxx
index 0a555607129c..850cb8591900 100644
--- a/xmlhelp/source/cxxhelp/provider/urlparameter.hxx
+++ b/xmlhelp/source/cxxhelp/provider/urlparameter.hxx
@@ -91,7 +91,7 @@ namespace chelp {
 //running into a later problem with strings >= 255
 const char* pTitle = m_ptr + 3 + m_ptr[0] +  
static_cast(m_ptr[ 1+ static_cast(m_ptr[0]) ]);
 
-return OUString(pTitle, rtl_str_getLength(pTitle), 
RTL_TEXTENCODING_UTF8);
+return OStringToOUString(pTitle, strlen(pTitle), 
RTL_TEXTENCODING_UTF8);
 }
 
 


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

2023-03-09 Thread Yousef_Rabia (via logerrit)
 sal/osl/unx/system.hxx |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

New commits:
commit ddd2e00278eb489576eb4c63f44a1a034e7b9d8e
Author: Yousef_Rabia 
AuthorDate: Wed Mar 8 00:45:42 2023 +0200
Commit: Ilmari Lauhakangas 
CommitDate: Thu Mar 9 10:12:10 2023 +

tdf#143148 Use pragma once instead of include guards

Change-Id: I1c175753242783d83b5b1edc9b8b4cee2a5bd277
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148449
Tested-by: Jenkins
Tested-by: Ilmari Lauhakangas 
Reviewed-by: Ilmari Lauhakangas 

diff --git a/sal/osl/unx/system.hxx b/sal/osl/unx/system.hxx
index 02d8b06c3bf5..f70887c8c42f 100644
--- a/sal/osl/unx/system.hxx
+++ b/sal/osl/unx/system.hxx
@@ -17,8 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_SAL_OSL_UNX_SYSTEM_HXX
-#define INCLUDED_SAL_OSL_UNX_SYSTEM_HXX
+#pragma once
 
 #include 
 #include 
@@ -387,6 +386,4 @@ struct tm *gmtime_r(const time_t *timep, struct tm *buffer);
 #endif /* !defined(FREEBSD) */
 #endif
 
-#endif // INCLUDED_SAL_OSL_UNX_SYSTEM_H
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


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

2023-02-24 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/nlsupport.cxx |  162 +-
 1 file changed, 33 insertions(+), 129 deletions(-)

New commits:
commit d7fd46b5155bda021b09faecdefba26f6a59e997
Author: Mike Kaganski 
AuthorDate: Tue Feb 21 17:55:26 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Feb 24 17:50:14 2023 +

Simplify osl_getTextEncodingFromLocale on Windows

Drop all the complexity of thread-local storage used only to make
EnumSystemLocalesW thread-safe. Just create a BCP47 tag, and use
GetLocaleInfoEx to get the codepage.

Also use locale name API in imp_getProcessLocale, and avoid the
deprecated LCID API.

Change-Id: I223564cc6d2cc919b0e5aadda1c12beee21e49f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147625
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 

diff --git a/sal/osl/w32/nlsupport.cxx b/sal/osl/w32/nlsupport.cxx
index f27b97aa7101..1c3648d5a09c 100644
--- a/sal/osl/w32/nlsupport.cxx
+++ b/sal/osl/w32/nlsupport.cxx
@@ -24,11 +24,11 @@
 
 #include "nlsupport.hxx"
 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* XXX NOTE:
@@ -38,158 +38,62 @@
  * nine, including a terminating null character." NINE?!? In ISO 639 and ISO
  * 3166?
  */
-#define ELP_LANGUAGE_FIELD_LENGTH 4
-#define ELP_COUNTRY_FIELD_LENGTH  3
+constexpr int ELP_LANGUAGE_FIELD_LENGTH = 4;
+constexpr int ELP_COUNTRY_FIELD_LENGTH = 3;
 
-namespace {
-
-/** Struct used in EnumLocalesProcW() called via EnumSystemLocalesW() to obtain
-available locales.
-*/
-struct EnumLocalesParams
-{
-WCHAR Language[ELP_LANGUAGE_FIELD_LENGTH];
-WCHAR Country[ELP_COUNTRY_FIELD_LENGTH];
-LCID  Locale;
-};
-
-}
-
-static DWORD g_dwTLSLocaleEncId = DWORD(-1);
-
-/*
- * callback function test
- */
-
-static BOOL CALLBACK EnumLocalesProcW( LPWSTR lpLocaleStringW )
-{
-/* check params received via TLS */
-EnumLocalesParams * params = static_cast(TlsGetValue( 
g_dwTLSLocaleEncId ));
-if( nullptr == params || '\0' == params->Language[0] )
-return FALSE;
-
-LPWSTR pszEnd;
-WCHAR langCode[ELP_LANGUAGE_FIELD_LENGTH];
-
-/* convert hex-string to LCID */
-LCID localeId = wcstol(lpLocaleStringW, , 16);
-
-/*
-get the ISO language code for this locale
-*/
-if( !GetLocaleInfoW( localeId, LOCALE_SISO639LANGNAME , langCode, 
ELP_LANGUAGE_FIELD_LENGTH ) )
-/* retry by going on */
-return TRUE;
-
-WCHAR ctryCode[ELP_COUNTRY_FIELD_LENGTH];
-
-/* continue if language code does not match */
-if( 0 != wcscmp( langCode, params->Language ) )
-return TRUE;
-
-/* check if country code is set and equals the current locale */
-if( '\0' != params->Country[0] && GetLocaleInfoW( localeId,
-LOCALE_SISO3166CTRYNAME , ctryCode, ELP_COUNTRY_FIELD_LENGTH ) 
)
-{
-/* save return value in TLS and break if found desired locale */
-if( 0 == wcscmp( ctryCode, params->Country ) )
-{
-params->Locale = localeId;
-return FALSE;
-}
-}
-else
-{
-/* fill with default values for that language */
-LANGID langId = LANGIDFROMLCID( localeId );
-
-/* exchange sublanguage with SUBLANG_NEUTRAL */
-langId = MAKELANGID( PRIMARYLANGID( langId ), SUBLANG_NEUTRAL );
-
-/* and use default sorting order */
-params->Locale = MAKELCID( langId, SORT_DEFAULT );
-
-return FALSE;
-}
-
-/* retry by going on */
-return TRUE;
-}
-
-static rtl_TextEncoding GetTextEncodingFromLCID( LCID localeId )
+static int GetLocaleInfoN(LPCWSTR l, LCTYPE t, DWORD& n)
 {
-/* query ansi codepage for given locale */
-WCHAR ansiCP[6];
-if( !localeId || !GetLocaleInfoW( localeId, LOCALE_IDEFAULTANSICODEPAGE, 
ansiCP, 6 ) )
-return RTL_TEXTENCODING_DONTKNOW;
-
-/* if GetLocaleInfo returns "0", it is a UNICODE only locale */
-if( 0 == wcscmp( ansiCP, L"0" ) )
-return RTL_TEXTENCODING_UNICODE;
-
-/* values returned from GetLocaleInfo are decimal based */
-WCHAR *pwcEnd;
-UINT codepage = wcstol( ansiCP, , 10 );
-
-/* find matching rtl encoding */
-return rtl_getTextEncodingFromWindowsCodePage( codepage );
+return GetLocaleInfoEx(l, t | LOCALE_RETURN_NUMBER, 
reinterpret_cast(),
+   sizeof(n) / sizeof(WCHAR));
 }
 
 rtl_TextEncoding SAL_CALL osl_getTextEncodingFromLocale( rtl_Locale * pLocale )
 {
-struct EnumLocalesParams params = { L"", L"", 0 };
-
-/* initialise global TLS id */
-if( DWORD(-1) == g_dwTLSLocaleEncId )
-{
-oslMutex globalMutex = * osl_getGlobalMutex();
-
-/* initializing must be thread save */
-osl_acquireMutex( globalMutex );
-
-if( DWORD(-1) == 

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

2023-02-16 Thread Noel Grandin (via logerrit)
 sal/osl/unx/conditn.cxx |  169 +++-
 1 file changed, 25 insertions(+), 144 deletions(-)

New commits:
commit 65efe0e2783660780da7dc126e5f34422f312814
Author: Noel Grandin 
AuthorDate: Tue Feb 14 10:48:56 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Feb 16 09:00:51 2023 +

use std::condition_variable for oslCondition

which is both faster (because we don't need to allocate a pthread
condition) and simpler

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

diff --git a/sal/osl/unx/conditn.cxx b/sal/osl/unx/conditn.cxx
index 602240922b8c..16c4ad11b15f 100644
--- a/sal/osl/unx/conditn.cxx
+++ b/sal/osl/unx/conditn.cxx
@@ -20,9 +20,9 @@
 #include 
 
 #include 
+#include 
+#include 
 
-#include "system.hxx"
-#include "unixerrnostring.hxx"
 #include 
 #include 
 
@@ -33,48 +33,16 @@ namespace {
 
 struct oslConditionImpl
 {
-pthread_cond_t  m_Condition;
-pthread_mutex_t m_Lock;
-boolm_State;
+std::condition_variable  m_Condition;
+std::mutex  m_Lock;
+boolm_State = false;
 };
 
 }
 
 oslCondition SAL_CALL osl_createCondition()
 {
-oslConditionImpl* pCond;
-int nRet=0;
-
-pCond = static_cast(malloc(sizeof(oslConditionImpl)));
-
-if ( pCond == nullptr )
-{
-return nullptr;
-}
-
-pCond->m_State = false;
-
-/* init condition variable with default attr. (PTHREAD_PROCESS_PRIVAT) */
-nRet =  pthread_cond_init(>m_Condition, PTHREAD_CONDATTR_DEFAULT);
-if ( nRet != 0 )
-{
-SAL_WARN( "sal.osl.condition", "pthread_cond_init failed: " << 
UnixErrnoString(nRet) );
-
-free(pCond);
-return nullptr;
-}
-
-nRet = pthread_mutex_init(>m_Lock, PTHREAD_MUTEXATTR_DEFAULT);
-if ( nRet != 0 )
-{
-SAL_WARN( "sal.osl.condition", "pthread_mutex_init failed: " << 
UnixErrnoString(nRet) );
-
-nRet = pthread_cond_destroy(>m_Condition);
-SAL_WARN_IF( nRet != 0, "sal.osl.condition", "pthread_cond_destroy 
failed: " << UnixErrnoString(nRet) );
-
-free(pCond);
-pCond = nullptr;
-}
+oslConditionImpl* pCond = new oslConditionImpl;
 
 SAL_INFO( "sal.osl.condition", "osl_createCondition(): " << pCond );
 
@@ -90,48 +58,22 @@ void SAL_CALL osl_destroyCondition(oslCondition Condition)
 SAL_INFO( "sal.osl.condition", "osl_destroyCondition(" << pCond << ")" );
 
 if ( pCond )
-{
-int nRet = pthread_cond_destroy(>m_Condition);
-SAL_WARN_IF( nRet != 0, "sal.osl.condition", "pthread_cond_destroy 
failed: " << UnixErrnoString(nRet) );
-nRet = pthread_mutex_destroy(>m_Lock);
-SAL_WARN_IF( nRet != 0, "sal.osl.condition", "pthread_mutex_destroy 
failed: " << UnixErrnoString(nRet) );
-
-free(Condition);
-}
+delete pCond;
 }
 
 sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
 {
oslConditionImpl* pCond;
-   int nRet=0;
 
assert(Condition);
pCond = static_cast(Condition);
 
-   nRet = pthread_mutex_lock(>m_Lock);
-   if ( nRet != 0 )
{
-   SAL_WARN( "sal.osl.condition", "osl_setCondition(" << pCond << "): 
pthread_mutex_lock failed: " << UnixErrnoString(nRet) );
-   return false;
-   }
-
-   pCond->m_State = true;
-   nRet = pthread_cond_broadcast(>m_Condition);
-   if ( nRet != 0 )
-   {
-   SAL_WARN( "sal.osl.condition", "osl_setCondition(" << pCond << "): 
pthread_cond_broadcast failed: " << UnixErrnoString(nRet) );
-   // try to unlock the mutex
-   pthread_mutex_unlock(>m_Lock);
-   return false;
-   }
+   std::unique_lock g(pCond->m_Lock);
 
-   nRet = pthread_mutex_unlock(>m_Lock);
-   if ( nRet != 0 )
-   {
-   SAL_WARN( "sal.osl.condition", "osl_setCondition(" << pCond << "): 
pthread_mutex_unlock failed: " << UnixErrnoString(nRet) );
-   return false;
+   pCond->m_State = true;
+   pCond->m_Condition.notify_all();
}
-
SAL_INFO( "sal.osl.condition", "osl_setCondition(" << pCond << ")" );
 
return true;
@@ -141,28 +83,16 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
 sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
 {
 oslConditionImpl* pCond;
-int nRet=0;
 
 assert(Condition);
 
 pCond = static_cast(Condition);
 
-nRet = pthread_mutex_lock(>m_Lock);
-if ( nRet != 0 )
 {
-SAL_WARN( "sal.osl.condition", "osl_resetCondition(" << pCond << "): 
pthread_mutex_lock failed: " << UnixErrnoString(nRet) );
-return false;
-}
+std::unique_lock g(pCond->m_Lock);
 
-pCond->m_State = false;
-
-nRet = pthread_mutex_unlock(>m_Lock);
-if ( nRet != 0 )
-{
-SAL_WARN( "sal.osl.condition", "osl_resetCondition(" << pCond << "): 
pthread_mutex_unlock failed: " << UnixErrnoString(nRet) );
-return false;
+pCond->m_State 

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

2023-02-14 Thread Stephan Bergmann (via logerrit)
 sal/osl/all/log.cxx |   37 -
 1 file changed, 20 insertions(+), 17 deletions(-)

New commits:
commit e2d8474857e8b39efcdf21441c95ad51a8aef6e8
Author: Stephan Bergmann 
AuthorDate: Tue Feb 14 16:25:45 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Tue Feb 14 17:23:59 2023 +

Let +TIMESTAMP and +RELATIVETIMER use the same osl_getSystemTime

...so that the reported numbers add up if you specify both in SAL_LOG.  Also
make the code look more symmetric.

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

diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 235c7267d22e..e9895e14cb7b 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -207,13 +207,17 @@ void maybeOutputTimestamp(std::ostringstream ) {
 static const std::pair aEnvFlags = 
getTimestampFlags(getLogLevelEnvVar());
 const auto& [outputTimestamp, outputRelativeTimer] = (pLogSelector == 
nullptr ? aEnvFlags : getTimestampFlags(pLogSelector));
 
+if (!(outputTimestamp || outputRelativeTimer)) {
+return;
+}
+TimeValue now;
+osl_getSystemTime();
+
 if (outputTimestamp)
 {
 char ts[100];
-TimeValue systemTime;
-osl_getSystemTime();
 TimeValue localTime;
-osl_getLocalTimeFromSystemTime(, );
+osl_getLocalTimeFromSystemTime(, );
 oslDateTime dateTime;
 osl_getDateTimeFromTimeValue(, );
 struct tm tm;
@@ -231,23 +235,22 @@ void maybeOutputTimestamp(std::ostringstream ) {
  static_cast(dateTime.NanoSeconds / 100));
 s << ts << '.' << milliSecs << ':';
 }
-if (!outputRelativeTimer)
-return;
 
-TimeValue now;
-osl_getSystemTime();
-int seconds = now.Seconds - aStartTime.aTime.Seconds;
-int milliSeconds;
-if (now.Nanosec < aStartTime.aTime.Nanosec)
+if (outputRelativeTimer)
 {
-seconds--;
-milliSeconds = 1000 - (aStartTime.aTime.Nanosec - now.Nanosec) / 
100;
+int seconds = now.Seconds - aStartTime.aTime.Seconds;
+int milliSeconds;
+if (now.Nanosec < aStartTime.aTime.Nanosec)
+{
+seconds--;
+milliSeconds = 1000 - (aStartTime.aTime.Nanosec - now.Nanosec) / 
100;
+}
+else
+milliSeconds = (now.Nanosec - aStartTime.aTime.Nanosec) / 100;
+char relativeTimestamp[100];
+snprintf(relativeTimestamp, sizeof(relativeTimestamp), "%d.%03d", 
seconds, milliSeconds);
+s << relativeTimestamp << ':';
 }
-else
-milliSeconds = (now.Nanosec - aStartTime.aTime.Nanosec) / 100;
-char relativeTimestamp[100];
-snprintf(relativeTimestamp, sizeof(relativeTimestamp), "%d.%03d", seconds, 
milliSeconds);
-s << relativeTimestamp << ':';
 }
 
 #endif


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

2022-12-13 Thread Tor Lillqvist (via logerrit)
 sal/osl/unx/process_impl.cxx |8 
 1 file changed, 8 insertions(+)

New commits:
commit 9d3c6d56cee179ac01b2ff57a4129fc4c0a3da83
Author: Tor Lillqvist 
AuthorDate: Tue Dec 13 10:47:15 2022 +0200
Commit: Tor Lillqvist 
CommitDate: Tue Dec 13 10:43:43 2022 +

Add Emscripten ifdef to bootstrap_getExecutableFile()

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

diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx
index 5d7f7644feb0..a61df87c2cff 100644
--- a/sal/osl/unx/process_impl.cxx
+++ b/sal/osl/unx/process_impl.cxx
@@ -97,6 +97,13 @@ oslProcessError bootstrap_getExecutableFile(rtl_uString ** 
ppFileURL)
 {
 oslProcessError result = osl_Process_E_NotFound;
 
+#ifdef EMSCRIPTEN
+// Just return some dummy file: URL for now to see what happens
+OUString fileURL = "vnd.sun.star.pathname:/instdir/program/soffice";
+rtl_uString_acquire(fileURL.pData);
+*ppFileURL = fileURL.pData;
+return osl_Process_E_None;
+#else
 #ifdef ANDROID
 /* Now with just a single DSO, this one from lo-bootstrap.c is as good as
  * any */
@@ -136,6 +143,7 @@ oslProcessError bootstrap_getExecutableFile(rtl_uString ** 
ppFileURL)
 }
 
 return result;
+#endif
 }
 
 }


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

2022-12-04 Thread Arnaud VERSINI (via logerrit)
 sal/osl/all/log.cxx |2 --
 1 file changed, 2 deletions(-)

New commits:
commit d64aed0b44f3070b4a7ec2fecd6ea80a0b8c4bc8
Author: Arnaud VERSINI 
AuthorDate: Sat Dec 3 16:03:35 2022 +0100
Commit: Noel Grandin 
CommitDate: Sun Dec 4 13:07:02 2022 +

osl : remove useless includes

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

diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 405d5599ccae..235c7267d22e 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -17,8 +17,6 @@
 #include 
 #include 
 
-#include 
-#include 
 #include 
 
 #include 


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

2022-11-21 Thread Arnaud VERSINI (via logerrit)
 sal/osl/w32/file.cxx   |   73 +
 sal/osl/w32/thread.cxx |   11 ---
 2 files changed, 32 insertions(+), 52 deletions(-)

New commits:
commit d5f29872f5a149fc7905cdf340215c07af0d4da8
Author: Arnaud VERSINI 
AuthorDate: Sun Nov 20 17:46:10 2022 +0100
Commit: Noel Grandin 
CommitDate: Mon Nov 21 09:15:59 2022 +0100

sal/osl win32 : use non recursive mutexes in file and thread

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

diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index be921aede733..4c4c06f462fa 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef max /* conflict w/ std::numeric_limits::max() */
 #undef max
@@ -64,7 +65,7 @@ namespace {
 */
 struct FileHandle_Impl
 {
-CRITICAL_SECTION m_mutex;
+std::mutex   m_mutex;
 HANDLE   m_hFile;
 
 StateBits m_state;
@@ -127,32 +128,10 @@ struct FileHandle_Impl
 SIZE_T  nBytes);
 
 oslFileError syncFile();
-
-/** Guard.
- */
-class Guard
-{
-LPCRITICAL_SECTION m_mutex;
-
-public:
-explicit Guard(LPCRITICAL_SECTION pMutex);
-~Guard();
-};
 };
 
 }
 
-FileHandle_Impl::Guard::Guard(LPCRITICAL_SECTION pMutex)
-: m_mutex (pMutex)
-{
-assert(pMutex);
-::EnterCriticalSection (m_mutex);
-}
-
-FileHandle_Impl::Guard::~Guard()
-{
-::LeaveCriticalSection (m_mutex);
-}
 
 FileHandle_Impl::FileHandle_Impl(HANDLE hFile)
 : m_hFile   (hFile),
@@ -165,7 +144,6 @@ FileHandle_Impl::FileHandle_Impl(HANDLE hFile)
   m_bufsiz  (getpagesize()),
   m_buffer  (nullptr)
 {
-::InitializeCriticalSection (_mutex);
 m_buffer = static_cast(calloc(m_bufsiz, 1));
 }
 
@@ -173,7 +151,6 @@ FileHandle_Impl::~FileHandle_Impl()
 {
 free(m_buffer);
 m_buffer = nullptr;
-::DeleteCriticalSection (_mutex);
 }
 
 SIZE_T FileHandle_Impl::getpagesize()
@@ -679,7 +656,7 @@ oslFileError SAL_CALL osl_syncFile(oslFileHandle Handle)
 if ((!pImpl) || !IsValidHandle(pImpl->m_hFile))
 return osl_File_E_INVAL;
 
-FileHandle_Impl::Guard lock(&(pImpl->m_mutex));
+std::lock_guard lock(pImpl->m_mutex);
 
 oslFileError result = pImpl->syncFile();
 if (result != osl_File_E_None)
@@ -697,21 +674,23 @@ oslFileError SAL_CALL osl_closeFile(oslFileHandle Handle)
 if ((!pImpl) || !IsValidHandle(pImpl->m_hFile))
 return osl_File_E_INVAL;
 
-::EnterCriticalSection(&(pImpl->m_mutex));
-
-oslFileError result = pImpl->syncFile();
-if (result != osl_File_E_None)
-{
-/* ignore double failure */
-(void)::CloseHandle(pImpl->m_hFile);
-}
-else if (!::CloseHandle(pImpl->m_hFile))
+oslFileError result;
 {
-/* translate error code */
-result = oslTranslateFileError(GetLastError());
+std::lock_guard lock(pImpl->m_mutex);
+
+result = pImpl->syncFile();
+if (result != osl_File_E_None)
+{
+/* ignore double failure */
+(void)::CloseHandle(pImpl->m_hFile);
+}
+else if (!::CloseHandle(pImpl->m_hFile))
+{
+/* translate error code */
+result = oslTranslateFileError(GetLastError());
+}
 }
 
-::LeaveCriticalSection(&(pImpl->m_mutex));
 delete pImpl;
 return result;
 }
@@ -820,7 +799,7 @@ SAL_CALL osl_readLine(
 sal_uInt64 uBytesRead = 0;
 
 // read at current filepos; filepos += uBytesRead;
-FileHandle_Impl::Guard lock(&(pImpl->m_mutex));
+std::lock_guard lock(pImpl->m_mutex);
 oslFileError result = pImpl->readLineAt(
 pImpl->m_filepos, ppSequence, );
 if (result == osl_File_E_None)
@@ -839,7 +818,7 @@ oslFileError SAL_CALL osl_readFile(
 return osl_File_E_INVAL;
 
 // read at current filepos; filepos += *pBytesRead;
-FileHandle_Impl::Guard lock(&(pImpl->m_mutex));
+std::lock_guard lock(pImpl->m_mutex);
 oslFileError result = pImpl->readFileAt(
 pImpl->m_filepos, pBuffer, uBytesRequested, pBytesRead);
 if (result == osl_File_E_None)
@@ -859,7 +838,7 @@ oslFileError SAL_CALL osl_writeFile(
 return osl_File_E_INVAL;
 
 // write at current filepos; filepos += *pBytesWritten;
-FileHandle_Impl::Guard lock(&(pImpl->m_mutex));
+std::lock_guard lock(pImpl->m_mutex);
 oslFileError result = pImpl->writeFileAt(
 pImpl->m_filepos, pBuffer, uBytesToWrite, pBytesWritten);
 if (result == osl_File_E_None)
@@ -899,7 +878,7 @@ oslFileError SAL_CALL osl_readFileAt(
 LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset);
 
 // read at specified fileptr
-FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
+std::lock_guard lock (pImpl->m_mutex);
 return pImpl->readFileAt(nOffset, pBuffer, 

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

2022-11-17 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/tempfile.cxx |6 --
 1 file changed, 6 deletions(-)

New commits:
commit d6a3510ebc04dd5f24366f5b6426060cb149c3ff
Author: Stephan Bergmann 
AuthorDate: Thu Nov 17 11:55:52 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Nov 17 15:18:35 2022 +0100

Revert "TempFile: clear handle on close"

This reverts commit 0d9613b77fc653c6144b5e4f0136c0536300c0db:  As discussed 
in
the comments at


"TempFile: clear handle on close", that change was intended to reset 
*pHandle to
null in cases where osl_createTempFile returns an error and has already set
*pHandle.  But that is obviously not what the change actually does, it 
rather
sets *pHandle to null in (only some of the) cases where osl_createTempFile
returns an error and has not modified *pHandle.  Given that there may
potentially be clients that rely on osl_createTempFile not modifying the 
passed
in *pHandle when it returns an error, and given that the
sal/osl/unx/tempfile.cxx implementation of osl_createTempFile now 
inconsistently
set *pHandle to null in only some of the cases where it returns an error 
while
the sal/osl/w32/tempfile.cxx implementation of osl_createTempFile never sets
*pHandle to null when it returns an error, it appears best to just revert 
that
change.

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

diff --git a/sal/osl/unx/tempfile.cxx b/sal/osl/unx/tempfile.cxx
index 3a7138b5218d..29a4d453f80c 100644
--- a/sal/osl/unx/tempfile.cxx
+++ b/sal/osl/unx/tempfile.cxx
@@ -330,13 +330,7 @@ oslFileError SAL_CALL osl_createTempFile(
 }
 
 if (temp_file_handle)
-{
 osl_closeFile(temp_file_handle);
-if (pHandle)
-{
-*pHandle = nullptr;
-}
-}
 
 rtl_uString_release(base_directory);
 


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

2022-11-11 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/file_misc.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit b74d50003145f3805e3316a51c8be0222e680152
Author: Stephan Bergmann 
AuthorDate: Thu Nov 10 18:59:54 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Fri Nov 11 15:40:45 2022 +0100

Drop useless std::move of const object

...introduced with d8b60f77f389a248f98aa45592e6e1045baafbe1 
"rtl_String->OString
in DirectoryItem_Impl".

(I came across this code with an upcoming loplugin:constmove that flags
suspicious uses of std::move involving const-qualified types.)

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

diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index c411b78cc260..01842dc73154 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -330,9 +330,9 @@ oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory 
pDirectory,
 pImpl = nullptr;
 }
 #ifdef _DIRENT_HAVE_D_TYPE
-pImpl = new DirectoryItem_Impl(std::move(strFilePath), pEntry->d_type);
+pImpl = new DirectoryItem_Impl(strFilePath, pEntry->d_type);
 #else
-pImpl = new DirectoryItem_Impl(std::move(strFilePath));
+pImpl = new DirectoryItem_Impl(strFilePath);
 #endif /* _DIRENT_HAVE_D_TYPE */
 *pItem = pImpl;
 


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

2022-11-07 Thread Dr. David Alan Gilbert (via logerrit)
 sal/osl/unx/file.cxx |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit 503195ad4df320da568fe089b4d0de2f761be660
Author: Dr. David Alan Gilbert 
AuthorDate: Sat Nov 5 18:50:15 2022 +
Commit: Noel Grandin 
CommitDate: Mon Nov 7 09:11:30 2022 +0100

file: Use calloc

Current code does, malloc->memset,  that's what calloc is for.

Change-Id: Ie3a4872249f78442b96f98c9dad9d7170afe784c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142345
Reviewed-by: Noel Grandin 
Tested-by: Noel Grandin 

diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index ac93ffacd13f..a39365b9b115 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -202,9 +202,7 @@ FileHandle_Impl::FileHandle_Impl(int fd, enum Kind kind, 
OString path)
 if (pagesize != size_t(-1))
 {
 m_bufsiz = pagesize;
-m_buffer = static_cast(malloc(m_bufsiz));
-if (m_buffer)
-memset(m_buffer, 0, m_bufsiz);
+m_buffer = static_cast(calloc(1, m_bufsiz));
 }
 }
 }


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

2022-11-07 Thread Dr. David Alan Gilbert (via logerrit)
 sal/osl/unx/tempfile.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 0d9613b77fc653c6144b5e4f0136c0536300c0db
Author: Dr. David Alan Gilbert 
AuthorDate: Sat Nov 5 18:44:05 2022 +
Commit: Noel Grandin 
CommitDate: Mon Nov 7 09:11:04 2022 +0100

TempFile: clear handle on close

If we close the file on error, then clear the handle we returned to
the caller so it doesn't try and close it again or do anything else
with it.

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

diff --git a/sal/osl/unx/tempfile.cxx b/sal/osl/unx/tempfile.cxx
index 29a4d453f80c..3a7138b5218d 100644
--- a/sal/osl/unx/tempfile.cxx
+++ b/sal/osl/unx/tempfile.cxx
@@ -330,7 +330,13 @@ oslFileError SAL_CALL osl_createTempFile(
 }
 
 if (temp_file_handle)
+{
 osl_closeFile(temp_file_handle);
+if (pHandle)
+{
+*pHandle = nullptr;
+}
+}
 
 rtl_uString_release(base_directory);
 


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

2022-09-23 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/file_url.cxx |  101 +--
 1 file changed, 81 insertions(+), 20 deletions(-)

New commits:
commit b60dc48bb48bec63b21eb9c2ef705af64d9b9069
Author: Mike Kaganski 
AuthorDate: Fri Sep 23 17:59:59 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Sep 23 19:16:14 2022 +0200

tdf#151117: Process non-existent long paths correctly

Regression after commit 92e835dbf00590c9c29509d2995cc7918a9bbb90
  Author Kunal Pawar 
  Date   Fri Feb 18 19:15:04 2022 +0530
tdf#98705 Replace GetCaseCorrectPathName with GetLongPathNameW

The fix tries to keep the performance improvement, and when the path
exists, it will only call GetLongPathNameW once. Anyway, for unclear
reason, this normalization only happens on long paths.

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

diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index 57d5fee5b320..8c525042ddef 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -41,14 +41,14 @@
 
 #include "path_helper.hxx"
 
-#define WSTR_SYSTEM_ROOT_PATH   u".\\"
-#define WSTR_LONG_PATH_PREFIX   u"?\\"
-#define WSTR_LONG_PATH_PREFIX_UNC   u"?\\UNC\\"
-
 // FileURL functions
 
 namespace
 {
+constexpr std::u16string_view WSTR_SYSTEM_ROOT_PATH = u".\\";
+constexpr std::u16string_view WSTR_LONG_PATH_PREFIX = u"?\\";
+constexpr std::u16string_view WSTR_LONG_PATH_PREFIX_UNC = u"?\\UNC\\";
+
 // Internal functions that expect only backslashes as path separators
 
 bool startsWithDriveColon(std::u16string_view s)
@@ -308,13 +308,13 @@ DWORD IsValidFilePath(const OUString& path, DWORD 
dwFlags, OUString* corrected)
 if (path.matchIgnoreAsciiCase(WSTR_LONG_PATH_PREFIX_UNC))
 {
 /* This is long path in UNC notation */
-oComponent = 
path.subView(SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1);
+oComponent = path.subView(WSTR_LONG_PATH_PREFIX_UNC.size());
 dwCandidatPathType = PATHTYPE_ABSOLUTE_UNC | PATHTYPE_IS_LONGPATH;
 }
 else if (path.matchIgnoreAsciiCase(WSTR_LONG_PATH_PREFIX))
 {
 /* This is long path */
-oComponent = path.subView(SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 
1);
+oComponent = path.subView(WSTR_LONG_PATH_PREFIX.size());
 
 if (startsWithDriveColon(*oComponent))
 {
@@ -567,6 +567,71 @@ static OUString osl_encodeURL_(std::u16string_view sURL)
 return sEncodedURL.makeStringAndClear();
 }
 
+// A helper that makes sure that for existing part of the path, the case is 
correct.
+// Unlike GetLongPathNameW that it wraps, this function does not require the 
path to exist.
+static OUString GetCaseCorrectPathName(std::u16string_view sysPath)
+{
+// Prepare a null-terminated string first.
+// Neither OUString, nor u16string_view are guaranteed to be 
null-terminated
+osl::LongPathBuffer szPath(sysPath.size() + 
WSTR_LONG_PATH_PREFIX_UNC.size() + 1);
+wchar_t* const pPath = szPath;
+wchar_t* pEnd = pPath;
+size_t sysPathOffset = 0;
+if (sysPath.size() >= MAX_PATH && isAbsolute(sysPath)
+&& !o3tl::starts_with(sysPath, WSTR_LONG_PATH_PREFIX))
+{
+// Allow GetLongPathNameW consume long paths
+std::u16string_view prefix = WSTR_LONG_PATH_PREFIX;
+if (startsWithSlashSlash(sysPath))
+{
+sysPathOffset = 2; // skip leading "\\"
+prefix = WSTR_LONG_PATH_PREFIX_UNC;
+}
+pEnd = std::copy(prefix.begin(), prefix.end(), pEnd);
+}
+wchar_t* const pStart = pEnd;
+pEnd = std::copy(sysPath.begin() + sysPathOffset, sysPath.end(), pStart);
+*pEnd = 0;
+osl::LongPathBuffer aBuf(MAX_LONG_PATH);
+while (pEnd > pStart)
+{
+std::u16string_view curPath(o3tl::toU(pPath), pEnd - pPath);
+if (curPath == u"" || curPath == WSTR_SYSTEM_ROOT_PATH
+|| curPath == WSTR_LONG_PATH_PREFIX
+|| o3tl::equalsIgnoreAsciiCase(curPath, WSTR_LONG_PATH_PREFIX_UNC))
+break; // Do not check if the special path prefix exists itself
+
+DWORD nNewLen = GetLongPathNameW(pPath, aBuf, 
aBuf.getBufSizeInSymbols());
+if (nNewLen == 0)
+{
+// Error?
+const DWORD err = GetLastError();
+if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
+{
+// Check the base path; skip possible trailing separator
+size_t sepPos = curPath.substr(0, curPath.size() - 
1).rfind(u'\\');
+if (sepPos != std::u16string_view::npos)
+{
+pEnd = pPath + sepPos;
+*pEnd = 0;
+continue;
+}
+}
+ 

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

2022-09-16 Thread Stephan Bergmann (via logerrit)
 sal/osl/w32/file_url.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit b040cf97c343076d8b98b16b5275df663cb86669
Author: Stephan Bergmann 
AuthorDate: Fri Sep 16 15:28:42 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Sep 16 17:37:11 2022 +0200

OUString::matchIgnoreAsciiCase returns bool

Regression introduced with d2272426cc79d9aacf4a34c5fd7744b59c29e95b "Use 
some
more C++ in sal/osl/w32", found with loplugin:implicitboolconversion.

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

diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index 390b58beed63..57d5fee5b320 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -581,7 +581,7 @@ oslFileError osl_getSystemPathFromFileURL_(const OUString& 
strURL, rtl_uString *
 
 SAL_WARN_IF(
 sUTF8.getLength() != strURL.getLength() &&
-0 == strURL.matchIgnoreAsciiCase("file:\\")
+strURL.matchIgnoreAsciiCase("file:\\")
 , "sal.osl"
 ,"osl_getSystemPathFromFileURL: \"" << strURL << "\" is not encoded 
!!!");
 


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

2022-09-13 Thread Caolán McNamara (via logerrit)
 sal/osl/unx/security.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit f0f0d385b91df30d4ec42a9f727cbdbe5ce0861f
Author: Caolán McNamara 
AuthorDate: Wed Sep 7 17:08:38 2022 +0100
Commit: Caolán McNamara 
CommitDate: Tue Sep 13 09:56:12 2022 +0200

cid#1509232 silence Out-of-bounds access

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

diff --git a/sal/osl/unx/security.cxx b/sal/osl/unx/security.cxx
index 1b1f16a54edc..b15ec9e773b0 100644
--- a/sal/osl/unx/security.cxx
+++ b/sal/osl/unx/security.cxx
@@ -106,6 +106,8 @@ static oslSecurityImpl * growSecurityImpl(
 }
 p = static_cast(realloc(impl, n));
 if (p != nullptr) {
+// coverity[overrun-buffer-arg] - theoretically massive n is not 
due to
+// a negative parameter being interpreted as unsigned
 memset (p, 0, n);
 }
 }


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

2022-09-07 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/security.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 1bd83f0f6ad3d9fa84b4eae38b3393526e233771
Author: Stephan Bergmann 
AuthorDate: Wed Sep 7 18:22:27 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Wed Sep 7 21:39:41 2022 +0200

Be careful with failed realloc

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

diff --git a/sal/osl/unx/security.cxx b/sal/osl/unx/security.cxx
index f541c90001b3..1b1f16a54edc 100644
--- a/sal/osl/unx/security.cxx
+++ b/sal/osl/unx/security.cxx
@@ -105,7 +105,9 @@ static oslSecurityImpl * growSecurityImpl(
 n = std::numeric_limits::max();
 }
 p = static_cast(realloc(impl, n));
-memset (p, 0, n);
+if (p != nullptr) {
+memset (p, 0, n);
+}
 }
 if (p == nullptr) {
 free(impl);


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

2022-08-30 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/file.cxx|   60 ++--
 sal/osl/w32/file_dirvol.cxx |   85 ---
 sal/osl/w32/file_url.cxx|  312 
 sal/osl/w32/file_url.hxx|   10 -
 sal/osl/w32/tempfile.cxx|   18 --
 5 files changed, 213 insertions(+), 272 deletions(-)

New commits:
commit d2272426cc79d9aacf4a34c5fd7744b59c29e95b
Author: Mike Kaganski 
AuthorDate: Mon Aug 29 10:14:53 2022 +0300
Commit: Mike Kaganski 
CommitDate: Tue Aug 30 12:41:51 2022 +0200

Use some more C++ in sal/osl/w32

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

diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index 57d95e14dfed..be921aede733 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -640,8 +640,8 @@ oslFileError SAL_CALL osl_openFile(
 oslFileHandle * pHandle,
 sal_uInt32  uFlags)
 {
-rtl_uString * strSysPath = nullptr;
-oslFileError result = osl_getSystemPathFromFileURL_(strPath, , 
false);
+OUString strSysPath;
+oslFileError result = 
osl_getSystemPathFromFileURL_(OUString::unacquired(), 
, false);
 if (result != osl_File_E_None)
 return result;
 
@@ -661,7 +661,7 @@ oslFileError SAL_CALL osl_openFile(
 dwCreation |= OPEN_EXISTING;
 
 HANDLE hFile = CreateFileW(
-o3tl::toW(rtl_uString_getStr(strSysPath)),
+o3tl::toW(strSysPath.getStr()),
 dwAccess, dwShare, nullptr, dwCreation, 0, nullptr);
 
 // @@@ ERROR HANDLING @@@
@@ -670,7 +670,6 @@ oslFileError SAL_CALL osl_openFile(
 
 *pHandle = osl_createFileHandleFromOSHandle(hFile, uFlags | 
osl_File_OpenFlag_Read);
 
-rtl_uString_release(strSysPath);
 return result;
 }
 
@@ -1030,33 +1029,31 @@ oslFileError SAL_CALL osl_setFileSize(oslFileHandle 
Handle, sal_uInt64 uSize)
 
 oslFileError SAL_CALL osl_removeFile(rtl_uString* strPath)
 {
-rtl_uString *strSysPath = nullptr;
-oslFileErrorerror = osl_getSystemPathFromFileURL_(strPath, 
, false);
+OUString strSysPath;
+oslFileErrorerror = 
osl_getSystemPathFromFileURL_(OUString::unacquired(), 
, false);
 
 if (error == osl_File_E_None)
 {
-if (DeleteFileW(o3tl::toW(rtl_uString_getStr(strSysPath
+if (DeleteFileW(o3tl::toW(strSysPath.getStr(
 error = osl_File_E_None;
 else
 error = oslTranslateFileError(GetLastError());
-
-rtl_uString_release(strSysPath);
 }
 return error;
 }
 
 oslFileError SAL_CALL osl_copyFile(rtl_uString* strPath, rtl_uString 
*strDestPath)
 {
-rtl_uString *strSysPath = nullptr, *strSysDestPath = nullptr;
-oslFileErrorerror = osl_getSystemPathFromFileURL_(strPath, 
, false);
+OUString strSysPath, strSysDestPath;
+oslFileErrorerror = 
osl_getSystemPathFromFileURL_(OUString::unacquired(), 
, false);
 
 if (error == osl_File_E_None)
-error = osl_getSystemPathFromFileURL_(strDestPath, , 
false);
+error = 
osl_getSystemPathFromFileURL_(OUString::unacquired(), 
, false);
 
 if (error == osl_File_E_None)
 {
-LPCWSTR src = o3tl::toW(rtl_uString_getStr(strSysPath));
-LPCWSTR dst = o3tl::toW(rtl_uString_getStr(strSysDestPath));
+LPCWSTR src = o3tl::toW(strSysPath.getStr());
+LPCWSTR dst = o3tl::toW(strSysDestPath.getStr());
 
 if (CopyFileW(src, dst, FALSE))
 error = osl_File_E_None;
@@ -1064,26 +1061,21 @@ oslFileError SAL_CALL osl_copyFile(rtl_uString* 
strPath, rtl_uString *strDestPat
 error = oslTranslateFileError(GetLastError());
 }
 
-if (strSysPath)
-rtl_uString_release(strSysPath);
-if (strSysDestPath)
-rtl_uString_release(strSysDestPath);
-
 return error;
 }
 
 oslFileError SAL_CALL osl_moveFile(rtl_uString* strPath, rtl_uString 
*strDestPath)
 {
-rtl_uString *strSysPath = nullptr, *strSysDestPath = nullptr;
-oslFileErrorerror = osl_getSystemPathFromFileURL_(strPath, 
, false);
+OUString strSysPath, strSysDestPath;
+oslFileErrorerror = 
osl_getSystemPathFromFileURL_(OUString::unacquired(), 
, false);
 
 if (error == osl_File_E_None)
-error = osl_getSystemPathFromFileURL_(strDestPath, , 
false);
+error = 
osl_getSystemPathFromFileURL_(OUString::unacquired(), 
, false);
 
 if (error == osl_File_E_None)
 {
-LPCWSTR src = o3tl::toW(rtl_uString_getStr(strSysPath));
-LPCWSTR dst = o3tl::toW(rtl_uString_getStr(strSysDestPath));
+LPCWSTR src = o3tl::toW(strSysPath.getStr());
+LPCWSTR dst = o3tl::toW(strSysDestPath.getStr());
 
 if (MoveFileExW(src, dst, MOVEFILE_COPY_ALLOWED | 
MOVEFILE_WRITE_THROUGH | MOVEFILE_REPLACE_EXISTING))
 error = osl_File_E_None;
@@ -1091,26 +1083,21 @@ oslFileError SAL_CALL osl_moveFile(rtl_uString* 
strPath, rtl_uString *strDestPat
 error 

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

2022-08-23 Thread Caolán McNamara (via logerrit)
 sal/osl/unx/file_misc.cxx |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

New commits:
commit 1c8ad4c95bd99dc6f8a105c109c725cbe92def26
Author: Caolán McNamara 
AuthorDate: Tue Aug 16 09:00:46 2022 +0100
Commit: Caolán McNamara 
CommitDate: Tue Aug 23 12:37:54 2022 +0200

cid#1509185 Logically dead code

do oslDoCopyFile only for S_ISREG. openFilePath (called from oslDoCopyFile)
returns osl_File_E_INVAL for !S_ISREG so use EINVAL as the error code here
to produce osl_File_E_INVAL too.

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

diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index b2d6010fe847..c411b78cc260 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -850,21 +850,18 @@ static oslFileError oslDoCopy(const char* 
pszSourceFileName, const char* pszDest
 }
 }
 
-/* mfe: should be S_ISREG */
-if ( !S_ISLNK(nMode) )
+if ( S_ISREG(nMode) )
 {
 /* copy SourceFile to DestFile */
 nRet = oslDoCopyFile(pszSourceFileName,pszDestFileName,nSourceSize, 
nMode);
 }
-/* mfe: OK redundant at the moment */
 else if ( S_ISLNK(nMode) )
 {
 nRet = oslDoCopyLink(pszSourceFileName,pszDestFileName);
 }
 else
 {
-/* mfe: what to do here? */
-nRet=ENOSYS;
+nRet = EINVAL;
 }
 
 if ( nRet > 0 && DestFileExists )


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

2022-08-09 Thread Caolán McNamara (via logerrit)
 sal/osl/w32/tempfile.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2d074a0b98c9150d2f15056ea86dcc9305f43ab3
Author: Caolán McNamara 
AuthorDate: Tue Aug 9 11:38:47 2022 +0100
Commit: Caolán McNamara 
CommitDate: Tue Aug 9 16:49:54 2022 +0200

crashreporting: frequent crash seen in PackedFile::flush

at:

if (osl::File::E_None == osl::FileBase::createTempFile(nullptr, , 
))
{

if (osl_File_E_None == osl_writeFile(aHandle, ...

createTempFile is returning osl::File::E_None but presumably we are
missing setting a possible error state here

https: 
//crashreport.libreoffice.org/stats/crash_details/ea4b4050-dd0f-42b1-b30f-b67612806371
Change-Id: Ib2d0c3c91e40fe985571e79822b91f2faf401471
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138013
Reviewed-by: Stephan Bergmann 
Tested-by: Jenkins

diff --git a/sal/osl/w32/tempfile.cxx b/sal/osl/w32/tempfile.cxx
index a4c272e57768..5d5d758ce244 100644
--- a/sal/osl/w32/tempfile.cxx
+++ b/sal/osl/w32/tempfile.cxx
@@ -192,7 +192,7 @@ oslFileError SAL_CALL osl_createTempFile(
 
 if (tmp_name)
 {
-osl_createTempFile_impl_(
+osl_error = osl_createTempFile_impl_(
 base_directory,
 tmp_name,
 b_delete_on_close,


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

2022-07-20 Thread Christian Lohmaier (via logerrit)
 sal/osl/unx/thread.cxx |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 1844326df477eb379f281e6f027fc8e6475f28bf
Author: Christian Lohmaier 
AuthorDate: Wed Jul 20 17:42:30 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Wed Jul 20 21:52:52 2022 +0200

tdf#141421 xml export: default stacksize for threads on macOS is too small

libxslt usage means lots of recursion for the sample document and the 
default
for non-main threads is 512kB, see
https://developer.apple.com/library/archive/qa/qa1419/_index.html
and contrary to linux it doesn't default to the value set via ulimit.

https://docs.microsoft.com/en-us/windows/win32/procthread/thread-stack-size
says default for Windows is 1MB, so use that as a new default.
(on linux it effectively is 8MB via ulimit, if not specified it would 
default
to 2MB for most architectures)

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

diff --git a/sal/osl/unx/thread.cxx b/sal/osl/unx/thread.cxx
index 54e674dd4de5..b122c5f31f3f 100644
--- a/sal/osl/unx/thread.cxx
+++ b/sal/osl/unx/thread.cxx
@@ -280,7 +280,7 @@ static oslThread osl_thread_create_Impl (
 short nFlags)
 {
 Thread_Impl* pImpl;
-#if defined OPENBSD || ((defined MACOSX || defined LINUX) && 
!ENABLE_RUNTIME_OPTIMIZATIONS)
+#if defined OPENBSD || defined MACOSX || (defined LINUX && 
!ENABLE_RUNTIME_OPTIMIZATIONS)
 pthread_attr_t attr;
 size_t stacksize;
 #endif
@@ -296,14 +296,16 @@ static oslThread osl_thread_create_Impl (
 
 pthread_mutex_lock (&(pImpl->m_Lock));
 
-#if defined OPENBSD || ((defined MACOSX || defined LINUX) && 
!ENABLE_RUNTIME_OPTIMIZATIONS)
+#if defined OPENBSD || defined MACOSX || (defined LINUX && 
!ENABLE_RUNTIME_OPTIMIZATIONS)
 if (pthread_attr_init() != 0)
 return nullptr;
 
 #if defined OPENBSD
 stacksize = 262144;
-#else
+#elif !ENABLE_RUNTIME_OPTIMIZATIONS
 stacksize = 12 * 1024 * 1024; // 8MB is not enough for ASAN on x86-64
+#else
+stacksize = 1 * 1024 * 1024; // macOS default for non-main threads (512kB) 
is not enough...
 #endif
 if (pthread_attr_setstacksize(, stacksize) != 0) {
 pthread_attr_destroy();
@@ -313,7 +315,7 @@ static oslThread osl_thread_create_Impl (
 
 if ((nRet = pthread_create (
 &(pImpl->m_hThread),
-#if defined OPENBSD || ((defined MACOSX || defined LINUX) && 
!ENABLE_RUNTIME_OPTIMIZATIONS)
+#if defined OPENBSD || defined MACOSX || (defined LINUX && 
!ENABLE_RUNTIME_OPTIMIZATIONS)
 ,
 #else
 PTHREAD_ATTR_DEFAULT,
@@ -331,7 +333,7 @@ static oslThread osl_thread_create_Impl (
 return nullptr;
 }
 
-#if defined OPENBSD || ((defined MACOSX || defined LINUX) && 
!ENABLE_RUNTIME_OPTIMIZATIONS)
+#if defined OPENBSD || defined MACOSX || (defined LINUX && 
!ENABLE_RUNTIME_OPTIMIZATIONS)
 pthread_attr_destroy();
 #endif
 


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

2022-07-02 Thread Noel Grandin (via logerrit)
 sal/osl/unx/uunxapi.cxx |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 05e037a9f104bba0749bd3c75d36ba581ea663cf
Author: Noel Grandin 
AuthorDate: Fri Jul 1 09:56:21 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat Jul 2 10:21:57 2022 +0200

fix --enable-macosx-sandbox build

after
commit eecc113e6f6e51e5e37059235c1069dc9c4c1cc8
Date:   Sat May 21 08:30:29 2022 +0200
rtl_String->OString in sal

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

diff --git a/sal/osl/unx/uunxapi.cxx b/sal/osl/unx/uunxapi.cxx
index 0aff1e469e04..5311bc71917f 100644
--- a/sal/osl/unx/uunxapi.cxx
+++ b/sal/osl/unx/uunxapi.cxx
@@ -363,7 +363,7 @@ int osl::mkdir(const OString& path, mode_t mode)
 
 int open_c(const OString& path, int oflag, int mode)
 {
-accessFilePathState *state = prepare_to_access_file_path(cpPath);
+accessFilePathState *state = prepare_to_access_file_path(path.getStr());
 
 int result = open(path.getStr(), oflag, mode);
 int saved_errno = errno;
@@ -382,9 +382,10 @@ int open_c(const OString& path, int oflag, int mode)
 // scoped bookmark for it so that we can access the file in
 // the future, too. (For the "Recent Files" functionality.)
 const char *sandbox = [NSHomeDirectory() UTF8String];
-if (!(strncmp(sandbox, cpPath, strlen(sandbox)) == 0 &&
-  cpPath[strlen(sandbox)] == '/'))
+if (!(strncmp(sandbox, path.getStr(), strlen(sandbox)) == 0 &&
+  path[strlen(sandbox)] == '/'))
 {
+auto cpPath = path.getStr();
 NSURL *url = [NSURL fileURLWithPath:[NSString 
stringWithUTF8String:cpPath]];
 NSData *data = [url 
bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope
  includingResourceValuesForKeys:nil
@@ -399,7 +400,7 @@ int open_c(const OString& path, int oflag, int mode)
 }
 #endif
 
-done_accessing_file_path(path, state);
+done_accessing_file_path(path.getStr(), state);
 
 errno = saved_errno;
 


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

2022-05-30 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/tempfile.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit bbcf26337cd2933205248909c55d5c1d161e9b9b
Author: Stephan Bergmann 
AuthorDate: Mon May 30 09:33:49 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Mon May 30 12:48:28 2022 +0200

Avoid uninitialized temp_file_handle

...in case osl_create_temp_file_impl_ doesn't assign to it, for whatever
osl_error reason, which then apparently leads to


SIGSEGV at (relative to libreoffice-7-1)

> 0  libuno_sal.so.3  osl_closeFile   
sal/osl/unx/file.cxx:1154
> 1  libuno_sal.so.3  osl_createTempFile  
sal/osl/unx/tempfile.cxx:330
> 2  libmergedlo.so   PackedFile::flush   
include/osl/file.hxx:310
> 3  libmergedlo.so   comphelper::BackupFileHelper::tryPush_file  
comphelper/source/misc/backupfilehelper.cxx:2090
[...]

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

diff --git a/sal/osl/unx/tempfile.cxx b/sal/osl/unx/tempfile.cxx
index bd8e88db742c..29a4d453f80c 100644
--- a/sal/osl/unx/tempfile.cxx
+++ b/sal/osl/unx/tempfile.cxx
@@ -278,7 +278,7 @@ oslFileError SAL_CALL osl_createTempFile(
 rtl_uString**  ppustrTempFileURL)
 {
 rtl_uString*  base_directory = nullptr;
-oslFileHandle temp_file_handle;
+oslFileHandle temp_file_handle = nullptr;
 bool  b_delete_on_close;
 oslFileError  osl_error;
 


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

2022-05-23 Thread Noel Grandin (via logerrit)
 sal/osl/unx/file.cxx  |   47 --
 sal/osl/unx/file_impl.hxx |2 -
 2 files changed, 26 insertions(+), 23 deletions(-)

New commits:
commit 476b1fa176f00ec8128ae72b48dfde11096ed85a
Author: Noel Grandin 
AuthorDate: Mon May 23 18:47:15 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon May 23 20:14:33 2022 +0200

Revert "[API CHANGE] call ftruncate instead of ftruncate_by_name"

This reverts commit 1d58828f2285064635ed776e0641e83ee26d34da.

because we need the filename for "sandboxed LibreOffice on OS X" 
functionality

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

diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index caa7f5dd57e9..ac93ffacd13f 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -82,6 +82,7 @@ namespace {
 struct FileHandle_Impl
 {
 pthread_mutex_t m_mutex;
+OString m_strFilePath; /*< holds native file path */
 int m_fd;
 
 enum Kind
@@ -108,7 +109,7 @@ struct FileHandle_Impl
 rtl_String*  m_memstreambuf; /*< used for in-memory streams */
 #endif
 
-explicit FileHandle_Impl(int fd, Kind kind = KIND_FD);
+explicit FileHandle_Impl(int fd, Kind kind = KIND_FD, OString path = 
"");
 ~FileHandle_Impl();
 
 static size_t getpagesize();
@@ -181,8 +182,9 @@ FileHandle_Impl::Guard::~Guard()
 (void) pthread_mutex_unlock(m_mutex);
 }
 
-FileHandle_Impl::FileHandle_Impl(int fd, enum Kind kind)
-: m_fd  (fd),
+FileHandle_Impl::FileHandle_Impl(int fd, enum Kind kind, OString path)
+: m_strFilePath(std::move(path)),
+  m_fd  (fd),
   m_kind(kind),
   m_state   (State::Seekable | State::Readable),
   m_size(0),
@@ -242,7 +244,7 @@ sal_uInt64 FileHandle_Impl::getSize() const
 oslFileError FileHandle_Impl::setSize(sal_uInt64 uSize)
 {
 off_t const nSize = sal::static_int_cast< off_t >(uSize);
-if (ftruncate(m_fd, nSize) == -1)
+if (ftruncate_with_name(m_fd, nSize, m_strFilePath) == -1)
 {
 /* Failure. Save original result. Try fallback algorithm */
 oslFileError result = oslTranslateFileError(errno);
@@ -730,12 +732,12 @@ oslFileHandle osl::detail::createFileHandleFromFD(int fd)
 pImpl->m_size = sal::static_int_cast< sal_uInt64 >(aFileStat.st_size);
 }
 
-SAL_INFO("sal.file", "osl::detail::createFileHandleFromFD(" << pImpl->m_fd 
<< ", writeable)");
+SAL_INFO("sal.file", "osl::detail::createFileHandleFromFD(" << pImpl->m_fd 
<< ", writeable) => " << pImpl->m_strFilePath);
 
 return static_cast(pImpl);
 }
 
-static int osl_file_adjustLockFlags(const char* cpPath, int flags)
+static int osl_file_adjustLockFlags(const OString& path, int flags)
 {
 #ifdef MACOSX
 /*
@@ -746,7 +748,7 @@ static int osl_file_adjustLockFlags(const char* cpPath, int 
flags)
  * for the filesystem name.
  */
 struct statfs s;
-if(statfs(cpPath, ) >= 0)
+if(statfs(path.getStr(), ) >= 0)
 {
 if(strncmp("afpfs", s.f_fstypename, 5) == 0)
 {
@@ -760,7 +762,7 @@ static int osl_file_adjustLockFlags(const char* cpPath, int 
flags)
 }
 }
 #else
-(void) cpPath;
+(void) path;
 #endif
 
 return flags;
@@ -796,12 +798,13 @@ static bool osl_file_queryLocking(sal_uInt32 uFlags)
 namespace {
 
 static oslFileError openMemoryAsFile(const OString ,
- oslFileHandle *pHandle)
+ oslFileHandle *pHandle,
+ const OString& path)
 {
 const char *address = rData.getStr();
 size_t size = rData.getLength();
 
-FileHandle_Impl *pImpl = new FileHandle_Impl(-1, 
FileHandle_Impl::KIND_MEM);
+FileHandle_Impl *pImpl = new FileHandle_Impl(-1, 
FileHandle_Impl::KIND_MEM, path);
 pImpl->m_size = sal::static_int_cast< sal_uInt64 >(size);
 
 *pHandle = (oslFileHandle)(pImpl);
@@ -871,7 +874,7 @@ private:
 
 #endif
 
-oslFileError openFilePath(const char* cpFilePath, oslFileHandle* pHandle,
+oslFileError openFilePath(const OString& filePath, oslFileHandle* pHandle,
   sal_uInt32 uFlags, mode_t mode)
 {
 oslFileError eRet;
@@ -880,16 +883,16 @@ oslFileError openFilePath(const char* cpFilePath, 
oslFileHandle* pHandle,
 /* Opening a file from /assets read-only means
  * we should mmap it from the .apk file
  */
-if (o3tl::starts_with(cpFilePath, "/assets/"))
+if (o3tl::starts_with(filePath, "/assets/"))
 {
 OString aData;
 bool bCache = true;
 
-const char *cpAssetsPath = cpFilePath + sizeof("/assets/") - 1;
+const char *cpAssetsPath = filePath.getStr() + sizeof("/assets/") - 1;
 // some requests are /assets//foo...
 if (cpAssetsPath[0] == '/')
 {
-

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

2022-05-23 Thread Noel Grandin (via logerrit)
 sal/osl/unx/file_url.cxx |4 ++--
 sal/osl/unx/file_url.hxx |2 +-
 sal/osl/unx/tempfile.cxx |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 72582e9fb3d634a28c1466126bbe8e36fc00b446
Author: Noel Grandin 
AuthorDate: Mon May 23 09:33:51 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon May 23 17:26:15 2022 +0200

rename osl_getSystemPathFromFileURL_Ex->getSystemPathFromFileURL_Ex

so I can more readily distinguish between functions that are actually in
the OSL API and functions that are not

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

diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index 2e21684eba8f..4b5a16885cb3 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -444,7 +444,7 @@ oslFileError SAL_CALL osl_getFileURLFromSystemPath( 
rtl_uString *ustrSystemPath,
 /*
  * relative URLs are not accepted
  */
-oslFileError osl_getSystemPathFromFileURL_Ex(
+oslFileError getSystemPathFromFileURL_Ex(
 rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath)
 {
 rtl_uString* temp = nullptr;
@@ -711,7 +711,7 @@ oslFileError osl_getAbsoluteFileURL(
 if (systemPathIsRelativePath(unresolved_path))
 {
 OUString base_path;
-oslFileError rc = osl_getSystemPathFromFileURL_Ex(ustrBaseDirURL, 
_path.pData);
+oslFileError rc = getSystemPathFromFileURL_Ex(ustrBaseDirURL, 
_path.pData);
 if (rc != osl_File_E_None)
 return rc;
 
diff --git a/sal/osl/unx/file_url.hxx b/sal/osl/unx/file_url.hxx
index f9f31eb2056a..3ffd9e06bace 100644
--- a/sal/osl/unx/file_url.hxx
+++ b/sal/osl/unx/file_url.hxx
@@ -27,7 +27,7 @@ namespace rtl {
 class OUString;
 }
 
-oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, 
rtl_uString **pustrSystemPath);
+oslFileError getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString 
**pustrSystemPath);
 
 oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* 
ustrFileURL);
 
diff --git a/sal/osl/unx/tempfile.cxx b/sal/osl/unx/tempfile.cxx
index 00ae0664b2c0..bd8e88db742c 100644
--- a/sal/osl/unx/tempfile.cxx
+++ b/sal/osl/unx/tempfile.cxx
@@ -127,7 +127,7 @@ static oslFileError osl_setup_base_directory_impl_(
 
 if (error == osl_File_E_None)
 {
-error = osl_getSystemPathFromFileURL_Ex(dir_url, );
+error = getSystemPathFromFileURL_Ex(dir_url, );
 rtl_uString_release(dir_url);
 }
 


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

2022-05-23 Thread Noel Grandin (via logerrit)
 sal/osl/unx/file.cxx  |   13 -
 sal/osl/unx/file_impl.hxx |3 ---
 sal/osl/unx/file_misc.cxx |9 -
 sal/osl/w32/file.cxx  |   12 
 4 files changed, 37 deletions(-)

New commits:
commit e1b3a6edd4b3400c25aa135d75bd1ad19b279609
Author: Noel Grandin 
AuthorDate: Mon May 23 09:12:51 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon May 23 15:25:04 2022 +0200

no need to override 'operator new' in FileHandle_Impl

it's been a while since we had our own allocator

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

diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 351d1457e89b..caa7f5dd57e9 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -111,9 +111,6 @@ struct FileHandle_Impl
 explicit FileHandle_Impl(int fd, Kind kind = KIND_FD);
 ~FileHandle_Impl();
 
-static void* operator new (size_t n);
-static void  operator delete (void * p);
-
 static size_t getpagesize();
 
 sal_uInt64   getPos() const;
@@ -221,16 +218,6 @@ FileHandle_Impl::~FileHandle_Impl()
 (void) pthread_mutex_destroy(_mutex); // ignoring EBUSY ...
 }
 
-void* FileHandle_Impl::operator new (size_t n)
-{
-return malloc(n);
-}
-
-void FileHandle_Impl::operator delete (void * p)
-{
-free(p);
-}
-
 size_t FileHandle_Impl::getpagesize()
 {
 return sal::static_int_cast< size_t >(::sysconf(_SC_PAGESIZE));
diff --git a/sal/osl/unx/file_impl.hxx b/sal/osl/unx/file_impl.hxx
index a4e0c66adc57..6d5e2d740913 100644
--- a/sal/osl/unx/file_impl.hxx
+++ b/sal/osl/unx/file_impl.hxx
@@ -35,9 +35,6 @@ struct DirectoryItem_Impl
 OString strFilePath, unsigned char DType = 0);
 ~DirectoryItem_Impl();
 
-static void * operator new(size_t n);
-static void operator delete (void * p);
-
 void acquire(); /* @see osl_acquireDirectoryItem() */
 void release(); /* @see osl_releaseDirectoryItem() */
 
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 50fdcc040765..b2d6010fe847 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -94,15 +94,6 @@ DirectoryItem_Impl::~DirectoryItem_Impl()
 {
 }
 
-void * DirectoryItem_Impl::operator new(size_t n)
-{
-return malloc(n);
-}
-void DirectoryItem_Impl::operator delete(void * p)
-{
-free(p);
-}
-
 void DirectoryItem_Impl::acquire()
 {
 ++m_RefCount;
diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index 96b2bba4b486..57d95e14dfed 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -83,8 +83,6 @@ struct FileHandle_Impl
 explicit  FileHandle_Impl (HANDLE hFile);
   ~FileHandle_Impl();
 
-static void*  operator new(size_t n);
-static void   operator delete(void * p, size_t);
 static SIZE_T getpagesize();
 
 sal_uInt64getPos() const;
@@ -178,16 +176,6 @@ FileHandle_Impl::~FileHandle_Impl()
 ::DeleteCriticalSection (_mutex);
 }
 
-void * FileHandle_Impl::operator new(size_t n)
-{
-return malloc(n);
-}
-
-void FileHandle_Impl::operator delete(void * p, size_t)
-{
-free(p);
-}
-
 SIZE_T FileHandle_Impl::getpagesize()
 {
 SYSTEM_INFO info;


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

2022-05-23 Thread Noel Grandin (via logerrit)
 sal/osl/unx/file_impl.hxx |4 ++--
 sal/osl/unx/file_misc.cxx |   14 +-
 sal/osl/unx/file_stat.cxx |6 +++---
 3 files changed, 10 insertions(+), 14 deletions(-)

New commits:
commit d8b60f77f389a248f98aa45592e6e1045baafbe1
Author: Noel Grandin 
AuthorDate: Mon May 23 09:21:19 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon May 23 14:32:41 2022 +0200

rtl_String->OString in DirectoryItem_Impl

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

diff --git a/sal/osl/unx/file_impl.hxx b/sal/osl/unx/file_impl.hxx
index 078474cf05ff..a4e0c66adc57 100644
--- a/sal/osl/unx/file_impl.hxx
+++ b/sal/osl/unx/file_impl.hxx
@@ -27,12 +27,12 @@
 
 struct DirectoryItem_Impl
 {
-rtl_String *  m_strFilePath;   /* holds native file name */
+OString   m_strFilePath;   /* holds native file name */
 sal_Int32 m_RefCount;
 unsigned char m_DType;
 
 explicit DirectoryItem_Impl(
-rtl_String * strFilePath, unsigned char DType = 0);
+OString strFilePath, unsigned char DType = 0);
 ~DirectoryItem_Impl();
 
 static void * operator new(size_t n);
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index fee04804ea19..50fdcc040765 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -84,18 +84,14 @@ struct DirectoryImpl
 }
 
 DirectoryItem_Impl::DirectoryItem_Impl(
-rtl_String * strFilePath, unsigned char DType)
-: m_strFilePath (strFilePath),
+OString strFilePath, unsigned char DType)
+: m_strFilePath (std::move(strFilePath)),
   m_RefCount (1),
   m_DType(DType)
 {
-if (m_strFilePath != nullptr)
-rtl_string_acquire(m_strFilePath);
 }
 DirectoryItem_Impl::~DirectoryItem_Impl()
 {
-if (m_strFilePath != nullptr)
-rtl_string_release(m_strFilePath);
 }
 
 void * DirectoryItem_Impl::operator new(size_t n)
@@ -343,9 +339,9 @@ oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory 
pDirectory,
 pImpl = nullptr;
 }
 #ifdef _DIRENT_HAVE_D_TYPE
-pImpl = new DirectoryItem_Impl(strFilePath.pData, pEntry->d_type);
+pImpl = new DirectoryItem_Impl(std::move(strFilePath), pEntry->d_type);
 #else
-pImpl = new DirectoryItem_Impl(strFilePath.pData);
+pImpl = new DirectoryItem_Impl(std::move(strFilePath));
 #endif /* _DIRENT_HAVE_D_TYPE */
 *pItem = pImpl;
 
@@ -372,7 +368,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString* 
ustrFileURL, oslDirector
 }
 else
 {
-*pItem = new DirectoryItem_Impl(strSystemPath.pData);
+*pItem = new DirectoryItem_Impl(std::move(strSystemPath));
 }
 
 return osl_error;
diff --git a/sal/osl/unx/file_stat.cxx b/sal/osl/unx/file_stat.cxx
index d08a6ed56894..3b702905cb99 100644
--- a/sal/osl/unx/file_stat.cxx
+++ b/sal/osl/unx/file_stat.cxx
@@ -191,7 +191,7 @@ namespace
 if ((pImpl == nullptr) || (pStat == nullptr))
 return osl_File_E_INVAL;
 
-file_path = OString(pImpl->m_strFilePath);
+file_path = pImpl->m_strFilePath;
 OSL_ASSERT(!file_path.isEmpty());
 if (file_path.isEmpty())
 return osl_File_E_INVAL;
@@ -443,8 +443,8 @@ SAL_CALL osl_identicalDirectoryItem( oslDirectoryItem a, 
oslDirectoryItem b)
 
 struct stat a_stat, b_stat;
 
-if (osl::lstat(OString(pA->m_strFilePath), a_stat) != 0 ||
-osl::lstat(OString(pB->m_strFilePath), b_stat) != 0)
+if (osl::lstat(pA->m_strFilePath, a_stat) != 0 ||
+osl::lstat(pB->m_strFilePath, b_stat) != 0)
 return false;
 
 return (a_stat.st_ino == b_stat.st_ino);


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

2022-05-22 Thread Noel Grandin (via logerrit)
 sal/osl/unx/file.cxx  |   47 +-
 sal/osl/unx/file_impl.hxx |2 -
 2 files changed, 23 insertions(+), 26 deletions(-)

New commits:
commit 1d58828f2285064635ed776e0641e83ee26d34da
Author: Noel Grandin 
AuthorDate: Sat May 21 12:30:21 2022 +0200
Commit: Noel Grandin 
CommitDate: Sun May 22 14:00:31 2022 +0200

[API CHANGE] call ftruncate instead of ftruncate_by_name

The actual point of this change is making osl_fileOpen faster by
avoiding constructing and storing an OString. But that requires changing
to using ftruncate on the filehandle, which is arguably more
correct anyway, using the filename to truncate in the presence
of unlink() is dubious

Change-Id: I8bc5022e1d1afb53fb4e2fd920e43e5daaf74ec4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134704
Tested-by: Noel Grandin 
Reviewed-by: Noel Grandin 

diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index cbf6e4fa57b6..351d1457e89b 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -82,7 +82,6 @@ namespace {
 struct FileHandle_Impl
 {
 pthread_mutex_t m_mutex;
-OString m_strFilePath; /*< holds native file path */
 int m_fd;
 
 enum Kind
@@ -109,7 +108,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);
 ~FileHandle_Impl();
 
 static void* operator new (size_t n);
@@ -185,9 +184,8 @@ FileHandle_Impl::Guard::~Guard()
 (void) pthread_mutex_unlock(m_mutex);
 }
 
-FileHandle_Impl::FileHandle_Impl(int fd, enum Kind kind, OString path)
-: m_strFilePath(std::move(path)),
-  m_fd  (fd),
+FileHandle_Impl::FileHandle_Impl(int fd, enum Kind kind)
+: m_fd  (fd),
   m_kind(kind),
   m_state   (State::Seekable | State::Readable),
   m_size(0),
@@ -257,7 +255,7 @@ sal_uInt64 FileHandle_Impl::getSize() const
 oslFileError FileHandle_Impl::setSize(sal_uInt64 uSize)
 {
 off_t const nSize = sal::static_int_cast< off_t >(uSize);
-if (ftruncate_with_name(m_fd, nSize, m_strFilePath) == -1)
+if (ftruncate(m_fd, nSize) == -1)
 {
 /* Failure. Save original result. Try fallback algorithm */
 oslFileError result = oslTranslateFileError(errno);
@@ -745,12 +743,12 @@ oslFileHandle osl::detail::createFileHandleFromFD(int fd)
 pImpl->m_size = sal::static_int_cast< sal_uInt64 >(aFileStat.st_size);
 }
 
-SAL_INFO("sal.file", "osl::detail::createFileHandleFromFD(" << pImpl->m_fd 
<< ", writeable) => " << pImpl->m_strFilePath);
+SAL_INFO("sal.file", "osl::detail::createFileHandleFromFD(" << pImpl->m_fd 
<< ", writeable)");
 
 return static_cast(pImpl);
 }
 
-static int osl_file_adjustLockFlags(const OString& path, int flags)
+static int osl_file_adjustLockFlags(const char* cpPath, int flags)
 {
 #ifdef MACOSX
 /*
@@ -761,7 +759,7 @@ static int osl_file_adjustLockFlags(const OString& path, 
int flags)
  * for the filesystem name.
  */
 struct statfs s;
-if(statfs(path.getStr(), ) >= 0)
+if(statfs(cpPath, ) >= 0)
 {
 if(strncmp("afpfs", s.f_fstypename, 5) == 0)
 {
@@ -775,7 +773,7 @@ static int osl_file_adjustLockFlags(const OString& path, 
int flags)
 }
 }
 #else
-(void) path;
+(void) cpPath;
 #endif
 
 return flags;
@@ -811,13 +809,12 @@ static bool osl_file_queryLocking(sal_uInt32 uFlags)
 namespace {
 
 static oslFileError openMemoryAsFile(const OString ,
- oslFileHandle *pHandle,
- const OString& path)
+ oslFileHandle *pHandle)
 {
 const char *address = rData.getStr();
 size_t size = rData.getLength();
 
-FileHandle_Impl *pImpl = new FileHandle_Impl(-1, 
FileHandle_Impl::KIND_MEM, path);
+FileHandle_Impl *pImpl = new FileHandle_Impl(-1, 
FileHandle_Impl::KIND_MEM);
 pImpl->m_size = sal::static_int_cast< sal_uInt64 >(size);
 
 *pHandle = (oslFileHandle)(pImpl);
@@ -887,7 +884,7 @@ private:
 
 #endif
 
-oslFileError openFilePath(const OString& filePath, oslFileHandle* pHandle,
+oslFileError openFilePath(const char* cpFilePath, oslFileHandle* pHandle,
   sal_uInt32 uFlags, mode_t mode)
 {
 oslFileError eRet;
@@ -896,16 +893,16 @@ oslFileError openFilePath(const OString& filePath, 
oslFileHandle* pHandle,
 /* Opening a file from /assets read-only means
  * we should mmap it from the .apk file
  */
-if (o3tl::starts_with(filePath, "/assets/"))
+if (o3tl::starts_with(cpFilePath, "/assets/"))
 {
 OString aData;
 bool bCache = true;
 
-const char *cpAssetsPath = filePath.getStr() + sizeof("/assets/") - 1;
+const char *cpAssetsPath = cpFilePath + 

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

2022-05-21 Thread Noel Grandin (via logerrit)
 sal/osl/unx/file.cxx  |   42 --
 sal/osl/unx/file_impl.hxx |3 ++-
 sal/osl/unx/uunxapi.cxx   |   12 ++--
 sal/osl/unx/uunxapi.hxx   |4 ++--
 4 files changed, 30 insertions(+), 31 deletions(-)

New commits:
commit eecc113e6f6e51e5e37059235c1069dc9c4c1cc8
Author: Noel Grandin 
AuthorDate: Sat May 21 08:30:29 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat May 21 11:17:22 2022 +0200

rtl_String->OString in sal

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

diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index d8396f6279b6..cbf6e4fa57b6 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -81,7 +82,7 @@ namespace {
 struct FileHandle_Impl
 {
 pthread_mutex_t m_mutex;
-rtl_String *m_strFilePath; /*< holds native file path */
+OString m_strFilePath; /*< holds native file path */
 int m_fd;
 
 enum Kind
@@ -108,7 +109,7 @@ struct FileHandle_Impl
 rtl_String*  m_memstreambuf; /*< used for in-memory streams */
 #endif
 
-explicit FileHandle_Impl(int fd, Kind kind = KIND_FD, char const * path = 
"");
+explicit FileHandle_Impl(int fd, Kind kind = KIND_FD, OString path = 
"");
 ~FileHandle_Impl();
 
 static void* operator new (size_t n);
@@ -184,8 +185,8 @@ FileHandle_Impl::Guard::~Guard()
 (void) pthread_mutex_unlock(m_mutex);
 }
 
-FileHandle_Impl::FileHandle_Impl(int fd, enum Kind kind, char const * path)
-: m_strFilePath(nullptr),
+FileHandle_Impl::FileHandle_Impl(int fd, enum Kind kind, OString path)
+: m_strFilePath(std::move(path)),
   m_fd  (fd),
   m_kind(kind),
   m_state   (State::Seekable | State::Readable),
@@ -198,7 +199,6 @@ FileHandle_Impl::FileHandle_Impl(int fd, enum Kind kind, 
char const * path)
   m_buffer  (nullptr)
 {
 (void) pthread_mutex_init(_mutex, nullptr);
-rtl_string_newFromStr(_strFilePath, path);
 if (m_kind == KIND_FD)
 {
 size_t const pagesize = getpagesize();
@@ -220,8 +220,6 @@ FileHandle_Impl::~FileHandle_Impl()
 m_buffer = nullptr;
 }
 
-rtl_string_release(m_strFilePath);
-m_strFilePath = nullptr;
 (void) pthread_mutex_destroy(_mutex); // ignoring EBUSY ...
 }
 
@@ -752,7 +750,7 @@ oslFileHandle osl::detail::createFileHandleFromFD(int fd)
 return static_cast(pImpl);
 }
 
-static int osl_file_adjustLockFlags(const char *path, int flags)
+static int osl_file_adjustLockFlags(const OString& path, int flags)
 {
 #ifdef MACOSX
 /*
@@ -763,7 +761,7 @@ static int osl_file_adjustLockFlags(const char *path, int 
flags)
  * for the filesystem name.
  */
 struct statfs s;
-if(statfs(path, ) >= 0)
+if(statfs(path.getStr(), ) >= 0)
 {
 if(strncmp("afpfs", s.f_fstypename, 5) == 0)
 {
@@ -814,7 +812,7 @@ namespace {
 
 static oslFileError openMemoryAsFile(const OString ,
  oslFileHandle *pHandle,
- const char *path)
+ const OString& path)
 {
 const char *address = rData.getStr();
 size_t size = rData.getLength();
@@ -889,7 +887,7 @@ private:
 
 #endif
 
-oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle,
+oslFileError openFilePath(const OString& filePath, oslFileHandle* pHandle,
   sal_uInt32 uFlags, mode_t mode)
 {
 oslFileError eRet;
@@ -898,16 +896,16 @@ oslFileError openFilePath(const char *cpFilePath, 
oslFileHandle* pHandle,
 /* Opening a file from /assets read-only means
  * we should mmap it from the .apk file
  */
-if (strncmp(cpFilePath, "/assets/", sizeof ("/assets/") - 1) == 0)
+if (o3tl::starts_with(filePath, "/assets/"))
 {
 OString aData;
 bool bCache = true;
 
-const char *cpAssetsPath = cpFilePath + sizeof("/assets/") - 1;
+const char *cpAssetsPath = filePath.getStr() + sizeof("/assets/") - 1;
 // some requests are /assets//foo...
 if (cpAssetsPath[0] == '/')
 {
-__android_log_print(ANDROID_LOG_DEBUG,"libo:sal/osl/unx/file", 
"double-slash in path: %s", cpFilePath);
+__android_log_print(ANDROID_LOG_DEBUG,"libo:sal/osl/unx/file", 
"double-slash in path: %s", filePath.getStr());
 cpAssetsPath++;
 }
 
@@ -922,7 +920,7 @@ oslFileError openFilePath(const char *cpFilePath, 
oslFileHandle* pHandle,
 if (pMiss)
 {
 errno = ENOENT;
-__android_log_print(ANDROID_LOG_ERROR,"libo:sal/osl/unx/file", 
"miss cache: failed to open %s", cpFilePath);
+__android_log_print(ANDROID_LOG_ERROR,"libo:sal/osl/unx/file", 
"miss cache: failed to open 

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

2022-05-14 Thread Noel Grandin (via logerrit)
 sal/osl/unx/thread.cxx |   16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

New commits:
commit 60ba608b33b993ea9dc9cead84bd2d62f2ed50e1
Author: Noel Grandin 
AuthorDate: Fri May 13 11:09:07 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat May 14 13:45:47 2022 +0200

pthread_mutex_t->std::mutex in lookupThreadId

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

diff --git a/sal/osl/unx/thread.cxx b/sal/osl/unx/thread.cxx
index ce5ece7c1d59..54e674dd4de5 100644
--- a/sal/osl/unx/thread.cxx
+++ b/sal/osl/unx/thread.cxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "system.hxx"
 #include "unixerrnostring.hxx"
@@ -598,7 +599,7 @@ struct HashEntry
 static HashEntry* HashTable[31];
 const int HashSize = SAL_N_ELEMENTS(HashTable);
 
-static pthread_mutex_t HashLock = PTHREAD_MUTEX_INITIALIZER;
+static std::mutex HashLock;
 
 #if ! ((defined LINUX && !defined __FreeBSD_kernel__) || defined MACOSX || 
defined IOS)
 static oslThreadIdentifier LastIdent = 0;
@@ -615,21 +616,18 @@ static oslThreadIdentifier lookupThreadId (pthread_t 
hThread)
 {
 HashEntry *pEntry;
 
-pthread_mutex_lock();
+std::unique_lock aGuard(HashLock);
 
 pEntry = HashTable[HASHID(hThread)];
 while (pEntry != nullptr)
 {
 if (pthread_equal(pEntry->Handle, hThread))
 {
-pthread_mutex_unlock();
 return pEntry->Ident;
 }
 pEntry = pEntry->Next;
 }
 
-pthread_mutex_unlock();
-
 return 0;
 }
 
@@ -637,7 +635,7 @@ static oslThreadIdentifier insertThreadId (pthread_t 
hThread)
 {
 HashEntry *pEntry, *pInsert = nullptr;
 
-pthread_mutex_lock();
+std::unique_lock aGuard(HashLock);
 
 pEntry = HashTable[HASHID(hThread)];
 
@@ -694,8 +692,6 @@ static oslThreadIdentifier insertThreadId (pthread_t 
hThread)
 HashTable[HASHID(hThread)] = pEntry;
 }
 
-pthread_mutex_unlock();
-
 return pEntry->Ident;
 }
 
@@ -703,7 +699,7 @@ static void removeThreadId (pthread_t hThread)
 {
 HashEntry *pEntry, *pRemove = nullptr;
 
-pthread_mutex_lock();
+std::unique_lock aGuard(HashLock);
 
 pEntry = HashTable[HASHID(hThread)];
 while (pEntry != nullptr)
@@ -724,8 +720,6 @@ static void removeThreadId (pthread_t hThread)
 
 free(pEntry);
 }
-
-pthread_mutex_unlock();
 }
 
 oslThreadIdentifier SAL_CALL osl_getThreadIdentifier(oslThread Thread)


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

2022-04-12 Thread Shady Mohamed (via logerrit)
 sal/osl/w32/sockimpl.hxx |5 +
 sal/osl/w32/thread.hxx   |5 +
 2 files changed, 2 insertions(+), 8 deletions(-)

New commits:
commit 4d27d087de2922f918a76437a1385dc4a287afc3
Author: Shady Mohamed 
AuthorDate: Mon Apr 11 21:45:19 2022 +0200
Commit: Ilmari Lauhakangas 
CommitDate: Tue Apr 12 10:29:28 2022 +0200

tdf#143148 Use pragma once instead of include guards

Change-Id: I6262d64edcff4e73f2b148e98a62ee8d4b0d3294
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132839
Tested-by: Jenkins
Reviewed-by: Ilmari Lauhakangas 

diff --git a/sal/osl/w32/sockimpl.hxx b/sal/osl/w32/sockimpl.hxx
index 44aeced6b3e6..72b204a2e0fd 100644
--- a/sal/osl/w32/sockimpl.hxx
+++ b/sal/osl/w32/sockimpl.hxx
@@ -17,8 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_SAL_OSL_W32_SOCKIMPL_HXX
-#define INCLUDED_SAL_OSL_W32_SOCKIMPL_HXX
+#pragma once
 
 #include 
 #include 
@@ -40,6 +39,4 @@ struct oslSocketAddrImpl
 oslSocket osl_createSocketImpl_(SOCKET Socket);
 void osl_destroySocketImpl_(oslSocket pImpl);
 
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/w32/thread.hxx b/sal/osl/w32/thread.hxx
index 8740fb72cc56..8002d8b7f855 100644
--- a/sal/osl/w32/thread.hxx
+++ b/sal/osl/w32/thread.hxx
@@ -7,8 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#ifndef INCLUDED_SAL_OSL_W32_THREAD_HXX
-#define INCLUDED_SAL_OSL_W32_THREAD_HXX
+#pragma once
 
 #include 
 
@@ -16,6 +15,4 @@
 
 void osl_callThreadKeyCallbackOnThreadDetach(void);
 
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */


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

2022-03-24 Thread Stephan Bergmann (via logerrit)
 sal/osl/w32/file_url.cxx |   87 ---
 1 file changed, 87 deletions(-)

New commits:
commit 0d22aa485110df0ada7761e2c7930f704fbc4bfa
Author: Stephan Bergmann 
AuthorDate: Thu Mar 24 07:51:56 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Mar 24 10:43:31 2022 +0100

-Werror,-Wunused-function

...after 92e835dbf00590c9c29509d2995cc7918a9bbb90 "tdf#98705 Replace
GetCaseCorrectPathName with GetLongPathNameW"

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

diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index 1fcdc1728696..c452a3624977 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -455,93 +455,6 @@ DWORD IsValidFilePath(rtl_uString *path, DWORD dwFlags, 
rtl_uString **corrected)
 return bValid ? dwPathType : PATHTYPE_ERROR;
 }
 
-// Expects a proper absolute or relative path
-static sal_Int32 PathRemoveFileSpec(LPWSTR lpPath, LPWSTR lpFileName, 
sal_Int32 nFileBufLen )
-{
-sal_Int32 nRemoved = 0;
-
-if (nFileBufLen && wcscmp(lpPath, L"") != 0) // tdf#98343 do not 
remove leading UNC backslashes!
-{
-lpFileName[0] = 0;
-LPWSTR  lpLastBkSlash = wcsrchr( lpPath, '\\' );
-LPWSTR  lpLastSlash = wcsrchr( lpPath, '/' );
-LPWSTR  lpLastDelimiter = std::max(lpLastSlash, lpLastBkSlash);
-
-if ( lpLastDelimiter )
-{
-sal_Int32 nDelLen = wcslen( lpLastDelimiter );
-if ( 1 == nDelLen )
-{
-if ( lpLastDelimiter > lpPath && *(lpLastDelimiter - 1) != 
':' )
-{
-*lpLastDelimiter = 0;
-*lpFileName = 0;
-nRemoved = nDelLen;
-}
-}
-else if ( nDelLen && nDelLen - 1 < nFileBufLen )
-{
-wcscpy( lpFileName, lpLastDelimiter + 1 );
-*(++lpLastDelimiter) = 0;
-nRemoved = nDelLen - 1;
-}
-}
-}
-
-return nRemoved;
-}
-
-// Undocumented in SHELL32.DLL ordinal 32
-static LPWSTR PathAddBackslash(LPWSTR lpPath, sal_uInt32 nBufLen)
-{
-LPWSTR  lpEndPath = nullptr;
-
-if ( lpPath )
-{
-std::size_t nLen = wcslen(lpPath);
-
-if ( !nLen || ( lpPath[nLen-1] != '\\' && lpPath[nLen-1] != '/' && 
nLen < nBufLen - 1 ) )
-{
-lpEndPath = lpPath + nLen;
-*lpEndPath++ = '\\';
-*lpEndPath = 0;
-}
-}
-return lpEndPath;
-}
-
-// True if the szPath + szFile is just a special prefix, not a path which we 
may test for existence.
-// E.g., \\ or \\server or \\server\share or \\? or \\?\UNC or \\?\UNC\server 
or \\?\UNC\server\share
-static bool IsPathSpecialPrefix(LPWSTR szPath, LPWSTR szFile)
-{
-if (szPath[0] == '\\' && szPath[1] == '\\')
-{
-if (szPath[2] == 0)
-return true; // "\\" -> now the server name or "." or "?" will 
append
-else if (szPath[2] == '?' && szPath[3] == '\\')
-{
-if (szPath[4] == 0)
-return wcscmp(szFile, L"UNC") == 0; // "\\?\" -> now "UNC" 
will append
-else
-{
-if (wcsncmp(szPath + 4, L"UNC\\", 4) == 0)
-{
-if (szPath[8] == 0)
-return true; // "\\?\UNC\" -> now the server name will 
append
-else if (const wchar_t* pBackSlash = wcschr(szPath + 8, 
'\\'))
-return *(pBackSlash + 1) == 0; // "\\?\UNC\Server\" -> 
now share name will append
-}
-}
-}
-else if (szPath[2] != '.')
-{
-if (const wchar_t* pBackSlash = wcschr(szPath + 2, '\\'))
-return *(pBackSlash + 1) == 0; // "\\Server\" -> now share 
name will append
-}
-}
-return false;
-}
-
 static std::optional osl_decodeURL_(const OString& sUTF8)
 {
 const char  *pSrcEnd;


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

2022-03-04 Thread Julien Nabet (via logerrit)
 sal/osl/w32/file_dirvol.cxx |3 ---
 1 file changed, 3 deletions(-)

New commits:
commit ef0e15aaefad8347fc4a3c71771de07e370eda2f
Author: Julien Nabet 
AuthorDate: Fri Mar 4 17:38:21 2022 +0100
Commit: Julien Nabet 
CommitDate: Fri Mar 4 20:41:31 2022 +0100

Remove useless comment on a commented line since always 
(sal/w32/file_dirvol)

git history gives:
commit b76cb86eaa0aec1d02c5ff29c5a43e1e7a675b27
Author: Oliver Bolte 
Date:   Wed Sep 9 09:38:41 2009 +

CWS-TOOLING: integrate CWS mhu20

where it was already commented and from sal/osl/w32/file.cxx

then digging a bit more gives:
commit 73cd79644d4355de483b0d0c04fba034ac02795b
Author: Rüdiger Timm 
Date:   Mon Oct 17 13:52:03 2005 +

INTEGRATION: CWS perform05 (1.5.52); FILE MERGED

where it's also already commented.

=> No need to keep this

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

diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index f5995f8de391..dc90f474dcfe 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -1019,9 +1019,6 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString 
*strFilePath, oslDirector
 CopyMemory(>FindData, , 
sizeof(WIN32_FIND_DATAW));
 pItemImpl->m_sFullPath = strSysFilePath;
 
-// MT: This costs 600ms startup time on fast v60x!
-// GetCaseCorrectPathName( pItemImpl->szFullPath, 
pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) );
-
 pItemImpl->uType = DIRECTORYITEM_FILE;
 *pItem = pItemImpl;
 }


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

2022-03-04 Thread Kunal Pawar (via logerrit)
 sal/osl/w32/file_dirvol.cxx |   18 -
 sal/osl/w32/file_url.cxx|  133 
 sal/osl/w32/file_url.hxx|7 --
 3 files changed, 15 insertions(+), 143 deletions(-)

New commits:
commit 92e835dbf00590c9c29509d2995cc7918a9bbb90
Author: Kunal Pawar 
AuthorDate: Fri Feb 18 19:15:04 2022 +0530
Commit: Mike Kaganski 
CommitDate: Fri Mar 4 17:00:48 2022 +0100

tdf#98705 Replace GetCaseCorrectPathName with GetLongPathNameW

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

diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index d0d5616678fb..f5995f8de391 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -1590,14 +1590,22 @@ oslFileError SAL_CALL osl_getFileStatus(
 {
 if ( !pItemImpl->bFullPathNormalized )
 {
-::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
-sal_uInt32 nNewLen = GetCaseCorrectPathName( o3tl::toW( 
sFullPath.getStr() ),
- o3tl::toW( aBuffer ),
- 
aBuffer.getBufSizeInSymbols(),
- true );
+::osl::LongPathBuffer aBuffer(MAX_LONG_PATH);
+sal_uInt32 nNewLen = 
GetLongPathNameW(o3tl::toW(sFullPath.getStr()), o3tl::toW(aBuffer),
+ 
aBuffer.getBufSizeInSymbols());
 
 if ( nNewLen )
 {
+/* Capitalizes drive name (single letter). Windows file paths 
are processed
+case-sensitively. While parsing a path, function 
osl_DirectoryItem has case
+PATHTYPE_VOLUME for drives, and capatalizes them. That can be 
overwritten by
+function osl_getFileStatus, in it win32 api GetLongPathNameW 
does no
+capatilization. Thus it needs to be postprocessed.*/
+sal_Int32 nIndex = rtl_ustr_indexOfChar(aBuffer, ':');
+if (nIndex > 0) {
+aBuffer[nIndex - 1] = rtl::toAsciiUpperCase(aBuffer[nIndex 
- 1]);
+}
+
 pItemImpl->m_sFullPath = OUString(&*aBuffer, nNewLen);
 sFullPath = pItemImpl->m_sFullPath;
 pItemImpl->bFullPathNormalized = true;
diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index a8d1644b7daa..1fcdc1728696 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -542,134 +542,6 @@ static bool IsPathSpecialPrefix(LPWSTR szPath, LPWSTR 
szFile)
 return false;
 }
 
-// Expects a proper absolute or relative path. NB: It is different from 
GetLongPathName WinAPI!
-static DWORD GetCaseCorrectPathNameEx(
-LPWSTR  lpszPath,   // path buffer to convert
-sal_uInt32 cchBuffer,  // size of path buffer
-DWORD   nSkipLevels,
-bool bCheckExistence )
-{
-::osl::LongPathBuffer< WCHAR > szFile( MAX_PATH + 1 );
-sal_Int32 nRemoved = PathRemoveFileSpec( lpszPath, szFile, MAX_PATH + 
1 );
-sal_Int32 nLastStepRemoved = nRemoved;
-while ( nLastStepRemoved && szFile[0] == 0 )
-{
-// remove separators
-nLastStepRemoved = PathRemoveFileSpec( lpszPath, szFile, MAX_PATH 
+ 1 );
-nRemoved += nLastStepRemoved;
-}
-
-if ( nRemoved )
-{
-bool bSkipThis = false;
-
-if ( 0 == wcscmp( szFile, L".." ) )
-{
-bSkipThis = true;
-nSkipLevels += 1;
-}
-else if ( 0 == wcscmp( szFile, L"." ) )
-{
-bSkipThis = true;
-}
-else if ( nSkipLevels )
-{
-bSkipThis = true;
-nSkipLevels--;
-}
-else
-bSkipThis = false;
-
-if ( !GetCaseCorrectPathNameEx( lpszPath, cchBuffer, nSkipLevels, 
bCheckExistence ) )
-return 0;
-
-PathAddBackslash( lpszPath, cchBuffer );
-
-/* Analyze parent if not only a trailing backslash was cut but a 
real file spec */
-if ( !bSkipThis )
-{
-if ( bCheckExistence )
-{
-
-if (IsPathSpecialPrefix(lpszPath, szFile))
-{
-/* add the segment name back */
-wcscat(lpszPath, szFile);
-}
-else
-{
-osl::LongPathBuffer aShortPath(MAX_LONG_PATH);
-wcscpy(aShortPath, lpszPath);
-wcscat(aShortPath, szFile);
-
-WIN32_FIND_DATAW aFindFileData;
-HANDLE hFind = 

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

2022-02-03 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/backtrace.cxx |   10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

New commits:
commit fdf84b42a09fa2eed03dccfaeec98dba720e6557
Author: Mike Kaganski 
AuthorDate: Thu Feb 3 07:42:57 2022 +0100
Commit: Mike Kaganski 
CommitDate: Thu Feb 3 10:52:47 2022 +0100

Call SymInitialize only once

Also simplify the logic by passing fInvadeProcess = false there, since
passing true is the same as calling SymRefreshModuleList explicitly.

Fixes an overlook from commit 853a058ca6b75b0fb14e232911eb9f9553574736.

Change-Id: I296f06845a9f92375908d72e69574c2ecd190028
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129338
Tested-by: Mike Kaganski 
Reviewed-by: Luboš Luňák 

diff --git a/sal/osl/w32/backtrace.cxx b/sal/osl/w32/backtrace.cxx
index fab3c5043a60..d9231de44517 100644
--- a/sal/osl/w32/backtrace.cxx
+++ b/sal/osl/w32/backtrace.cxx
@@ -61,13 +61,9 @@ OUString sal::backtrace_to_string(BacktraceState* 
backtraceState)
 {
 HANDLE hProcess = GetCurrentProcess();
 // 
https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-syminitialize
-// says to not initialize more than once. This still leaks for some
-// reason if called often enough.
-static bool needsInit = true;
-if( needsInit )
-SymInitialize( hProcess, nullptr, true );
-else
-SymRefreshModuleList( hProcess );
+// says to not initialize more than once.
+[[maybe_unused]] static bool bInitialized = SymInitialize(hProcess, 
nullptr, false);
+SymRefreshModuleList(hProcess);
 SYMBOL_INFO  * pSymbol;
 pSymbol = static_cast(calloc( sizeof( SYMBOL_INFO ) + 1024 
* sizeof( char ), 1 ));
 assert(pSymbol);


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

2022-01-10 Thread Jan-Marek Glogowski (via logerrit)
 sal/osl/unx/nlsupport.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 46b6ddc000a12795af361062bce471fa6e997d9a
Author: Jan-Marek Glogowski 
AuthorDate: Mon Jan 10 10:38:52 2022 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Tue Jan 11 05:23:45 2022 +0100

Fix ISO C++11 -Wwritable-strings

osl/unx/nlsupport.cxx:863:18: warning: ISO C++11 does not allow \
  conversion from string literal to 'char *' [-Wwritable-strings]

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

diff --git a/sal/osl/unx/nlsupport.cxx b/sal/osl/unx/nlsupport.cxx
index b1b1af706491..cc07a13805ba 100644
--- a/sal/osl/unx/nlsupport.cxx
+++ b/sal/osl/unx/nlsupport.cxx
@@ -848,10 +848,10 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
 /* No locale environment variables on Android, so why even bother
  * with getenv().
  */
-   char const * locale = "en-US.UTF-8";
+const char* locale = "en-US.UTF-8";
 #else
 /* simulate behavior off setlocale */
-char * locale = getenv( "LC_ALL" );
+const char* locale = getenv("LC_ALL");
 
 if( NULL == locale )
 locale = getenv( "LC_CTYPE" );


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

2022-01-10 Thread Jan-Marek Glogowski (via logerrit)
 sal/osl/unx/nlsupport.cxx |   50 +++---
 1 file changed, 25 insertions(+), 25 deletions(-)

New commits:
commit 1bb08a227ca4854a7d1960ca61a5b0de9fe9363d
Author: Jan-Marek Glogowski 
AuthorDate: Mon Jan 10 11:41:25 2022 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Mon Jan 10 15:33:37 2022 +0100

Use one define for the common NLS archs

Just some refactoring.

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

diff --git a/sal/osl/unx/nlsupport.cxx b/sal/osl/unx/nlsupport.cxx
index 28d367c11ae9..b1b1af706491 100644
--- a/sal/osl/unx/nlsupport.cxx
+++ b/sal/osl/unx/nlsupport.cxx
@@ -31,19 +31,20 @@
 
 #include "nlsupport.hxx"
 
-#if defined(LINUX) || defined(__sun) || defined(NETBSD) || \
-defined(FREEBSD) || defined(MACOSX)  || defined(IOS) || defined(OPENBSD) 
|| \
-defined(DRAGONFLY)
-#if !defined(MACOSX) && !defined(IOS)
+// these share a lot, so use one define
+#if defined(LINUX) || defined(__sun) || \
+defined(FREEBSD) || defined(OPENBSD) || defined(DRAGONFLY) || 
defined(NETBSD)
+#define LO_COMMON_NLS_ARCHS 1
+#else
+#define LO_COMMON_NLS_ARCHS 0
+#endif
+
+#if LO_COMMON_NLS_ARCHS
 #include 
 #include 
-#else
+#elif defined(MACOSX) || defined(IOS)
 #include 
 #include 
-#endif  /* !MACOSX && !IOS */
-#endif  /* LINUX || __sun || NETBSD || MACOSX || IOS */
-
-#if defined(MACOSX) || defined(IOS)
 #include "system.hxx"
 #endif
 
@@ -226,23 +227,14 @@ static rtl_Locale * parse_locale( const char * locale )
 return ret;
 }
 
-#if defined(LINUX) || defined(__sun) || defined(NETBSD) || \
-defined(FREEBSD) || defined(OPENBSD) || defined(DRAGONFLY)
+#if LO_COMMON_NLS_ARCHS
 
 /*
  * This implementation of osl_getTextEncodingFromLocale maps
  * from nl_langinfo_l(CODESET) to rtl_textencoding defines.
  * nl_langinfo() is supported only on Linux, Solaris,
  * >= NetBSD 1.6 and >= FreeBSD 4.4
- */
-
-#ifdef LINUX
-#if !defined(CODESET)
-#define CODESET _NL_CTYPE_CODESET_NAME
-#endif
-#endif
-
-/*
+ *
  * _nl_language_list[] is an array list of supported encodings. Because
  * we are using a binary search, the list has to be in ascending order.
  * We are comparing the encodings case insensitive, so the list has
@@ -294,6 +286,10 @@ static const Pair nl_language_list[] = {
 
 #elif defined(LINUX)
 
+#if !defined(CODESET)
+#define CODESET _NL_CTYPE_CODESET_NAME
+#endif
+
 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 */
@@ -557,7 +553,9 @@ static const Pair nl_language_list[] = {
 { "UTF-8", RTL_TEXTENCODING_UTF8   }  /* ISO-10646/UTF-8 */
 };
 
-#endif /* ifdef __sun LINUX FREEBSD NETBSD OPENBSD */
+#else
+#error Unhandled individual LO_COMMON_NLS_ARCHS
+#endif // individual common NLS archs
 
 /*
  return the text encoding corresponding to the given locale
@@ -643,7 +641,7 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
 *ppLocale = parse_locale(locale);
 }
 
-#else /* ifdef LINUX || __sun || MACOSX || NETBSD */
+#else // !LO_COMMON_NLS_ARCHS
 
 /*
  * This implementation of osl_getTextEncodingFromLocale maps
@@ -837,7 +835,9 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
 /* return the locale */
 *ppLocale = parse_locale( locale.getStr() );
 }
-#else
+
+#else // !MACOSX && !IOS
+
 /*
  return the current process locale
  */
@@ -865,8 +865,8 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
 #endif
 *ppLocale = parse_locale( locale );
 }
-#endif
 
-#endif /* ifdef LINUX || __sun || MACOSX || NETBSD || AIX */
+#endif // !MACOSX && !IOS
+#endif // !LO_COMMON_NLS_ARCHS
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


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

2022-01-07 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/thread.cxx |   31 ---
 1 file changed, 8 insertions(+), 23 deletions(-)

New commits:
commit 809a36a6d5beb09ca916ee4313bc19a92099a672
Author: Mike Kaganski 
AuthorDate: Fri Jan 7 12:36:52 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Jan 7 18:21:09 2022 +0100

Use CreateThread instead of _beginthreadex

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

diff --git a/sal/osl/w32/thread.cxx b/sal/osl/w32/thread.cxx
index 71d11901cebf..fe5ac30b01df 100644
--- a/sal/osl/w32/thread.cxx
+++ b/sal/osl/w32/thread.cxx
@@ -20,6 +20,7 @@
 #include "system.h"
 #include "thread.hxx"
 
+#include 
 #include 
 #include 
 #include 
@@ -27,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -39,7 +41,7 @@ namespace {
 typedef struct
 {
 HANDLE  m_hThread;  /* OS-handle used for all 
thread-functions */
-unsignedm_ThreadId; /* identifier for this thread */
+DWORD   m_ThreadId; /* identifier for this thread */
 sal_Int32   m_nTerminationRequested;
 oslWorkerFunction   m_WorkerFunction;
 void*   m_pData;
@@ -50,7 +52,7 @@ typedef struct
 
 static oslThread oslCreateThread(oslWorkerFunction pWorker, void* pThreadData, 
sal_uInt32 nFlags);
 
-static unsigned __stdcall oslWorkerWrapperFunction(void* pData)
+static DWORD WINAPI oslWorkerWrapperFunction(_In_ LPVOID pData)
 {
 osl_TThreadImpl* pThreadImpl= static_cast(pData);
 
@@ -85,34 +87,17 @@ static oslThread oslCreateThread(oslWorkerFunction pWorker,
 pThreadImpl->m_pData= pThreadData;
 pThreadImpl->m_nTerminationRequested= 0;
 
-pThreadImpl->m_hThread=
-reinterpret_cast(_beginthreadex(nullptr,   
 /* no security */
+pThreadImpl->m_hThread= CreateThread(
+   nullptr, /* no security */
0,   /* default 
stack-size */
oslWorkerWrapperFunction,/* worker-function 
*/
pThreadImpl, /* provide 
worker-function with data */
nFlags,  /* start thread 
immediately or suspended */
-   >m_ThreadId));
+   >m_ThreadId);
 
 if(pThreadImpl->m_hThread == nullptr)
 {
-switch (errno)
-{
-case EAGAIN:
-fprintf(stderr, "_beginthreadex errno EAGAIN\n");
-break;
-case EINVAL:
-fprintf(stderr, "_beginthreadex errno EINVAL\n");
-break;
-case EACCES:
-fprintf(stderr, "_beginthreadex errno EACCES\n");
-break;
-case ENOMEM:
-fprintf(stderr, "_beginthreadex undocumented errno ENOMEM - 
this means not enough VM for stack\n");
-break;
-default:
-fprintf(stderr, "_beginthreadex unexpected errno %d\n", errno);
-break;
-}
+SAL_WARN("sal.osl", "CreateThread failed:" << 
WindowsErrorString(GetLastError()));
 
 /* create failed */
 free(pThreadImpl);


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

2022-01-07 Thread Stephan Bergmann (via logerrit)
 sal/osl/w32/module.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2796d4ab5c3cc3637d04b33a5e7f0dad4c90d408
Author: Stephan Bergmann 
AuthorDate: Fri Jan 7 08:18:27 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Fri Jan 7 09:48:17 2022 +0100

loplugin:redundantcast

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

diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx
index 57eec8b70012..8379e14b2fd5 100644
--- a/sal/osl/w32/module.cxx
+++ b/sal/osl/w32/module.cxx
@@ -178,7 +178,7 @@ sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, 
rtl_uString **pustrURL
 HMODULE hModule{};
 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
| GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
-   reinterpret_cast(pv), );
+   static_cast(pv), );
 if (!hModule)
 return false;
 


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

2022-01-07 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/thread.cxx |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 6d0956c8a61bacc154bef225f83eb74cdf442c57
Author: Mike Kaganski 
AuthorDate: Fri Jan 7 07:32:18 2022 +0100
Commit: Mike Kaganski 
CommitDate: Fri Jan 7 09:12:40 2022 +0100

Drop unused forward declaration

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

diff --git a/sal/osl/w32/thread.cxx b/sal/osl/w32/thread.cxx
index a82ac2ea8a19..71d11901cebf 100644
--- a/sal/osl/w32/thread.cxx
+++ b/sal/osl/w32/thread.cxx
@@ -48,7 +48,6 @@ typedef struct
 
 }
 
-static unsigned __stdcall oslWorkerWrapperFunction(void* pData);
 static oslThread oslCreateThread(oslWorkerFunction pWorker, void* pThreadData, 
sal_uInt32 nFlags);
 
 static unsigned __stdcall oslWorkerWrapperFunction(void* pData)


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

2022-01-05 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/module.cxx |   11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

New commits:
commit 2fd019442e14e122884fff42b88de23fa150e4df
Author: Mike Kaganski 
AuthorDate: Thu Jan 6 01:12:31 2022 +0300
Commit: Mike Kaganski 
CommitDate: Thu Jan 6 06:46:20 2022 +0100

Simplify osl_getModuleURLFromAddress a bit

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

diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx
index 201f2dd164ee..57eec8b70012 100644
--- a/sal/osl/w32/module.cxx
+++ b/sal/osl/w32/module.cxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -182,15 +183,11 @@ sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, 
rtl_uString **pustrURL
 return false;
 
 ::osl::LongPathBuffer aBuffer(MAX_LONG_PATH);
-rtl_uString* ustrSysPath = nullptr;
 
-GetModuleFileNameW(hModule, o3tl::toW(aBuffer), 
aBuffer.getBufSizeInSymbols());
+DWORD nch = GetModuleFileNameW(hModule, o3tl::toW(aBuffer), 
aBuffer.getBufSizeInSymbols());
 
-rtl_uString_newFromStr(, aBuffer);
-osl_getFileURLFromSystemPath(ustrSysPath, pustrURL);
-rtl_uString_release(ustrSysPath);
-
-return true;
+OUString ustrSysPath(aBuffer, nch);
+return osl_getFileURLFromSystemPath(ustrSysPath.pData, pustrURL) == 
osl_File_E_None;
 }
 
 sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress( oslGenericFunction 
addr, rtl_uString ** ppLibraryUrl )


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

2021-10-23 Thread Luboš Luňák (via logerrit)
 sal/osl/unx/backtraceapi.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 84a54f6c388d3abe1d6f6e04bf07441ae96f60cd
Author: Luboš Luňák 
AuthorDate: Sat Oct 23 07:59:12 2021 +0200
Commit: Luboš Luňák 
CommitDate: Sat Oct 23 20:47:38 2021 +0200

move access inside mutex guard

Change-Id: I784fbc3b39a645c7984aa836cc32980343ddd1f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124095
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx
index bd8db79e0181..a4cec46ca95b 100644
--- a/sal/osl/unx/backtraceapi.cxx
+++ b/sal/osl/unx/backtraceapi.cxx
@@ -206,8 +206,9 @@ OUString sal::backtrace_to_string(BacktraceState* 
backtraceState)
 void* addr = backtraceState->buffer[i];
 std::unique_lock guard(frameCacheMutex);
 auto it = frameCache.find(addr);
+bool found = it != frameCache.end();
 guard.unlock();
-if( it != frameCache.end())
+if( found )
 {
 frameData[ i ].info = it->second;
 frameData[ i ].handled = true;


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

2021-10-22 Thread Luboš Luňák (via logerrit)
 sal/osl/unx/backtraceapi.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 6c9909dee4b06948ca6932397caa338d77ec7290
Author: Luboš Luňák 
AuthorDate: Fri Oct 22 14:11:39 2021 +0200
Commit: Luboš Luňák 
CommitDate: Fri Oct 22 16:33:15 2021 +0200

fix std::unique_lock unlocking

std: :unique_lock::release() does not unlock.
Change-Id: Ida5a28a8b1c275a0a702121bf00faeaf76a57426
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124063
Reviewed-by: Arnaud Versini 
Tested-by: Jenkins

diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx
index d67806d9268b..bd8db79e0181 100644
--- a/sal/osl/unx/backtraceapi.cxx
+++ b/sal/osl/unx/backtraceapi.cxx
@@ -206,7 +206,7 @@ OUString sal::backtrace_to_string(BacktraceState* 
backtraceState)
 void* addr = backtraceState->buffer[i];
 std::unique_lock guard(frameCacheMutex);
 auto it = frameCache.find(addr);
-guard.release();
+guard.unlock();
 if( it != frameCache.end())
 {
 frameData[ i ].info = it->second;


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

2021-10-22 Thread Luboš Luňák (via logerrit)
 sal/osl/unx/backtraceapi.cxx |   18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

New commits:
commit bb2e861827cb854dd380d2b7ac3d8907de7043d7
Author: Luboš Luňák 
AuthorDate: Fri Oct 22 10:26:50 2021 +0200
Commit: Luboš Luňák 
CommitDate: Fri Oct 22 16:32:57 2021 +0200

prefer llvm-addr2line to addr2line for backtraces if possible

It's faster, and at least when compiling with Clang it should work
fine.

Change-Id: I474857c2a54b8032b74202ccd5c67d25f6062790
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124055
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx
index 23d3bec498b9..d67806d9268b 100644
--- a/sal/osl/unx/backtraceapi.cxx
+++ b/sal/osl/unx/backtraceapi.cxx
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "backtrace.h"
@@ -74,8 +75,17 @@ FrameCache frameCache( 256 );
 
 void process_file_addr2line( const char* file, std::vector& 
frameData )
 {
+if(access( file, R_OK ) != 0)
+return; // cannot read info from the binary file anyway
 OUString binary("addr2line");
 OUString dummy;
+#if defined __clang__
+// llvm-addr2line is faster than addr2line
+if(osl::detail::find_in_PATH("llvm-addr2line", dummy))
+binary = "llvm-addr2line";
+#endif
+if(!osl::detail::find_in_PATH(binary, dummy))
+return; // Will not work, avoid warnings from osl process code.
 OUString arg1("-Cfe");
 OUString arg2 = OUString::fromUtf8(file);
 std::vector addrs;
@@ -93,8 +103,6 @@ void process_file_addr2line( const char* file, 
std::vector& frameData
 }
 }
 
-if(!osl::detail::find_in_PATH(binary, dummy) || access( file, R_OK ) != 0)
-return; // Will not work, avoid warnings from osl process code.
 oslProcess aProcess;
 oslFileHandle pOut = nullptr;
 oslFileHandle pErr = nullptr;
@@ -105,7 +113,10 @@ void process_file_addr2line( const char* file, 
std::vector& frameData
 osl_freeSecurityHandle(pSecurity);
 
 if (eErr != osl_Process_E_None)
+{
+SAL_WARN("sal.osl", binary << " call to resolve " << file << " symbols 
failed");
 return;
+}
 
 OStringBuffer outputBuffer;
 if (pOut)
@@ -148,7 +159,10 @@ void process_file_addr2line( const char* file, 
std::vector& frameData
 outputPos = end2 + 1;
 }
 if(lines.size() != addrs.size() * 2)
+{
+SAL_WARN("sal.osl", "failed to parse " << binary << " call output to 
resolve " << file << " symbols ");
 return; // addr2line problem?
+}
 size_t linesPos = 0;
 for( FrameData& frame : frameData )
 {


[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

2021-10-10 Thread Arnaud Versini (via logerrit)
 sal/osl/all/debugbase.cxx |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

New commits:
commit 96726f4a7f2f23972c987e9a4be75539f24fb0b7
Author: Arnaud Versini 
AuthorDate: Sat Oct 9 20:45:49 2021 +0200
Commit: Noel Grandin 
CommitDate: Sun Oct 10 19:46:36 2021 +0200

OSL : remove useless rtl::Static in debugbase

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

diff --git a/sal/osl/all/debugbase.cxx b/sal/osl/all/debugbase.cxx
index 209dc55e1e32..208fa3e92a92 100644
--- a/sal/osl/all/debugbase.cxx
+++ b/sal/osl/all/debugbase.cxx
@@ -56,8 +56,6 @@ bool isSubStr( char const* pStr, OString const& subStr )
 return rtl_str_indexOfStr( pStr, subStr.getStr() ) >= 0;
 }
 
-struct DebugBaseMutex : rtl::Static {};
-
 } // anon namespace
 
 extern "C" {
@@ -72,7 +70,8 @@ extern "C" {
 osl::Mutex & SAL_CALL osl_detail_ObjectRegistry_getMutex()
 SAL_THROW_EXTERN_C()
 {
-return DebugBaseMutex::get();
+static osl::Mutex aMutex;
+return aMutex;
 }
 #ifdef __clang__
 #pragma clang diagnostic pop


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

2021-10-10 Thread Arnaud Versini (via logerrit)
 sal/osl/unx/backtraceapi.cxx |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 82bc337c979f6d74cb08d0332b44f26b155f9554
Author: Arnaud Versini 
AuthorDate: Sat Oct 9 20:51:27 2021 +0200
Commit: Noel Grandin 
CommitDate: Sun Oct 10 14:43:21 2021 +0200

OSL : use std::mutex in backtraceapi

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

diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx
index 79fa3adf7296..e98d8d663f39 100644
--- a/sal/osl/unx/backtraceapi.cxx
+++ b/sal/osl/unx/backtraceapi.cxx
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -68,7 +69,7 @@ struct FrameData
 };
 
 typedef o3tl::lru_map FrameCache;
-osl::Mutex frameCacheMutex;
+std::mutex frameCacheMutex;
 FrameCache frameCache( 256 );
 
 void process_file_addr2line( const char* file, std::vector& 
frameData )
@@ -164,7 +165,7 @@ void process_file_addr2line( const char* file, 
std::vector& frameData
 frame.info = function + " in " + file;
 else
 frame.info = function + " at " + source;
-osl::MutexGuard guard(frameCacheMutex);
+std::lock_guard guard(frameCacheMutex);
 frameCache.insert( { frame.addr, frame.info } );
 }
 }
@@ -183,9 +184,9 @@ OUString sal::backtrace_to_string(BacktraceState* 
backtraceState)
 {
 Dl_info dli;
 void* addr = backtraceState->buffer[i];
-osl::ClearableMutexGuard guard(frameCacheMutex);
+std::unique_lock guard(frameCacheMutex);
 auto it = frameCache.find(addr);
-guard.clear();
+guard.release();
 if( it != frameCache.end())
 {
 frameData[ i ].info = it->second;


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

2021-09-30 Thread Stephan Bergmann (via logerrit)
 sal/osl/w32/time.cxx  |2 +-
 vcl/source/helper/driverblocklist.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit cbe233766dc4cb028446aa599609b1a7d594785e
Author: Stephan Bergmann 
AuthorDate: Thu Sep 30 09:56:16 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Sep 30 12:13:35 2021 +0200

loplugin:unusedcapturedefault (clang-cl)

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

diff --git a/sal/osl/w32/time.cxx b/sal/osl/w32/time.cxx
index 688fef211519..3f11746fedad 100644
--- a/sal/osl/w32/time.cxx
+++ b/sal/osl/w32/time.cxx
@@ -35,7 +35,7 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal)
 
 OSL_ASSERT(pTimeVal != nullptr);
 
-static GetSystemTimePreciseAsFileTime_PROC pGetSystemTimePreciseAsFileTime 
= [&]()
+static GetSystemTimePreciseAsFileTime_PROC pGetSystemTimePreciseAsFileTime 
= []()
 {
 HMODULE hModule = GetModuleHandleW( L"Kernel32.dll" );
 return reinterpret_cast(
diff --git a/vcl/source/helper/driverblocklist.cxx 
b/vcl/source/helper/driverblocklist.cxx
index 7fb20da6ab94..855376dc1fb5 100644
--- a/vcl/source/helper/driverblocklist.cxx
+++ b/vcl/source/helper/driverblocklist.cxx
@@ -723,7 +723,7 @@ bool IsDeviceBlocked(const OUString& blocklistURL, 
VersionType versionType,
 #ifdef _WIN32
 int32_t GetWindowsVersion()
 {
-static int32_t winVersion = [&]() {
+static int32_t winVersion = []() {
 // GetVersion(Ex) and VersionHelpers (based on VerifyVersionInfo) API 
are
 // subject to manifest-based behavior since Windows 8.1, so give wrong 
results.
 // Another approach would be to use NetWkstaGetInfo, but that has some 
small


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

2021-09-13 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/backtraceapi.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 53165f584ff777df429fc43a451614d88914627d
Author: Stephan Bergmann 
AuthorDate: Mon Sep 13 14:13:15 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Mon Sep 13 15:56:16 2021 +0200

loplugin:simplifypointertobool

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

diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx
index 1868ae7132bb..79fa3adf7296 100644
--- a/sal/osl/unx/backtraceapi.cxx
+++ b/sal/osl/unx/backtraceapi.cxx
@@ -238,7 +238,7 @@ OUString sal::backtrace_to_string(BacktraceState* 
backtraceState)
 OUString sal::backtrace_to_string(BacktraceState* backtraceState)
 {
 std::unique_ptr 
b2{backtrace_symbols(backtraceState->buffer, backtraceState->nDepth), free};
-if (b2.get() == nullptr) {
+if (!b2) {
 return OUString();
 }
 OUStringBuffer b3;


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

2021-09-07 Thread Luboš Luňák (via logerrit)
 sal/osl/unx/backtraceapi.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 57cac3a19f5e07da137ecd616ccddf81ca185fa9
Author: Luboš Luňák 
AuthorDate: Mon Sep 6 15:46:36 2021 +0200
Commit: Luboš Luňák 
CommitDate: Tue Sep 7 09:19:36 2021 +0200

prepend # to frames in unx backtraces

To make complex backtraces readable.

Change-Id: I3a95d03d97c8e6d1aa7aeab37957d3b8441c3c90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121724
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx
index 8e55cc338020..1868ae7132bb 100644
--- a/sal/osl/unx/backtraceapi.cxx
+++ b/sal/osl/unx/backtraceapi.cxx
@@ -213,6 +213,7 @@ OUString sal::backtrace_to_string(BacktraceState* 
backtraceState)
 {
 if (i != 0)
 b3.append("\n");
+b3.append( "#" + OUString::number( i ) + " " );
 if(!frameData[i].info.isEmpty())
 b3.append(o3tl::runtimeToOUString(frameData[i].info.getStr()));
 else
@@ -245,6 +246,7 @@ OUString sal::backtrace_to_string(BacktraceState* 
backtraceState)
 if (i != 0) {
 b3.append("\n");
 }
+b3.append( "#" + OUString::number( i ) + " " );
 b3.append(o3tl::runtimeToOUString(b2.get()[i]));
 }
 return b3.makeStringAndClear();


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

2021-09-06 Thread Luboš Luňák (via logerrit)
 sal/osl/unx/backtraceapi.cxx |   24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

New commits:
commit 1d021c87208c44b4943e4260ae58fb2478851d47
Author: Luboš Luňák 
AuthorDate: Fri Sep 3 12:20:56 2021 +0200
Commit: Luboš Luňák 
CommitDate: Mon Sep 6 14:40:50 2021 +0200

also cache addr2line results

Change-Id: Ib4351ba7a585ada3887f1cbeb5d676733250598b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121585
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx
index e24a9150c91d..8e55cc338020 100644
--- a/sal/osl/unx/backtraceapi.cxx
+++ b/sal/osl/unx/backtraceapi.cxx
@@ -52,6 +52,8 @@ std::unique_ptr 
sal::backtrace_get(sal_uInt32 maxDepth)
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "file_url.hxx"
 
 namespace
@@ -59,11 +61,16 @@ namespace
 struct FrameData
 {
 const char* file = nullptr;
+void* addr;
 ptrdiff_t offset;
 OString info;
 bool handled = false;
 };
 
+typedef o3tl::lru_map FrameCache;
+osl::Mutex frameCacheMutex;
+FrameCache frameCache( 256 );
+
 void process_file_addr2line( const char* file, std::vector& 
frameData )
 {
 OUString binary("addr2line");
@@ -77,7 +84,7 @@ void process_file_addr2line( const char* file, 
std::vector& frameData
 args.push_back( arg2.pData );
 for( FrameData& frame : frameData )
 {
-if( strcmp( file, frame.file ) == 0 )
+if( frame.file != nullptr && strcmp( file, frame.file ) == 0 )
 {
 addrs.push_back("0x" + OUString::number(frame.offset, 16));
 args.push_back(addrs.back().pData);
@@ -144,7 +151,7 @@ void process_file_addr2line( const char* file, 
std::vector& frameData
 size_t linesPos = 0;
 for( FrameData& frame : frameData )
 {
-if( strcmp( file, frame.file ) == 0 )
+if( frame.file != nullptr && strcmp( file, frame.file ) == 0 )
 {
 // There should be two lines, first function name and second 
source file information.
 // If each of them starts with ??, it is invalid/unknown.
@@ -157,6 +164,8 @@ void process_file_addr2line( const char* file, 
std::vector& frameData
 frame.info = function + " in " + file;
 else
 frame.info = function + " at " + source;
+osl::MutexGuard guard(frameCacheMutex);
+frameCache.insert( { frame.addr, frame.info } );
 }
 }
 }
@@ -174,11 +183,20 @@ OUString sal::backtrace_to_string(BacktraceState* 
backtraceState)
 {
 Dl_info dli;
 void* addr = backtraceState->buffer[i];
-if (dladdr(addr, ) != 0)
+osl::ClearableMutexGuard guard(frameCacheMutex);
+auto it = frameCache.find(addr);
+guard.clear();
+if( it != frameCache.end())
+{
+frameData[ i ].info = it->second;
+frameData[ i ].handled = true;
+}
+else if (dladdr(addr, ) != 0)
 {
 if (dli.dli_fname && dli.dli_fbase)
 {
 frameData[ i ].file = dli.dli_fname;
+frameData[ i ].addr = addr;
 frameData[ i ].offset = reinterpret_cast(addr) - 
reinterpret_cast(dli.dli_fbase);
 }
 }


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

2021-08-27 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/module.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit fc87a30e64f28d5f7f19a4220910681e918244e3
Author: Mike Kaganski 
AuthorDate: Fri Aug 27 14:55:31 2021 +0200
Commit: Mike Kaganski 
CommitDate: Fri Aug 27 16:19:00 2021 +0200

Fix this FIXME

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

diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx
index ab50450daf7d..798da4183e7c 100644
--- a/sal/osl/w32/module.cxx
+++ b/sal/osl/w32/module.cxx
@@ -107,9 +107,9 @@ oslModule SAL_CALL osl_loadModuleAscii(const char 
*pModuleName, sal_Int32 )
 }
 
 oslModule osl_loadModuleRelativeAscii(
-oslGenericFunction, char const * relativePath, sal_Int32 mode)
+oslGenericFunction baseModule, char const * relativePath, sal_Int32 mode)
 {
-return osl_loadModuleAscii(relativePath, mode); //TODO: FIXME
+return osl_loadModuleRelative(baseModule, 
OUString::createFromAscii(relativePath).pData, mode);
 }
 
 sal_Bool SAL_CALL


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

2021-08-27 Thread Stephan Bergmann (via logerrit)
 sal/osl/w32/module.cxx |   15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

New commits:
commit 8d8e5ab9193785acc4e1cb05e0db7f97afde1e2b
Author: Stephan Bergmann 
AuthorDate: Fri Aug 27 10:28:11 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Aug 27 11:32:29 2021 +0200

Use PSAPI functionality directly

Dynamically trying to obtain the two PSAPI functions was apparently 
originally
done because "This version can fail because PSAPI.DLL is not always part of
NT 4 despite MSDN Libary 6.0a say so", according to the comment added with
961512bd9ae008fdd8ab5cdf1ba6b5d25ffb0429 "#94875# Added additional method 
(for
NT4) to determine the module containing an address".  (That comment was 
removed
again in 515d2579d305a6127c6c194319a58eac62437e33 "Replace legacy 
dynamically-
loaded functions with statically linked ones", which curiously left the 
dynamic
loading of PSAPI.DLL in place there, though.)



states that the PSAPI functionality is available in "Kernel32.dll on 
Windows 7
and Windows Server 2008 R2; Psapi.dll (if PSAPI_VERSION=1) on Windows 7 and
Windows Server 2008 R2; Psapi.dll on Windows Server 2008, Windows Vista, 
Windows
Server 2003 and Windows XP".  I do not find any mention of PSAPI_VERSION 
across
our code base, so assume that PSAPI_VERSION=1 would be some legacy mode 
that we
do not use, so with our baseline of Windows 7 (cf. README.md), relying on 
the
PSAPI functionality being available without adding anything specific to
gb_Library_use_system_win32_libs,sal should presumably be OK.

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

diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx
index 620be0e6d664..ab50450daf7d 100644
--- a/sal/osl/w32/module.cxx
+++ b/sal/osl/w32/module.cxx
@@ -182,15 +182,6 @@ osl_getAsciiFunctionSymbol( oslModule Module, const char 
*pSymbol )
 
 sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, rtl_uString 
**pustrURL )
 {
-static HMODULE hModPsapi = LoadLibraryW( L"PSAPI.DLL" );
-static auto lpfnEnumProcessModules = 
reinterpret_cast(
-hModPsapi ? GetProcAddress(hModPsapi, "EnumProcessModules") : nullptr);
-static auto lpfnGetModuleInformation = 
reinterpret_cast(
-hModPsapi ? GetProcAddress(hModPsapi, "GetModuleInformation") : 
nullptr);
-
-if (!lpfnEnumProcessModules || !lpfnGetModuleInformation)
-return false;
-
 bool bSuccess= false;/* Assume failure */
 DWORD cbNeeded = 0;
 HMODULE* lpModules = nullptr;
@@ -198,16 +189,16 @@ sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, 
rtl_uString **pustrURL
 UINT iModule = 0;
 MODULEINFO modinfo;
 
-lpfnEnumProcessModules(GetCurrentProcess(), nullptr, 0, );
+EnumProcessModules(GetCurrentProcess(), nullptr, 0, );
 
 lpModules = static_cast(_alloca(cbNeeded));
-lpfnEnumProcessModules(GetCurrentProcess(), lpModules, cbNeeded, 
);
+EnumProcessModules(GetCurrentProcess(), lpModules, cbNeeded, );
 
 nModules = cbNeeded / sizeof(HMODULE);
 
 for (iModule = 0; !bSuccess && iModule < nModules; iModule++)
 {
-lpfnGetModuleInformation(GetCurrentProcess(), lpModules[iModule], 
,
+GetModuleInformation(GetCurrentProcess(), lpModules[iModule], ,
  sizeof(modinfo));
 
 if (static_cast(pv) >= static_cast(modinfo.lpBaseOfDll)


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

2021-06-02 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/thread.cxx |   32 +---
 1 file changed, 25 insertions(+), 7 deletions(-)

New commits:
commit a5eba5fef0b6eade2c0a39f8e8fc90bdeb08dff2
Author: Mike Kaganski 
AuthorDate: Wed Jun 2 11:05:21 2021 +0200
Commit: Mike Kaganski 
CommitDate: Wed Jun 2 15:27:09 2021 +0200

Make optional use of SetThreadDescription in osl_setThreadName

... so that thread name could appear in crash dumps, and be
potentially available for logging on Windows 10 version 1607
and later.

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

diff --git a/sal/osl/w32/thread.cxx b/sal/osl/w32/thread.cxx
index d4a9d6d67060..e269e7cbd455 100644
--- a/sal/osl/w32/thread.cxx
+++ b/sal/osl/w32/thread.cxx
@@ -358,25 +358,43 @@ void SAL_CALL osl_yieldThread(void)
 Sleep(0);
 }
 
+static void impSetThreadDescription(char const * name) {
+// SetThreadDescription is only available since Windows 10 version 1607
+typedef HRESULT(WINAPI * TSetThreadDescription)(HANDLE, PCWSTR);
+static const auto pSetThreadDescription = 
reinterpret_cast(
+GetProcAddress(GetModuleHandleA("KernelBase.dll"), 
"SetThreadDescription"));
+if (pSetThreadDescription)
+{
+if (const int nReqCCh = MultiByteToWideChar(CP_ACP, 0, name, -1, 
nullptr, 0))
+{
+if (PWSTR wStr = static_cast(malloc(nReqCCh * 
sizeof(WCHAR
+{
+if (MultiByteToWideChar(CP_ACP, 0, name, -1, wStr, nReqCCh))
+pSetThreadDescription(GetCurrentThread(), wStr);
+free(wStr);
+}
+}
+}
+}
+
 void SAL_CALL osl_setThreadName(char const * name) {
-/* See : */
+/* See < 
https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code
 >: */
 #pragma pack(push, 8)
 struct {
-DWORD dwType;
+DWORD dwType = 0x1000;
 LPCSTR szName;
-DWORD dwThreadID;
-DWORD dwFlags;
+DWORD dwThreadID = DWORD(-1);
+DWORD dwFlags = 0;
 } info;
 #pragma pack(pop)
-info.dwType = 0x1000;
 info.szName = name;
-info.dwThreadID = DWORD(-1);
-info.dwFlags = 0;
 __try {
 RaiseException(
 0x406D1388, 0, sizeof info / sizeof (ULONG_PTR),
 reinterpret_cast());
 } __except (EXCEPTION_EXECUTE_HANDLER) {}
+
+impSetThreadDescription(name);
 }
 
 namespace {
___
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-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

2021-05-26 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/socket.cxx |   41 +++--
 1 file changed, 15 insertions(+), 26 deletions(-)

New commits:
commit 581f12c0bdfb718379c16bef01d71ee9e45a5b5a
Author: Stephan Bergmann 
AuthorDate: Tue May 25 18:49:16 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Wed May 26 08:08:12 2021 +0200

Replace a use of select with poll

...to avoid undefined behavior with file descriptors >= FD_SETSIZE (cf.
0a126b4c661d65860fd2de92f8cc49bdb65a957c "Deprecate 
osl_demultiplexSocketEvents
et al")

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

diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx
index 2eafd39394cb..376d6f1412ce 100644
--- a/sal/osl/unx/socket.cxx
+++ b/sal/osl/unx/socket.cxx
@@ -264,6 +264,14 @@ static sal_Int32 osl_psz_getServicePort (
 static void osl_psz_getLastSocketErrorDescription (
 oslSocket Socket, char* pBuffer, sal_uInt32 BufferSize);
 
+namespace {
+
+int convertToMs(TimeValue const * value) {
+return value->Seconds * 1000 + value->Nanosec / 100; //TODO: overflow
+}
+
+}
+
 static oslSocket createSocketImpl()
 {
 oslSocket pSocket;
@@ -1328,10 +1336,7 @@ oslSocketResult SAL_CALL osl_connectSocketTo(oslSocket 
pSocket,
 oslSocketAddr pAddr,
 const TimeValue* pTimeout)
 {
-fd_set   WriteSet;
-fd_set   ExcptSet;
 int  ReadyHandles;
-struct timeval  tv;
 
 SAL_WARN_IF( !pSocket, "sal.osl", "undefined socket" );
 
@@ -1387,30 +1392,16 @@ oslSocketResult SAL_CALL osl_connectSocketTo(oslSocket 
pSocket,
 return osl_Socket_Error;
 }
 
-/* prepare select set for socket  */
-FD_ZERO();
-FD_ZERO();
-FD_SET(pSocket->m_Socket, );
-FD_SET(pSocket->m_Socket, );
-
-/* prepare timeout */
-if (pTimeout)
-{
-/* divide milliseconds into seconds and microseconds */
-tv.tv_sec=  pTimeout->Seconds;
-tv.tv_usec= pTimeout->Nanosec / 1000;
-}
+/* prepare poll set for socket  */
+pollfd Set = {pSocket->m_Socket, POLLPRI | POLLOUT, 0};
 
-/* select */
-ReadyHandles= select(pSocket->m_Socket+1,
- nullptr,
- PTR_FD_SET(WriteSet),
- PTR_FD_SET(ExcptSet),
- pTimeout ?  : nullptr);
+/* poll */
+ReadyHandles= poll(, 1,
+ pTimeout ? convertToMs(pTimeout) : -1);
 
 if (ReadyHandles > 0)  /* connected */
 {
-if ( FD_ISSET(pSocket->m_Socket,  ) )
+if ( (Set.revents & POLLOUT) != 0 )
 {
 int nErrorCode = 0;
 socklen_t nErrorSize = sizeof( nErrorCode );
@@ -1789,9 +1780,7 @@ static bool socket_poll (
 timeout = -1;
 if (pTimeout)
 {
-/* Convert to [ms] */
-timeout  = pTimeout->Seconds * 1000;
-timeout += pTimeout->Nanosec / (1000 * 1000);
+timeout  = convertToMs(pTimeout);
 }
 
 result = poll (, 1, timeout);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-05-21 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/socket.cxx |   74 -
 1 file changed, 74 deletions(-)

New commits:
commit e9da22d3308557640e0edc45f72b1897f016d19b
Author: Stephan Bergmann 
AuthorDate: Thu May 20 21:18:08 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Fri May 21 08:04:56 2021 +0200

Lets assume general availability of POSIX poll.h

...which should have been first released in SuS Issue 4, Version 2 in 1995.

If there should still be any relevant platforms that provide the 
functionality
only in a non-standard header, please add back the relevant #if'ery.

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

diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx
index 0c93e2928500..2eafd39394cb 100644
--- a/sal/osl/unx/socket.cxx
+++ b/sal/osl/unx/socket.cxx
@@ -38,27 +38,7 @@
 #include "unixerrnostring.hxx"
 #include 
 
-/* defines for poll */
-#ifdef HAVE_POLL_H
-#undef HAVE_POLL_H
-#endif
-
-#if defined(LINUX) || defined(NETBSD) || defined ( FREEBSD ) || \
-defined (MACOSX) || defined (OPENBSD) || defined(DRAGONFLY)
-#include 
-#define HAVE_POLL_H
-#endif /* HAVE_POLL_H */
-
-#if defined(__sun)
 #include 
-#define HAVE_POLL_H
-#endif /* __sun */
-
-#ifndef HAVE_POLL_H
-#define POLLIN  0x0001
-#define POLLOUT 0x0002
-#define POLLPRI 0x0004
-#endif /* HAVE_POLL_H */
 
 /* defines for shutdown */
 #define SD_RECEIVE 0
@@ -1787,8 +1767,6 @@ sal_Int32 SAL_CALL osl_writeSocket(
 return BytesSend;
 }
 
-#ifdef HAVE_POLL_H /* poll() */
-
 static bool socket_poll (
 oslSocketpSocket,
 const TimeValue* pTimeout,
@@ -1833,58 +1811,6 @@ static bool socket_poll (
 return ((fds.revents & nEvent) == nEvent);
 }
 
-#else  /* select() */
-
-static sal_Bool socket_poll (
-oslSocketpSocket,
-const TimeValue* pTimeout,
-shortnEvent)
-{
-fd_set fds;
-struct timeval tv;
-intresult;
-
-SAL_WARN_IF( !pSocket, "sal.osl", "undefined socket" );
-if (0 == pSocket)
-  return sal_False; /* EINVAL */
-
-pSocket->m_nLastError = 0;
-
-FD_ZERO();
-FD_SET(pSocket->m_Socket, );
-
-if (pTimeout)
-{
-/* Convert to 'timeval' */
-tv.tv_sec  = pTimeout->Seconds;
-tv.tv_usec = pTimeout->Nanosec / 1000;
-}
-
-result = select (
-pSocket->m_Socket + 1,
-(nEvent == POLLIN ) ? PTR_FD_SET(fds) : NULL,
-(nEvent == POLLOUT) ? PTR_FD_SET(fds) : NULL,
-(nEvent == POLLPRI) ? PTR_FD_SET(fds) : NULL,
-(pTimeout)  ?  : NULL);
-
-if (result < 0)
-{
-pSocket->m_nLastError = errno;
-int nErrno = errno;
-SAL_WARN( "sal.osl", "select failed: " << UnixErrnoString(nErrno) );
-return sal_False;
-}
-if (result == 0)
-{
-/* Timeout */
-return sal_False;
-}
-
-return (FD_ISSET(pSocket->m_Socket, ) ? sal_True : sal_False);
-}
-
-#endif /* HAVE_POLL_H */
-
 sal_Bool SAL_CALL osl_isReceiveReady (
 oslSocket pSocket, const TimeValue* pTimeout)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-04-28 Thread Stephan Bergmann (via logerrit)
 sal/osl/w32/file_url.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit c0aede431fd641ea9b92aa145db69a6d45c5bf9c
Author: Stephan Bergmann 
AuthorDate: Tue Apr 27 08:40:07 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Wed Apr 28 08:36:43 2021 +0200

loplugin:stringviewparam (clang-cl)

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

diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index 2e9bbc013233..a8d1644b7daa 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -723,7 +724,7 @@ static std::optional osl_decodeURL_(const 
OString& sUTF8)
  : std::optional();
 }
 
-static OUString osl_encodeURL_(const OUString& sURL)
+static OUString osl_encodeURL_(std::u16string_view sURL)
 {
 /* Encode non ascii characters within the URL */
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-04-27 Thread Stephan Bergmann (via logerrit)
 sal/osl/w32/file_dirvol.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d507c8b3e2939f66a395f163b5f21c29ffe59d02
Author: Stephan Bergmann 
AuthorDate: Tue Apr 27 08:39:18 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Tue Apr 27 10:48:12 2021 +0200

loplugin:nullptr (clang-cl)

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

diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index d150b36277f4..d0d5616678fb 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -247,7 +247,7 @@ struct Directory_Impl
 {
 UINT uType = 0;
 union {
-HANDLE  hDirectory = 0;
+HANDLE  hDirectory = nullptr;
 HANDLE  hEnumDrives;
 };
 OUStringm_sDirectoryPath;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-04-20 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/file_url.cxx |  207 ++-
 1 file changed, 63 insertions(+), 144 deletions(-)

New commits:
commit 81a5d8f160dbc7e2f51ed833f3cf82d0392fdd75
Author: Mike Kaganski 
AuthorDate: Tue Apr 20 19:50:19 2021 +0300
Commit: Mike Kaganski 
CommitDate: Wed Apr 21 07:41:36 2021 +0200

Simplify some code by using OUString instead of raw rtl_uString

Mimic 277554987fcd697c14f348f05e5e378d1db77ad5 in Win code

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

diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index fde2bb92b82e..2e9bbc013233 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -21,6 +21,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include 
@@ -30,6 +31,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -37,9 +39,9 @@
 
 #include "path_helper.hxx"
 
-#define WSTR_SYSTEM_ROOT_PATH   L".\\"
-#define WSTR_LONG_PATH_PREFIX   L"?\\"
-#define WSTR_LONG_PATH_PREFIX_UNC   L"?\\UNC\\"
+#define WSTR_SYSTEM_ROOT_PATH   u".\\"
+#define WSTR_LONG_PATH_PREFIX   u"?\\"
+#define WSTR_LONG_PATH_PREFIX_UNC   u"?\\UNC\\"
 
 // FileURL functions
 
@@ -313,13 +315,13 @@ DWORD IsValidFilePath(rtl_uString *path, DWORD dwFlags, 
rtl_uString **corrected)
 
 DWORD   dwCandidatPathType = PATHTYPE_ERROR;
 
-if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( 
path->buffer, nLength, o3tl::toU(WSTR_LONG_PATH_PREFIX_UNC), 
SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1, 
SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1 ) )
+if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( 
path->buffer, nLength, WSTR_LONG_PATH_PREFIX_UNC, 
SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1, 
SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1 ) )
 {
 /* This is long path in UNC notation */
 lpComponent = lpszPath + SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) 
- 1;
 dwCandidatPathType = PATHTYPE_ABSOLUTE_UNC | PATHTYPE_IS_LONGPATH;
 }
-else if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( 
path->buffer, nLength, o3tl::toU(WSTR_LONG_PATH_PREFIX), 
SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, 
SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) )
+else if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( 
path->buffer, nLength, WSTR_LONG_PATH_PREFIX, 
SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, 
SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) )
 {
 /* This is long path */
 lpComponent = lpszPath + SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1;
@@ -643,11 +645,11 @@ DWORD GetCaseCorrectPathName(
 )
 {
 /* Special handling for "\\.\" as system root */
-if ( lpszShortPath && 0 == wcscmp( lpszShortPath, WSTR_SYSTEM_ROOT_PATH ) )
+if ( lpszShortPath && 0 == wcscmp( lpszShortPath, 
o3tl::toW(WSTR_SYSTEM_ROOT_PATH) ) )
 {
 if ( cchBuffer >= SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) )
 {
-wcscpy( lpszLongPath, WSTR_SYSTEM_ROOT_PATH );
+wcscpy( lpszLongPath, o3tl::toW(WSTR_SYSTEM_ROOT_PATH) );
 return SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1;
 }
 else
@@ -667,22 +669,18 @@ DWORD GetCaseCorrectPathName(
 return 0;
 }
 
-static bool osl_decodeURL_( rtl_String* strUTF8, rtl_uString** pstrDecodedURL )
+static std::optional osl_decodeURL_(const OString& sUTF8)
 {
-char*pBuffer;
 const char  *pSrcEnd;
 const char  *pSrc;
-char*pDest;
-sal_Int32   nSrcLen;
 boolbValidEncoded = true;   /* Assume success */
 
 /* The resulting decoded string length is shorter or equal to the source 
length */
 
-nSrcLen = rtl_string_getLength(strUTF8);
-pBuffer = static_cast(malloc((nSrcLen + 1) * sizeof(char)));
+const sal_Int32 nSrcLen = sUTF8.getLength();
+OStringBuffer aBuffer(nSrcLen + 1);
 
-pDest = pBuffer;
-pSrc = rtl_string_getStr(strUTF8);
+pSrc = sUTF8.getStr();
 pSrcEnd = pSrc + nSrcLen;
 
 /* Now decode the URL what should result in a UTF-8 string */
@@ -707,7 +705,7 @@ static bool osl_decodeURL_( rtl_String* strUTF8, 
rtl_uString** pstrDecodedURL )
 if ( 0 == aChar || '\\' == aChar || '/' == aChar || ':' == 
aChar )
 bValidEncoded = false;
 else
-*pDest++ = aChar;
+aBuffer.append(aChar);
 }
 break;
 case '\0':
@@ -716,42 +714,28 @@ static bool osl_decodeURL_( rtl_String* strUTF8, 
rtl_uString** pstrDecodedURL )
 bValidEncoded = false;
 break;
 default:
-*pDest++ = *pSrc++;
+aBuffer.append(*pSrc++);
 break;
 }
 }
 

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

2021-04-20 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/file_url.cxx |   26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

New commits:
commit 277554987fcd697c14f348f05e5e378d1db77ad5
Author: Stephan Bergmann 
AuthorDate: Tue Apr 20 16:06:27 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Tue Apr 20 17:37:41 2021 +0200

Simplify some code by using OUString instead of raw rtl_uString

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

diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index d7fa6b5c3660..a738010f867b 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -369,23 +369,23 @@ oslFileError SAL_CALL osl_getSystemPathFromFileURL( 
rtl_uString *ustrFileURL, rt
 
 oslFileError SAL_CALL osl_getFileURLFromSystemPath( rtl_uString 
*ustrSystemPath, rtl_uString **pustrFileURL )
 {
-static const sal_Unicode pDoubleSlash[2] = { '/', '/' };
-
 rtl_uString *pTmp = nullptr;
 sal_Int32 nIndex;
 
-if( ustrSystemPath->length == 0 )
+auto const & systemPath = OUString::unacquired();
+
+if( systemPath.isEmpty() )
 return osl_File_E_INVAL;
 
-if( rtl_ustr_ascii_shortenedCompare_WithLength( ustrSystemPath->buffer, 
ustrSystemPath->length,"file:", 5 ) == 0 )
+if( systemPath.startsWith( "file:" ) )
 return osl_File_E_INVAL;
 
 /* check if system path starts with ~ or ~user and replace it with the 
appropriate home dir */
-if( ustrSystemPath->buffer[0] == '~' )
+if( systemPath.startsWith("~") )
 {
 /* check if another user is specified */
-if( ( ustrSystemPath->length == 1 ) ||
-( ustrSystemPath->buffer[1] == '/' ) )
+if( ( systemPath.getLength() == 1 ) ||
+( systemPath[1] == '/' ) )
 {
 /* osl_getHomeDir returns file URL */
 oslSecurity pSecurity = osl_getCurrentSecurity();
@@ -399,7 +399,7 @@ oslFileError SAL_CALL osl_getFileURLFromSystemPath( 
rtl_uString *ustrSystemPath,
 rtl_uString_newFromStr_WithLength( , pTmp->buffer + 7, 
pTmp->length - 7 );
 
 /* replace '~' in original string */
-rtl_uString_newReplaceStrAt( , ustrSystemPath, 0, 1, pTmp );
+rtl_uString_newReplaceStrAt( , systemPath.pData, 0, 1, pTmp );
 }
 else
 {
@@ -409,18 +409,18 @@ oslFileError SAL_CALL osl_getFileURLFromSystemPath( 
rtl_uString *ustrSystemPath,
 }
 
 /* check if initial string contains repeated '/' characters */
-nIndex = rtl_ustr_indexOfStr_WithLength( ustrSystemPath->buffer, 
ustrSystemPath->length, pDoubleSlash, 2 );
+nIndex = systemPath.indexOf( "//" );
 if( nIndex != -1 )
 {
 sal_Int32 nSrcIndex;
 sal_Int32 nDeleted = 0;
 
-/* if pTmp is not already allocated, copy ustrSystemPath for 
modification */
+/* if pTmp is not already allocated, copy systemPath for modification 
*/
 if( pTmp == nullptr )
-rtl_uString_newFromString( , ustrSystemPath );
+rtl_uString_newFromString( , systemPath.pData );
 
 /* adapt index to pTmp */
-nIndex += pTmp->length - ustrSystemPath->length;
+nIndex += pTmp->length - systemPath.getLength();
 
 /* replace repeated '/' characters with a single '/' */
 for( nSrcIndex = nIndex + 1; nSrcIndex < pTmp->length; nSrcIndex++ )
@@ -436,7 +436,7 @@ oslFileError SAL_CALL osl_getFileURLFromSystemPath( 
rtl_uString *ustrSystemPath,
 }
 
 if( pTmp == nullptr )
-rtl_uString_assign( , ustrSystemPath );
+rtl_uString_assign( , systemPath.pData );
 
 /* file URLs must be URI encoded */
 rtl_uriEncode( pTmp, uriCharClass, rtl_UriEncodeIgnoreEscapes, 
RTL_TEXTENCODING_UTF8, pustrFileURL );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-04-20 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/file_url.cxx |2 --
 1 file changed, 2 deletions(-)

New commits:
commit b9f0060b943fa765646ff575ad725c9e7c5a2475
Author: Stephan Bergmann 
AuthorDate: Tue Apr 20 12:45:41 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Tue Apr 20 15:35:31 2021 +0200

Remove obsolete comment

...which was already obsolete at least back in
84c4489cb7da4a9a600d102267f589b4a0419b4c "#104563#moved parts of file.c into
separate files" (where the hack had already been commented out) and should 
have
been removed in e7982510d23c4b6047f0b81bfe1c684ecb1fff8a "osl: cleanup
file_url.cxx" (which removed the commented-out code)

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

diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index ba5ccc766e6c..d7fa6b5c3660 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -377,8 +377,6 @@ oslFileError SAL_CALL osl_getFileURLFromSystemPath( 
rtl_uString *ustrSystemPath,
 if( ustrSystemPath->length == 0 )
 return osl_File_E_INVAL;
 
-/* temporary hack: if already file url, return ustrSystemPath */
-
 if( rtl_ustr_ascii_shortenedCompare_WithLength( ustrSystemPath->buffer, 
ustrSystemPath->length,"file:", 5 ) == 0 )
 return osl_File_E_INVAL;
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-04-19 Thread Noel Grandin (via logerrit)
 sal/osl/w32/file_dirvol.cxx |  305 
 1 file changed, 145 insertions(+), 160 deletions(-)

New commits:
commit 481b3bb669c7f2322723145aaf7271f844236e5e
Author: Noel Grandin 
AuthorDate: Sat Apr 17 08:50:01 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Apr 19 18:38:09 2021 +0200

flatten some code

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

diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index d7d03501f0e1..d150b36277f4 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -285,26 +285,23 @@ static HANDLE WINAPI OpenLogicalDrivesEnum()
 
 static bool WINAPI EnumLogicalDrives(HANDLE hEnum, LPWSTR lpBuffer)
 {
-boolfSuccess = false;
 LPDRIVEENUM pEnum = static_cast(hEnum);
-
-if ( pEnum )
+if ( !pEnum )
 {
-int nLen = wcslen( pEnum->lpCurrent );
+SetLastError( ERROR_INVALID_HANDLE );
+return false;
+}
 
-if ( nLen )
-{
-CopyMemory( lpBuffer, pEnum->lpCurrent, (nLen + 1) * sizeof(WCHAR) 
);
-pEnum->lpCurrent += nLen + 1;
-fSuccess = true;
-}
-else
-SetLastError( ERROR_NO_MORE_FILES );
+int nLen = wcslen( pEnum->lpCurrent );
+if ( !nLen )
+{
+SetLastError( ERROR_NO_MORE_FILES );
+return false;
 }
-else
-SetLastError( ERROR_INVALID_HANDLE );
 
-return fSuccess;
+CopyMemory( lpBuffer, pEnum->lpCurrent, (nLen + 1) * sizeof(WCHAR) );
+pEnum->lpCurrent += nLen + 1;
+return true;
 }
 
 static bool WINAPI CloseLogicalDrivesEnum(HANDLE hEnum)
@@ -335,82 +332,78 @@ typedef struct tagDIRECTORY
 
 static HANDLE WINAPI OpenDirectory( rtl_uString* pPath)
 {
-LPDIRECTORY pDirectory = nullptr;
+if ( !pPath )
+return nullptr;
 
-if ( pPath )
-{
-sal_uInt32 nLen = rtl_uString_getLength( pPath );
-if ( nLen )
-{
-const WCHAR* pSuffix = nullptr;
-sal_uInt32 nSuffLen = 0;
+sal_uInt32 nLen = rtl_uString_getLength( pPath );
+if ( !nLen )
+return nullptr;
 
-if ( pPath->buffer[nLen - 1] != L'\\' )
-{
-pSuffix = L"\\*.*";
-nSuffLen = 4;
-}
-else
-{
-pSuffix = L"*.*";
-nSuffLen = 3;
-}
+const WCHAR* pSuffix = nullptr;
+sal_uInt32 nSuffLen = 0;
+if ( pPath->buffer[nLen - 1] != L'\\' )
+{
+pSuffix = L"\\*.*";
+nSuffLen = 4;
+}
+else
+{
+pSuffix = L"*.*";
+nSuffLen = 3;
+}
 
-WCHAR* szFileMask = static_cast< WCHAR* >( malloc( sizeof( WCHAR ) 
* ( nLen + nSuffLen + 1 ) ) );
-assert(szFileMask); // Don't handle OOM conditions
-wcscpy( szFileMask, o3tl::toW(rtl_uString_getStr( pPath )) );
-wcscat( szFileMask, pSuffix );
+WCHAR* szFileMask = static_cast< WCHAR* >( malloc( sizeof( WCHAR ) * ( 
nLen + nSuffLen + 1 ) ) );
+assert(szFileMask); // Don't handle OOM conditions
+wcscpy( szFileMask, o3tl::toW(rtl_uString_getStr( pPath )) );
+wcscat( szFileMask, pSuffix );
 
-pDirectory = static_cast(HeapAlloc(GetProcessHeap(), 
0, sizeof(DIRECTORY)));
-assert(pDirectory); // Don't handle OOM conditions
-pDirectory->hFind = FindFirstFileW(szFileMask, 
>aFirstData);
+LPDIRECTORY pDirectory = 
static_cast(HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY)));
+assert(pDirectory); // Don't handle OOM conditions
+pDirectory->hFind = FindFirstFileW(szFileMask, >aFirstData);
 
-if (!IsValidHandle(pDirectory->hFind))
-{
-if ( GetLastError() != ERROR_NO_MORE_FILES )
-{
-HeapFree(GetProcessHeap(), 0, pDirectory);
-pDirectory = nullptr;
-}
-}
-free(szFileMask);
+if (!IsValidHandle(pDirectory->hFind))
+{
+if ( GetLastError() != ERROR_NO_MORE_FILES )
+{
+HeapFree(GetProcessHeap(), 0, pDirectory);
+pDirectory = nullptr;
 }
 }
+free(szFileMask);
 
 return static_cast(pDirectory);
 }
 
 static bool WINAPI EnumDirectory(HANDLE hDirectory, LPWIN32_FIND_DATAW 
pFindData)
 {
-boolfSuccess = false;
 LPDIRECTORY pDirectory = static_cast(hDirectory);
-
-if ( pDirectory )
+if ( !pDirectory )
 {
-boolfValid;
+SetLastError( ERROR_INVALID_HANDLE );
+return false;
+}
 
-do
+bool fSuccess = false;
+bool fValid;
+do
+{
+if ( pDirectory->aFirstData.cFileName[0] )
 {
-if ( pDirectory->aFirstData.cFileName[0] )
-{
-*pFindData 

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

2021-04-17 Thread Noel Grandin (via logerrit)
 sal/osl/w32/file_dirvol.cxx |  152 +++-
 1 file changed, 39 insertions(+), 113 deletions(-)

New commits:
commit 61462eff266903fe495ecd185ca84b57f6cb3cd8
Author: Noel Grandin 
AuthorDate: Thu Apr 15 10:36:08 2021 +0200
Commit: Noel Grandin 
CommitDate: Sat Apr 17 08:41:12 2021 +0200

use OUString in dir handling operations

which simplifies things nicely

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

diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index 0b8824674d79..d7d03501f0e1 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -225,14 +225,14 @@ namespace {
 
 struct DirectoryItem_Impl
 {
-UINT uType;
+UINT uType = 0;
 union {
 WIN32_FIND_DATAW FindData;
 WCHARcDriveString[MAX_PATH];
 };
-rtl_uString*m_pFullPath;
-boolbFullPathNormalized;
-int nRefCount;
+OUStringm_sFullPath;
+boolbFullPathNormalized = false;
+int nRefCount = 0;
 };
 
 }
@@ -245,12 +245,12 @@ namespace {
 
 struct Directory_Impl
 {
-UINT uType;
+UINT uType = 0;
 union {
-HANDLE  hDirectory;
+HANDLE  hDirectory = 0;
 HANDLE  hEnumDrives;
 };
-rtl_uString*m_pDirectoryPath;
+OUStringm_sDirectoryPath;
 };
 
 typedef struct tagDRIVEENUM
@@ -447,29 +447,19 @@ static oslFileError osl_openLocalRoot(
 error = osl_getSystemPathFromFileURL_( strDirectoryPath, , 
false );
 if ( osl_File_E_None == error )
 {
-Directory_Impl  *pDirImpl;
-
-pDirImpl = static_cast(malloc( 
sizeof(Directory_Impl)));
+Directory_Impl* pDirImpl = new (std::nothrow) Directory_Impl;
 assert(pDirImpl); // Don't handle OOM conditions
-ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
-rtl_uString_newFromString( >m_pDirectoryPath, strSysPath );
+pDirImpl->m_sDirectoryPath = OUString(strSysPath, SAL_NO_ACQUIRE);
 
 /* Append backslash if necessary */
 
 /* @@@ToDo
use function ensure backslash
 */
-sal_uInt32 nLen = rtl_uString_getLength( pDirImpl->m_pDirectoryPath );
-if ( nLen && pDirImpl->m_pDirectoryPath->buffer[nLen - 1] != L'\\' )
+sal_uInt32 nLen = pDirImpl->m_sDirectoryPath.getLength();
+if ( nLen && pDirImpl->m_sDirectoryPath[nLen - 1] != L'\\' )
 {
-rtl_uString* pCurDir = nullptr;
-rtl_uString* pBackSlash = nullptr;
-
-rtl_uString_assign( , pDirImpl->m_pDirectoryPath );
-rtl_uString_newFromAscii( , "\\" );
-rtl_uString_newConcat( >m_pDirectoryPath, pCurDir, 
pBackSlash );
-rtl_uString_release( pBackSlash );
-rtl_uString_release( pCurDir );
+pDirImpl->m_sDirectoryPath += "\\";
 }
 
 pDirImpl->uType = DIRECTORYTYPE_LOCALROOT;
@@ -487,20 +477,12 @@ static oslFileError osl_openLocalRoot(
 {
 if ( pDirImpl )
 {
-if ( pDirImpl->m_pDirectoryPath )
-{
-rtl_uString_release( pDirImpl->m_pDirectoryPath );
-pDirImpl->m_pDirectoryPath = nullptr;
-}
-
-free(pDirImpl);
+delete pDirImpl;
 pDirImpl = nullptr;
 }
 
 error = oslTranslateFileError( GetLastError() );
 }
-
-rtl_uString_release( strSysPath );
 }
 return error;
 }
@@ -514,43 +496,27 @@ static oslFileError osl_openFileDirectory(
 return osl_File_E_INVAL;
 *pDirectory = nullptr;
 
-Directory_Impl *pDirImpl = 
static_cast(malloc(sizeof(Directory_Impl)));
+Directory_Impl *pDirImpl = new (std::nothrow) Directory_Impl;
 assert(pDirImpl); // Don't handle OOM conditions
-ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
-rtl_uString_newFromString( >m_pDirectoryPath, strDirectoryPath );
+pDirImpl->m_sDirectoryPath = strDirectoryPath;
 
 /* Append backslash if necessary */
 
 /* @@@ToDo
use function ensure backslash
 */
-sal_uInt32 nLen = rtl_uString_getLength( pDirImpl->m_pDirectoryPath );
-if ( nLen && pDirImpl->m_pDirectoryPath->buffer[nLen - 1] != L'\\' )
-{
-rtl_uString* pCurDir = nullptr;
-rtl_uString* pBackSlash = nullptr;
-
-rtl_uString_assign( , pDirImpl->m_pDirectoryPath );
-rtl_uString_newFromAscii( , "\\" );
-rtl_uString_newConcat( >m_pDirectoryPath, pCurDir, 
pBackSlash );
-rtl_uString_release( pBackSlash );
-rtl_uString_release( pCurDir );
-}
+sal_uInt32 nLen = pDirImpl->m_sDirectoryPath.getLength();
+if ( nLen && pDirImpl->m_sDirectoryPath[nLen - 1] != '\\' )
+pDirImpl->m_sDirectoryPath += "\\";
 
  

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

2021-04-16 Thread Noel Grandin (via logerrit)
 sal/osl/w32/module.cxx|   58 ++--
 sal/osl/w32/nlsupport.cxx |  105 
 sal/osl/w32/pipe.cxx  |   32 +-
 sal/osl/w32/security.cxx  |  552 ++
 sal/osl/w32/socket.cxx|   91 +++
 sal/osl/w32/time.cxx  |   55 ++--
 6 files changed, 435 insertions(+), 458 deletions(-)

New commits:
commit 8b127d938d852d0ec3590cc05ee2d5b50d8e70b7
Author: Noel Grandin 
AuthorDate: Fri Apr 16 11:52:37 2021 +0200
Commit: Noel Grandin 
CommitDate: Fri Apr 16 14:50:28 2021 +0200

flatten some code in sal/osl/w32

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

diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx
index 67eeb2df0f6d..620be0e6d664 100644
--- a/sal/osl/w32/module.cxx
+++ b/sal/osl/w32/module.cxx
@@ -182,49 +182,49 @@ osl_getAsciiFunctionSymbol( oslModule Module, const char 
*pSymbol )
 
 sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, rtl_uString 
**pustrURL )
 {
-boolbSuccess= false;/* Assume failure */
 static HMODULE hModPsapi = LoadLibraryW( L"PSAPI.DLL" );
 static auto lpfnEnumProcessModules = 
reinterpret_cast(
 hModPsapi ? GetProcAddress(hModPsapi, "EnumProcessModules") : nullptr);
 static auto lpfnGetModuleInformation = 
reinterpret_cast(
 hModPsapi ? GetProcAddress(hModPsapi, "GetModuleInformation") : 
nullptr);
 
-if (lpfnEnumProcessModules && lpfnGetModuleInformation)
-{
-DWORD cbNeeded = 0;
-HMODULE* lpModules = nullptr;
-DWORD nModules = 0;
-UINT iModule = 0;
-MODULEINFO modinfo;
+if (!lpfnEnumProcessModules || !lpfnGetModuleInformation)
+return false;
 
-lpfnEnumProcessModules(GetCurrentProcess(), nullptr, 0, );
+bool bSuccess= false;/* Assume failure */
+DWORD cbNeeded = 0;
+HMODULE* lpModules = nullptr;
+DWORD nModules = 0;
+UINT iModule = 0;
+MODULEINFO modinfo;
 
-lpModules = static_cast(_alloca(cbNeeded));
-lpfnEnumProcessModules(GetCurrentProcess(), lpModules, cbNeeded, 
);
+lpfnEnumProcessModules(GetCurrentProcess(), nullptr, 0, );
 
-nModules = cbNeeded / sizeof(HMODULE);
+lpModules = static_cast(_alloca(cbNeeded));
+lpfnEnumProcessModules(GetCurrentProcess(), lpModules, cbNeeded, 
);
 
-for (iModule = 0; !bSuccess && iModule < nModules; iModule++)
-{
-lpfnGetModuleInformation(GetCurrentProcess(), lpModules[iModule], 
,
- sizeof(modinfo));
+nModules = cbNeeded / sizeof(HMODULE);
 
-if (static_cast(pv) >= 
static_cast(modinfo.lpBaseOfDll)
-&& static_cast(pv)
-   < static_cast(modinfo.lpBaseOfDll) + 
modinfo.SizeOfImage)
-{
-::osl::LongPathBuffer aBuffer(MAX_LONG_PATH);
-rtl_uString* ustrSysPath = nullptr;
+for (iModule = 0; !bSuccess && iModule < nModules; iModule++)
+{
+lpfnGetModuleInformation(GetCurrentProcess(), lpModules[iModule], 
,
+ sizeof(modinfo));
+
+if (static_cast(pv) >= static_cast(modinfo.lpBaseOfDll)
+&& static_cast(pv)
+   < static_cast(modinfo.lpBaseOfDll) + 
modinfo.SizeOfImage)
+{
+::osl::LongPathBuffer aBuffer(MAX_LONG_PATH);
+rtl_uString* ustrSysPath = nullptr;
 
-GetModuleFileNameW(lpModules[iModule], o3tl::toW(aBuffer),
-   aBuffer.getBufSizeInSymbols());
+GetModuleFileNameW(lpModules[iModule], o3tl::toW(aBuffer),
+   aBuffer.getBufSizeInSymbols());
 
-rtl_uString_newFromStr(, aBuffer);
-osl_getFileURLFromSystemPath(ustrSysPath, pustrURL);
-rtl_uString_release(ustrSysPath);
+rtl_uString_newFromStr(, aBuffer);
+osl_getFileURLFromSystemPath(ustrSysPath, pustrURL);
+rtl_uString_release(ustrSysPath);
 
-bSuccess = true;
-}
+bSuccess = true;
 }
 }
 
diff --git a/sal/osl/w32/nlsupport.cxx b/sal/osl/w32/nlsupport.cxx
index e253cc0cb7e8..f27b97aa7101 100644
--- a/sal/osl/w32/nlsupport.cxx
+++ b/sal/osl/w32/nlsupport.cxx
@@ -77,38 +77,39 @@ static BOOL CALLBACK EnumLocalesProcW( LPWSTR 
lpLocaleStringW )
 /*
 get the ISO language code for this locale
 */
-if( GetLocaleInfoW( localeId, LOCALE_SISO639LANGNAME , langCode, 
ELP_LANGUAGE_FIELD_LENGTH ) )
-{
-WCHAR ctryCode[ELP_COUNTRY_FIELD_LENGTH];
+if( !GetLocaleInfoW( localeId, LOCALE_SISO639LANGNAME , langCode, 
ELP_LANGUAGE_FIELD_LENGTH ) )
+/* retry by going on */
+return TRUE;
+
+WCHAR ctryCode[ELP_COUNTRY_FIELD_LENGTH];
 
-/* continue if language code does not match */
- 

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

2021-04-16 Thread Noel Grandin (via logerrit)
 sal/osl/w32/file_dirvol.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit e36c2b46981f87a4d01a8552d4440a42a6770429
Author: Noel Grandin 
AuthorDate: Thu Apr 15 10:05:00 2021 +0200
Commit: Noel Grandin 
CommitDate: Fri Apr 16 08:59:40 2021 +0200

set path to fully normalized in osl_getNextFileItem

which speeds up startup, because then we don't need to do the
GetCaseCorrect stuff when scanning large folders of fonts.

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

diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index 6f0b18cbda8b..0b8824674d79 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -890,7 +890,7 @@ static oslFileError osl_getNextFileItem(
 rtl_uString_newConcat( >m_pFullPath, 
pDirImpl->m_pDirectoryPath, pTmpFileName );
 rtl_uString_release( pTmpFileName );
 
-pItemImpl->bFullPathNormalized = false;
+pItemImpl->bFullPathNormalized = true;
 *pItem = static_cast(pItemImpl);
 return osl_File_E_None;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-03-12 Thread Andrea Gelmini (via logerrit)
 sal/osl/w32/file.cxx|2 +-
 sfx2/source/devtools/ObjectInspectorTreeHandler.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 5e404d6289f433e72218e13ed5a083b59dbc307b
Author: Andrea Gelmini 
AuthorDate: Fri Mar 12 17:19:32 2021 +0100
Commit: Adolfo Jayme Barrientos 
CommitDate: Fri Mar 12 19:54:29 2021 +0100

Fix typos

Change-Id: I7366c5e7d6c9fb4dd7aa17a5d0405f28179a92af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112399
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index 44b8ac97ba09..1c13b6211779 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -657,7 +657,7 @@ oslFileError SAL_CALL osl_openFile(
 if (result != osl_File_E_None)
 return result;
 
-// tdf126742 use FILE_SHARE_WRITE to get closer to non-Windows plattform 
behavoiur,
+// tdf126742 use FILE_SHARE_WRITE to get closer to non-Windows platform 
behaviour,
 // for details and discussion see task please
 DWORD dwAccess = GENERIC_READ, dwShare = FILE_SHARE_READ | 
FILE_SHARE_WRITE, dwCreation = 0;
 
diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx 
b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
index 6b6a1bdfcc1d..58f14e16274a 100644
--- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
+++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
@@ -442,7 +442,7 @@ public:
 
 bool shouldShowExpander() override
 {
-// Show expnder only if the sequence has elements
+// Show expander only if the sequence has elements
 int nLength = mxIdlArray->getLen(maAny);
 return nLength > 0;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-03-12 Thread Armin Le Grand (Allotropia) (via logerrit)
 sal/osl/w32/file.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 2b4cd99d3360ccffb9829a02412824864d045753
Author: Armin Le Grand (Allotropia) 
AuthorDate: Tue Mar 9 19:53:25 2021 +0100
Commit: Armin Le Grand 
CommitDate: Fri Mar 12 10:01:33 2021 +0100

tdf#126742 make Windows file handling more unx-like

The bug mentioned happens due to a system-dependent
difference: Unx-systems allow files to be opened for
write multiple times while our windows implementation
until now did prevent that.
For that reason an embedded OLE which is still opened
in the same LO instance behaves wrong/strange - the
e.g. changed size cannot be written (to the file).
Since we already have unx-like handling and in that
scenario useful sync has to be done anyways, no new
scenario will be created. Only Windows implemenation
will change to behave closer to unx-like behaviour,
I already test-built that on gerrit to make sure all
tests for Windows work as before.
I thought about this for quite some time, but see no
too big risk. For thoughts/discussion please refer
to the task.

Change-Id: I8dbfd70c2f69d0a013f445e152e597f37fa6ecc7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112237
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 

diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index ca31d714dfef..44b8ac97ba09 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -657,15 +657,15 @@ oslFileError SAL_CALL osl_openFile(
 if (result != osl_File_E_None)
 return result;
 
-DWORD dwAccess = GENERIC_READ, dwShare = FILE_SHARE_READ, dwCreation = 0;
+// tdf126742 use FILE_SHARE_WRITE to get closer to non-Windows plattform 
behavoiur,
+// for details and discussion see task please
+DWORD dwAccess = GENERIC_READ, dwShare = FILE_SHARE_READ | 
FILE_SHARE_WRITE, dwCreation = 0;
 
 if (uFlags & osl_File_OpenFlag_Write)
 dwAccess |= GENERIC_WRITE;
-else
-dwShare  |= FILE_SHARE_WRITE;
 
 if (uFlags & osl_File_OpenFlag_NoLock)
-dwShare  |= FILE_SHARE_WRITE | FILE_SHARE_DELETE;
+dwShare  |= FILE_SHARE_DELETE;
 
 if (uFlags & osl_File_OpenFlag_Create)
 dwCreation |= CREATE_NEW;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-03-04 Thread Tor Lillqvist (via logerrit)
 sal/osl/unx/backtrace.c |   69 
 1 file changed, 1 insertion(+), 68 deletions(-)

New commits:
commit 6b439e81a1916bcb42fb0fc24b1aea06e2da0d1e
Author: Tor Lillqvist 
AuthorDate: Thu Mar 4 11:56:50 2021 +0200
Commit: Tor Lillqvist 
CommitDate: Thu Mar 4 12:55:59 2021 +0100

The backtrace() etc API is available on macOS and iOS, too

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

diff --git a/sal/osl/unx/backtrace.c b/sal/osl/unx/backtrace.c
index a3aeb3dae3f8..26005f7715af 100644
--- a/sal/osl/unx/backtrace.c
+++ b/sal/osl/unx/backtrace.c
@@ -212,74 +212,7 @@ void backtrace_symbols_fd( void **buffer, int size, int fd 
)
 }
 }
 
-#elif defined( MACOSX )
-
-#include 
-#include 
-#include "backtrace.h"
-
-/* glib backtrace is only available on MacOsX 10.5 or higher
-   so we do it on our own */
-
-int backtrace( void **buffer, int max_frames )
-{
-void **frame = (void **)__builtin_frame_address(0);
-void **bp = ( void **)(*frame);
-void *ip = frame[1];
-int i;
-
-for ( i = 0; bp && ip && i < max_frames; i++ )
-{
-*(buffer++) = ip;
-
-ip = bp[1];
-bp = (void**)(bp[0]);
-}
-
-return i;
-}
-
-char ** backtrace_symbols(void * const * buffer, int size)
-{
-(void)buffer; (void)size;
-return NULL; /*TODO*/
-}
-
-void backtrace_symbols_fd( void **buffer, int size, int fd )
-{
-FILE*fp = fdopen( fd, "w" );
-
-if ( fp )
-{
-void **pFramePtr;
-
-for ( pFramePtr = buffer; size > 0 && pFramePtr && *pFramePtr; 
pFramePtr++, size-- )
-{
-Dl_info dli;
-
-if ( 0 != dladdr( *pFramePtr,  ) )
-{
-ptrdiff_t offset;
-
-if ( dli.dli_fname && dli.dli_fbase )
-{
-offset = (ptrdiff_t)*pFramePtr - (ptrdiff_t)dli.dli_fbase;
-fprintf( fp, "%s+0x%tx", dli.dli_fname, offset );
-}
-if ( dli.dli_sname && dli.dli_saddr )
-{
-offset = (ptrdiff_t)*pFramePtr - (ptrdiff_t)dli.dli_saddr;
-fprintf( fp, "(%s+0x%tx)", dli.dli_sname, offset );
-}
-}
-fprintf( fp, "[%p]\n", *pFramePtr );
-}
-
-fclose( fp );
-}
-}
-
-#elif !defined LINUX
+#elif !defined LINUX && !defined MACOSX && !defined IOS
 
 int backtrace( void **buffer, int max_frames )
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-02-16 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/module.cxx |   28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

New commits:
commit c8976bdfdfa361fec9e1e5ff342094e409981fad
Author: Stephan Bergmann 
AuthorDate: Tue Feb 16 20:57:05 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Tue Feb 16 22:16:04 2021 +0100

tdf#137208 Assume that dladdr provides an absolute pathname

3dfb38a45d6495d357c3359b5b02cde871df6f67 "added getUrlFromAddress 
(#88338#)" had
introduced the call to osl_getAbsoluteFileURL for no documented reason, but 
it
looks unlikely that any relevant implementation of dladdr (as called by
getModulePathFromAddress; and where dladdr is a non-POSIX extension on the
various platforms) would provide pathnames that are relative to the 
process's
CWD.

(Instead, add a check whether osl_getFileURLFromSystemPath succeeds.)

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

diff --git a/sal/osl/unx/module.cxx b/sal/osl/unx/module.cxx
index 7669c047a7a3..72653a997f92 100644
--- a/sal/osl/unx/module.cxx
+++ b/sal/osl/unx/module.cxx
@@ -298,27 +298,27 @@ sal_Bool SAL_CALL osl_getModuleURLFromAddress(void * 
addr, rtl_uString ** ppLibr
 rtl_String * path = nullptr;
 if (getModulePathFromAddress(addr, ))
 {
-rtl_uString * workDir = nullptr;
-osl_getProcessWorkingDir();
-if (workDir)
+rtl_string2UString(ppLibraryUrl,
+   path->buffer,
+   path->length,
+   osl_getThreadTextEncoding(),
+   OSTRING_TO_OUSTRING_CVTFLAGS);
+
+SAL_WARN_IF(
+*ppLibraryUrl == nullptr, "sal.osl", "rtl_string2UString failed");
+auto const e = osl_getFileURLFromSystemPath(*ppLibraryUrl, 
ppLibraryUrl);
+if (e == osl_File_E_None)
 {
-rtl_string2UString(ppLibraryUrl,
-   path->buffer,
-   path->length,
-   osl_getThreadTextEncoding(),
-   OSTRING_TO_OUSTRING_CVTFLAGS);
-
-SAL_WARN_IF(
-*ppLibraryUrl == nullptr, "sal.osl", "rtl_string2UString 
failed");
-osl_getFileURLFromSystemPath(*ppLibraryUrl, ppLibraryUrl);
-osl_getAbsoluteFileURL(workDir, *ppLibraryUrl, ppLibraryUrl);
 SAL_INFO("sal.osl", "osl_getModuleURLFromAddress(" << addr << ") 
=> " << OUString(*ppLibraryUrl));
 
-rtl_uString_release(workDir);
 result = true;
 }
 else
 {
+SAL_WARN(
+"sal.osl",
+"osl_getModuleURLFromAddress(" << addr << "), 
osl_getFileURLFromSystemPath("
+<< OUString::unacquired(ppLibraryUrl) << ") failed with " 
<< e);
 result = false;
 }
 rtl_string_release(path);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-02-16 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/module.cxx |7 ---
 1 file changed, 7 deletions(-)

New commits:
commit 0b86394983e05f7ffecb9e20792aba090680eff6
Author: Stephan Bergmann 
AuthorDate: Tue Feb 16 11:02:45 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Tue Feb 16 16:46:57 2021 +0100

Remove dead "defined(ANDROID) && !defined(DISABLE_DYNLOADING)" code

4b7e701024219be48b7f8154a508c79cb0a6fdc1 "Use DISABLE_DYNLOADING on 
Android" has
removed lo_dladdr, so this conditional code is apparently dead, and its 
clean-up
was presumably forgotten in that commit.

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

diff --git a/sal/osl/unx/module.cxx b/sal/osl/unx/module.cxx
index 7befa66678f6..7669c047a7a3 100644
--- a/sal/osl/unx/module.cxx
+++ b/sal/osl/unx/module.cxx
@@ -89,18 +89,11 @@ static bool getModulePathFromAddress(void * address, 
rtl_String ** path) {
 #else
 Dl_info dl_info;
 
-#if defined(ANDROID) && !defined(DISABLE_DYNLOADING)
-result = lo_dladdr(address, _info) != 0;
-#else
 result = dladdr(address, _info) != 0;
-#endif
 
 if (result)
 {
 rtl_string_newFromStr(path, dl_info.dli_fname);
-#if defined(ANDROID) && !defined(DISABLE_DYNLOADING)
-free((void *) dl_info.dli_fname);
-#endif
 }
 #endif
 return result;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-02-15 Thread Mike Kaganski (via logerrit)
 sal/osl/unx/tempfile.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 376101c41cf23852b19db5725b0257069f3abd2e
Author: Mike Kaganski 
AuthorDate: Mon Feb 15 13:40:13 2021 +0300
Commit: Mike Kaganski 
CommitDate: Mon Feb 15 14:34:51 2021 +0100

Do not remove '/' when it's the only character in the path

Follow-up to commit 3380163bc0fb9dab7f289cc36b0eeb0c9b3ddaa9.

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

diff --git a/sal/osl/unx/tempfile.cxx b/sal/osl/unx/tempfile.cxx
index b91d4b6e0ac7..00ae0664b2c0 100644
--- a/sal/osl/unx/tempfile.cxx
+++ b/sal/osl/unx/tempfile.cxx
@@ -51,7 +51,7 @@ oslFileError SAL_CALL osl_getTempDirURL( rtl_uString** 
pustrTempDir )
 pValue = "/tmp";
 
 auto nLen = strlen(pValue);
-while (nLen && pValue[nLen - 1] == '/')
+while (nLen > 1 && pValue[nLen - 1] == '/') // Allow path consisting of 
single "/"
 --nLen;
 rtl_string2UString( , pValue, nLen, 
osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
 assert(ustrTempPath);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-02-15 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/tempfile.cxx |   11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

New commits:
commit 181fc61c4cce5192e57657c313ee7fa4f640fb69
Author: Mike Kaganski 
AuthorDate: Mon Feb 15 12:49:30 2021 +0100
Commit: Mike Kaganski 
CommitDate: Mon Feb 15 14:34:37 2021 +0100

Reuse known length of the temp dir path

And make this code a bit more C++-ish.

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

diff --git a/sal/osl/w32/tempfile.cxx b/sal/osl/w32/tempfile.cxx
index 5424bfbde077..a4c272e57768 100644
--- a/sal/osl/w32/tempfile.cxx
+++ b/sal/osl/w32/tempfile.cxx
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 
 #include "file-impl.hxx"
 #include "file_error.hxx"
@@ -227,16 +228,12 @@ oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** 
pustrTempDir)
 }
 else if ( nLength )
 {
-rtl_uString *ustrTempPath = nullptr;
-
 if ( '\\' == lpBuffer[nLength-1] )
-lpBuffer[nLength-1] = 0;
-
-rtl_uString_newFromStr( , o3tl::toU(lpBuffer) );
+--nLength;
 
-error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir );
+const OUString ustrTempPath(o3tl::toU(lpBuffer), 
static_cast(nLength));
 
-rtl_uString_release( ustrTempPath );
+error = osl_getFileURLFromSystemPath(ustrTempPath.pData, pustrTempDir);
 }
 else
 error = oslTranslateFileError( GetLastError() );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-02-12 Thread Mike Kaganski (via logerrit)
 sal/osl/unx/tempfile.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 3380163bc0fb9dab7f289cc36b0eeb0c9b3ddaa9
Author: Mike Kaganski 
AuthorDate: Fri Feb 12 14:40:13 2021 +0100
Commit: Mike Kaganski 
CommitDate: Fri Feb 12 18:20:30 2021 +0100

Make sure osl_getTempDirURL result doesn't end with / also on unx

This is consistent with what osl_getTempDirURL does on Windows
This is a blind attempt to fix a part of a failure reported on IRC:

  /lode/dev/core/sal/qa/osl/file/osl_File.cxx:486: Assertion
  Test name: osl_FileBase::getAbsoluteFileURL::getAbsoluteFileURL_001_1
  equality assertion failed
  - Expected: 
file:///var/folders/tj/jl7sh26124n4b94tm541m6xrgn/T//relative/file1
  - Actual  : 
file:///private/var/folders/tj/jl7sh26124n4b94tm541m6xrgn/T/relative/file1
  - Assumption is wrong: ResultURL is not equal to expected URL

That "//" in Expected might be because user's TMPDIR ends with /.

Change-Id: I9a9c6e00f63b81dbaf2e8532110dffa58ebe8cc9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110784
Reviewed-by: Christian Lohmaier 
Tested-by: Jenkins

diff --git a/sal/osl/unx/tempfile.cxx b/sal/osl/unx/tempfile.cxx
index 01247ae24fe3..b91d4b6e0ac7 100644
--- a/sal/osl/unx/tempfile.cxx
+++ b/sal/osl/unx/tempfile.cxx
@@ -50,7 +50,10 @@ oslFileError SAL_CALL osl_getTempDirURL( rtl_uString** 
pustrTempDir )
 if ( !pValue )
 pValue = "/tmp";
 
-rtl_string2UString( , pValue, strlen( pValue ), 
osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
+auto nLen = strlen(pValue);
+while (nLen && pValue[nLen - 1] == '/')
+--nLen;
+rtl_string2UString( , pValue, nLen, 
osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
 assert(ustrTempPath);
 error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir );
 rtl_uString_release( ustrTempPath );
___
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 vcl/unx

2021-01-31 Thread Andrea Gelmini (via logerrit)
 sal/osl/w32/file_url.cxx |4 ++--
 vcl/unx/gtk3/gtk3gtkinst.cxx |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit c0a91ae8f45bc340918a5b2bac41a0f3db5ee61a
Author: Andrea Gelmini 
AuthorDate: Sat Jan 30 19:30:58 2021 +0100
Commit: Julien Nabet 
CommitDate: Sun Jan 31 09:23:21 2021 +0100

Fix typos

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

diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index c2094f568edd..b0b266e0d40e 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -436,7 +436,7 @@ static DWORD GetCaseCorrectPathNameEx(
 
 PathAddBackslash( lpszPath, cchBuffer );
 
-/* Analyze parent if not only a trailing backslash was cutted but 
a real file spec */
+/* Analyze parent if not only a trailing backslash was cut but a 
real file spec */
 if ( !bSkipThis )
 {
 if ( bCheckExistence )
@@ -1016,7 +1016,7 @@ OUString combinePath(rtl_uString* basePath, const 
sal_Unicode* relPath)
 const bool needSep = basePath->buffer[basePath->length - 1] != '\\' && 
relPath[0] != '\\';
 const auto sSeparator = needSep ? std::u16string_view(u"\\") : 
std::u16string_view();
 if (basePath->buffer[basePath->length - 1] == '\\' && relPath[0] == '\\')
-++relPath; // avoid two agjacent backslashes
+++relPath; // avoid two adjacent backslashes
 return OUString::unacquired() + sSeparator + relPath;
 }
 }
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 735a8fd24e68..12dc1b224ebf 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -6035,8 +6035,8 @@ public:
 }
 
 m_pScrollBarCssProvider = gtk_css_provider_new();
-OUString aBuffer = "scrollbar contents trough { background-color: #" + 
rBackgroundColor.AsRGBHexString() + "; } "
-   "scrollbar contents trough slider { 
background-color: #" + rShadowColor.AsRGBHexString() + "; } "
+OUString aBuffer = "scrollbar contents through { background-color: #" 
+ rBackgroundColor.AsRGBHexString() + "; } "
+   "scrollbar contents through slider { 
background-color: #" + rShadowColor.AsRGBHexString() + "; } "
"scrollbar contents button { background-color: #" + 
rFaceColor.AsRGBHexString() + "; } "
"scrollbar contents button { color: #00; } "
"scrollbar contents button:disabled { color: 
#7f7f7f; }";
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-01-30 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/dllentry.cxx |4 
 sal/osl/w32/thread.cxx   |   35 ++-
 sal/osl/w32/thread.hxx   |2 --
 3 files changed, 10 insertions(+), 31 deletions(-)

New commits:
commit 396c2ad2daad6fe6a11703d0ae1593929834afe2
Author: Mike Kaganski 
AuthorDate: Sat Jan 30 19:56:46 2021 +0300
Commit: Mike Kaganski 
CommitDate: Sun Jan 31 00:50:34 2021 +0100

Use C++ thread_local instead of Tls* WinAPI

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

diff --git a/sal/osl/w32/dllentry.cxx b/sal/osl/w32/dllentry.cxx
index a36e6cda8840..81139a05852b 100644
--- a/sal/osl/w32/dllentry.cxx
+++ b/sal/osl/w32/dllentry.cxx
@@ -84,8 +84,6 @@ static BOOL WINAPI RawDllMain( HINSTANCE, DWORD fdwReason, 
LPVOID )
 SetErrorMode( SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS 
);
 #endif
 
-g_dwTLSTextEncodingIndex = TlsAlloc();
-
 //We disable floating point exceptions. This is the usual 
state at program startup
 //but on Windows 98 and ME this is not always the case.
 _control87(_MCW_EM, _MCW_EM);
@@ -95,8 +93,6 @@ static BOOL WINAPI RawDllMain( HINSTANCE, DWORD fdwReason, 
LPVOID )
 case DLL_PROCESS_DETACH:
 WSACleanup( );
 
-TlsFree( g_dwTLSTextEncodingIndex );
-
 /*
 
 On a product build memory management finalization might
diff --git a/sal/osl/w32/thread.cxx b/sal/osl/w32/thread.cxx
index f11c17668371..c10950e9151f 100644
--- a/sal/osl/w32/thread.cxx
+++ b/sal/osl/w32/thread.cxx
@@ -520,36 +520,21 @@ sal_Bool SAL_CALL osl_setThreadKeyData(oslThreadKey Key, 
void *pData)
 return false;
 }
 
-DWORD   g_dwTLSTextEncodingIndex = DWORD(-1);
-
-rtl_TextEncoding SAL_CALL osl_getThreadTextEncoding(void)
+namespace
 {
-DWORD_PTR   dwEncoding;
-rtl_TextEncoding_encoding;
-boolgotACP;
-
-if ( DWORD(-1) == g_dwTLSTextEncodingIndex )
-g_dwTLSTextEncodingIndex = TlsAlloc();
-
-dwEncoding = reinterpret_cast(TlsGetValue( 
g_dwTLSTextEncodingIndex ));
-_encoding = LOWORD(dwEncoding);
-gotACP = HIWORD(dwEncoding);
-
-if ( !gotACP )
-{
-_encoding = rtl_getTextEncodingFromWindowsCodePage( GetACP() );
-TlsSetValue( g_dwTLSTextEncodingIndex, 
reinterpret_cast(static_cast(MAKELONG( _encoding, TRUE ))) );
-}
-
-return _encoding;
+rtl_TextEncoding& getThreadTextEncodingImpl()
+{
+static thread_local rtl_TextEncoding s_enc = 
rtl_getTextEncodingFromWindowsCodePage(GetACP());
+return s_enc;
+}
 }
 
+rtl_TextEncoding SAL_CALL osl_getThreadTextEncoding(void) { return 
getThreadTextEncodingImpl(); }
+
 rtl_TextEncoding SAL_CALL osl_setThreadTextEncoding( rtl_TextEncoding Encoding 
)
 {
-rtl_TextEncoding oldEncoding = osl_getThreadTextEncoding();
-
-TlsSetValue( g_dwTLSTextEncodingIndex, 
reinterpret_cast(static_cast(MAKELONG( Encoding, TRUE))) );
-
+rtl_TextEncoding oldEncoding = getThreadTextEncodingImpl();
+getThreadTextEncodingImpl() = Encoding;
 return oldEncoding;
 }
 
diff --git a/sal/osl/w32/thread.hxx b/sal/osl/w32/thread.hxx
index 03491a8341c1..8740fb72cc56 100644
--- a/sal/osl/w32/thread.hxx
+++ b/sal/osl/w32/thread.hxx
@@ -16,8 +16,6 @@
 
 void osl_callThreadKeyCallbackOnThreadDetach(void);
 
-extern DWORD g_dwTLSTextEncodingIndex;
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-01-29 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/file_url.cxx |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit f2a9629658e35103a072181e6954cb2de8b1b0b0
Author: Mike Kaganski 
AuthorDate: Sat Jan 30 09:13:53 2021 +0300
Commit: Mike Kaganski 
CommitDate: Sat Jan 30 08:09:32 2021 +0100

Reinstate still relevant bits of comment

... removed in commit 6e0fa7d4c7b45c98418c289d1d4715eb9eb133f7.

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

diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index e71da15a66b9..c2094f568edd 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -1042,7 +1042,10 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( 
rtl_uString* ustrBaseURL, rtl_uStr
 if ( !eError )
 {
 OUString sResultPath;
-
+/*@@@ToDo
+  The whole FileURL implementation should be merged
+  with the rtl/uri class.
+*/
 // If ustrRelSysPath is absolute, we don't need ustrBaseSysPath.
 if (ustrBaseSysPath && !isAbsolute(ustrRelSysPath))
 {
@@ -1051,7 +1054,7 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( 
rtl_uString* ustrBaseURL, rtl_uStr
 
 // Don't use SetCurrentDirectoryW together with GetFullPathNameW, 
because:
 // (a) it needs synchronization and may affect threads that may 
access relative paths;
-// (b) it would fail or give wrong results for non-existing base 
path (possible in URL).
+// (b) it would give wrong results for non-existing base path 
(allowed by RFC2396).
 
 if (startsWithDriveColon(ustrRelSysPath))
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-01-29 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/dllentry.cxx |2 --
 sal/osl/w32/thread.cxx   |   19 ++-
 sal/osl/w32/thread.hxx   |2 --
 3 files changed, 10 insertions(+), 13 deletions(-)

New commits:
commit ab91f93cfb0e16462a7979b12e3e3de843527548
Author: Mike Kaganski 
AuthorDate: Fri Jan 29 13:47:35 2021 +0300
Commit: Mike Kaganski 
CommitDate: Sat Jan 30 07:33:45 2021 +0100

Use function-local static Mutex here instead of global CRITICAL_SECTION

Our Mutes uses sritical sections on Windows anyway

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

diff --git a/sal/osl/w32/dllentry.cxx b/sal/osl/w32/dllentry.cxx
index 06857df6bbc5..3dba6d0e0c9f 100644
--- a/sal/osl/w32/dllentry.cxx
+++ b/sal/osl/w32/dllentry.cxx
@@ -89,7 +89,6 @@ static BOOL WINAPI RawDllMain( HINSTANCE, DWORD fdwReason, 
LPVOID )
 g_Mutex = osl_createMutex();
 
 g_dwTLSTextEncodingIndex = TlsAlloc();
-InitializeCriticalSection( _ThreadKeyListCS );
 
 //We disable floating point exceptions. This is the usual 
state at program startup
 //but on Windows 98 and ME this is not always the case.
@@ -101,7 +100,6 @@ static BOOL WINAPI RawDllMain( HINSTANCE, DWORD fdwReason, 
LPVOID )
 WSACleanup( );
 
 TlsFree( g_dwTLSTextEncodingIndex );
-DeleteCriticalSection( _ThreadKeyListCS );
 
 osl_destroyMutex( g_Mutex );
 
diff --git a/sal/osl/w32/thread.cxx b/sal/osl/w32/thread.cxx
index 19479de033cd..f11c17668371 100644
--- a/sal/osl/w32/thread.cxx
+++ b/sal/osl/w32/thread.cxx
@@ -21,6 +21,7 @@
 #include "thread.hxx"
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -391,16 +392,20 @@ typedef struct TLS_
 struct TLS_ *pNext, *pPrev;
 } TLS, *PTLS;
 
+PTLS g_pThreadKeyList = nullptr;
+osl::Mutex& getThreadKeyListMutex()
+{
+static osl::Mutex g_ThreadKeyListMutex;
+return g_ThreadKeyListMutex;
 }
 
-static  PTLSg_pThreadKeyList = nullptr;
-CRITICAL_SECTIONg_ThreadKeyListCS;
+}
 
 static void AddKeyToList( PTLS pTls )
 {
 if ( pTls )
 {
-EnterCriticalSection( _ThreadKeyListCS );
+osl::MutexGuard aGuard(getThreadKeyListMutex());
 
 pTls->pNext = g_pThreadKeyList;
 pTls->pPrev = nullptr;
@@ -409,8 +414,6 @@ static void AddKeyToList( PTLS pTls )
 g_pThreadKeyList->pPrev = pTls;
 
 g_pThreadKeyList = pTls;
-
-LeaveCriticalSection( _ThreadKeyListCS );
 }
 }
 
@@ -418,7 +421,7 @@ static void RemoveKeyFromList( PTLS pTls )
 {
 if ( pTls )
 {
-EnterCriticalSection( _ThreadKeyListCS );
+osl::MutexGuard aGuard(getThreadKeyListMutex());
 if ( pTls->pPrev )
 pTls->pPrev->pNext = pTls->pNext;
 else
@@ -429,7 +432,6 @@ static void RemoveKeyFromList( PTLS pTls )
 
 if ( pTls->pNext )
 pTls->pNext->pPrev = pTls->pPrev;
-LeaveCriticalSection( _ThreadKeyListCS );
 }
 }
 
@@ -437,7 +439,7 @@ void osl_callThreadKeyCallbackOnThreadDetach(void)
 {
 PTLSpTls;
 
-EnterCriticalSection( _ThreadKeyListCS );
+osl::MutexGuard aGuard(getThreadKeyListMutex());
 pTls = g_pThreadKeyList;
 while ( pTls )
 {
@@ -451,7 +453,6 @@ void osl_callThreadKeyCallbackOnThreadDetach(void)
 
 pTls = pTls->pNext;
 }
-LeaveCriticalSection( _ThreadKeyListCS );
 }
 
 oslThreadKey SAL_CALL osl_createThreadKey(oslThreadKeyCallbackFunction 
pCallback)
diff --git a/sal/osl/w32/thread.hxx b/sal/osl/w32/thread.hxx
index c7455aab8b0c..03491a8341c1 100644
--- a/sal/osl/w32/thread.hxx
+++ b/sal/osl/w32/thread.hxx
@@ -18,8 +18,6 @@ void osl_callThreadKeyCallbackOnThreadDetach(void);
 
 extern DWORD g_dwTLSTextEncodingIndex;
 
-extern CRITICAL_SECTION g_ThreadKeyListCS;
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-01-29 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/dllentry.cxx |5 -
 sal/osl/w32/file_url.cxx |  119 +--
 sal/osl/w32/file_url.hxx |4 -
 sal/osl/w32/process.cxx  |6 --
 4 files changed, 76 insertions(+), 58 deletions(-)

New commits:
commit 6e0fa7d4c7b45c98418c289d1d4715eb9eb133f7
Author: Mike Kaganski 
AuthorDate: Sat Jan 30 00:01:25 2021 +0300
Commit: Mike Kaganski 
CommitDate: Sat Jan 30 07:08:33 2021 +0100

Don't change process current directory in osl_getAbsoluteFileURL

This removes the need to synchronize using global mutex, and allows
to get correct result when base directory is unavailable.

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

diff --git a/sal/osl/w32/dllentry.cxx b/sal/osl/w32/dllentry.cxx
index 9493e59bc982..06857df6bbc5 100644
--- a/sal/osl/w32/dllentry.cxx
+++ b/sal/osl/w32/dllentry.cxx
@@ -88,9 +88,6 @@ static BOOL WINAPI RawDllMain( HINSTANCE, DWORD fdwReason, 
LPVOID )
 /* initialize global mutex */
 g_Mutex = osl_createMutex();
 
-/* initialize "current directory" mutex */
-g_CurrentDirectoryMutex = osl_createMutex();
-
 g_dwTLSTextEncodingIndex = TlsAlloc();
 InitializeCriticalSection( _ThreadKeyListCS );
 
@@ -108,8 +105,6 @@ static BOOL WINAPI RawDllMain( HINSTANCE, DWORD fdwReason, 
LPVOID )
 
 osl_destroyMutex( g_Mutex );
 
-osl_destroyMutex( g_CurrentDirectoryMutex );
-
 /*
 
 On a product build memory management finalization might
diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index a0cb52257b96..e71da15a66b9 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -28,6 +28,7 @@
 #include "file_error.hxx"
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,8 +41,6 @@
 
 // FileURL functions
 
-oslMutex g_CurrentDirectoryMutex = nullptr; /* Initialized in dllentry.c */
-
 static bool IsValidFilePathComponent(
 sal_Unicode const * lpComponent, sal_Unicode const **lppComponentEnd,
 DWORD dwFlags)
@@ -991,9 +990,40 @@ oslFileError SAL_CALL osl_searchFileURL(
 return error;
 }
 
+namespace
+{
+bool startsWithDriveColon(const rtl_uString* path)
+{
+return rtl::isAsciiAlpha(path->buffer[0]) && path->buffer[1] == ':';
+}
+bool startsWithDriveColonSlash(const rtl_uString* path)
+{
+return startsWithDriveColon(path) && path->buffer[2] == '\\';
+}
+// 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* path)
+{
+return (path->buffer[0] == '\\' && path->buffer[1] == '\\') || 
startsWithDriveColonSlash(path);
+}
+bool onSameDrive(const rtl_uString* path1, const rtl_uString* path2)
+{
+return rtl::toAsciiUpperCase(path1->buffer[0]) == 
rtl::toAsciiUpperCase(path2->buffer[0])
+   && rtl::toAsciiUpperCase(path1->buffer[1]) == 
rtl::toAsciiUpperCase(path2->buffer[1]);
+}
+OUString combinePath(rtl_uString* basePath, const sal_Unicode* relPath)
+{
+const bool needSep = basePath->buffer[basePath->length - 1] != '\\' && 
relPath[0] != '\\';
+const auto sSeparator = needSep ? std::u16string_view(u"\\") : 
std::u16string_view();
+if (basePath->buffer[basePath->length - 1] == '\\' && relPath[0] == '\\')
+++relPath; // avoid two agjacent backslashes
+return OUString::unacquired() + sSeparator + relPath;
+}
+}
+
 oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, 
rtl_uString* ustrRelativeURL, rtl_uString** pustrAbsoluteURL )
 {
-oslFileErroreError;
+oslFileError eError = osl_File_E_None;
 rtl_uString *ustrRelSysPath = nullptr;
 rtl_uString *ustrBaseSysPath = nullptr;
 
@@ -1001,64 +1031,63 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( 
rtl_uString* ustrBaseURL, rtl_uStr
 {
 eError = osl_getSystemPathFromFileURL_( ustrBaseURL, , 
false );
 OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called 
with relative or invalid base URL" );
-
-eError = osl_getSystemPathFromFileURL_( ustrRelativeURL, 
, true );
 }
-else
+if (eError == osl_File_E_None)
 {
-eError = osl_getSystemPathFromFileURL_( ustrRelativeURL, 
, false );
+eError = osl_getSystemPathFromFileURL_(ustrRelativeURL, 
,
+   ustrBaseSysPath != nullptr);
 OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called 
with empty base URL and/or invalid relative URL" );
 }
 
 if ( !eError )
 {
-::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
-::osl::LongPathBuffer< sal_Unicode > aCurrentDir( MAX_LONG_PATH );
-LPWSTR  lpFilePart = nullptr;
-DWORD   

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

2021-01-29 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/process.cxx |   24 +++-
 1 file changed, 7 insertions(+), 17 deletions(-)

New commits:
commit 3dbc42e56e5a84c2b1689063b6ff3530916f7e6a
Author: Mike Kaganski 
AuthorDate: Fri Jan 29 12:28:57 2021 +0300
Commit: Mike Kaganski 
CommitDate: Fri Jan 29 21:46:21 2021 +0100

Use OUString and its fast concat instead of C string manipulation

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

diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx
index c5885c96282f..205d6415e035 100644
--- a/sal/osl/w32/process.cxx
+++ b/sal/osl/w32/process.cxx
@@ -23,7 +23,6 @@
 #include 
 
 #include 
-#include 
 
 #include 
 #include 
@@ -35,6 +34,7 @@
 #include "file_url.hxx"
 #include "path_helper.hxx"
 #include 
+#include 
 #include 
 
 oslProcessError SAL_CALL osl_terminateProcess(oslProcess Process)
@@ -446,16 +446,10 @@ oslProcessError SAL_CALL osl_getEnvironment(rtl_uString 
*ustrVar, rtl_uString **
 oslProcessError SAL_CALL osl_setEnvironment(rtl_uString *ustrVar, rtl_uString 
*ustrValue)
 {
 // set Windows environment variable
-LPCWSTR lpName = o3tl::toW(ustrVar->buffer);
-LPCWSTR lpValue = o3tl::toW(ustrValue->buffer);
-if (SetEnvironmentVariableW(lpName, lpValue))
+if (SetEnvironmentVariableW(o3tl::toW(ustrVar->buffer), 
o3tl::toW(ustrValue->buffer)))
 {
-auto buffer = std::unique_ptr(
-new wchar_t[wcslen(lpName) + 1 + wcslen(lpValue) + 1]);
-wcscpy(buffer.get(), lpName);
-wcscat(buffer.get(), L"=");
-wcscat(buffer.get(), lpValue);
-_wputenv(buffer.get());
+OUString sAssign = OUString::unacquired() + "=" + 
OUString::unacquired();
+_wputenv(o3tl::toW(sAssign.getStr()));
 return osl_Process_E_None;
 }
 return osl_Process_E_Unknown;
@@ -465,14 +459,10 @@ oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString 
*ustrVar)
 {
 // delete the variable from the current process environment
 // by setting SetEnvironmentVariable's second parameter to NULL
-LPCWSTR lpName = o3tl::toW(ustrVar->buffer);
-if (SetEnvironmentVariableW(lpName, nullptr))
+if (SetEnvironmentVariableW(o3tl::toW(ustrVar->buffer), nullptr))
 {
-auto buffer = std::unique_ptr(
-new wchar_t[wcslen(lpName) + 1 + 1]);
-wcscpy(buffer.get(), lpName);
-wcscat(buffer.get(), L"=");
-_wputenv(buffer.get());
+OUString sAssign = OUString::unacquired() + "=";
+_wputenv(o3tl::toW(sAssign.getStr()));
 return osl_Process_E_None;
 }
 return osl_Process_E_Unknown;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-01-29 Thread Mike Kaganski (via logerrit)
 sal/osl/w32/process.cxx |   33 ++---
 1 file changed, 14 insertions(+), 19 deletions(-)

New commits:
commit b8bdd88c4e9b62cff422e13fb43078fc8e31661e
Author: Mike Kaganski 
AuthorDate: Fri Jan 29 11:12:54 2021 +0300
Commit: Mike Kaganski 
CommitDate: Fri Jan 29 18:28:00 2021 +0100

Use MutexGuard instead of direct oslMutex manipulations

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

diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx
index 81f05e84777f..c5885c96282f 100644
--- a/sal/osl/w32/process.cxx
+++ b/sal/osl/w32/process.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -362,24 +363,23 @@ static rtl_uString ** osl_createCommandArgs_Impl (int 
argc, char **)
 
 oslProcessError SAL_CALL osl_getExecutableFile( rtl_uString **ppustrFile )
 {
-osl_acquireMutex (*osl_getGlobalMutex());
-if (g_command_args.m_nCount == 0)
 {
-osl_releaseMutex (*osl_getGlobalMutex());
-return bootstrap_getExecutableFile(ppustrFile);
+osl::MutexGuard aGuard(osl::Mutex::getGlobalMutex());
+if (g_command_args.m_nCount > 0)
+{
+/* CommandArgs set. Obtain arv[0]. */
+rtl_uString_assign(ppustrFile, g_command_args.m_ppArgs[0]);
+return osl_Process_E_None;
+}
 }
-
-/* CommandArgs set. Obtain arv[0]. */
-rtl_uString_assign (ppustrFile, g_command_args.m_ppArgs[0]);
-osl_releaseMutex (*osl_getGlobalMutex());
-return osl_Process_E_None;
+return bootstrap_getExecutableFile(ppustrFile);
 }
 
 sal_uInt32 SAL_CALL osl_getCommandArgCount()
 {
 sal_uInt32 result = 0;
 
-osl_acquireMutex (*osl_getGlobalMutex());
+osl::MutexGuard aGuard(osl::Mutex::getGlobalMutex());
 SAL_INFO_IF(
 g_command_args.m_nCount == 0, "sal.osl",
 "osl_getCommandArgCount w/o prior call to osl_setCommandArgs");
@@ -388,7 +388,6 @@ sal_uInt32 SAL_CALL osl_getCommandArgCount()
 /* We're not counting argv[0] here. */
 result = g_command_args.m_nCount - 1;
 }
-osl_releaseMutex (*osl_getGlobalMutex());
 
 return result;
 }
@@ -397,7 +396,7 @@ oslProcessError SAL_CALL osl_getCommandArg( sal_uInt32 
nArg, rtl_uString **strCo
 {
 oslProcessError result = osl_Process_E_NotFound;
 
-osl_acquireMutex (*osl_getGlobalMutex());
+osl::MutexGuard aGuard(osl::Mutex::getGlobalMutex());
 assert(g_command_args.m_nCount > 0);
 if (g_command_args.m_nCount > (nArg + 1))
 {
@@ -405,7 +404,6 @@ oslProcessError SAL_CALL osl_getCommandArg( sal_uInt32 
nArg, rtl_uString **strCo
 rtl_uString_assign (strCommandArg, g_command_args.m_ppArgs[nArg + 1]);
 result = osl_Process_E_None;
 }
-osl_releaseMutex (*osl_getGlobalMutex());
 
 return result;
 }
@@ -413,7 +411,7 @@ oslProcessError SAL_CALL osl_getCommandArg( sal_uInt32 
nArg, rtl_uString **strCo
 void SAL_CALL osl_setCommandArgs (int argc, char ** argv)
 {
 assert(argc > 0);
-osl_acquireMutex (*osl_getGlobalMutex());
+osl::MutexGuard aGuard(osl::Mutex::getGlobalMutex());
 SAL_WARN_IF(g_command_args.m_nCount != 0, "sal.osl", "args already set");
 if (g_command_args.m_nCount == 0)
 {
@@ -424,7 +422,6 @@ void SAL_CALL osl_setCommandArgs (int argc, char ** argv)
 g_command_args.m_ppArgs = ppArgs;
 }
 }
-osl_releaseMutex (*osl_getGlobalMutex());
 }
 
 /* TODO because of an issue with GetEnvironmentVariableW we have to
@@ -513,7 +510,7 @@ static rtl_Locale * g_theProcessLocale = nullptr;
 
 oslProcessError SAL_CALL osl_getProcessLocale( rtl_Locale ** ppLocale )
 {
-osl_acquireMutex( *osl_getGlobalMutex() );
+osl::MutexGuard aGuard(osl::Mutex::getGlobalMutex());
 
 /* determine the users default locale */
 if( nullptr == g_theProcessLocale )
@@ -522,13 +519,12 @@ oslProcessError SAL_CALL osl_getProcessLocale( rtl_Locale 
** ppLocale )
 /* or return the cached value */
 *ppLocale = g_theProcessLocale;
 
-osl_releaseMutex( *osl_getGlobalMutex() );
 return osl_Process_E_None;
 }
 
 oslProcessError SAL_CALL osl_setProcessLocale( rtl_Locale * pLocale )
 {
-osl_acquireMutex( *osl_getGlobalMutex() );
+osl::MutexGuard aGuard(osl::Mutex::getGlobalMutex());
 
 /* check if locale is supported */
 if( RTL_TEXTENCODING_DONTKNOW == osl_getTextEncodingFromLocale( pLocale ) )
@@ -537,7 +533,6 @@ oslProcessError SAL_CALL osl_setProcessLocale( rtl_Locale * 
pLocale )
 /* just remember the locale here */
 g_theProcessLocale = pLocale;
 
-osl_releaseMutex( *osl_getGlobalMutex() );
 return osl_Process_E_None;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-01-17 Thread Julien Nabet (via logerrit)
 sal/osl/unx/process.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ad55d51486264260a135b36c85973a728e006de7
Author: Julien Nabet 
AuthorDate: Sun Jan 17 13:42:50 2021 +0100
Commit: Julien Nabet 
CommitDate: Sun Jan 17 15:15:47 2021 +0100

cppcheck: zerodivcond

I don't know if it can happen or if it's a false positive
but at least, we're sure now it won't fail

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

diff --git a/sal/osl/unx/process.cxx b/sal/osl/unx/process.cxx
index 861324963dec..f75534fdc311 100644
--- a/sal/osl/unx/process.cxx
+++ b/sal/osl/unx/process.cxx
@@ -1067,7 +1067,7 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess 
Process, oslProcessData F
 unsigned long systemseconds;
 
 clktck = sysconf(_SC_CLK_TCK);
-if (clktck < 0) {
+if (clktck <= 0) {
 return osl_Process_E_Unknown;
 }
 hz = static_cast(clktck);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-12-10 Thread Samuel Mehrbrodt (via logerrit)
 sal/osl/w32/socket.cxx |   40 
 1 file changed, 8 insertions(+), 32 deletions(-)

New commits:
commit afc41a467fdfabb2cd0879be3e4f1879a1d1dc91
Author: Samuel Mehrbrodt 
AuthorDate: Thu Dec 10 09:31:29 2020 +0100
Commit: Samuel Mehrbrodt 
CommitDate: Thu Dec 10 14:21:15 2020 +0100

Do not call GetAddrInfoW if we just want the hostname

Calling 'gethostname' already gives us the current host name on Windows.
For some reason, if that name does not contain a dot, GetAddrInfoW is
called, which "provides protocol-independent translation from a Unicode
host name to an address".

So all this function does, is returning an address for a hostname,
while we still only need the hostname and not the address.

This causes a lag when creating the lockfile on opening a document
if the network is flaky/disabled.
See tdf#97931 and tdf#47179 for some problems caused by this.

Change-Id: I0c543ea12c23506b2daa50da40bae1a471f6fe16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107513
Tested-by: Samuel Mehrbrodt 
Reviewed-by: Samuel Mehrbrodt 

diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx
index f1c46e8f2568..ba96cc5ed838 100644
--- a/sal/osl/w32/socket.cxx
+++ b/sal/osl/w32/socket.cxx
@@ -613,39 +613,15 @@ oslSocketResult SAL_CALL osl_getLocalHostname 
(rtl_uString **strLocalHostname)
 char Host[256]= "";
 if (gethostname(Host, sizeof(Host)) == 0)
 {
-/* check if we have an FQDN; if not, try to determine it via 
dns first: */
-if (strchr(Host, '.') == nullptr)
+OUString u;
+if (rtl_convertStringToUString(
+, Host, strlen(Host), 
osl_getThreadTextEncoding(),
+(RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
+| RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
+| RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))
+&& o3tl::make_unsigned(u.getLength()) < 
SAL_N_ELEMENTS(LocalHostname))
 {
-oslHostAddr pAddr;
-rtl_uString *hostName= nullptr;
-
-rtl_string2UString(
-, Host, strlen(Host),
-RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS);
-OSL_ASSERT(hostName != nullptr);
-
-pAddr = osl_createHostAddrByName(hostName);
-rtl_uString_release (hostName);
-
-if (pAddr && pAddr->pHostName)
-memcpy(LocalHostname, pAddr->pHostName->buffer, 
sizeof(sal_Unicode)*(rtl_ustr_getLength(pAddr->pHostName->buffer)+1));
-else
-memset(LocalHostname, 0, sizeof(LocalHostname));
-
-osl_destroyHostAddr (pAddr);
-}
-if (LocalHostname[0] == u'\0')
-{
-OUString u;
-if (rtl_convertStringToUString(
-, Host, strlen(Host), 
osl_getThreadTextEncoding(),
-(RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
- | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
- | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))
-&& o3tl::make_unsigned(u.getLength()) < 
SAL_N_ELEMENTS(LocalHostname))
-{
-memcpy(LocalHostname, u.getStr(), (u.getLength() + 1) 
* sizeof (sal_Unicode));
-}
+memcpy(LocalHostname, u.getStr(), (u.getLength() + 1) * 
sizeof (sal_Unicode));
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-10-12 Thread Gleb Popov (via logerrit)
 sal/osl/unx/thread.cxx |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit b47a8eda6ecd2b508054a68b4879c769cce87363
Author: Gleb Popov <6year...@gmail.com>
AuthorDate: Thu Oct 8 23:07:10 2020 +0400
Commit: Samuel Mehrbrodt 
CommitDate: Mon Oct 12 08:57:41 2020 +0200

Use `pthread_set_name_np` on FreeBSD 12.1 and below, as 
`pthread_setname_np` isn't available there.

While here, change the #ifdef check from __FreeBSD_kernel_ to __FreeBSD__, 
because pthreads API is userspace (read, belongs to libc).

Change-Id: I83e76b5502a6dfa1be5d3598eb1367f25815396e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104098
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 

diff --git a/sal/osl/unx/thread.cxx b/sal/osl/unx/thread.cxx
index 2472efec8618..ce5ece7c1d59 100644
--- a/sal/osl/unx/thread.cxx
+++ b/sal/osl/unx/thread.cxx
@@ -30,6 +30,12 @@
 #if defined(OPENBSD)
 #include 
 #endif
+#ifdef __FreeBSD__
+#if __FreeBSD_version <= 1201517
+#include 
+#define pthread_setname_np pthread_set_name_np
+#endif
+#endif
 #include 
 #include 
 #include 
@@ -567,7 +573,7 @@ void SAL_CALL osl_setThreadName(char const * name)
 int err = pthread_setname_np( pthread_self(), shortname );
 if ( 0 != err )
 SAL_WARN("sal.osl", "pthread_setname_np failed with errno " << err);
-#elif defined __FreeBSD_kernel__
+#elif defined __FreeBSD__
 pthread_setname_np( pthread_self(), name );
 #elif defined MACOSX || defined IOS
 pthread_setname_np( name );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-10-08 Thread Gleb Popov (via logerrit)
 sal/osl/unx/system.hxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit d775d570ea336d1d0d9e9c778d6841e9b64d2ad1
Author: Gleb Popov <6year...@gmail.com>
AuthorDate: Mon Oct 5 10:27:02 2020 +0400
Commit: Mike Kaganski 
CommitDate: Thu Oct 8 08:04:03 2020 +0200

Do not redefine ETIME unconditionally on FreeBSD.

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

diff --git a/sal/osl/unx/system.hxx b/sal/osl/unx/system.hxx
index bbf9c0449357..a8b0e10cd163 100644
--- a/sal/osl/unx/system.hxx
+++ b/sal/osl/unx/system.hxx
@@ -136,7 +136,9 @@
 #endif
 
 #ifdef FREEBSD
-#   define  ETIME ETIMEDOUT
+#   ifndef ETIME
+#   define ETIME ETIMEDOUT
+#   endif
 #   include 
 #   include 
 #   include 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-09-26 Thread Andrea Gelmini (via logerrit)
 sal/osl/w32/pipe.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 7d5499c5e1bae536fe54434ff95e1fbbd2e3361d
Author: Andrea Gelmini 
AuthorDate: Fri Sep 25 11:54:14 2020 +0200
Commit: Julien Nabet 
CommitDate: Sat Sep 26 09:41:23 2020 +0200

Fix typo in code

It passed "make check" on Linux

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

diff --git a/sal/osl/w32/pipe.cxx b/sal/osl/w32/pipe.cxx
index 06a6bf82d98d..3e71ef1d44d2 100644
--- a/sal/osl/w32/pipe.cxx
+++ b/sal/osl/w32/pipe.cxx
@@ -285,7 +285,7 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
 
 OVERLAPPED os = {};
 
-DWORD nBytesTransfered;
+DWORD nBytesTransferred;
 rtl_uString* path = nullptr;
 rtl_uString* temp = nullptr;
 
@@ -311,7 +311,7 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
 case ERROR_IO_PENDING:  // This is normal if not client is 
connected yet
 case ERROR_MORE_DATA:   // Should not happen
 // blocking call to accept
-if( !GetOverlappedResult(pPipe->m_File, , 
, TRUE))
+if( !GetOverlappedResult(pPipe->m_File, , 
, TRUE))
 {
 // Possible error could be that between ConnectNamedPipe 
and
 // GetOverlappedResult a connect took place.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-08-17 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/salinit.cxx |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 3f2e85ae2c6cd8a775587524788f61e4c93676b9
Author: Stephan Bergmann 
AuthorDate: Mon Aug 17 08:17:37 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Mon Aug 17 09:41:30 2020 +0200

Remove leftover debug include

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

diff --git a/sal/osl/unx/salinit.cxx b/sal/osl/unx/salinit.cxx
index 5f75bef3ced6..c55cb2667be3 100644
--- a/sal/osl/unx/salinit.cxx
+++ b/sal/osl/unx/salinit.cxx
@@ -1,4 +1,3 @@
-#include 
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
  * This file is part of the LibreOffice project.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-08-17 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/salinit.cxx |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit 30e5617f6bb30a85ae13990e9045ac95b8f0be4d
Author: Stephan Bergmann 
AuthorDate: Mon Aug 17 08:18:07 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Mon Aug 17 09:41:10 2020 +0200

loplugin:loopvartoosmall

And while at it, merge the change from 
e2bd5afd726abd5df438b6b821416bd7cf496e4d
"Make the C++/UNO bridge work to some extent on macOS on arm64" into the
existing code in a better way, reviving the assertion that openMax will be 
non-
negative when entering the loop.

Change-Id: I4b4e173a79ae6a0bbbf07df87d46761e86f460c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100841
Reviewed-by: Tor Lillqvist 
Reviewed-by: Stephan Bergmann 
Tested-by: Jenkins

diff --git a/sal/osl/unx/salinit.cxx b/sal/osl/unx/salinit.cxx
index c3ac48c575d1..5f75bef3ced6 100644
--- a/sal/osl/unx/salinit.cxx
+++ b/sal/osl/unx/salinit.cxx
@@ -23,7 +23,6 @@
 #include 
 
 #if defined MACOSX
-#include 
 #include 
 #include 
 #include 
@@ -69,14 +68,14 @@ void sal_detail_initialize(int argc, char ** argv) {
 // macOS appears to have no better interface to close all fds (like
 // closefrom):
 long openMax = sysconf(_SC_OPEN_MAX);
-if (openMax == -1) {
-// Some random value, but hopefully sysconf never returns -1 anyway:
-openMax = 1024;
-}
 // When LibreOffice restarts itself on macOS 11 beta on arm64, for
 // some reason sysconf(_SC_OPEN_MAX) returns 0x7FFF,
 // so use a sanity limit here.
-for (int fd = 3; fd < std::min(10l, openMax); ++fd) {
+if (openMax == -1 || openMax == std::numeric_limits::max()) {
+openMax = 10;
+}
+assert(openMax >= 0 && openMax <= std::numeric_limits< int >::max());
+for (int fd = 3; fd < int(openMax); ++fd) {
 struct stat s;
 if (fstat(fd, ) != -1 && S_ISREG(s.st_mode))
 close(fd);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sal/osl vcl/osx vcl/quartz

2020-07-21 Thread Stephan Bergmann (via logerrit)
 sal/osl/unx/nlsupport.cxx |6 +++---
 vcl/osx/DataFlavorMapping.cxx |2 +-
 vcl/quartz/salbmp.cxx |8 
 vcl/quartz/salgdicommon.cxx   |2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

New commits:
commit 4401f13a9e2d29503529c219f5f447c68b327007
Author: Stephan Bergmann 
AuthorDate: Tue Jul 21 08:09:59 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Tue Jul 21 09:19:33 2020 +0200

Improved oplugin:staticanonymous -> redundantstatic redux, macOS

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

diff --git a/sal/osl/unx/nlsupport.cxx b/sal/osl/unx/nlsupport.cxx
index 3a0b1021e726..28d367c11ae9 100644
--- a/sal/osl/unx/nlsupport.cxx
+++ b/sal/osl/unx/nlsupport.cxx
@@ -650,7 +650,7 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
  * from the ISO language codes.
  */
 
-static const Pair full_locale_list[] = {
+const Pair full_locale_list[] = {
 { "ja_JP.eucJP",  RTL_TEXTENCODING_EUC_JP  },
 { "ja_JP.EUC",RTL_TEXTENCODING_EUC_JP  },
 { "ko_KR.EUC",RTL_TEXTENCODING_EUC_KR  },
@@ -658,7 +658,7 @@ static const Pair full_locale_list[] = {
 { "zh_TW.EUC",RTL_TEXTENCODING_EUC_TW  }
 };
 
-static const Pair locale_extension_list[] = {
+const Pair locale_extension_list[] = {
 { "big5", RTL_TEXTENCODING_BIG5},
 { "big5hk",   RTL_TEXTENCODING_BIG5_HKSCS  },
 { "gb18030",  RTL_TEXTENCODING_GB_18030},
@@ -687,7 +687,7 @@ static const Pair locale_extension_list[] = {
 { "utf-8",RTL_TEXTENCODING_UTF8}
 };
 
-static const Pair iso_language_list[] = {
+const Pair iso_language_list[] = {
 { "af",  RTL_TEXTENCODING_ISO_8859_1 },
 { "ar",  RTL_TEXTENCODING_ISO_8859_6 },
 { "az",  RTL_TEXTENCODING_ISO_8859_9 },
diff --git a/vcl/osx/DataFlavorMapping.cxx b/vcl/osx/DataFlavorMapping.cxx
index dfba27d20e31..07534d0c893b 100644
--- a/vcl/osx/DataFlavorMapping.cxx
+++ b/vcl/osx/DataFlavorMapping.cxx
@@ -109,7 +109,7 @@ namespace
 
   /* At the moment it appears as if only MS Office pastes "public.html" to the 
clipboard.
*/
-  static const FlavorMap flavorMap[] =
+  const FlavorMap flavorMap[] =
 {
   { NSPasteboardTypeString, "text/plain;charset=utf-16", "Unicode Text 
(UTF-16)", true },
   { NSPasteboardTypeRTF, "text/rtf", "Rich Text Format", false },
diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx
index 43c39e66ca23..aa932de1fc69 100644
--- a/vcl/quartz/salbmp.cxx
+++ b/vcl/quartz/salbmp.cxx
@@ -45,9 +45,9 @@
 #include "saldatabasic.hxx"
 #endif
 
-static const unsigned long k32BitRedColorMask   = 0x00ff;
-static const unsigned long k32BitGreenColorMask = 0xff00;
-static const unsigned long k32BitBlueColorMask  = 0x00ff;
+const unsigned long k32BitRedColorMask   = 0x00ff;
+const unsigned long k32BitGreenColorMask = 0xff00;
+const unsigned long k32BitBlueColorMask  = 0x00ff;
 
 static bool isValidBitCount( sal_uInt16 nBitCount )
 {
@@ -610,7 +610,7 @@ struct pal_entry
 
 }
 
-static pal_entry const aImplSalSysPalEntryAry[ 16 ] =
+pal_entry const aImplSalSysPalEntryAry[ 16 ] =
 {
 {0,0,0 },
 {0,0, 0x80 },
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index 5acc4d4e4e77..c72e8ee5cabd 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -46,7 +46,7 @@
 
 using namespace vcl;
 
-static const basegfx::B2DPoint aHalfPointOfs ( 0.5, 0.5 );
+const basegfx::B2DPoint aHalfPointOfs ( 0.5, 0.5 );
 
 static void AddPolygonToPath( CGMutablePathRef xPath,
   const basegfx::B2DPolygon& rPolygon,
___
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 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
@@ 

  1   2   3   4   5   6   >