Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Mar 2002 19:09:32 +1100 (EST)
From:      "Tim J. Robbins" <tim@robbins.dropbear.id.au>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   standards/36130: P1003.2 asa utility is missing
Message-ID:  <200203200809.g2K89W605096@descent.robbins.dropbear.id.au>

next in thread | raw e-mail | index | archive | help

>Number:         36130
>Category:       standards
>Synopsis:       P1003.2 asa utility is missing
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 20 01:00:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Tim J. Robbins
>Release:        FreeBSD 4.5-STABLE i386
>Organization:
>Environment:
System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #8: Tue Mar 19 08:46:39 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386


	
>Description:
FreeBSD is missing the POSIX.2 (1992) asa utility.
>How-To-Repeat:
a.out | asa
>Fix:

This is a modified version of NetBSD's asa(1) utility. I've made the
following changes:
 * $FreeBSD$, __FBSDID etc.
 * Remove prototype for main()
 * Remove __P
 * Use getopt so "asa -- foo" works, and add usage() function
 * Correct exit status
 * style(9) fixes. Most notably, space between function name and parenthesis.
(if you're interested: http://www.wiretapped.net/~fyre/freebsd/asa.diff)

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	Makefile
#	asa.c
#	asa.1
#
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
X#	$NetBSD: Makefile,v 1.2 1995/03/25 18:04:51 glass Exp $
X# $FreeBSD$
X
XPROG=	asa
X
X.include <bsd.prog.mk>
END-of-Makefile
echo x - asa.c
sed 's/^X//' >asa.c << 'END-of-asa.c'
X/*
X * Copyright (c) 1993,94 Winning Strategies, Inc.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *      This product includes software developed by Winning Strategies, Inc.
X * 4. The name of the author may not be used to endorse or promote products
X *    derived from this software without specific prior written permission
X *
X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
X */
X
X#include <sys/cdefs.h>
X__FBSDID("$FreeBSD$");
X__RCSID("$NetBSD: asa.c,v 1.11 1997/09/20 14:55:00 lukem Exp $");
X
X#include <err.h>
X#include <stdio.h>
X#include <stdlib.h>
X#include <unistd.h>
X
Xstatic void asa(FILE *);
Xstatic void usage(void);
X
Xint
Xmain(int argc, char *argv[])
X{
X	FILE *fp;
X	const char *fn;
X	int ch, exval;
X
X	while ((ch = getopt(argc, argv, "")) != -1) {
X		switch (ch) {
X		case '?':
X		default:
X			usage();
X			/*NOTREACHED*/
X		}
X	}
X	argc -= optind;
X	argv += optind;
X
X	exval = 0;
X	if (argc == 0)
X		asa(stdin);
X	else {
X		while ((fn = *argv++) != NULL) {
X                        if ((fp = fopen(fn, "r")) == NULL) {
X				warn("%s", fn);
X				exval = 1;
X				continue;
X                        }
X			asa(fp);
X			fclose(fp);
X		}
X	}
X
X	return (exval);
X}
X
Xstatic void
Xusage(void)
X{
X	fprintf(stderr, "usage: asa [file...]\n");
X	exit(1);
X}
X
Xstatic void
Xasa(FILE *f)
X{
X	char *buf;
X	size_t len;
X
X	if ((buf = fgetln(f, &len)) != NULL) {
X		if (buf[len - 1] == '\n')
X			buf[--len] = '\0';
X		/* special case the first line  */
X		switch (buf[0]) {
X		case '0':
X			putchar('\n');
X			break;
X		case '1':
X			putchar('\f');
X			break;
X		}
X
X		if (len > 1 && buf[0] && buf[1])
X			printf("%.*s", (int)(len - 1), buf + 1);
X
X		while ((buf = fgetln(f, &len)) != NULL) {
X			if (buf[len - 1] == '\n')
X				buf[--len] = '\0';
X			switch (buf[0]) {
X			default:
X			case ' ':
X				putchar('\n');
X				break;
X			case '0':
X				putchar('\n');
X				putchar('\n');
X				break;
X			case '1':
X				putchar('\f');
X				break;
X			case '+':
X				putchar('\r');
X				break;
X			}
X
X			if (len > 1 && buf[0] && buf[1])
X				printf("%.*s", (int)(len - 1), buf + 1);
X		}
X
X		putchar('\n');
X	}
X}
END-of-asa.c
echo x - asa.1
sed 's/^X//' >asa.1 << 'END-of-asa.1'
X.\" Copyright (c) 1993 Winning Strategies, Inc.
X.\" All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\" 3. All advertising materials mentioning features or use of this software
X.\"    must display the following acknowledgement:
X.\"      This product includes software developed by Winning Strategies, Inc.
X.\" 4. The name of the author may not be used to endorse or promote products
X.\"    derived from this software without specific prior written permission
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
X.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
X.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
X.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
X.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
X.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
X.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
X.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
X.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
X.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
X.\"
X.\"	$NetBSD: asa.1,v 1.11 2002/02/08 01:36:18 ross Exp $
X.\" $FreeBSD$
X.\"
X.Dd September 23, 1993
X.Dt ASA 1
X.Os
X.Sh NAME
X.Nm asa
X.Nd interpret carriage-control characters
X.Sh SYNOPSIS
X.Nm
X.Op Ar
X.Sh DESCRIPTION
XThe
X.Nm
Xutility reads files sequentially, mapping
X.Tn FORTRAN
Xcarriage-control characters to line-printer control sequences,
Xand writes them to the standard output.
X.Pp
XThe first character of each line is interpreted as a carriage-control
Xcharacter.  The following characters are interpreted as follows:
X.Bl -tag -width "\*[Lt]space\*[Gt]"
X.It \*[Lt]space\*[Gt]
XOutput the rest of the line without change.
X.It 0
XOutput a \*[Lt]newline\*[Gt] character before printing the rest of the line.
X.It 1
XOutput a \*[Lt]formfeed\*[Gt] character before printing the rest of the line.
X.It +
XThe trailing \*[Lt]newline\*[Gt] of the previous line is replaced by a \*[Lt]carriage-return\*[Gt]
Xbefore printing the rest of the line.
X.El
X.Pp
XLines beginning with characters other than the above are treated as if they
Xbegin with \*[Lt]space\*[Gt].
X.Sh EXIT STATUS
XThe
X.Nm
Xutility exit 0 on success, and \*[Gt]0 if an error occurs.
X.Sh EXAMPLES
XTo view a file containing the output of a
X.Tn FORTRAN
Xprogram:
X.Dl asa file
X.Pp
XTo format the output of a
X.Tn FORTRAN
Xprogram and redirect it to a line-printer:
X.Dl a.out | asa | lpr
X.Sh SEE ALSO
X.Xr f77 1
X.Sh STANDARDS
XThe
X.Nm
Xutility conforms to
X.St -p1003.1-2001 .
X.Sh AUTHORS
XJ.T. Conklin, Winning Strategies, Inc.
END-of-asa.1
exit

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-standards" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203200809.g2K89W605096>