diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2004-01-17 10:33:11 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2004-01-17 10:33:11 +0000 |
commit | 72cb070ee4aa8b28d821ea03a083e6b10c7e12dd (patch) | |
tree | 1473077c5006ee2e8b17049f41b07728164c5ffb /src/common/weeconfig.c | |
parent | 390a0977181b1c21615306a63068e3b2aca367fb (diff) | |
download | weechat-72cb070ee4aa8b28d821ea03a083e6b10c7e12dd.zip |
Fixed bug when un*x realname (in /etc/passwd) is not set
Diffstat (limited to 'src/common/weeconfig.c')
-rw-r--r-- | src/common/weeconfig.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c index 3cb2f134b..8932a1417 100644 --- a/src/common/weeconfig.c +++ b/src/common/weeconfig.c @@ -956,11 +956,9 @@ config_create_default () fprintf (file, "\n[%s]\n", config_sections[i].section_name); if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) || (i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY)) - { fprintf (file, "# WARNING!!! Options for section \"%s\" are not developed!\n", config_sections[i].section_name); - } for (j = 0; weechat_options[i][j].option_name; j++) { switch (weechat_options[i][j].option_type) @@ -1031,20 +1029,30 @@ config_create_default () fprintf (file, "server_nick2=%s1\n", my_passwd->pw_name); fprintf (file, "server_nick3=%s2\n", my_passwd->pw_name); fprintf (file, "server_username=%s\n", my_passwd->pw_name); - realname = strdup (my_passwd->pw_gecos); - pos = strchr (realname, ','); - if (pos) - pos[0] = '\0'; - fprintf (file, "server_realname=%s\n", - realname); - if (pos) - pos[0] = ','; - free (realname); + if ((!my_passwd->pw_gecos) + || (my_passwd->pw_gecos[0] == '\0') + || (my_passwd->pw_gecos[0] == ',') + || (my_passwd->pw_gecos[0] == ' ')) + fprintf (file, "server_realname=%s\n", my_passwd->pw_name); + else + { + realname = strdup (my_passwd->pw_gecos); + pos = strchr (realname, ','); + if (pos) + pos[0] = '\0'; + fprintf (file, "server_realname=%s\n", + realname); + if (pos) + pos[0] = ','; + free (realname); + } } else { /* default values if /etc/passwd can't be read */ - fprintf (stderr, "%s (%s).", _("Unable to get user's name"), + fprintf (stderr, "%s: %s (%s).", + WEECHAT_WARNING, + _("Unable to get user's name"), strerror (errno)); fprintf (file, "server_nick1=weechat1\n"); fprintf (file, "server_nick2=weechat2\n"); @@ -1109,11 +1117,9 @@ config_write (char *config_name) fprintf (file, "\n[%s]\n", config_sections[i].section_name); if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) || (i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY)) - { fprintf (file, "# WARNING!!! Options for section \"%s\" are not developed!\n", config_sections[i].section_name); - } for (j = 0; weechat_options[i][j].option_name; j++) { switch (weechat_options[i][j].option_type) |