mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-06-03 04:29:35 +00:00
modified for inclusion in GNO base build
This commit is contained in:
parent
fbcef9625a
commit
e7015008c4
|
@ -1,24 +1,16 @@
|
||||||
#
|
#
|
||||||
# $Id: Makefile,v 1.1 1997/09/21 22:12:26 gdr Exp $
|
# $Id: Makefile,v 1.2 1997/10/30 03:49:46 gdr Exp $
|
||||||
#
|
#
|
||||||
include ../../../paths.mk
|
|
||||||
include ../../constants.mk
|
|
||||||
|
|
||||||
BUILD_TARGET = $(BUILD_DIR)/fmt
|
# Program name
|
||||||
CPPFLAGS += -I../../hdr
|
PROG = fmt
|
||||||
|
SRCS = fmt.c head.c
|
||||||
|
|
||||||
build: setup $(BUILD_TARGET)
|
# Add -D__STACK_CHECK__ to print, on exit, the amount of stack used
|
||||||
|
CFLAGS += -DBUILD_FMT -DNO_LOCALE
|
||||||
|
STACK = 1536
|
||||||
|
BINDIR = /usr/bin
|
||||||
|
|
||||||
$(BUILD_TARGET): $(OBJS)
|
.INCLUDE: /src/gno/prog.mk
|
||||||
$(CC) -o $@ $(LDFLAGS) $(OBJS) $(LDLIBS)
|
|
||||||
|
|
||||||
install:
|
head.o:: def.h extern.h
|
||||||
$(INSTALL) -m755 -d $(INSTROOT)/$(BUILD_DIR)/install
|
|
||||||
$(INSTALL) -m755 $(BUILD_TARGET) $(INSTROOT)/$(BUILD_DIR)/install
|
|
||||||
$(INSTALL) -m644 fmt.README $(INSTROOT)/$(BUILD_DIR)/install
|
|
||||||
|
|
||||||
clobber::
|
|
||||||
$(RM) -f *~
|
|
||||||
|
|
||||||
include ../../rules.mk
|
|
||||||
-include $(BUILD_DIR)/dependencies
|
|
||||||
|
|
|
@ -50,7 +50,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef BUILD_FMT
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define APPEND /* New mail goes to end of mailbox */
|
#define APPEND /* New mail goes to end of mailbox */
|
||||||
|
|
||||||
|
@ -102,6 +104,7 @@ struct message {
|
||||||
* The actual table is declared and initialized
|
* The actual table is declared and initialized
|
||||||
* in lex.c
|
* in lex.c
|
||||||
*/
|
*/
|
||||||
|
#ifndef BUILD_FMT
|
||||||
struct cmd {
|
struct cmd {
|
||||||
char *c_name; /* Name of command */
|
char *c_name; /* Name of command */
|
||||||
int (*c_func)(); /* Implementor of the command */
|
int (*c_func)(); /* Implementor of the command */
|
||||||
|
@ -109,6 +112,7 @@ struct cmd {
|
||||||
short c_msgflag; /* Required flags of messages */
|
short c_msgflag; /* Required flags of messages */
|
||||||
short c_msgmask; /* Relevant flags of messages */
|
short c_msgmask; /* Relevant flags of messages */
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Yechh, can't initialize unions */
|
/* Yechh, can't initialize unions */
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,6 @@
|
||||||
* @(#)extern.h 8.1 (Berkeley) 6/6/93
|
* @(#)extern.h 8.1 (Berkeley) 6/6/93
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __P
|
|
||||||
#ifdef __STDC__
|
|
||||||
#define __P(a) a
|
|
||||||
#else
|
|
||||||
#define __P(a) ()
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct name *cat __P((struct name *, struct name *));
|
struct name *cat __P((struct name *, struct name *));
|
||||||
struct name *delname __P((struct name *, char []));
|
struct name *delname __P((struct name *, char []));
|
||||||
struct name *elide __P((struct name *));
|
struct name *elide __P((struct name *));
|
||||||
|
@ -208,7 +200,10 @@ void regret __P((int));
|
||||||
void relsesigs __P((void));
|
void relsesigs __P((void));
|
||||||
int respond __P((int *));
|
int respond __P((int *));
|
||||||
int retfield __P((char *[]));
|
int retfield __P((char *[]));
|
||||||
|
#ifndef __GNO__
|
||||||
|
/* hmmm.. conflict through mutual namespace pollution */
|
||||||
int rexit __P((int));
|
int rexit __P((int));
|
||||||
|
#endif
|
||||||
int rm __P((char *));
|
int rm __P((char *));
|
||||||
int run_command __P((char *, int, int, int, char *, char *, char *));
|
int run_command __P((char *, int, int, int, char *, char *, char *));
|
||||||
int save __P((char []));
|
int save __P((char []));
|
||||||
|
|
|
@ -31,21 +31,18 @@
|
||||||
.\"
|
.\"
|
||||||
.\" @(#)fmt.1 8.1 (Berkeley) 6/6/93
|
.\" @(#)fmt.1 8.1 (Berkeley) 6/6/93
|
||||||
.\"
|
.\"
|
||||||
.\" $Id: fmt.1,v 1.2 1997/09/21 22:12:26 gdr Exp $
|
.\" $Id: fmt.1,v 1.3 1997/10/30 03:49:47 gdr Exp $
|
||||||
.\"
|
.\"
|
||||||
.TH FMT 1 "2 August 1997" "GNO" "Commands and Applications"
|
.TH FMT 1 "19 October 1997" "GNO" "Commands and Applications"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
fmt \- simple text formatter
|
fmt \- simple text formatter
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.BR fmt
|
.BR fmt
|
||||||
[
|
[
|
||||||
.B -o
|
|
||||||
.I goal
|
.I goal
|
||||||
[
|
[
|
||||||
.I maximum
|
.I maximum
|
||||||
]] [
|
]] [
|
||||||
.B -c
|
|
||||||
] [
|
|
||||||
.I "name ..."
|
.I "name ..."
|
||||||
]
|
]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
|
|
@ -31,9 +31,7 @@
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifndef __GNO__
|
||||||
#define lint
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
|
@ -45,43 +43,44 @@ static char copyright[] =
|
||||||
static char sccsid[] = "@(#)fmt.c 8.1 (Berkeley) 7/20/93";
|
static char sccsid[] = "@(#)fmt.c 8.1 (Berkeley) 7/20/93";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#endif /* ! __GNO__ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#ifndef NO_LOCALE
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* some architectures have a broken (and non-standard) realloc(3) */
|
||||||
#ifdef SUNOS4
|
#ifdef SUNOS4
|
||||||
#include "sunos4stdio.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __P
|
|
||||||
#ifdef __STDC__
|
|
||||||
#define __P(a) a
|
|
||||||
#else
|
|
||||||
#define __P(a) ()
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define REALLOC my_realloc
|
#define REALLOC my_realloc
|
||||||
|
static void * my_realloc __P((void *buf, size_t size));
|
||||||
|
#else
|
||||||
|
#define REALLOC realloc
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* reduce stack usage */
|
||||||
|
#ifdef __ORCAC__
|
||||||
|
#define STATIC static
|
||||||
|
#else
|
||||||
|
#define STATIC
|
||||||
|
#endif
|
||||||
|
|
||||||
static void fmt __P((FILE *fi));
|
static void fmt __P((FILE *fi));
|
||||||
static void prefix __P((char *line));
|
static void prefix __P((char *line));
|
||||||
static void split __P((char *line));
|
static void split __P((char *line));
|
||||||
static void setout __P((void));
|
static void setout __P((void));
|
||||||
static void pack __P((char *word, int wl));
|
static void pack __P((char *textword, int wl));
|
||||||
static void oflush __P((void));
|
static void oflush __P((void));
|
||||||
static void tabulate __P((char *line));
|
static void tabulate __P((char *line));
|
||||||
static void leadin __P((void));
|
static void leadin __P((void));
|
||||||
static int ispref __P((char *s1, char *s2));
|
static int ispref __P((char *s1, char *s2));
|
||||||
static void *my_realloc __P((void *buf, size_t size));
|
|
||||||
#if 0
|
|
||||||
static char *savestr __P((char *str));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern int ishead __P((char *));
|
extern int ishead __P((char *));
|
||||||
|
|
||||||
#if defined(SOLARIS) || defined(HALOS)
|
#if defined(SOLARIS) || defined(HALOS) || defined(__ORCAC__)
|
||||||
#define INDEX(s,c) strchr((s),(c))
|
#define INDEX(s,c) strchr((s),(c))
|
||||||
#else
|
#else
|
||||||
#define INDEX index
|
#define INDEX index
|
||||||
|
@ -112,6 +111,14 @@ int mark; /* Last place we saw a head line */
|
||||||
|
|
||||||
char *headnames[] = {"To", "Subject", "Cc", 0};
|
char *headnames[] = {"To", "Subject", "Cc", 0};
|
||||||
|
|
||||||
|
#ifdef __STACK_CHECK__
|
||||||
|
#include <gno/gno.h>
|
||||||
|
static void
|
||||||
|
printStack (void) {
|
||||||
|
printf("stack usage: %d bytes\n", _endStackCheck());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Drive the whole formatter by managing input files. Also,
|
* Drive the whole formatter by managing input files. Also,
|
||||||
* cause initialization of the output stuff and flush it out
|
* cause initialization of the output stuff and flush it out
|
||||||
|
@ -119,15 +126,20 @@ char *headnames[] = {"To", "Subject", "Cc", 0};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(int argc, char **argv)
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
register FILE *fi;
|
register FILE *fi;
|
||||||
register int errs = 0;
|
register int errs = 0;
|
||||||
int number; /* LIZ@UOM 6/18/85 */
|
int number; /* LIZ@UOM 6/18/85 */
|
||||||
|
|
||||||
|
#ifdef __STACK_CHECK__
|
||||||
|
_beginStackCheck();
|
||||||
|
atexit(printStack);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_LOCALE
|
||||||
(void) setlocale(LC_CTYPE, "");
|
(void) setlocale(LC_CTYPE, "");
|
||||||
|
#endif
|
||||||
|
|
||||||
goal_length = GOAL_LENGTH;
|
goal_length = GOAL_LENGTH;
|
||||||
max_length = MAX_LENGTH;
|
max_length = MAX_LENGTH;
|
||||||
|
@ -176,8 +188,7 @@ main(argc, argv)
|
||||||
* and sending each line down for analysis.
|
* and sending each line down for analysis.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
fmt(fi)
|
fmt(FILE *fi)
|
||||||
FILE *fi;
|
|
||||||
{
|
{
|
||||||
static char *linebuf = 0, *canonb = 0;
|
static char *linebuf = 0, *canonb = 0;
|
||||||
register char *cp, *cp2, cc;
|
register char *cp, *cp2, cc;
|
||||||
|
@ -289,8 +300,7 @@ fmt(fi)
|
||||||
* it on a line by itself.
|
* it on a line by itself.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
prefix(line)
|
prefix(char *line)
|
||||||
char line[];
|
|
||||||
{
|
{
|
||||||
register char *cp, **hp;
|
register char *cp, **hp;
|
||||||
register int np, h;
|
register int np, h;
|
||||||
|
@ -337,20 +347,19 @@ prefix(line)
|
||||||
* line packer.
|
* line packer.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
split(line)
|
split(char *line)
|
||||||
char line[];
|
|
||||||
{
|
{
|
||||||
register char *cp, *cp2;
|
register char *cp, *cp2;
|
||||||
char word[BUFSIZ];
|
STATIC char textword[BUFSIZ];
|
||||||
int wordl; /* LIZ@UOM 6/18/85 */
|
int wordl; /* LIZ@UOM 6/18/85 */
|
||||||
|
|
||||||
cp = line;
|
cp = line;
|
||||||
while (*cp) {
|
while (*cp) {
|
||||||
cp2 = word;
|
cp2 = textword;
|
||||||
wordl = 0; /* LIZ@UOM 6/18/85 */
|
wordl = 0; /* LIZ@UOM 6/18/85 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Collect a 'word,' allowing it to contain escaped white
|
* Collect a 'textword,' allowing it to contain escaped white
|
||||||
* space.
|
* space.
|
||||||
*/
|
*/
|
||||||
while (*cp && *cp != ' ') {
|
while (*cp && *cp != ' ') {
|
||||||
|
@ -373,9 +382,9 @@ split(line)
|
||||||
*cp2++ = *cp++;
|
*cp2++ = *cp++;
|
||||||
*cp2 = '\0';
|
*cp2 = '\0';
|
||||||
/*
|
/*
|
||||||
* LIZ@UOM 6/18/85 pack(word);
|
* LIZ@UOM 6/18/85 pack(textword);
|
||||||
*/
|
*/
|
||||||
pack(word, wordl);
|
pack(textword, wordl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,35 +404,33 @@ char *outp; /* Pointer in above */
|
||||||
* Initialize the output section.
|
* Initialize the output section.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
setout()
|
setout(void)
|
||||||
{
|
{
|
||||||
outp = NOSTR;
|
outp = NOSTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pack a word onto the output line. If this is the beginning of
|
* Pack a textword onto the output line. If this is the beginning of
|
||||||
* the line, push on the appropriately-sized string of blanks first.
|
* the line, push on the appropriately-sized string of blanks first.
|
||||||
* If the word won't fit on the current line, flush and begin a new
|
* If the textword won't fit on the current line, flush and begin a new
|
||||||
* line. If the word is too long to fit all by itself on a line,
|
* line. If the textword is too long to fit all by itself on a line,
|
||||||
* just give it its own and hope for the best.
|
* just give it its own and hope for the best.
|
||||||
*
|
*
|
||||||
* LIZ@UOM 6/18/85 -- If the new word will fit in at less than the
|
* LIZ@UOM 6/18/85 -- If the new textword will fit in at less than the
|
||||||
* goal length, take it. If not, then check to see if the line
|
* goal length, take it. If not, then check to see if the line
|
||||||
* will be over the max length; if so put the word on the next
|
* will be over the max length; if so put the textword on the next
|
||||||
* line. If not, check to see if the line will be closer to the
|
* line. If not, check to see if the line will be closer to the
|
||||||
* goal length with or without the word and take it or put it on
|
* goal length with or without the textword and take it or put it on
|
||||||
* the next line accordingly.
|
* the next line accordingly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LIZ@UOM 6/18/85 -- pass in the length of the word as well
|
* LIZ@UOM 6/18/85 -- pass in the length of the textword as well
|
||||||
* pack(word)
|
* pack(textword)
|
||||||
* char word[];
|
* char textword[];
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
pack(word,wl)
|
pack(char *textword, int wl)
|
||||||
char word[];
|
|
||||||
int wl;
|
|
||||||
{
|
{
|
||||||
register char *cp;
|
register char *cp;
|
||||||
register int s, t;
|
register int s, t;
|
||||||
|
@ -432,9 +439,9 @@ pack(word,wl)
|
||||||
leadin();
|
leadin();
|
||||||
/*
|
/*
|
||||||
* LIZ@UOM 6/18/85 -- change condition to check goal_length; s is the
|
* LIZ@UOM 6/18/85 -- change condition to check goal_length; s is the
|
||||||
* length of the line before the word is added; t is now the length
|
* length of the line before the textword is added; t is now the length
|
||||||
* of the line after the word is added
|
* of the line after the textword is added
|
||||||
* t = strlen(word);
|
* t = strlen(textword);
|
||||||
* if (t+s <= LENGTH)
|
* if (t+s <= LENGTH)
|
||||||
*/
|
*/
|
||||||
s = outp - outbuf;
|
s = outp - outbuf;
|
||||||
|
@ -444,14 +451,14 @@ pack(word,wl)
|
||||||
/*
|
/*
|
||||||
* In like flint!
|
* In like flint!
|
||||||
*/
|
*/
|
||||||
for (cp = word; *cp; *outp++ = *cp++);
|
for (cp = textword; *cp; *outp++ = *cp++);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (s > pfx) {
|
if (s > pfx) {
|
||||||
oflush();
|
oflush();
|
||||||
leadin();
|
leadin();
|
||||||
}
|
}
|
||||||
for (cp = word; *cp; *outp++ = *cp++);
|
for (cp = textword; *cp; *outp++ = *cp++);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -460,7 +467,7 @@ pack(word,wl)
|
||||||
* line prefix.
|
* line prefix.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
oflush()
|
oflush(void)
|
||||||
{
|
{
|
||||||
if (outp == NOSTR)
|
if (outp == NOSTR)
|
||||||
return;
|
return;
|
||||||
|
@ -474,8 +481,7 @@ oflush()
|
||||||
* output on standard output (finally).
|
* output on standard output (finally).
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
tabulate(line)
|
tabulate(char *line)
|
||||||
char line[];
|
|
||||||
{
|
{
|
||||||
register char *cp;
|
register char *cp;
|
||||||
register int b, t;
|
register int b, t;
|
||||||
|
@ -514,7 +520,7 @@ tabulate(line)
|
||||||
* leading blanks.
|
* leading blanks.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
leadin()
|
leadin(void)
|
||||||
{
|
{
|
||||||
register int b;
|
register int b;
|
||||||
register char *cp;
|
register char *cp;
|
||||||
|
@ -530,9 +536,10 @@ leadin()
|
||||||
* This little goodie is needed for
|
* This little goodie is needed for
|
||||||
* a headline detector in head.c
|
* a headline detector in head.c
|
||||||
*/
|
*/
|
||||||
|
static char *savestr __P((char *str));
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
savestr(str)
|
savestr(char *str)
|
||||||
char str[];
|
|
||||||
{
|
{
|
||||||
register char *top;
|
register char *top;
|
||||||
|
|
||||||
|
@ -550,8 +557,7 @@ savestr(str)
|
||||||
* Is s1 a prefix of s2??
|
* Is s1 a prefix of s2??
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ispref(s1, s2)
|
ispref(register char *s1, register char *s2)
|
||||||
register char *s1, *s2;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
while (*s1++ == *s2)
|
while (*s1++ == *s2)
|
||||||
|
@ -560,6 +566,7 @@ ispref(s1, s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __ORCAC__
|
||||||
/*
|
/*
|
||||||
* some architectures' reallocs are too damned stupid to accept NULL
|
* some architectures' reallocs are too damned stupid to accept NULL
|
||||||
* buf arguments ...
|
* buf arguments ...
|
||||||
|
@ -574,3 +581,4 @@ my_realloc (void *buf, size_t size)
|
||||||
return (void *) realloc(buf, size);
|
return (void *) realloc(buf, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
9
usr.bin/fmt/fmt.desc
Normal file
9
usr.bin/fmt/fmt.desc
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Name: fmt
|
||||||
|
Version: 1.0 (19 Oct 97)
|
||||||
|
Shell: GNO
|
||||||
|
Author: Ported by Devin Reade.
|
||||||
|
Contact: gdr@eddore.myrias.com
|
||||||
|
Where: /usr/bin
|
||||||
|
FTP: ground.isca.uiowa.edu apple2.caltech.edu trenco.myrias.com
|
||||||
|
|
||||||
|
Simple text formatter.
|
17
usr.bin/fmt/fmt.rez
Normal file
17
usr.bin/fmt/fmt.rez
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
* $Id: fmt.rez,v 1.1 1997/10/30 03:49:47 gdr Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Types.Rez"
|
||||||
|
|
||||||
|
resource rVersion (0x1, purgeable3, nocrossbank) {
|
||||||
|
|
||||||
|
{ 1, 0, 0, /* version 1.0.0 */
|
||||||
|
release, /* development|alpha|beta|final|release */
|
||||||
|
0 /* non-final release number */
|
||||||
|
},
|
||||||
|
verUS,
|
||||||
|
"fmt",
|
||||||
|
"Simple text formatter\n"
|
||||||
|
"Ported by Devin Reade for GNO v2.0.6"
|
||||||
|
};
|
|
@ -35,11 +35,22 @@
|
||||||
#define lint
|
#define lint
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef lint
|
#if !defined(lint) && !defined(__GNO__)
|
||||||
static char sccsid[] = "@(#)head.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)head.c 8.1 (Berkeley) 6/6/93";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "rcv.h"
|
/* save some stack space */
|
||||||
|
#ifdef __ORCAC__
|
||||||
|
#define STATIC static
|
||||||
|
#else
|
||||||
|
#define STATIC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CHECK_RECURSION
|
||||||
|
#include <assert.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "def.h"
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -54,36 +65,50 @@ static char sccsid[] = "@(#)head.c 8.1 (Berkeley) 6/6/93";
|
||||||
* accomodate all funny formats.
|
* accomodate all funny formats.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ishead(linebuf)
|
ishead(char linebuf[])
|
||||||
char linebuf[];
|
|
||||||
{
|
{
|
||||||
register char *cp;
|
register char *cp;
|
||||||
struct headline hl;
|
struct headline hl;
|
||||||
char parbuf[BUFSIZ];
|
STATIC char parbuf[BUFSIZ];
|
||||||
|
#ifdef CHECK_RECURSION
|
||||||
|
static int recursing = 0;
|
||||||
|
|
||||||
|
assert(recursing == 0);
|
||||||
|
recursing++;
|
||||||
|
#define RETURN(val) { recursing--; return val; }
|
||||||
|
#else
|
||||||
|
#define RETURN(val) return (val)
|
||||||
|
#endif
|
||||||
|
|
||||||
cp = linebuf;
|
cp = linebuf;
|
||||||
if (*cp++ != 'F' || *cp++ != 'r' || *cp++ != 'o' || *cp++ != 'm' ||
|
if (*cp++ != 'F' || *cp++ != 'r' || *cp++ != 'o' || *cp++ != 'm' ||
|
||||||
*cp++ != ' ')
|
*cp++ != ' ')
|
||||||
return (0);
|
RETURN (0);
|
||||||
parse(linebuf, &hl, parbuf);
|
parse(linebuf, &hl, parbuf);
|
||||||
if (hl.l_from == NOSTR || hl.l_date == NOSTR) {
|
if (hl.l_from == NOSTR || hl.l_date == NOSTR) {
|
||||||
|
#ifndef BUILD_FMT
|
||||||
fail(linebuf, "No from or date field");
|
fail(linebuf, "No from or date field");
|
||||||
return (0);
|
#endif
|
||||||
|
RETURN (0);
|
||||||
}
|
}
|
||||||
if (!isdate(hl.l_date)) {
|
if (!isdate(hl.l_date)) {
|
||||||
|
#ifndef BUILD_FMT
|
||||||
fail(linebuf, "Date field not legal date");
|
fail(linebuf, "Date field not legal date");
|
||||||
return (0);
|
#endif
|
||||||
|
RETURN (0);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* I guess we got it!
|
* I guess we got it!
|
||||||
*/
|
*/
|
||||||
return (1);
|
RETURN (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef RETURN
|
||||||
|
|
||||||
|
#ifndef BUILD_FMT
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
void
|
void
|
||||||
fail(linebuf, reason)
|
fail(char *linebuf, char *reason)
|
||||||
char linebuf[], reason[];
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -92,6 +117,7 @@ fail(linebuf, reason)
|
||||||
fprintf(stderr, "\"%s\"\nnot a header because %s\n", linebuf, reason);
|
fprintf(stderr, "\"%s\"\nnot a header because %s\n", linebuf, reason);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Split a headline into its useful components.
|
* Split a headline into its useful components.
|
||||||
|
@ -100,13 +126,17 @@ fail(linebuf, reason)
|
||||||
* structure. Actually, it scans.
|
* structure. Actually, it scans.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
parse(line, hl, pbuf)
|
parse(char line[], register struct headline *hl, char pbuf[])
|
||||||
char line[], pbuf[];
|
|
||||||
register struct headline *hl;
|
|
||||||
{
|
{
|
||||||
register char *cp;
|
register char *cp;
|
||||||
char *sp;
|
char *sp;
|
||||||
char word[LINESIZE];
|
STATIC char word[LINESIZE];
|
||||||
|
#ifdef CHECK_RECURSION
|
||||||
|
static int recursing = 0;
|
||||||
|
|
||||||
|
assert(recursing == 0);
|
||||||
|
recursing++;
|
||||||
|
#endif
|
||||||
|
|
||||||
hl->l_from = NOSTR;
|
hl->l_from = NOSTR;
|
||||||
hl->l_tty = NOSTR;
|
hl->l_tty = NOSTR;
|
||||||
|
@ -126,6 +156,9 @@ parse(line, hl, pbuf)
|
||||||
}
|
}
|
||||||
if (cp != NOSTR)
|
if (cp != NOSTR)
|
||||||
hl->l_date = copyin(cp, &sp);
|
hl->l_date = copyin(cp, &sp);
|
||||||
|
#ifdef CHECK_RECURSION
|
||||||
|
recursing--;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -135,9 +168,7 @@ parse(line, hl, pbuf)
|
||||||
* the left string into it.
|
* the left string into it.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
copyin(src, space)
|
copyin(register char *src, char **space)
|
||||||
register char *src;
|
|
||||||
char **space;
|
|
||||||
{
|
{
|
||||||
register char *cp;
|
register char *cp;
|
||||||
char *top;
|
char *top;
|
||||||
|
@ -170,10 +201,8 @@ char ctype[] = "Aaa Aaa O0 00:00:00 0000";
|
||||||
char tmztype[] = "Aaa Aaa O0 00:00:00 AAA 0000";
|
char tmztype[] = "Aaa Aaa O0 00:00:00 AAA 0000";
|
||||||
|
|
||||||
int
|
int
|
||||||
isdate(date)
|
isdate(char date[])
|
||||||
char date[];
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return cmatch(date, ctype) || cmatch(date, tmztype);
|
return cmatch(date, ctype) || cmatch(date, tmztype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,8 +211,7 @@ isdate(date)
|
||||||
* Return 1 if they match, 0 if they don't
|
* Return 1 if they match, 0 if they don't
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cmatch(cp, tp)
|
cmatch(register char *cp, register char *tp)
|
||||||
register char *cp, *tp;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
while (*cp && *tp)
|
while (*cp && *tp)
|
||||||
|
@ -229,8 +257,7 @@ cmatch(cp, tp)
|
||||||
* or NOSTR if none follow.
|
* or NOSTR if none follow.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
nextword(wp, wbuf)
|
nextword(register char *wp, register char *wbuf)
|
||||||
register char *wp, *wbuf;
|
|
||||||
{
|
{
|
||||||
register c;
|
register c;
|
||||||
|
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 1989, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* @(#)pathnames.h 8.1 (Berkeley) 6/6/93
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* #include <paths.h> */
|
|
||||||
|
|
||||||
#define _PATH_EX "/usr/bin/ex"
|
|
||||||
#define _PATH_HELP "/usr/share/misc/mail.help"
|
|
||||||
#define _PATH_TILDE "/usr/share/misc/mail.tildehelp"
|
|
||||||
#define _PATH_MASTER_RC "/etc/mail.rc"
|
|
||||||
#define _PATH_MORE "/usr/bin/more"
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 1980, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* @(#)rcv.h 8.1 (Berkeley) 6/6/93
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Mail -- a mail program
|
|
||||||
*
|
|
||||||
* This file is included by normal files which want both
|
|
||||||
* globals and declarations.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "def.h"
|
|
||||||
#ifndef SUNOS4
|
|
||||||
#include "glob.h"
|
|
||||||
#endif
|
|
14
usr.bin/fmt/tests/in1
Normal file
14
usr.bin/fmt/tests/in1
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
now is the
|
||||||
|
time
|
||||||
|
to fribble in the glotz
|
||||||
|
|
||||||
|
And this would be a new paragraph. One that is slightly longer
|
||||||
|
and therefore should be gauranteed to wrap over on to at least a
|
||||||
|
few lines. Rickem, rackem, ruckem, get that ball and really fight!
|
||||||
|
|
||||||
|
This one is a final paragraph that *should* broken up.
|
||||||
|
This line should be indented eight characters.
|
||||||
|
This line should be attached to the previous one.
|
||||||
|
This line should also be indented eight characters.
|
||||||
|
This line should be a carry-over from the last but should only be
|
||||||
|
indented four characters.
|
Loading…
Reference in New Issue
Block a user