]> git.lyx.org Git - features.git/commitdiff
Strip gecos on Unix systems on user name only.
authorPavel Sanda <sanda@lyx.org>
Sun, 6 May 2012 11:36:54 +0000 (13:36 +0200)
committerPavel Sanda <sanda@lyx.org>
Sun, 6 May 2012 11:36:54 +0000 (13:36 +0200)
Patch from Scott Kostyshak.

src/support/userinfo.cpp
src/support/userinfo.h

index 5f2cfcab65599d954b565d8df803d0ab4c93a2ef..c873afe24744d9c5616348f97e34662c77869ce3 100644 (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);
index 2c482f475c5a3358eabc4d0f28d491992071d08f..6232a2b427496c2a2bb09309bf30696dc54d0173 100644 (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