diff options
author | Kris Kennaway <kris@FreeBSD.org> | 1999-12-04 02:11:51 +0000 |
---|---|---|
committer | Kris Kennaway <kris@FreeBSD.org> | 1999-12-04 02:11:51 +0000 |
commit | 1b2fef9f1ef253fee2ebb5a7f1ff19fadc452920 (patch) | |
tree | 4e2c380cd38de6d38658bca157f9265eac7d22f4 /usr.bin/banner | |
parent | 2963da13bf7b5df4a358a2a9b10e4721bf375cdd (diff) | |
download | src-1b2fef9f1ef253fee2ebb5a7f1ff19fadc452920.tar.gz src-1b2fef9f1ef253fee2ebb5a7f1ff19fadc452920.zip |
Notes
Diffstat (limited to 'usr.bin/banner')
-rw-r--r-- | usr.bin/banner/banner.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/usr.bin/banner/banner.c b/usr.bin/banner/banner.c index e516f57f60cc..804f0365b961 100644 --- a/usr.bin/banner/banner.c +++ b/usr.bin/banner/banner.c @@ -38,7 +38,11 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint +#if 0 static const char sccsid[] = "@(#)banner.c 8.4 (Berkeley) 4/29/95"; +#endif +static const char rcsid[] = + "$FreeBSD$"; #endif /* not lint */ /* @@ -1018,7 +1022,7 @@ const char data_table[NBYTES] = { }; char line[DWIDTH]; -char message[MAXMSG]; +char *message; char print[DWIDTH]; int debug, i, j, linen, max, nchars, pc, term, trace, x, y; int width = DWIDTH; /* -w option: scrunch letters to 80 columns */ @@ -1058,6 +1062,10 @@ main(argc, argv) /* Have now read in the data. Next get the message to be printed. */ if (*argv) { + for(i=0, j=0; i < argc; i++) + j += strlen(argv[i]) + (i != 0); + if ((message = malloc(j)) == NULL) + err(1, "malloc"); strcpy(message, *argv); while (*++argv) { strcat(message, " "); @@ -1065,8 +1073,10 @@ main(argc, argv) } nchars = strlen(message); } else { + if ((message = malloc(MAXMSG)) == NULL) + err(1, "malloc"); fprintf(stderr,"Message: "); - (void)fgets(message, sizeof(message), stdin); + (void)fgets(message, MAXMSG, stdin); nchars = strlen(message); message[nchars--] = '\0'; /* get rid of newline */ } @@ -1156,5 +1166,6 @@ main(argc, argv) } } + free(message); exit(0); } |