X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/c4e3a0c3f0c72c6932d132974e268f0c0a54afbc..63621a81d16ab743de6b57d47578a9a2c670ad22:/test/getfullname.c diff --git a/test/getfullname.c b/test/getfullname.c index 0e12fe93..9a342ca1 100644 --- a/test/getfullname.c +++ b/test/getfullname.c @@ -22,9 +22,12 @@ main(int argc, char *argv[]) struct passwd *pwd; char buf[BUFSIZ], *p; + if (argc > 2) { + fprintf (stderr, "usage: %s [name]\n", argv[0]); + return 1; + } if (argc < 2) { pwd = getpwuid(getuid()); - if (! pwd) { fprintf(stderr, "Unable to retrieve user info for " "userid %ld\n", (long) getuid()); @@ -33,12 +36,8 @@ main(int argc, char *argv[]) strncpy(buf, pwd->pw_gecos, sizeof(buf)); buf[sizeof(buf) - 1] = '\0'; - } else if (argc == 2) { + } else strncpy(buf, argv[1], sizeof(buf)); - } else if (argc > 2) { - fprintf (stderr, "usage: %s [name]\n", argv[0]); - return 1; - } /* * Perform the same processing that getuserinfo() does. @@ -54,8 +53,7 @@ main(int argc, char *argv[]) * Quote the entire string if it has a special character in it. */ escape_display_name (buf, sizeof(buf)); - - printf("%s\n", buf); + puts(buf); exit(0); }