From 400fe81087960eb786a5adec589d2d2431a3c6bc Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 30 Apr 2021 11:42:30 -0400 Subject: [PATCH 1/8] Deprecate get_env.h and move content to env.{h,c} Signed-off-by: Christophe Bedard --- CMakeLists.txt | 1 - include/rcutils/env.h | 64 ++++++++++++++++++++++++++++++-- include/rcutils/get_env.h | 77 ++++----------------------------------- src/env.c | 50 ++++++++++++++++++++++++- src/get_env.c | 74 ------------------------------------- 5 files changed, 116 insertions(+), 150 deletions(-) delete mode 100644 src/get_env.c diff --git a/CMakeLists.txt b/CMakeLists.txt index f573c547..56f04189 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,6 @@ set(rcutils_sources src/filesystem.c src/find.c src/format_string.c - src/get_env.c src/hash_map.c src/logging.c src/process.c diff --git a/include/rcutils/env.h b/include/rcutils/env.h index 97bcfe49..db11fd54 100644 --- a/include/rcutils/env.h +++ b/include/rcutils/env.h @@ -27,9 +27,6 @@ extern "C" #include "rcutils/macros.h" #include "rcutils/visibility_control.h" -// TODO(cottsay): Deprecate get_env.h and eventually merge it here -#include "rcutils/get_env.h" - /// Set or un-set a process-scoped environment variable. /** * This function modifies the environment variables for the current process by @@ -58,6 +55,67 @@ RCUTILS_WARN_UNUSED bool rcutils_set_env(const char * env_name, const char * env_value); +/// Retrieve the value of the given environment variable if it exists, or "". +/** The c-string which is returned in the env_value output parameter is only + * valid until the next time this function is called, because it is a direct + * pointer to the static storage. + * The variable env_value populated by this function should never have free() + * called on it. + * If the environment variable is not set, an empty string will be returned. + * + * In both cases, environment variable set or unset, NULL is returned unless + * an exception has occurred, in which case the error string is returned. + * For example: + * + * ```c + * #include + * #include + * const char * env_value; + * const char * error_str; + * error_str = rcutils_get_env("SOME_ENV_VAR", &env_value); + * if (error_str != NULL) { + * fprintf(stderr, "Error getting env var: %s\n", error_str); + * } + * printf("Valued of 'SOME_ENV_VAR': %s\n", env_value); + * ``` + * + * This function cannot be concurrently called together with rcutils_set_env (or any platform specific equivalent) + * on different threads, but multiple concurrent calls to this function are thread safe. + * + * \param[in] env_name the name of the environment variable + * \param[out] env_value pointer to the value cstring, or "" if unset + * \return NULL on success (success can be returning an empty string), or + * \return an error string on failure. + */ +RCUTILS_PUBLIC +RCUTILS_WARN_UNUSED +const char * +rcutils_get_env(const char * env_name, const char ** env_value); + +/// Retrieve the full path to the home directory. +/** + * The c-string which is returned is only valid until the next time this + * function is called, because it is a direct pointer to the static storage. + * Also note that the string returned here should *not* be freed. + * + * The function first tries to get the HOME environment variable. + * If that variable exists and is non-empty, that will be returned. + * Otherwise, the function tries to get the USERPROFILE environment variable. + * If that variable exists and is non-empty, that will be returned. + * If neither exists, NULL will be returned. + * The above algorithm is portable across both Unix and Windows. + * + * This function cannot be thread-safely called together with rcutils_set_env + * (or any platform specific equivalent), but multiple calls to this function are thread safe. + * + * \return The home directory on success, or + * \return `NULL` on failure. + */ +RCUTILS_PUBLIC +RCUTILS_WARN_UNUSED +const char * +rcutils_get_home_dir(void); + #ifdef __cplusplus } #endif diff --git a/include/rcutils/get_env.h b/include/rcutils/get_env.h index 8bb66b1e..d08045eb 100644 --- a/include/rcutils/get_env.h +++ b/include/rcutils/get_env.h @@ -17,77 +17,14 @@ #ifndef RCUTILS__GET_ENV_H_ #define RCUTILS__GET_ENV_H_ -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "rcutils/macros.h" -#include "rcutils/visibility_control.h" - -/// Retrieve the value of the given environment variable if it exists, or "". -/** The c-string which is returned in the env_value output parameter is only - * valid until the next time this function is called, because it is a direct - * pointer to the static storage. - * The variable env_value populated by this function should never have free() - * called on it. - * If the environment variable is not set, an empty string will be returned. - * - * In both cases, environment variable set or unset, NULL is returned unless - * an exception has occurred, in which case the error string is returned. - * For example: - * - * ```c - * #include - * #include - * const char * env_value; - * const char * error_str; - * error_str = rcutils_get_env("SOME_ENV_VAR", &env_value); - * if (error_str != NULL) { - * fprintf(stderr, "Error getting env var: %s\n", error_str); - * } - * printf("Valued of 'SOME_ENV_VAR': %s\n", env_value); - * ``` - * - * This function cannot be concurrently called together with rcutils_set_env (or any platform specific equivalent) - * on different threads, but multiple concurrent calls to this function are thread safe. - * - * \param[in] env_name the name of the environment variable - * \param[out] env_value pointer to the value cstring, or "" if unset - * \return NULL on success (success can be returning an empty string), or - * \return an error string on failure. - */ -RCUTILS_PUBLIC -RCUTILS_WARN_UNUSED -const char * -rcutils_get_env(const char * env_name, const char ** env_value); +// TODO(christophebedard) remove this header completely in I-turtle -/// Retrieve the full path to the home directory. -/** - * The c-string which is returned is only valid until the next time this - * function is called, because it is a direct pointer to the static storage. - * Also note that the string returned here should *not* be freed. - * - * The function first tries to get the HOME environment variable. - * If that variable exists and is non-empty, that will be returned. - * Otherwise, the function tries to get the USERPROFILE environment variable. - * If that variable exists and is non-empty, that will be returned. - * If neither exists, NULL will be returned. - * The above algorithm is portable across both Unix and Windows. - * - * This function cannot be thread-safely called together with rcutils_set_env - * (or any platform specific equivalent), but multiple calls to this function are thread safe. - * - * \return The home directory on success, or - * \return `NULL` on failure. - */ -RCUTILS_PUBLIC -RCUTILS_WARN_UNUSED -const char * -rcutils_get_home_dir(void); - -#ifdef __cplusplus -} +#ifdef _MSC_VER +#pragma message ("rcutils/get_env.h has been deprecated, please include rcutils/env.h instead") +#else +#warning rcutils/get_env.h has been deprecated, please include rcutils/env.h instead #endif +#include "rcutils/env.h" + #endif // RCUTILS__GET_ENV_H_ diff --git a/src/env.c b/src/env.c index 566886bc..569c53ca 100644 --- a/src/env.c +++ b/src/env.c @@ -18,13 +18,12 @@ extern "C" #endif #include +#include #include #include "rcutils/env.h" #include "rcutils/error_handling.h" -// TODO(cottsay): Move the stuff in get_env.c in here - bool rcutils_set_env(const char * env_name, const char * env_value) { @@ -58,6 +57,53 @@ rcutils_set_env(const char * env_name, const char * env_value) return true; } +#ifdef _WIN32 +#pragma warning(disable : 4996) +#endif + +const char * +rcutils_get_env(const char * env_name, const char ** env_value) +{ + RCUTILS_CAN_RETURN_WITH_ERROR_OF("some string error"); + + if (NULL == env_name) { + return "argument env_name is null"; + } + if (NULL == env_value) { + return "argument env_value is null"; + } + + // TODO(Suyash458): getenv is deprecated on Windows; consider using getenv_s instead + *env_value = getenv(env_name); + + if (NULL == *env_value) { + *env_value = ""; + } + return NULL; +} + +const char * +rcutils_get_home_dir(void) +{ + const char * homedir; + + if (rcutils_get_env("HOME", &homedir) == NULL && *homedir != '\0') { + // The HOME environment variable was set and is non-empty, return it. + return homedir; + } + +#ifdef _WIN32 + // We didn't find a HOME variable, try USERPROFILE on Windows. + if (rcutils_get_env("USERPROFILE", &homedir) == NULL && *homedir != '\0') { + // The USERPROFILE environment variable was set and is non-empty, return it. + return homedir; + } +#endif + + // Couldn't get the home directory, return NULL. + return NULL; +} + #ifdef __cplusplus } #endif diff --git a/src/get_env.c b/src/get_env.c deleted file mode 100644 index 214060aa..00000000 --- a/src/get_env.c +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2016 Open Source Robotics Foundation, Inc. -// -// Licensed 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 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include - -#include "rcutils/get_env.h" - -#ifdef _WIN32 -#pragma warning(disable : 4996) -#endif - -const char * -rcutils_get_env(const char * env_name, const char ** env_value) -{ - RCUTILS_CAN_RETURN_WITH_ERROR_OF("some string error"); - - if (NULL == env_name) { - return "argument env_name is null"; - } - if (NULL == env_value) { - return "argument env_value is null"; - } - - // TODO(Suyash458): getenv is deprecated on Windows; consider using getenv_s instead - *env_value = getenv(env_name); - - if (NULL == *env_value) { - *env_value = ""; - } - return NULL; -} - -const char * -rcutils_get_home_dir(void) -{ - const char * homedir; - - if (rcutils_get_env("HOME", &homedir) == NULL && *homedir != '\0') { - // The HOME environment variable was set and is non-empty, return it. - return homedir; - } - -#ifdef _WIN32 - // We didn't find a HOME variable, try USERPROFILE on Windows. - if (rcutils_get_env("USERPROFILE", &homedir) == NULL && *homedir != '\0') { - // The USERPROFILE environment variable was set and is non-empty, return it. - return homedir; - } -#endif - - // Couldn't get the home directory, return NULL. - return NULL; -} - -#ifdef __cplusplus -} -#endif From 603b717161c9b400244b5c5c4734e083e70c64a4 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 30 Apr 2021 11:04:42 -0400 Subject: [PATCH 2/8] Update documentation Signed-off-by: Christophe Bedard --- include/rcutils/env.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rcutils/env.h b/include/rcutils/env.h index db11fd54..8ddc417f 100644 --- a/include/rcutils/env.h +++ b/include/rcutils/env.h @@ -69,7 +69,7 @@ rcutils_set_env(const char * env_name, const char * env_value); * * ```c * #include - * #include + * #include * const char * env_value; * const char * error_str; * error_str = rcutils_get_env("SOME_ENV_VAR", &env_value); From 9a22e91bf945e93a3571159a7a27a457ee93485f Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 30 Apr 2021 11:03:38 -0400 Subject: [PATCH 3/8] Merge test_get_env.cpp into test_env.cpp Signed-off-by: Christophe Bedard --- CMakeLists.txt | 9 +----- test/test_env.cpp | 53 ++++++++++++++++++++++++++++++- test/test_get_env.cpp | 72 ------------------------------------------- 3 files changed, 53 insertions(+), 81 deletions(-) delete mode 100644 test/test_get_env.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 56f04189..d01470a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,19 +310,12 @@ if(BUILD_TESTING) target_link_libraries(test_string_array ${PROJECT_NAME}) endif() - rcutils_custom_add_gtest(test_get_env test/test_get_env.cpp + rcutils_custom_add_gtest(test_env test/test_env.cpp ENV EMPTY_TEST= NORMAL_TEST=foo APPEND_LIBRARY_DIRS "$" ) - if(TARGET test_get_env) - target_link_libraries(test_get_env ${PROJECT_NAME}) - endif() - - rcutils_custom_add_gtest(test_env test/test_env.cpp - APPEND_LIBRARY_DIRS "$" - ) if(TARGET test_env) target_link_libraries(test_env ${PROJECT_NAME}) endif() diff --git a/test/test_env.cpp b/test/test_env.cpp index 5b638d7e..9a0604ce 100644 --- a/test/test_env.cpp +++ b/test/test_env.cpp @@ -18,7 +18,6 @@ #include "rcutils/env.h" #include "rcutils/error_handling.h" -#include "rcutils/get_env.h" TEST(TestEnv, test_set_env) { const char * res = nullptr; @@ -55,3 +54,55 @@ TEST(TestEnv, test_set_env) { ASSERT_EQ(nullptr, rcutils_get_env("NEW_ENV_VAR", &res)); EXPECT_STREQ("", res); } + +/* Tests rcutils_get_env. + * + * Expected environment variables must be set by the calling code: + * + * - EMPTY_TEST= + * - NORMAL_TEST=foo + * + * These are set in the call to `ament_add_gtest()` in the `CMakeLists.txt`. + */ +TEST(TestEnv, test_get_env) { + const char * env; + const char * ret; + ret = rcutils_get_env("NORMAL_TEST", NULL); + EXPECT_STREQ("argument env_value is null", ret); + ret = rcutils_get_env(NULL, &env); + EXPECT_STREQ("argument env_name is null", ret); + ret = rcutils_get_env("SHOULD_NOT_EXIST_TEST", &env); + EXPECT_FALSE(ret); + EXPECT_STREQ("", env); + ret = rcutils_get_env("NORMAL_TEST", &env); + EXPECT_FALSE(ret); + EXPECT_FALSE(NULL == env); + EXPECT_STREQ("foo", env); + ret = rcutils_get_env("EMPTY_TEST", &env); + EXPECT_FALSE(ret); + EXPECT_FALSE(NULL == env); + EXPECT_STREQ("", env); +} + +TEST(TestEnv, test_get_home) { + EXPECT_STRNE(NULL, rcutils_get_home_dir()); + const char * home = NULL; + +#ifdef _WIN32 + // Assert pre-condition that USERPROFILE is defined + const char * ret = rcutils_get_env("USERPROFILE", &home); + ASSERT_EQ(NULL, ret); + + // Check USERPROFILE is not defined + EXPECT_TRUE(rcutils_set_env("USERPROFILE", NULL)); + EXPECT_EQ(NULL, rcutils_get_home_dir()); +#else + // Assert pre-condition that HOME is defined + const char * ret = rcutils_get_env("HOME", &home); + ASSERT_EQ(NULL, ret); + + // Check HOME is not defined + EXPECT_TRUE(rcutils_set_env("HOME", NULL)); + EXPECT_EQ(NULL, rcutils_get_home_dir()); +#endif +} diff --git a/test/test_get_env.cpp b/test/test_get_env.cpp deleted file mode 100644 index edb29ef4..00000000 --- a/test/test_get_env.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2016 Open Source Robotics Foundation, Inc. -// -// Licensed 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 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include - -#include "rcutils/env.h" -#include "rcutils/get_env.h" - -/* Tests rcutils_get_env. - * - * Expected environment variables must be set by the calling code: - * - * - EMPTY_TEST= - * - NORMAL_TEST=foo - * - * These are set in the call to `ament_add_gtest()` in the `CMakeLists.txt`. - */ -TEST(TestGetEnv, test_get_env) { - const char * env; - const char * ret; - ret = rcutils_get_env("NORMAL_TEST", NULL); - EXPECT_STREQ("argument env_value is null", ret); - ret = rcutils_get_env(NULL, &env); - EXPECT_STREQ("argument env_name is null", ret); - ret = rcutils_get_env("SHOULD_NOT_EXIST_TEST", &env); - EXPECT_FALSE(ret); - EXPECT_STREQ("", env); - ret = rcutils_get_env("NORMAL_TEST", &env); - EXPECT_FALSE(ret); - EXPECT_FALSE(NULL == env); - EXPECT_STREQ("foo", env); - ret = rcutils_get_env("EMPTY_TEST", &env); - EXPECT_FALSE(ret); - EXPECT_FALSE(NULL == env); - EXPECT_STREQ("", env); -} - -TEST(TestGetEnv, test_get_home) { - EXPECT_STRNE(NULL, rcutils_get_home_dir()); - const char * home = NULL; - -#ifdef _WIN32 - // Assert pre-condition that USERPROFILE is defined - const char * ret = rcutils_get_env("USERPROFILE", &home); - ASSERT_EQ(NULL, ret); - - // Check USERPROFILE is not defined - EXPECT_TRUE(rcutils_set_env("USERPROFILE", NULL)); - EXPECT_EQ(NULL, rcutils_get_home_dir()); -#else - // Assert pre-condition that HOME is defined - const char * ret = rcutils_get_env("HOME", &home); - ASSERT_EQ(NULL, ret); - - // Check HOME is not defined - EXPECT_TRUE(rcutils_set_env("HOME", NULL)); - EXPECT_EQ(NULL, rcutils_get_home_dir()); -#endif -} From 7f6086db8d4a428e751bafacac3b6ae526ff257c Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 30 Apr 2021 11:08:58 -0400 Subject: [PATCH 4/8] Use push/pop for Windows warning Signed-off-by: Christophe Bedard --- src/env.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/env.c b/src/env.c index 569c53ca..8162cf9d 100644 --- a/src/env.c +++ b/src/env.c @@ -58,6 +58,7 @@ rcutils_set_env(const char * env_name, const char * env_value) } #ifdef _WIN32 +#pragma warning(push) #pragma warning(disable : 4996) #endif @@ -82,6 +83,10 @@ rcutils_get_env(const char * env_name, const char ** env_value) return NULL; } +#ifdef _WIN32 +#pragma warning(pop) +#endif + const char * rcutils_get_home_dir(void) { From d18710e9ef6a5adac359a16ad6933913377d0187 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 30 Apr 2021 11:10:39 -0400 Subject: [PATCH 5/8] Remove rcutils/get_env.h includes Signed-off-by: Christophe Bedard --- src/filesystem.c | 2 +- src/logging.c | 2 +- test/test_filesystem.cpp | 2 +- test/test_shared_library.cpp | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/filesystem.c b/src/filesystem.c index 02c02fd4..c88e74ae 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -42,9 +42,9 @@ extern "C" #include #endif // _WIN32 +#include "rcutils/env.h" #include "rcutils/error_handling.h" #include "rcutils/format_string.h" -#include "rcutils/get_env.h" #include "rcutils/repl_str.h" #include "rcutils/strdup.h" diff --git a/src/logging.c b/src/logging.c index 434b85d4..2dc0237f 100644 --- a/src/logging.c +++ b/src/logging.c @@ -43,10 +43,10 @@ extern "C" #endif #include "rcutils/allocator.h" +#include "rcutils/env.h" #include "rcutils/error_handling.h" #include "rcutils/find.h" #include "rcutils/format_string.h" -#include "rcutils/get_env.h" #include "rcutils/logging.h" #include "rcutils/snprintf.h" #include "rcutils/strdup.h" diff --git a/test/test_filesystem.cpp b/test/test_filesystem.cpp index e263128a..add41976 100644 --- a/test/test_filesystem.cpp +++ b/test/test_filesystem.cpp @@ -16,9 +16,9 @@ #include #include +#include "rcutils/env.h" #include "rcutils/error_handling.h" #include "rcutils/filesystem.h" -#include "rcutils/get_env.h" #include "osrf_testing_tools_cpp/scope_exit.hpp" diff --git a/test/test_shared_library.cpp b/test/test_shared_library.cpp index 5a32dd0a..cfa30cbf 100644 --- a/test/test_shared_library.cpp +++ b/test/test_shared_library.cpp @@ -20,11 +20,10 @@ #include "./mocking_utils/patch.hpp" #include "rcutils/allocator.h" +#include "rcutils/env.h" #include "rcutils/error_handling.h" #include "rcutils/shared_library.h" -#include "rcutils/get_env.h" - class TestSharedLibrary : public ::testing::Test { protected: From 4eb6f857ba63e3e26b8f2384c10031cff7f3a399 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 30 Apr 2021 11:45:18 -0400 Subject: [PATCH 6/8] Carry over & update copyright years Signed-off-by: Christophe Bedard --- include/rcutils/env.h | 2 +- include/rcutils/get_env.h | 2 +- src/env.c | 2 +- test/test_env.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/rcutils/env.h b/include/rcutils/env.h index 8ddc417f..8b1c5546 100644 --- a/include/rcutils/env.h +++ b/include/rcutils/env.h @@ -1,4 +1,4 @@ -// Copyright 2020 Open Source Robotics Foundation, Inc. +// Copyright 2017-2021 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/rcutils/get_env.h b/include/rcutils/get_env.h index d08045eb..ef28f2d4 100644 --- a/include/rcutils/get_env.h +++ b/include/rcutils/get_env.h @@ -1,4 +1,4 @@ -// Copyright 2017 Open Source Robotics Foundation, Inc. +// Copyright 2017-2021 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/env.c b/src/env.c index 8162cf9d..d5e27f16 100644 --- a/src/env.c +++ b/src/env.c @@ -1,4 +1,4 @@ -// Copyright 2020 Open Source Robotics Foundation, Inc. +// Copyright 2016-2021 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/test_env.cpp b/test/test_env.cpp index 9a0604ce..bd860918 100644 --- a/test/test_env.cpp +++ b/test/test_env.cpp @@ -1,4 +1,4 @@ -// Copyright 2020 Open Source Robotics Foundation, Inc. +// Copyright 2016-2021 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From fed8ca8fdf7094adb99ce2e936162c64f78dfffa Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sun, 2 May 2021 11:10:09 -0400 Subject: [PATCH 7/8] Revert "Carry over & update copyright years" This reverts commit 4eb6f857ba63e3e26b8f2384c10031cff7f3a399. Signed-off-by: Christophe Bedard --- include/rcutils/env.h | 2 +- include/rcutils/get_env.h | 2 +- src/env.c | 2 +- test/test_env.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/rcutils/env.h b/include/rcutils/env.h index 8b1c5546..8ddc417f 100644 --- a/include/rcutils/env.h +++ b/include/rcutils/env.h @@ -1,4 +1,4 @@ -// Copyright 2017-2021 Open Source Robotics Foundation, Inc. +// Copyright 2020 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/rcutils/get_env.h b/include/rcutils/get_env.h index ef28f2d4..d08045eb 100644 --- a/include/rcutils/get_env.h +++ b/include/rcutils/get_env.h @@ -1,4 +1,4 @@ -// Copyright 2017-2021 Open Source Robotics Foundation, Inc. +// Copyright 2017 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/env.c b/src/env.c index d5e27f16..8162cf9d 100644 --- a/src/env.c +++ b/src/env.c @@ -1,4 +1,4 @@ -// Copyright 2016-2021 Open Source Robotics Foundation, Inc. +// Copyright 2020 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/test_env.cpp b/test/test_env.cpp index bd860918..9a0604ce 100644 --- a/test/test_env.cpp +++ b/test/test_env.cpp @@ -1,4 +1,4 @@ -// Copyright 2016-2021 Open Source Robotics Foundation, Inc. +// Copyright 2020 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From 7eb69e04cecd44bd3bf0a47c38bae5b05a873ba3 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sun, 2 May 2021 11:48:47 -0400 Subject: [PATCH 8/8] Fix rcutils_get_home_dir doc Signed-off-by: Christophe Bedard --- include/rcutils/env.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/rcutils/env.h b/include/rcutils/env.h index 8ddc417f..61879ef7 100644 --- a/include/rcutils/env.h +++ b/include/rcutils/env.h @@ -100,10 +100,9 @@ rcutils_get_env(const char * env_name, const char ** env_value); * * The function first tries to get the HOME environment variable. * If that variable exists and is non-empty, that will be returned. - * Otherwise, the function tries to get the USERPROFILE environment variable. + * Otherwise, on Windows, the function tries to get the USERPROFILE environment variable. * If that variable exists and is non-empty, that will be returned. - * If neither exists, NULL will be returned. - * The above algorithm is portable across both Unix and Windows. + * Otherwise, NULL will be returned. * * This function cannot be thread-safely called together with rcutils_set_env * (or any platform specific equivalent), but multiple calls to this function are thread safe.