[Libreoffice-commits] core.git: sal/inc sal/osl sal/rtl
sal/inc/uri_internal.hxx | 40 ++ sal/osl/unx/file_impl.hxx|4 sal/osl/unx/file_misc.cxx| 170 ++-- sal/osl/unx/file_path_helper.cxx | 96 +--- sal/osl/unx/file_path_helper.hxx | 34 +++-- sal/osl/unx/file_stat.cxx| 39 -- sal/osl/unx/file_url.cxx | 234 +++ sal/osl/unx/file_url.hxx |9 + sal/osl/unx/uunxapi.cxx | 74 +--- sal/osl/unx/uunxapi.hxx | 14 ++ sal/rtl/uri.cxx | 35 +++-- 11 files changed, 509 insertions(+), 240 deletions(-) New commits: commit caa211b62048ac5037b3fd4320f3eb4dea7b639d Author: Stephan Bergmann AuthorDate: Tue Sep 10 10:52:57 2019 +0200 Commit: Stephan Bergmann CommitDate: Tue Sep 17 15:05:11 2019 +0200 Better handling of non--UTF-8 filesystem pathnames in sal/osl/unx/ The idea is to internally in sal/osl/unx/ use OString instead of OUString to represent pathnames, so that the OString carries the actual bytes that make up the pathname. At the boundary of translating between pathname OStrings and file URL OUStrings, translate sequences of bytes that are valid according to osl_getThreadTextEncoding() into UTF-8 and translate other bytes into individual (percent-encoded) bytes in the file URL. This change required duplicating some of the internal functionality in sal/osl/unx/ for both OString and OUString, and to make part of sal/rtl/uri.cxx accessible from sal/osl/unx/ via new sal/inc/uri_internal.hxx. Change-Id: Id1ebaebe9e7f2d21f350f6b1a07849edee54331f Reviewed-on: https://gerrit.libreoffice.org/78798 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/sal/inc/uri_internal.hxx b/sal/inc/uri_internal.hxx new file mode 100644 index ..0ec0650cab63 --- /dev/null +++ b/sal/inc/uri_internal.hxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SAL_INC_URI_INTERNAL_HXX +#define INCLUDED_SAL_INC_URI_INTERNAL_HXX + +#include + +namespace rtl::uri::detail +{ +enum EscapeType +{ +EscapeNo, +EscapeChar, +EscapeOctet +}; + +sal_uInt32 readUcs4(sal_Unicode const** pBegin, sal_Unicode const* pEnd, bool bEncoded, +rtl_TextEncoding eCharset, EscapeType* pType); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sal/osl/unx/file_impl.hxx b/sal/osl/unx/file_impl.hxx index de7a450e478d..eadb1257a068 100644 --- a/sal/osl/unx/file_impl.hxx +++ b/sal/osl/unx/file_impl.hxx @@ -28,11 +28,11 @@ struct DirectoryItem_Impl { sal_Int32 m_RefCount; -rtl_uString * const m_ustrFilePath; /* holds native file name */ +rtl_String * const m_strFilePath; /* holds native file name */ unsigned char const m_DType; explicit DirectoryItem_Impl( -rtl_uString * ustrFilePath, unsigned char DType = 0); +rtl_String * 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 1690ca884dda..4e33e06da0ae 100644 --- a/sal/osl/unx/file_misc.cxx +++ b/sal/osl/unx/file_misc.cxx @@ -48,6 +48,8 @@ #include #include +#include +#include #include #ifdef ANDROID @@ -66,7 +68,7 @@ namespace { struct DirectoryImpl { -OUString ustrPath; /* holds native directory path */ +OString strPath; /* holds native directory path */ DIR* pDirStruct; #ifdef ANDROID enum Kind @@ -82,18 +84,18 @@ struct DirectoryImpl } DirectoryItem_Impl::DirectoryItem_Impl( -rtl_uString * ustrFilePath, unsigned char DType) +rtl_String * strFilePath, unsigned char DType) : m_RefCount (1), - m_ustrFilePath (ustrFilePath), + m_strFilePath (strFilePath), m_DType(DType) { -if (m_ustrFilePath != nullptr) -rtl_uString_acquire(m_ustrFilePath); +if (m_strFilePath !=
[Libreoffice-commits] core.git: sal/inc sal/osl sal/rtl
sal/inc/getexecutablefile.hxx | 44 -- sal/osl/unx/process_impl.cxx | 37 --- sal/osl/w32/process.cxx | 32 ++ sal/rtl/bootstrap.cxx |6 + 4 files changed, 30 insertions(+), 89 deletions(-) New commits: commit 41565560250294e22fc1c21bc4bab8286255d4cc Author: Stephan Bergmann sberg...@redhat.com Date: Thu Nov 27 11:48:34 2014 +0100 Make osl_getExecutableFile work even without a prior osl_setCommandArgs After 2ad716f406e0fdb9b9294876c64ae92fecbf5e27 Revert 'pyuno: set up fake command line in getComponentContext(),' e.g. PythonTest_sw_python would fail on Windows, where WinSalGraphics::GetDevFontList (vcl/win/source/gdi/salgdi3.cxx) calls osl_getExecutableFile and is itself called in a python process where osl_setCommandArgs has not been set up. This patch makes osl_getExecutableFile on all platforms if osl_setCommandArgs has not (yet) been set fall back to the code that was osl_bootstrap_getExecutableFile_Impl (which was called from sal/rtl/bootstrap.cxx, which can now call osl_getExecutableFile). Change-Id: I6c1bb59205041b3208c830a8b8406e28128b4566 diff --git a/sal/inc/getexecutablefile.hxx b/sal/inc/getexecutablefile.hxx deleted file mode 100644 index 9ebf872..000 --- a/sal/inc/getexecutablefile.hxx +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the License); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SAL_INC_GETEXECUTABLEFILE_HXX -#define INCLUDED_SAL_INC_GETEXECUTABLEFILE_HXX - -#include sal/config.h - -#include osl/process.h -#include rtl/ustring.h -#include sal/types.h - -/*** - osl_bootstrap_getExecutableFile_Impl(). - - @internal - @see rtl_bootstrap - @see #i37371# - - **/ - -extern C oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( -rtl_uString ** ppFileURL -) SAL_THROW_EXTERN_C(); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index 0936b38..7d8cc81 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -34,7 +34,6 @@ #include file_path_helper.hxx #include uunxapi.hxx -#include getexecutablefile.hxx #include nlsupport.hxx #ifdef ANDROID @@ -44,9 +43,9 @@ #if defined(MACOSX) || defined(IOS) #include mach-o/dyld.h -oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( -rtl_uString ** ppFileURL -) SAL_THROW_EXTERN_C() +namespace { + +oslProcessError SAL_CALL bootstrap_getExecutableFile(rtl_uString ** ppFileURL) { oslProcessError result = osl_Process_E_NotFound; @@ -83,12 +82,14 @@ oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( return (result); } +} + #else #include dlfcn.h -oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( -rtl_uString ** ppFileURL -) SAL_THROW_EXTERN_C() +namespace { + +oslProcessError SAL_CALL bootstrap_getExecutableFile(rtl_uString ** ppFileURL) { oslProcessError result = osl_Process_E_NotFound; @@ -110,13 +111,11 @@ oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( } } -/* Fallback to ordinary osl_getExecutableFile(). */ -if (result == osl_Process_E_NotFound) -result = osl_getExecutableFile (ppFileURL); - return (result); } +} + #endif /*** @@ -141,19 +140,17 @@ static struct CommandArgs_Impl g_command_args = **/ oslProcessError SAL_CALL osl_getExecutableFile (rtl_uString ** ppustrFile) { -oslProcessError result = osl_Process_E_NotFound; - pthread_mutex_lock ((g_command_args.m_mutex)); -OSL_ASSERT(g_command_args.m_nCount 0); -if (g_command_args.m_nCount 0) +if (g_command_args.m_nCount == 0) { -/* CommandArgs set. Obtain argv[0]. */ -rtl_uString_assign (ppustrFile, g_command_args.m_ppArgs[0]); -result = osl_Process_E_None; +pthread_mutex_unlock