Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external awk glue



details:   https://anonhg.NetBSD.org/src/rev/73a6f8b8c30e
branches:  trunk
changeset: 757357:73a6f8b8c30e
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Aug 26 14:57:15 2010 +0000

description:
awk glue

diffstat:

 external/Makefile                     |    5 +-
 external/historical/Makefile          |    7 +
 external/historical/nawk/Makefile     |    5 +
 external/historical/nawk/bin/Makefile |   36 +
 external/historical/nawk/bin/TODO     |   22 +
 external/historical/nawk/bin/awk.1    |  732 ++++++++++++++++++++++++++++++++++
 6 files changed, 805 insertions(+), 2 deletions(-)

diffs (truncated from 836 to 300 lines):

diff -r 41bd73c70ea5 -r 73a6f8b8c30e external/Makefile
--- a/external/Makefile Thu Aug 26 14:55:19 2010 +0000
+++ b/external/Makefile Thu Aug 26 14:57:15 2010 +0000
@@ -1,7 +1,8 @@
-#      $NetBSD: Makefile,v 1.8 2009/10/05 22:44:26 haad Exp $
+#      $NetBSD: Makefile,v 1.9 2010/08/26 14:57:15 christos Exp $
 
 SUBDIR+= lib .WAIT
 
-SUBDIR+= apache2 bsd intel-fw-eula intel-fw-public gpl2 gpl3 ibm-public intel-public cddl
+SUBDIR+= apache2 bsd intel-fw-eula intel-fw-public gpl2 gpl3 historical
+SUBDIR+= ibm-public intel-public cddl
 
 .include <bsd.subdir.mk>
