]> git.lyx.org Git - lyx.git/blobdiff - src/support/userinfo.cpp
Remove non-copyable idioms
[lyx.git] / src / support / userinfo.cpp
index c68d55ac3e02b27d001b1496259142bba74ff605..97c458c7c710882403686494f990a99112611960 100644 (file)
 
 #include "support/userinfo.h"
 #include "support/environment.h"
+#include "support/docstring.h"
 
-#include <boost/assert.hpp>
+#include "support/lassert.h"
 
 #if defined (_WIN32)
-# include "gettext.h"
+# include "support/gettext.h"
 # include <windows.h>
 # include <lmcons.h>
 #else
@@ -29,7 +30,7 @@
 # include <sys/types.h>
 #endif
 
-using std::string;
+using namespace std;
 
 namespace lyx {
 namespace support {
@@ -44,10 +45,12 @@ docstring const user_name()
                return _("Unknown user");
        return from_local8bit(name);
 #else
-       struct passwd * pw(getpwuid(geteuid()));
-       BOOST_ASSERT(pw);
+       struct passwd * pw = getpwuid(geteuid());
+       LASSERT(pw, return docstring());
 
-       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);
@@ -61,11 +64,12 @@ docstring const user_email()
        //The code after should be used only after user approval.
        return docstring();
 
-       
+#if 0
        string email = getEnv("EMAIL_ADDRESS");
        if (email.empty())
                email = getEnv("EMAIL");
        return from_local8bit(email);
+#endif
 }
 
 } // namespace support