diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-12-08 14:19:00 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-12-08 16:03:47 +0100 |
commit | a5484e496dcee9b110ef696101576a14b7a5a20e (patch) | |
tree | 2c18b8fa933bf2e21ebaa4b89c204c6d86f0ba23 /l10ntools | |
parent | c13909b415d701b4618d645b98d314974a25ee57 (diff) |
Assert that certain env vars are set in these build-time tools
All of those env vars are exported from config_host.mk or config_host_lang.mk.
The asserts guard potential future changes from using OString to using
std::string_view, where OString has an undocumented feature of allowing
construction from a null pointer.
Change-Id: I7bb2217fb1d38300bf169b17e9e72dafc6970b2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107414
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'l10ntools')
-rw-r--r-- | l10ntools/source/localize.cxx | 9 | ||||
-rw-r--r-- | l10ntools/source/merge.cxx | 5 | ||||
-rw-r--r-- | l10ntools/source/pocheck.cxx | 7 |
3 files changed, 17 insertions, 4 deletions
diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index 402403a8e5ea..17ad73f3b2a4 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -19,6 +19,7 @@ #include <sal/config.h> +#include <cassert> #include <cstddef> #include <cstdlib> #include <iostream> @@ -90,12 +91,16 @@ void handleCommand( OStringBuffer buf; if (rExecutable == "uiex" || rExecutable == "hrcex") { - buf.append(OString(getenv("SRC_ROOT"))); + auto const env = getenv("SRC_ROOT"); + assert(env != nullptr); + buf.append(OString(env)); buf.append("/solenv/bin/"); } else { - buf.append(OString(getenv("WORKDIR_FOR_BUILD"))); + auto const env = getenv("WORKDIR_FOR_BUILD"); + assert(env != nullptr); + buf.append(OString(env)); buf.append("/LinkTarget/Executable/"); } buf.append(rExecutable.data()); diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx index 75afdf77b9a6..b94bb7c84fc8 100644 --- a/l10ntools/source/merge.cxx +++ b/l10ntools/source/merge.cxx @@ -21,6 +21,7 @@ #include <sal/log.hxx> #include <algorithm> +#include <cassert> #include <fstream> #include <string> #include <vector> @@ -112,7 +113,9 @@ MergeDataFile::MergeDataFile( const OString &rFileName, const OString &rFile, bool bCaseSensitive, bool bWithQtz ) { - OString sEnableReleaseBuild(getenv("ENABLE_RELEASE_BUILD")); + auto const env = getenv("ENABLE_RELEASE_BUILD"); + assert(env != nullptr); + OString sEnableReleaseBuild(env); std::ifstream aInputStream( rFileName.getStr() ); if ( !aInputStream.is_open() ) diff --git a/l10ntools/source/pocheck.cxx b/l10ntools/source/pocheck.cxx index 1e7c951863be..0dcb2d0dcef9 100644 --- a/l10ntools/source/pocheck.cxx +++ b/l10ntools/source/pocheck.cxx @@ -7,6 +7,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sal/config.h> + +#include <cassert> #include <iostream> #include <map> #include <vector> @@ -395,7 +398,9 @@ int main() { try { - OString aLanguages(getenv("ALL_LANGS")); + auto const env = getenv("ALL_LANGS"); + assert(env != nullptr); + OString aLanguages(env); if( aLanguages.isEmpty() ) { std::cerr << "Usage: LD_LIBRARY_PATH=instdir/program make cmd cmd=workdir/LinkTarget/Executable/pocheck\n"; |