little clarification
[hband-tools.git] / compiled-tools / wall.d / wall.c.patch
bloba1450b6b71702375e2749a5a110902574df5739e
1 --- a/util-linux-2.25.1/term-utils/wall.c 2014-08-26 16:48:45.000000000 +0200
2 +++ b/util-linux-2.25.1/term-utils/wall.c 2016-03-17 15:52:07.000000000 +0100
3 @@ -199,19 +199,20 @@
5 if (print_banner == TRUE) {
6 char *hostname = xgethostname();
7 - char *whom, *where, *date;
8 + char *whom = NULL, *where, *date;
9 struct passwd *pw;
10 time_t now;
12 - if (!(whom = getlogin()) || !*whom)
13 - whom = (pw = getpwuid(getuid())) ? pw->pw_name : "???";
14 + if((pw = getpwuid(getuid()))!=NULL)
15 + whom = pw->pw_name;
16 if (!whom) {
17 whom = "someone";
18 warn(_("cannot get passwd uid"));
20 - where = ttyname(STDOUT_FILENO);
21 + where = ttyname(STDIN_FILENO);
22 + if (!where) where = ttyname(STDERR_FILENO);
23 + if (!where) where = ttyname(STDOUT_FILENO);
24 if (!where) {
25 - where = "somewhere";
26 warn(_("cannot get tty name"));
27 } else if (strncmp(where, "/dev/", 5) == 0)
28 where += 5;
29 @@ -230,15 +232,15 @@
30 /* snprintf is not always available, but the sprintf's here
31 will not overflow as long as %d takes at most 100 chars */
32 fprintf(fp, "\r%*s\r\n", TERM_WIDTH, " ");
33 - sprintf(lbuf, _("Broadcast message from %s@%s (%s) (%s):"),
34 - whom, hostname, where, date);
35 - fprintf(fp, "%-*.*s\007\007\r\n", TERM_WIDTH, TERM_WIDTH, lbuf);
36 + fprintf(fp, _("Broadcast message from %s@%s%s%s%s on %s:"),
37 + whom, hostname, where?" (":"", where?where:"", where?")":"", date);
38 + fprintf(fp, "\007\007\r\n");
39 free(hostname);
40 free(date);
42 fprintf(fp, "%*s\r\n", TERM_WIDTH, " ");
44 - if (mvec) {
45 + if (mvec) {
47 * Read message from argv[]
49 @@ -252,7 +254,8 @@
50 fputc('\r', fp);
51 fputc('\n', fp);
53 - } else {
54 + }
55 + else {
57 * read message from <file>