summaryrefslogtreecommitdiff
path: root/usr/src/cmd/fmt
diff options
context:
space:
mode:
authorceastha <none@none>2005-08-18 15:40:59 -0700
committerceastha <none@none>2005-08-18 15:40:59 -0700
commitb7d62af5b42f0da2eb668e8d33d24d2f4fdd98a8 (patch)
tree365a354cfe8236488955cf206e4f43644ca03ea0 /usr/src/cmd/fmt
parentd6555420322a42c16b93414c29a62f8e841abc7b (diff)
downloadillumos-joyent-b7d62af5b42f0da2eb668e8d33d24d2f4fdd98a8.tar.gz
6268906 ucbcmd/plot and gcc don't get along
6271073 gcc and cmd/fmt don't get along 6271996 gcc and cmd/mail don't get along 6272084 gcc and cmd/pax don't get along 6273914 gcc and cmd/tar don't get along --HG-- rename : usr/src/cmd/fmt/head.c => deleted_files/usr/src/cmd/fmt/head.c rename : usr/src/cmd/mail/maid.c => deleted_files/usr/src/cmd/mail/maid.c
Diffstat (limited to 'usr/src/cmd/fmt')
-rw-r--r--usr/src/cmd/fmt/fmt.c93
-rw-r--r--usr/src/cmd/fmt/head.c324
-rwxr-xr-xusr/src/cmd/fmt/inc.flg30
3 files changed, 85 insertions, 362 deletions
diff --git a/usr/src/cmd/fmt/fmt.c b/usr/src/cmd/fmt/fmt.c
index 28e035a258..816b8a3f89 100644
--- a/usr/src/cmd/fmt/fmt.c
+++ b/usr/src/cmd/fmt/fmt.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -47,7 +47,7 @@
* Author: Kurt Shoens (UCB) 12/7/78
*/
-#define NOSTR ((wchar_t *) 0) /* Null string pointer for lint */
+#define NOSTR ((wchar_t *)0) /* Null string pointer for lint */
#define MAXLINES 100 /* maximum mail header lines to verify */
wchar_t outbuf[BUFSIZ]; /* Sandbagged output line image */
@@ -85,12 +85,25 @@ enum hdr_type hdr_state = not_in_hdr;
wchar_t *hdrbuf[MAXLINES]; /* buffer to hold potential mail header lines */
int h_lines; /* index into lines of hdrbuf */
-int (*(split))();
+void (*(split))(wchar_t []);
extern int scrwidth(wchar_t);
+extern int ishead(char []);
-static void fill_hdrbuf(wchar_t line[]);
+
+static void fill_hdrbuf(wchar_t []);
static void header_chk(void);
static void process_hdrbuf(void);
+static void leadin(void);
+static void tabulate(wchar_t []);
+static void oflush(void);
+static void pack(wchar_t []);
+static void msplit(wchar_t []);
+static void csplit(wchar_t []);
+static void _wckind_init(void);
+static void prefix(wchar_t []);
+static void fmt(FILE *);
+static int setopt(char *);
+int _wckind(wchar_t);
/*
* Drive the whole formatter by managing input files. Also,
@@ -98,15 +111,14 @@ static void process_hdrbuf(void);
* at the end.
*/
+int
main(int argc, char **argv)
{
- register FILE *fi;
+ FILE *fi;
char sobuf[BUFSIZ];
- register char *cp;
+ char *cp;
int nofile;
char *locale;
- int csplit(), msplit();
- void _wckind_init();
outp = NOSTR;
setbuf(stdout, sobuf);
@@ -116,7 +128,7 @@ main(int argc, char **argv)
split = csplit;
} else {
split = msplit;
- (void) _wckind_init();
+ _wckind_init();
}
if (argc < 2) {
single:
@@ -141,8 +153,7 @@ single:
if (nofile)
goto single;
oflush();
- exit(errs);
- /* NOTREACHED */
+ return (errs);
}
/*
@@ -151,11 +162,12 @@ single:
* and sending each line down for analysis.
*/
+static void
fmt(FILE *fi)
{
wchar_t linebuf[BUFSIZ], canonb[BUFSIZ];
- register wchar_t *cp, *cp2;
- register int col;
+ wchar_t *cp, *cp2;
+ int col;
wchar_t c;
char cbuf[BUFSIZ]; /* stores wchar_t string as char string */
@@ -282,11 +294,11 @@ fmt(FILE *fi)
* it on a line by itself.
*/
+static void
prefix(wchar_t line[])
{
- register wchar_t *cp;
- register int np;
- register int i;
+ wchar_t *cp;
+ int np;
int nosplit = 0; /* flag set if line should not be split */
if (line[0] == L'\0') {
@@ -368,9 +380,10 @@ prefix(wchar_t line[])
* line packer.
*/
+static void
csplit(wchar_t line[])
{
- register wchar_t *cp, *cp2;
+ wchar_t *cp, *cp2;
wchar_t word[BUFSIZ];
static const wchar_t *srchlist = (const wchar_t *) L".:!?";
@@ -406,9 +419,10 @@ csplit(wchar_t line[])
}
}
+static void
msplit(wchar_t line[])
{
- register wchar_t *cp, *cp2, prev;
+ wchar_t *cp, *cp2, prev;
wchar_t word[BUFSIZ];
static const wchar_t *srchlist = (const wchar_t *) L".:!?";
@@ -469,10 +483,11 @@ msplit(wchar_t line[])
* just give it its own and hope for the best.
*/
+static void
pack(wchar_t word[])
{
- register wchar_t *cp;
- register int s, t;
+ wchar_t *cp;
+ int s, t;
if (outp == NOSTR)
leadin();
@@ -496,6 +511,7 @@ pack(wchar_t word[])
* line prefix.
*/
+static void
oflush(void)
{
if (outp == NOSTR)
@@ -510,10 +526,11 @@ oflush(void)
* output on standard output (finally).
*/
+static void
tabulate(wchar_t line[])
{
- register wchar_t *cp, *cp2;
- register int b, t;
+ wchar_t *cp;
+ int b, t;
/* Toss trailing blanks in the output line */
@@ -544,11 +561,12 @@ tabulate(wchar_t line[])
* leading blanks.
*/
-leadin()
+static void
+leadin(void)
{
- register int b;
- register wchar_t *cp;
- register int l;
+ int b;
+ wchar_t *cp;
+ int l;
switch (crown_state) {
case c_head:
@@ -580,6 +598,7 @@ leadin()
* Is s1 a prefix of s2??
*/
+static int
ispref(wchar_t *s1, wchar_t *s2)
{
@@ -593,8 +612,8 @@ ispref(wchar_t *s1, wchar_t *s2)
* Set an input option
*/
-setopt(cp)
- register char *cp;
+static int
+setopt(char *cp)
{
static int ws = 0;
@@ -628,14 +647,14 @@ setopt(cp)
#define LIB_WDRESOLVE "/usr/lib/locale/%s/LC_CTYPE/wdresolve.so"
#define WCHKIND "_wdchkind_"
-static int _wckind_c_locale();
+static int _wckind_c_locale(wchar_t);
-static int (*__wckind)() = _wckind_c_locale;
+static int (*__wckind)(wchar_t) = _wckind_c_locale;
static void *dlhandle = NULL;
-void
-_wckind_init()
+static void
+_wckind_init(void)
{
char *locale;
char path[MAXPATHLEN + 1];
@@ -653,7 +672,7 @@ _wckind_init()
(void) sprintf(path, LIB_WDRESOLVE, locale);
if ((dlhandle = dlopen(path, RTLD_LAZY)) != NULL) {
- __wckind = (int (*)(int))dlsym(dlhandle, WCHKIND);
+ __wckind = (int (*)(wchar_t))dlsym(dlhandle, WCHKIND);
if (__wckind != NULL)
return;
(void) dlclose(dlhandle);
@@ -666,16 +685,14 @@ c_locale:
int
-_wckind(wc)
-wchar_t wc;
+_wckind(wchar_t wc)
{
return (*__wckind) (wc);
}
static int
-_wckind_c_locale(wc)
-wchar_t wc;
+_wckind_c_locale(wchar_t wc)
{
int ret;
@@ -732,7 +749,7 @@ header_chk(void)
for (l = 0; l < h_lines; l++) {
/* skip initial blanks */
for (cp = hdrbuf[l]; *cp == L' '; cp++);
- for (hp = &headnames[0]; *hp != (wchar_t *) 0; hp++)
+ for (hp = &headnames[0]; *hp != (wchar_t *)0; hp++)
if (ispref(*hp, cp)) {
hdrcount++;
break;
diff --git a/usr/src/cmd/fmt/head.c b/usr/src/cmd/fmt/head.c
deleted file mode 100644
index 12f44beac0..0000000000
--- a/usr/src/cmd/fmt/head.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
-/*
- * University Copyright- Copyright (c) 1982, 1986, 1988
- * The Regents of the University of California
- * All Rights Reserved
- *
- * University Acknowledgment- Portions of this document are derived from
- * software developed by the University of California, Berkeley, and its
- * contributors.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "rcv.h"
-
-/*
- * mailx -- a modified version of a University of California at Berkeley
- * mail program
- *
- * Routines for processing and detecting headlines.
- */
-
-/*
- * See if the passed line buffer is a mail header.
- * Return true if yes. Note the extreme pains to
- * accomodate all funny formats.
- */
-
-extern int debug;
-
-ishead(linebuf)
- char linebuf[];
-{
- register char *cp;
- struct headline hl;
- char parbuf[BUFSIZ];
-
- cp = linebuf;
- if (strncmp("From ", cp, 5) != 0)
- return(0);
- parse(cp, &hl, parbuf);
- if (hl.l_from == NOSTR || hl.l_date == NOSTR) {
- fail(linebuf, "No from or date field");
- return(0);
- }
-#ifdef notdef
- /*
- * Seems to be no reason to be so fussy.
- */
- if (!Tflag && !isdate(hl.l_date)) {
- fail(linebuf, "Date field not legal date");
- return(0);
- }
-#endif
-
- /*
- * I guess we got it!
- */
-
- return(1);
-}
-
-fail(linebuf, reason)
- char linebuf[], reason[];
-{
-
- if (debug)
- (void)fprintf(stderr, "\"%s\"\nnot a header because %s\n", linebuf, reason);
-}
-
-/*
- * Split a headline into its useful components.
- * Copy the line into dynamic string space, then set
- * pointers into the copied line in the passed headline
- * structure. Actually, it scans.
- */
-
-parse(line, hl, pbuf)
- char line[], pbuf[];
- struct headline *hl;
-{
- register char *cp, *dp;
- char *sp;
- char word[LINESIZE];
-
- hl->l_from = NOSTR;
- hl->l_tty = NOSTR;
- hl->l_date = NOSTR;
- cp = line;
- sp = pbuf;
-
- /*
- * Skip the first "word" of the line, which should be "From"
- * anyway.
- */
-
- cp = nextword(cp, word);
- dp = nextword(cp, word);
- if (dp == NOSTR)
- return;
- if (!equal(word, ""))
- hl->l_from = copyin(word, &sp);
- if (strncmp(dp, "tty", 3) == 0) {
- cp = nextword(dp, word);
- hl->l_tty = copyin(word, &sp);
- if (cp != NOSTR)
- hl->l_date = copyin(cp, &sp);
- }
- else
- if (dp != NOSTR)
- hl->l_date = copyin(dp, &sp);
-}
-
-/*
- * Copy the string on the left into the string on the right
- * and bump the right (reference) string pointer by the length.
- * Thus, dynamically allocate space in the right string, copying
- * the left string into it.
- */
-
-char *
-copyin(src, space)
- char src[];
- char **space;
-{
- register char *cp, *top;
- register int s;
-
- s = strlen(src);
- cp = *space;
- top = cp;
- (void)strcpy(cp, src);
- cp += s + 1;
- *space = cp;
- return(top);
-}
-
-#ifdef notdef
-/*
- * Test to see if the passed string is a ctime(3) generated
- * date string as documented in the manual. The template
- * below is used as the criterion of correctness.
- * Also, we check for a possible trailing time zone using
- * the auxtype template.
- */
-
-#define L 1 /* A lower case char */
-#define S 2 /* A space */
-#define D 3 /* A digit */
-#define O 4 /* An optional digit or space */
-#define C 5 /* A colon */
-#define N 6 /* A new line */
-#define U 7 /* An upper case char */
-
-char ctypes[] = {U,L,L,S,U,L,L,S,O,D,S,D,D,C,D,D,C,D,D,S,D,D,D,D,0};
-char tmztypes[] = {U,L,L,S,U,L,L,S,O,D,S,D,D,C,D,D,C,D,D,S,U,U,U,S,D,D,D,D,0};
-
-isdate(date)
- char date[];
-{
- register char *cp;
-
- cp = date;
- if (cmatch(cp, ctypes))
- return(1);
- return(cmatch(cp, tmztypes));
-}
-
-/*
- * Match the given string against the given template.
- * Return 1 if they match, 0 if they don't
- */
-
-cmatch(str, temp)
- char str[], temp[];
-{
- register char *cp, *tp;
- register int c;
-
- cp = str;
- tp = temp;
- while (*cp != '\0' && *tp != 0) {
- c = *cp++;
- switch (*tp++) {
- case L:
- if (c < 'a' || c > 'z')
- return(0);
- break;
-
- case U:
- if (c < 'A' || c > 'Z')
- return(0);
- break;
-
- case S:
- if (c != ' ')
- return(0);
- break;
-
- case D:
- if (!isdigit(c))
- return(0);
- break;
-
- case O:
- if (c != ' ' && !isdigit(c))
- return(0);
- break;
-
- case C:
- if (c != ':')
- return(0);
- break;
-
- case N:
- if (c != '\n')
- return(0);
- break;
- }
- }
- if (*cp != '\0' || *tp != 0)
- return(0);
- return(1);
-}
-#endif
-
-/*
- * Collect a liberal (space, tab delimited) word into the word buffer
- * passed. Also, return a pointer to the next word following that,
- * or NOSTR if none follow.
- */
-
-char *
-nextword(wp, wbuf)
- char wp[], wbuf[];
-{
- register char *cp, *cp2;
-
- if ((cp = wp) == NOSTR) {
- (void)copy("", wbuf);
- return(NOSTR);
- }
- cp2 = wbuf;
- while (!any(*cp, " \t") && *cp != '\0')
- if (*cp == '"') {
- *cp2++ = *cp++;
- while (*cp != '\0' && *cp != '"')
- *cp2++ = *cp++;
- if (*cp == '"')
- *cp2++ = *cp++;
- } else
- *cp2++ = *cp++;
- *cp2 = '\0';
- while (any(*cp, " \t"))
- cp++;
- if (*cp == '\0')
- return(NOSTR);
- return(cp);
-}
-
-/*
- * Copy str1 to str2, return pointer to null in str2.
- */
-
-char *
-copy(str1, str2)
- char *str1, *str2;
-{
- register char *s1, *s2;
-
- s1 = str1;
- s2 = str2;
- while (*s1)
- *s2++ = *s1++;
- *s2 = 0;
- return(s2);
-}
-
-/*
- * Is ch any of the characters in str?
- */
-
-any(ch, str)
- char *str;
-{
- register char *f;
- register c;
-
- f = str;
- c = ch;
- while (*f)
- if (c == *f++)
- return(1);
- return(0);
-}
-
diff --git a/usr/src/cmd/fmt/inc.flg b/usr/src/cmd/fmt/inc.flg
new file mode 100755
index 0000000000..c223ee0e7e
--- /dev/null
+++ b/usr/src/cmd/fmt/inc.flg
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+
+#ident "%Z%%M% %I% %E% SMI"
+
+echo_file usr/src/cmd/mailx/Makefile
+echo_file usr/src/cmd/mailx/head.c
+find_files "*.h" usr/src/cmd/mailx/hdr