Use g_get_user_name instead of access through getpwuid

It is more portable - available also on Windows

Change-Id: I424e1993ad9621ca42b6f48896d5025832ac681e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141584
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2022-10-21 23:10:00 +02:00
parent 8dcf53b3d2
commit 66fcc9db0f

View file

@ -9,8 +9,6 @@
#include <gtk/gtk.h>
#include <pwd.h>
#include <cstring>
#include "gtv-helpers.hxx"
@ -94,8 +92,7 @@ void GtvHelpers::clipboardSetHtml(GtkClipboard* pClipboard, const char* pSelecti
std::string GtvHelpers::getNextAuthor()
{
static int nCounter = 0;
struct passwd* pPasswd = getpwuid(getuid());
return std::string(pPasswd->pw_gecos) + " #" + std::to_string(++nCounter);
return std::string(g_get_user_name()) + " #" + std::to_string(++nCounter);
}
GtkWidget* GtvHelpers::createCommentBox(const boost::property_tree::ptree& aComment)