diff -r 41bd73c70ea5 -r 73a6f8b8c30e external/historical/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/historical/Makefile      Thu Aug 26 14:57:15 2010 +0000
@@ -0,0 +1,7 @@
+#      $NetBSD: Makefile,v 1.1 2010/08/26 14:57:15 christos Exp $
+
+.include <bsd.own.mk>
+
+SUBDIR+= nawk
+
+.include <bsd.subdir.mk>
diff -r 41bd73c70ea5 -r 73a6f8b8c30e external/historical/nawk/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/historical/nawk/Makefile Thu Aug 26 14:57:15 2010 +0000
@@ -0,0 +1,5 @@
+#      $NetBSD: Makefile,v 1.1 2010/08/26 14:57:16 christos Exp $
+
+SUBDIR+= bin
+
+.include <bsd.subdir.mk>
diff -r 41bd73c70ea5 -r 73a6f8b8c30e external/historical/nawk/bin/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/historical/nawk/bin/Makefile     Thu Aug 26 14:57:15 2010 +0000
@@ -0,0 +1,36 @@
+#      $NetBSD: Makefile,v 1.1 2010/08/26 14:57:16 christos Exp $
+
+WARNS?= 4
+
+.include <bsd.own.mk>
+
+DIST=  ${.CURDIR}/../dist
+.PATH: ${DIST}
+
+PROG=  awk
+SRCS=  awkgram.y b.c lex.c lib.c main.c parse.c proctab.c run.c tran.c
+CPPFLAGS+=     -I${DIST} -I.
+LDADD+=        -lm
+.if !defined(HOSTPROG)
+DPADD+=        ${LIBM}
+.endif
+YHEADER=       yes
+.if (defined(HAVE_GCC) && ${HAVE_GCC} == 4) || defined(HAVE_PCC)
+COPTS+=        -Wno-pointer-sign
+.endif
+
+# info file originally from GNU awk 3.1.3, adjusted for nawk slightly
+.PATH: ${NETBSDSRCDIR}/gnu/dist/gawk
+TEXINFO=        awk.info
+
+# During the tools build (from src/tools/awk/Makefile),
+# src/tools/Makefile.host changes .CURDIR back and forth between
+# src/tools/awk and src/usr.bin/awk.  For some unknown reason, including
+# bsd.info.mk here leads to the obj dir being created at the wrong time,
+# while .CURDIR is src/usr.bin/awk.  Work around the problem by not
+# including bsd.info.mk when MKINFO=no.
+.if ${MKINFO} != "no"
+.include <bsd.info.mk>
+.endif
+
+.include <bsd.prog.mk>
diff -r 41bd73c70ea5 -r 73a6f8b8c30e external/historical/nawk/bin/TODO
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/historical/nawk/bin/TODO Thu Aug 26 14:57:15 2010 +0000
@@ -0,0 +1,22 @@
+$NetBSD: TODO,v 1.1 2010/08/26 14:57:16 christos Exp $
+
+Besides general regression testing to ensure everything still works
+with nawk instead of gawk, following GNU awk extensions should be implemented
+or handled somehow (the list is probably incomplete, please add entries 
+if anything is missing):
+
+* String functions: gensub() (partly done, finish backref. support)
+* (done) Time functions: strftime(), systime()
+* --posix flag, which would switch off nawk extensions over POSIX awk (?)
+* special file names: /dev/pid, /dev/ppid, /dev/pgrpid, /dev/user,
+       /dev/stdin, /dev/stdout, /dev/stderr, /dev/fd/X
+* special variables: ARGIND, ERRNO, FIELDWIDTHS, IGNORECASE, RT
+
+Also, the manpage should be improved to be generally more helpful
+and document extensions over what POSIX says about awk.
+
+Other misc:
+* run.c: don't limit files[] to FOPEN_MAX (which is ridiculously low),
+  make the limit the current process open file limit
+* nawk doesn't permit empty RE, like
+// { do_something; }
diff -r 41bd73c70ea5 -r 73a6f8b8c30e external/historical/nawk/bin/awk.1
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/historical/nawk/bin/awk.1        Thu Aug 26 14:57:15 2010 +0000
@@ -0,0 +1,732 @@
+.\"    $NetBSD: awk.1,v 1.1 2010/08/26 14:57:16 christos Exp $
+.\"
+.\" Copyright (C) Lucent Technologies 1997
+.\" All Rights Reserved
+.\"
+.\" Permission to use, copy, modify, and distribute this software and
+.\" its documentation for any purpose and without fee is hereby
+.\" granted, provided that the above copyright notice appear in all
+.\" copies and that both that the copyright notice and this
+.\" permission notice and warranty disclaimer appear in supporting
+.\" documentation, and that the name Lucent Technologies or any of
+.\" its entities not be used in advertising or publicity pertaining
+.\" to distribution of the software without specific, written prior
+.\" permission.
+.\"
+.\" LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+.\" IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+.\" SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+.\" THIS SOFTWARE.
+.\"
+.Dd May 25, 2008
+.Dt AWK 1
+.Os
+.Sh NAME
+.Nm awk
+.Nd pattern-directed scanning and processing language
+.Sh SYNOPSIS
+.Nm
+.Op Fl F Ar fs
+.Op Fl v Ar var=value
+.Op Fl safe
+.Op Fl d Ns Op Ar N
+.Op Ar prog | Fl f Ar filename
+.Ar
+.Nm
+.Fl V
+.Sh DESCRIPTION
+.Nm
+is the Bell Labs' implementation of the AWK programming language as
+described in the
+.Em The AWK Programming Language
+by
+A. V. Aho, B. W. Kernighan, and P. J. Weinberger.
+.Pp
+.Nm
+scans each input
+.Ar file
+for lines that match any of a set of patterns specified literally in
+.Ar prog
+or in one or more files
+specified as
+.Fl f Ar filename .
+With each pattern
+there can be an associated action that will be performed
+when a line of a
+.Ar file
+matches the pattern.
+Each line is matched against the
+pattern portion of every pattern-action statement;
+the associated action is performed for each matched pattern.
+The file name
+.Ar -
+means the standard input.
+Any
+.Ar file
+of the form
+.Ar var=value
+is treated as an assignment, not a filename,
+and is executed at the time it would have been opened if it were a filename.
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl d Ns Op Ar N
+Set debug level to specified number
+.Ar N .
+If the number is omitted, debug level is set to 1.
+.It Fl f Ar filename
+Read the AWK program source from specified file
+.Ar filename ,
+instead of the first command line argument.
+Multiple
+.Fl f
+options may be specified.
+.It Fl F Ar fs
+Set the input field separator
+.Va FS
+to the regular expression
+.Ar fs .
+.It Fl mr Ar NNN , Fl mf Ar NNN
+Obsolete, no longer needed options.
+Set limit on maximum record or
+fields number.
+.It Fl safe
+Potentially unsafe functions such as
+.Fn system
+make the program abort (with a warning message).
+.It Fl v Ar var Ns = Ns Ar value
+Assign the value
+.Ar value
+to the variable
+.Va var
+before
+.Ar prog
+is executed.
+Any number of
+.Fl v
+options may be present.
+.It Fl V
+Print
+.Nm
+version on standard output and exit.
+.El
+.Pp
+An input line is normally made up of fields separated by white space,
+or by regular expression
+.Va FS .
+The fields are denoted
+.Va $1 ,
+.Va $2 ,
+\&..., while
+.Va $0
+refers to the entire line.
+If
+.Va FS
+is null, the input line is split into one field per character.
+.Pp
+A pattern-action statement has the form
+.Lp
+.Dl pattern \&{ action \&}
+.Lp
+A missing \&{ action \&}
+means print the line;
+a missing pattern always matches.
+Pattern-action statements are separated by newlines or semicolons.
+.Pp
+An action is a sequence of statements.
+Statements are terminated by
+semicolons, newlines or right braces.
+An empty
+.Ar expression-list
+stands for
+.Va $0 .
+String constants are quoted
+.Em \&"\ \&" ,
+with the usual C escapes recognized within.
+Expressions take on string or numeric values as appropriate,
+and are built using the
+.Sx Operators
+(see next subsection).
+Variables may be scalars, array elements
+(denoted
+.Va x[i] )
+or fields.
+Variables are initialized to the null string.
+Array subscripts may be any string,
+not necessarily numeric;
+this allows for a form of associative memory.
+Multiple subscripts such as
+.Va [i,j,k]
+are permitted; the constituents are concatenated,
+separated by the value of
+.Va SUBSEP .
+.Ss Operators
+.Nm
+operators, in order of decreasing precedence, are:
+.Pp
+.Bl -tag -width ident -compact
+.It Ic (...)
+Grouping
+.It Ic $
+Field reference
+.It Ic ++ --
+Increment and decrement, can be used either as postfix or prefix.
+.It Ic ^
+Exponentiation (the
+.Ic **
+form is also supported, and
+.Ic **=
+for the assignment operator).
+.It + - \&!
+Unary plus, unary minus and logical negation.
+.It * / %
+Multiplication, division and modulus.
+.It + -
+Addition and subtraction.
+.It Ar space
+String concatenation.
+.It Ic \*[Lt] \*[Gt]
+.It Ic \*[Le] \*[Ge]
+.It Ic != ==
+Regular relational operators
+.It Ic ~ !~



Home | Main Index | Thread Index | Old Index