summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/Makefile4
-rw-r--r--usr.bin/mg/mail.c171
-rw-r--r--usr.bin/mg/main.c4
3 files changed, 3 insertions, 176 deletions
diff --git a/usr.bin/mg/Makefile b/usr.bin/mg/Makefile
index 8b610342043..a52df469093 100644
--- a/usr.bin/mg/Makefile
+++ b/usr.bin/mg/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.20 2008/06/12 01:58:44 kjell Exp $
+# $OpenBSD: Makefile,v 1.21 2008/06/13 18:51:02 kjell Exp $
PROG= mg
@@ -25,6 +25,6 @@ SRCS= cinfo.c fileio.c spawn.c ttyio.c tty.c ttykbd.c \
#
# More or less standalone extensions.
#
-SRCS+= grep.c theo.c mail.c cmode.c
+SRCS+= grep.c theo.c cmode.c
.include <bsd.prog.mk>
diff --git a/usr.bin/mg/mail.c b/usr.bin/mg/mail.c
deleted file mode 100644
index 1309683ac2d..00000000000
--- a/usr.bin/mg/mail.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/* $OpenBSD: mail.c,v 1.9 2005/11/18 20:56:53 deraadt Exp $ */
-/*
- * This file is in the public domain.
- *
- * Author: Vincent Labrecque, April 2003
- */
-#include <ctype.h>
-
-#include "def.h"
-#include "kbd.h"
-#include "funmap.h"
-
-void mail_init(void);
-static int fake_self_insert(int, int);
-static int mail(int, int);
-
-int limit = 72;
-
-/* mappings for all "printable" characters ('-' -> '~') */
-static PF mail_fake[] = {
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert, fake_self_insert,
- fake_self_insert, fake_self_insert, fake_self_insert
-};
-
-static struct KEYMAPE (1 + IMAPEXT) mailmap = {
- 1,
- 1 + IMAPEXT,
- rescan,
- {
- { ' ', '~', mail_fake, NULL }
- }
-};
-
-int
-mail_set_limit(int f, int n)
-{
- char buf[32], *rep;
-
- if ((f & FFARG) != 0) {
- limit = n;
- } else {
- if ((rep = eread("Margin: ", buf, sizeof(buf),
- EFNEW | EFCR)) == NULL)
- return (ABORT);
- else if (rep[0] == '\0')
- return (FALSE);
- limit = atoi(rep);
- }
- return (TRUE);
-}
-
-void
-mail_init(void)
-{
- funmap_add(mail, "mail-mode");
- funmap_add(mail_set_limit, "mail-set-margin");
- maps_add((KEYMAP *)&mailmap, "mail-mode");
-}
-
-/* ARGSUSED */
-static int
-mail(int f, int n)
-{
- curbp->b_modes[0] = name_mode("fundamental");
- curbp->b_modes[1] = name_mode("mail-mode");
- if (curbp->b_modes[1] == NULL) {
- panic("can't happen");
- mail_init();
- curbp->b_modes[1] = name_mode("mail-mode");
- }
- curbp->b_nmodes = 1;
- curwp->w_flag |= WFMODE;
- return (TRUE);
-}
-
-static int
-fake_self_insert(int f, int n)
-{
- int len = llength(curwp->w_dotp), col;
-
- if (len + 1 > limit) {
- /*
- * Find the column at which we should cut, taking
- * word boundaries into account.
- */
- for (col = limit; col > 0; col--)
- if (isspace(curwp->w_dotp->l_text[col])) {
- col++; /* XXX - skip the space */
- break;
- }
-
- if (curbp->b_doto == len) {
- /*
- * User is appending to the line; simple case.
- */
- if (col) {
- curwp->w_doto = col;
- lnewline();
- gotoeol(0, 1);
- }
- curwp->w_wrapline = NULL;
- } else if ((len - col) > 0) {
- /*
- * User is shifting words by inserting in the middle.
- */
- const char *trail;
- int save_doto = curwp->w_doto;
- struct line *save_dotp = curwp->w_dotp;
- int tlen = len - col;
-
- trail = curwp->w_dotp->l_text + col;
-
- /*
- * Create a new line or reuse the last wrapping line
- * unless we could fill it.
- */
- if (curwp->w_wrapline != lforw(curwp->w_dotp) ||
- llength(curwp->w_wrapline) + tlen >= limit) {
- curwp->w_doto = col;
- lnewline();
- curwp->w_wrapline = curwp->w_dotp;
- curwp->w_dotp = save_dotp;
- } else {
- curwp->w_dotp = curwp->w_wrapline;
- curwp->w_doto = 0;
-
- /* insert trail */
- linsert_str(trail, tlen);
-
- /* delete trail */
- curwp->w_dotp = save_dotp;
- curwp->w_doto = col;
- ldelete(tlen, KNONE); /* don't store in kill ring */
- }
-
- /*
- * Readjust dot to point at where the user expects
- * it to be after an insertion.
- */
- curwp->w_doto = save_doto;
- if (curwp->w_doto >= col) {
- curwp->w_dotp = curwp->w_wrapline;
- curwp->w_doto -= col;
- }
- }
- }
- selfinsert(f, n);
- return (TRUE);
-}
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c
index 961690f2b02..9e54a18c834 100644
--- a/usr.bin/mg/main.c
+++ b/usr.bin/mg/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.59 2008/06/13 18:41:57 kjell Exp $ */
+/* $OpenBSD: main.c,v 1.60 2008/06/13 18:51:02 kjell Exp $ */
/* This file is in the public domain. */
@@ -75,14 +75,12 @@ main(int argc, char **argv)
{
extern void grep_init(void);
extern void theo_init(void);
- extern void mail_init(void);
extern void cmode_init(void);
extern void dired_init(void);
dired_init();
grep_init();
theo_init();
- mail_init();
cmode_init();
}