Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions libbutl/path.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions libbutl/path.mxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '\\';
Expand All @@ -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)
Expand Down Expand Up @@ -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<C>;
Expand Down