diff --git a/libbutl/path.cxx b/libbutl/path.cxx index 3b047302..e20380e8 100644 --- a/libbutl/path.cxx +++ b/libbutl/path.cxx @@ -168,14 +168,17 @@ namespace butl passwd* rpw; int r (getpwuid_r (getuid (), &pw, buf, sizeof (buf), &rpw)); - if (r == -1) - throw_generic_error (errno); - - if (r == 0 && rpw == nullptr) - // According to POSIX errno should be left unchanged if an entry is not - // found. - // - throw_generic_error (ENOENT); + if (rpw == nullptr) + { + if (r == 0) + // According to POSIX errno should be left unchanged if an entry is not + // found. + throw_generic_error (ENOENT); + else { + errno = r; + throw_generic_error (errno); + } + } return pw.pw_dir; } diff --git a/libbutl/path.mxx b/libbutl/path.mxx index 1ee2a66c..d55841e9 100644 --- a/libbutl/path.mxx +++ b/libbutl/path.mxx @@ -105,7 +105,7 @@ LIBBUTL_MODEXPORT namespace butl using char_traits_type = typename string_type::traits_type; using size_type = typename string_type::size_type; - // Canonical directory and path seperators. + // Canonical directory and path separators. // #ifdef _WIN32 static constexpr const C directory_separator = '\\'; @@ -125,7 +125,7 @@ LIBBUTL_MODEXPORT namespace butl #endif // Directory separator tests. On some platforms there could be multiple - // seperators. For example, on Windows we check for both '/' and '\'. + // separators. For example, on Windows we check for both '/' and '\'. // static bool is_separator (C c) @@ -659,7 +659,7 @@ LIBBUTL_MODEXPORT namespace butl // necessary. Otherwise, return the empty object and leave the passed // string untouched. // - // If extact is false, throw invalid_path if the string is not a valid + // If exact is false, throw invalid_path if the string is not a valid // path (e.g., uses an unsupported path notation on Windows). // using data_type = path_data;