Strip gecos on Unix systems on user name only.

Patch from Scott Kostyshak.
This commit is contained in:
Pavel Sanda 2012-05-06 13:36:54 +02:00
parent 9541e6b851
commit 4ce24954aa
2 changed files with 4 additions and 2 deletions

View File

@ -48,7 +48,9 @@ docstring const user_name()
struct passwd * pw = getpwuid(geteuid());
LASSERT(pw, /**/);
string name = pw->pw_gecos;
const string gecos = pw->pw_gecos;
const size_t pos = gecos.find(",");
string name = gecos.substr(0, pos);
if (name.empty())
name = pw->pw_name;
return from_local8bit(name);

View File

@ -18,7 +18,7 @@
namespace lyx {
namespace support {
/// return the current user's real name
/// return the current user's real name or user name
docstring const user_name();
/// return the current user's e-mail address