Module Name: src
Committed By: christos
Date: Sat Apr 11 14:22:32 UTC 2009
Modified Files:
src/usr.bin/mail: Makefile cmd3.c cmd4.c fio.c format.c mime_attach.c
thread.c
Log Message:
- magic fix for short files
- knf
from Anon Ymous
To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/mail/Makefile
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/mail/cmd3.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/mail/cmd4.c
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/mail/fio.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/mail/format.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/mail/mime_attach.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/mail/thread.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/Makefile
diff -u src/usr.bin/mail/Makefile:1.31 src/usr.bin/mail/Makefile:1.32
--- src/usr.bin/mail/Makefile:1.31 Fri Apr 10 09:08:24 2009
+++ src/usr.bin/mail/Makefile Sat Apr 11 10:22:32 2009
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.31 2009/04/10 13:08:24 christos Exp $
+# $NetBSD: Makefile,v 1.32 2009/04/11 14:22:32 christos Exp $
# @(#)Makefile 8.3 (Berkeley) 4/20/95
.include <bsd.own.mk>
@@ -15,6 +15,7 @@
#
CPPFLAGS+= -DBROKEN_EXEC_TTY_RESTORE # broken since 4.99.10
CPPFLAGS+= -DBROKEN_CLONE_STAT # see PRs 37878 and 37550
+CPPFLAGS+= -DBROKEN_MAGIC # bad MIME type on short files
# Debugging options (most should go away - please leave for now).
#
Index: src/usr.bin/mail/cmd3.c
diff -u src/usr.bin/mail/cmd3.c:1.40 src/usr.bin/mail/cmd3.c:1.41
--- src/usr.bin/mail/cmd3.c:1.40 Fri Apr 10 09:08:24 2009
+++ src/usr.bin/mail/cmd3.c Sat Apr 11 10:22:32 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: cmd3.c,v 1.40 2009/04/10 13:08:24 christos Exp $ */
+/* $NetBSD: cmd3.c,v 1.41 2009/04/11 14:22:32 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: cmd3.c,v 1.40 2009/04/10 13:08:24 christos Exp $");
+__RCSID("$NetBSD: cmd3.c,v 1.41 2009/04/11 14:22:32 christos Exp $");
#endif
#endif /* not lint */
@@ -477,7 +477,7 @@
(void)printf("address missing!\n");
return 1;
}
- for ( ip = msgvec; *ip; ip++) {
+ for (ip = msgvec; *ip; ip++) {
int e;
if ((e = forward_one(*ip, hdr.h_to)) != 0)
return e;
@@ -578,7 +578,7 @@
return 1;
smargs = unpack(hdr.h_to);
- for ( ip = msgvec; *ip; ip++) {
+ for (ip = msgvec; *ip; ip++) {
int e;
if ((e = bounce_one(*ip, smargs, hdr.h_to)) != 0)
return e;
Index: src/usr.bin/mail/cmd4.c
diff -u src/usr.bin/mail/cmd4.c:1.5 src/usr.bin/mail/cmd4.c:1.6
--- src/usr.bin/mail/cmd4.c:1.5 Fri Apr 10 09:08:24 2009
+++ src/usr.bin/mail/cmd4.c Sat Apr 11 10:22:32 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: cmd4.c,v 1.5 2009/04/10 13:08:24 christos Exp $ */
+/* $NetBSD: cmd4.c,v 1.6 2009/04/11 14:22:32 christos Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#if 0
static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: cmd4.c,v 1.5 2009/04/10 13:08:24 christos Exp $");
+__RCSID("$NetBSD: cmd4.c,v 1.6 2009/04/11 14:22:32 christos Exp $");
#endif
#endif /* not lint */
@@ -137,13 +137,13 @@
int cnt;
cnt = 1;
- for (h = 0; h < (int)__arraycount(smoptstbl); h++ )
+ for (h = 0; h < (int)__arraycount(smoptstbl); h++)
for (sp = smoptstbl[h]; sp && sp->s_name != NULL; sp = sp->s_link)
cnt++;
argv = salloc(cnt * sizeof(*argv));
ap = argv;
- for (h = 0; h < (int)__arraycount(smoptstbl); h++ )
+ for (h = 0; h < (int)__arraycount(smoptstbl); h++)
for (sp = smoptstbl[h]; sp && sp->s_name != NULL; sp = sp->s_link)
*ap++ = sp->s_name;
*ap = NULL;
Index: src/usr.bin/mail/fio.c
diff -u src/usr.bin/mail/fio.c:1.32 src/usr.bin/mail/fio.c:1.33
--- src/usr.bin/mail/fio.c:1.32 Fri Apr 10 09:08:24 2009
+++ src/usr.bin/mail/fio.c Sat Apr 11 10:22:32 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: fio.c,v 1.32 2009/04/10 13:08:24 christos Exp $ */
+/* $NetBSD: fio.c,v 1.33 2009/04/11 14:22:32 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: fio.c,v 1.32 2009/04/10 13:08:24 christos Exp $");
+__RCSID("$NetBSD: fio.c,v 1.33 2009/04/11 14:22:32 christos Exp $");
#endif
#endif /* not lint */
@@ -235,7 +235,7 @@
(void)fwrite(linebuf, sizeof(*linebuf), len, otf);
if (ferror(otf))
err(EXIT_FAILURE, "/tmp");
- if(len)
+ if (len)
linebuf[len - 1] = 0;
if (maybe && linebuf[0] == 'F' && ishead(linebuf)) {
nmsgCount++;
Index: src/usr.bin/mail/format.c
diff -u src/usr.bin/mail/format.c:1.14 src/usr.bin/mail/format.c:1.15
--- src/usr.bin/mail/format.c:1.14 Fri Apr 10 09:08:24 2009
+++ src/usr.bin/mail/format.c Sat Apr 11 10:22:32 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: format.c,v 1.14 2009/04/10 13:08:24 christos Exp $ */
+/* $NetBSD: format.c,v 1.15 2009/04/11 14:22:32 christos Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef __lint__
-__RCSID("$NetBSD: format.c,v 1.14 2009/04/10 13:08:24 christos Exp $");
+__RCSID("$NetBSD: format.c,v 1.15 2009/04/11 14:22:32 christos Exp $");
#endif /* not __lint__ */
#include <time.h>
@@ -912,7 +912,7 @@
if (!quoted && q < qend) {
*q++ = *p;
if (!is_WSP(*p)
- /* && !is_specials((unsigned char)*p) */ )
+ /* && !is_specials((unsigned char)*p) */)
lastq = q;
}
break;
Index: src/usr.bin/mail/mime_attach.c
diff -u src/usr.bin/mail/mime_attach.c:1.12 src/usr.bin/mail/mime_attach.c:1.13
--- src/usr.bin/mail/mime_attach.c:1.12 Fri Apr 10 09:08:25 2009
+++ src/usr.bin/mail/mime_attach.c Sat Apr 11 10:22:32 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: mime_attach.c,v 1.12 2009/04/10 13:08:25 christos Exp $ */
+/* $NetBSD: mime_attach.c,v 1.13 2009/04/11 14:22:32 christos Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef __lint__
-__RCSID("$NetBSD: mime_attach.c,v 1.12 2009/04/10 13:08:25 christos Exp $");
+__RCSID("$NetBSD: mime_attach.c,v 1.13 2009/04/11 14:22:32 christos Exp $");
#endif /* not __lint__ */
#include <assert.h>
@@ -337,10 +337,11 @@
magic_t magic;
struct stat sb;
+#ifdef BROKEN_MAGIC
/*
- * libmagic produces annoying results on very short files.
- * The common case is with mime-encode-message defined and an
- * empty message body.
+ * libmagic(3) produces annoying results on very short files.
+ * The common case is MIME encoding an empty message body.
+ * XXX - it would be better to fix libmagic(3)!
*
* Note: a 1-byte message body always consists of a newline,
* so size determines all there. However, 1-byte attachments
@@ -351,6 +352,7 @@
if (sb.st_size < 2 && S_ISREG(sb.st_mode)) {
FILE *fp;
int ch;
+
if (sb.st_size == 0 || filename == NULL ||
(fp = Fopen(filename, "r")) == NULL)
return "text/plain";
@@ -362,6 +364,7 @@
"text/plain" : "application/octet-stream";
}
}
+#endif
magic = magic_open(MAGIC_MIME);
if (magic == NULL) {
warnx("magic_open: %s", magic_error(magic));
Index: src/usr.bin/mail/thread.c
diff -u src/usr.bin/mail/thread.c:1.8 src/usr.bin/mail/thread.c:1.9
--- src/usr.bin/mail/thread.c:1.8 Fri Apr 10 09:08:25 2009
+++ src/usr.bin/mail/thread.c Sat Apr 11 10:22:32 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: thread.c,v 1.8 2009/04/10 13:08:25 christos Exp $ */
+/* $NetBSD: thread.c,v 1.9 2009/04/11 14:22:32 christos Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifndef __lint__
-__RCSID("$NetBSD: thread.c,v 1.8 2009/04/10 13:08:25 christos Exp $");
+__RCSID("$NetBSD: thread.c,v 1.9 2009/04/11 14:22:32 christos Exp $");
#endif /* not __lint__ */
#include <assert.h>
@@ -450,7 +450,11 @@
message_array.t_head = nmessage; /* for assert check in thread_fix_new_links */
#endif
-# define FIX_LINK(p) do { if (p) p = nmessage + (p - message); } while(/*CONSTCOND*/0)
+# define FIX_LINK(p) do {\
+ if (p)\
+ p = nmessage + (p - message);\
+ } while (/*CONSTCOND*/0)
+
FIX_LINK(current_thread.t_head);
for (i = 0; i < omsgCount; i++) {
FIX_LINK(nmessage[i].m_blink);
@@ -458,7 +462,7 @@
FIX_LINK(nmessage[i].m_clink);
FIX_LINK(nmessage[i].m_plink);
}
- for (i = 0; i < current_thread.t_msgCount; i++ )
+ for (i = 0; i < current_thread.t_msgCount; i++)
FIX_LINK(current_thread.t_msgtbl[i]);
# undef FIX_LINK
@@ -1095,7 +1099,7 @@
if (mp) {
depth = mp->m_depth;
for (mp = first_message(current_thread.t_head); mp; mp = next_message(mp))
- if (mp->m_depth > depth ) {
+ if (mp->m_depth > depth) {
mp->m_flag |= MTAGGED;
touch(mp);
}
@@ -1449,7 +1453,7 @@
#endif
for (i = 0; i < mcount; i++) {
char *subj = hfield(key, mp);
- while( strncasecmp(subj, "Re:", 3) == 0 )
+ while (strncasecmp(subj, "Re:", 3) == 0)
subj = skip_WSP(subj + 3);
marray[i].mp = mp;
marray[i].key.str = subj;
@@ -1716,7 +1720,7 @@
redepth(¤t_thread);
depth = current_thread.t_head->m_depth;
for (mp = first_message(current_thread.t_head); mp; mp = next_message(mp)) {
- if (mp->m_depth > depth ) {
+ if (mp->m_depth > depth) {
mp->m_flag &= ~(MPRESERVE | MSAVED | MBOX);
mp->m_flag |= MDELETED | MTOUCH;
touch(mp);