summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar John Kohl <jtkohl@mit.edu>1988-06-17 13:01:31 +0000
committerGravatar John Kohl <jtkohl@mit.edu>1988-06-17 13:01:31 +0000
commit2e3d61a176cf240fde14752dd50699176c3c2c60 (patch)
tree6a4740a6226167cf0de28752a7558d743b10c861
parent1953766048aa7606a9510fb587fd35026bfcbce7 (diff)
don't use ping if a cmd line arg was given.
clean up cmd-line message handling (make it work sanely)
-rw-r--r--clients/zwrite/zwrite.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/clients/zwrite/zwrite.c b/clients/zwrite/zwrite.c
index 8771cfc..10b60e7 100644
--- a/clients/zwrite/zwrite.c
+++ b/clients/zwrite/zwrite.c
@@ -143,36 +143,36 @@ main(argc, argv)
notice.z_message_len = 0;
notice.z_recipient = "";
notice.z_default_format = "";
+ notice.z_num_other_fields = 0;
- if (!nocheck)
+ if (!nocheck && !msgarg)
send_off(&notice, 0);
if (!msgarg && isatty(0))
printf("Type your message now. End with control-D or a dot on a line by itself.\n");
+ message = NULL;
+ msgsize = 0;
if (signature) {
message = malloc(strlen(signature)+1);
strcpy(message, signature);
msgsize = strlen(message)+1;
}
- else {
- message = malloc(1);
- message[0] = '\0';
- msgsize = 1;
- }
if (msgarg) {
for (arg=msgarg;arg<argc;arg++) {
- message = realloc(message, msgsize+strlen(argv[arg])+
- (arg != argc-1)?2:1);
+ if (message)
+ message = realloc(message, msgsize+strlen(argv[arg])+
+ (arg == argc-1)?2:1);
+ else
+ message = malloc(strlen(argv[arg])+ (arg == argc-1)?2:1);
strcpy(message+msgsize, argv[arg]);
msgsize += strlen(argv[arg]);
if (arg != argc-1) {
- strcpy(message+msgsize+1, " ");
+ message[msgsize] = ' ';
msgsize++;
}
}
- message = realloc(message, msgsize+2);
message[msgsize] = '\n';
message[msgsize+1] = '\0';
msgsize += 2;