Module Name:    src
Committed By:   christos
Date:           Tue Jan 12 14:44:24 UTC 2010

Modified Files:
        src/usr.bin/mail: complete.c

Log Message:
- 1 -> EXIT_FAILURE
- avoid assertion firing when hitting ^D in CC: line.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/mail/complete.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mail/complete.c
diff -u src/usr.bin/mail/complete.c:1.19 src/usr.bin/mail/complete.c:1.20
--- src/usr.bin/mail/complete.c:1.19	Fri Apr 10 09:08:24 2009
+++ src/usr.bin/mail/complete.c	Tue Jan 12 09:44:24 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: complete.c,v 1.19 2009/04/10 13:08:24 christos Exp $	*/
+/*	$NetBSD: complete.c,v 1.20 2010/01/12 14:44:24 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997-2000,2005,2006 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: complete.c,v 1.19 2009/04/10 13:08:24 christos Exp $");
+__RCSID("$NetBSD: complete.c,v 1.20 2010/01/12 14:44:24 christos Exp $");
 #endif /* not lint */
 
 /*
@@ -178,7 +178,7 @@
 
 	p = sl_init();
 	if (p == NULL)
-		err(1, "Unable to allocate memory for stringlist");
+		err(EXIT_FAILURE, "Unable to allocate memory for stringlist");
 	return p;
 }
 
@@ -191,7 +191,7 @@
 {
 
 	if (sl_add(sl, i) == -1)
-		err(1, "Unable to add `%s' to stringlist", i);
+		err(EXIT_FAILURE, "Unable to add `%s' to stringlist", i);
 }
 
 
@@ -1143,12 +1143,13 @@
 		return NULL;
 	}
 
-	assert(cnt > 0);
-	if (buf[cnt - 1] == '\n')
-		cnt--;	/* trash the trailing LF */
+	if (cnt > 0) {
+		if (buf[cnt - 1] == '\n')
+			cnt--;	/* trash the trailing LF */
 
-	len = MIN(sizeof(line) - 1, (size_t)cnt);
-	(void)memcpy(line, buf, len);
+		len = MIN(sizeof(line) - 1, (size_t)cnt);
+		(void)memcpy(line, buf, len);
+	}
 	line[cnt] = '\0';
 
 	/* enter non-empty lines into history */

Reply via email to