1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

This commit was generated by cvs2svn to compensate for changes in r85898,

which included commits to RCS files with non-trunk default branches.
This commit is contained in:
David E. O'Brien 2001-11-02 21:06:08 +00:00
commit ff8c7f95b2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=85899
206 changed files with 42020 additions and 12643 deletions

9
contrib/awk/AUTHORS Normal file
View File

@ -0,0 +1,9 @@
Wed Feb 16 10:06:17 IST 2000
Gawk was written by Paul Rubin, and finished by Paul Finlason and
Richard Stallman.
David Trueman and Arnold Robbins took it over, with David doing most
of the work to make it compatible with new awk.
Circa 1994, Arnold Robbins took over maintenance.

View File

@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -313,7 +313,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

File diff suppressed because it is too large Load Diff

View File

@ -10,97 +10,76 @@ know where to get it.")
The focus on the future is thus narrowed to performance and functional
enhancements, with only minor plans for significant new features.
For 3.0
=======
DONE: Move to autoconf-based configure system.
DONE: Allow RS to be a regexp.
DONE: RT variable to hold text of record terminator
DONE: split() with null string as third arg to split up strings
DONE: Analogously, setting FS="" would split the input record into
individual characters.
DONE: Generalize IGNORECASE
- any value makes it work, not just numeric non-zero
- make it apply to *all* string comparisons
DONE: Incorporate newer dfa.c and regex.c
DONE: Go to POSIX regexps
DONE: Make regex + dfa less dependant on gawk header file includes
DONE: Source code formatting cleaned up and regularized
DONE: Clean up code by isolating system-specific functions in
separate files.
DONE: General sub function:
gensub(pat, sub, global_flag[, line])
that return the substituted strings and allow \1 etc.
in the sub string.
DONE: Add AWKPATH to ENVIRON if it's not there
DONE: Undertake significant directory reorganization.
DONE: Extensive manual cleanup:
Use of texinfo 2.0 features
Lots more examples
Document posix regexps
Document all of the above.
(OK, so 3.1 had a bad case of feature-itis. I think I'm mostly over it
now, though. :-)
In 3.1
======
A PROCINFO array to replace /dev/pid, /dev/user, et al.
DONE: A PROCINFO array to replace /dev/pid, /dev/user, et al.
DONE: Use mmap to read input files on systems that support it.
DONE: Add `abort' statement a la Thompson awk.
Add `abort' statement a la Thompson awk.
DONE: Provide awk profiling.
Consider removing use of and/or need for the protos.h file.
DONE: Integrate GNU NLS support.
Use a new or improved dfa.
Integrate GNU NLS support.
Bring out hooks for NLS support into gawk itself.
DBM storage of awk arrays. Try to allow multiple dbm packages.
Use GNU malloc.
DONE: Bring out hooks for NLS support into gawk itself.
DONE: Do a reference card.
? Have strftime() pay attention to the value of ENVIRON["TZ"]
DONE: Switch to full ANSI C and use ansi2kr.
Additional manual features:
DONE: Document NLS support
For 3.2
=======
Move the loadable modules interface to libtool.
Redo the loadable modules interface from the awk level.
Rework management of array index storage.
A RECLEN variable for fixed-length record input. PROCINFO["RS"]
would be "RS" or "RECLEN" depending upon what's in use.
DBM storage of awk arrays. Try to allow multiple dbm packages.
Look at ISO C 99 printf features.
Add %'d for putting in commas in formatting?
Consider integrating Fred Fish's DBUG library into gawk.
Consider removing use of and/or need for the protos.h file.
Additional manual features:
Document use of dbm arrays
Document NLS support
? Add exercises
Document use of dbm arrays
? Add an error messages section to the manual
For 3.3
=======
Use a new or improved dfa and/or regex library.
? Have strftime() pay attention to the value of ENVIRON["TZ"]
Add a lint check if the return value of a function is used but
the function did not supply a value.
Additional manual features:
? A section on where gawk is bounded
regex
i/o
sun fp conversions
For 3.2
For 3.4
=======
Add a lint check if the return value of a function is used but
the function did not supply a value.
Do an optimization pass over parse tree?
Make awk '/foo/' files... run at egrep speeds
Make awk '/foo/' files... run at egrep speeds (how?)
For 4.x:
========
Create a gawk compiler?
Create a gawk-to-C translator? (or C++??)
Provide awk profiling and debugging.
Provide awk debugging.

161
contrib/awk/Makefile.am Normal file
View File

@ -0,0 +1,161 @@
#
# Makefile.am --- automake input file for gawk
#
# Copyright (C) 2000-2001 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
#
# GAWK is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GAWK is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
## process this file with automake to produce Makefile.in
# Automatic de-ANSI-fication if needed
AUTOMAKE_OPTIONS = ansi2knr
# This undocumented variable insures that aclocal runs
# correctly after changing configure.in
ACLOCAL_AMFLAGS = -I m4
# This insures that make flags get passed down to child makes.
AM_MAKEFLAGS = 'CFLAGS=$(CFLAGS)' 'LDFLAGS=$(LDFLAGS)'
# Stuff to include in the dist that doesn't need it's own
# Makefile.am files
EXTRA_DIST = \
COPYING \
FUTURES \
INSTALL \
LIMITATIONS \
NEWS \
POSIX.STD \
PROBLEMS \
README_d \
bisonfix.sed \
depcomp \
extension \
fixvers \
m4 \
missing \
missing_d \
pc \
posix \
unsupported \
vms
# The order to do things in.
# Build in intl first in case we need the local gettext version.
# Build explicitly "." next in order to build gawk first, so
# that `make check' without a prior `make' works.
SUBDIRS = \
intl \
. \
awklib \
doc \
po \
test
# what to make and install
bin_PROGRAMS = gawk pgawk
# sources for both gawk and pgawk
base_sources = \
array.c \
awk.h \
awkgram.y \
builtin.c \
custom.h \
dfa.c \
dfa.h \
ext.c \
field.c \
gawkmisc.c \
getopt.c \
getopt.h \
getopt1.c \
io.c \
main.c \
msg.c \
node.c \
patchlev.h \
protos.h \
random.c \
random.h \
re.c \
regex.c \
regex.h \
replace.c \
version.in \
version.c
gawk_SOURCES = $(base_sources) eval.c profile.c
pgawk_SOURCES = $(base_sources) eval_p.c profile_p.c
# Get extra libs as needed
LDADD = @INTLLIBS@ @SOCKET_LIBS@
# stuff for compiling gawk/pgawk
DEFPATH="\".:$(datadir)\""
DEFS= -DDEFPATH=$(DEFPATH) -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR="\"$(datadir)/locale\""
INCLUDES = -I. -I$(srcdir) -I$(srcdir)/intl
# We want hard links for install-exec-hook, below
LN= ln
# First, add a link from gawk to gawk-X.Y.Z
# For systems where gawk is awk, add a link to awk
install-exec-hook:
(fullname=gawk-`./gawk --version | sed 1q | awk '{print $$3}'` ; \
cd $(DESTDIR)$(bindir); \
$(LN) gawk $$fullname ; \
if [ ! -f awk ]; \
then $(LN_S) gawk awk; \
fi; exit 0)
# Undo the above when uninstalling
uninstall-links:
(cd $(DESTDIR)$(bindir); \
if [ -f awk ] && cmp awk gawk > /dev/null; then rm -f awk; fi ; \
fullname=gawk-`./gawk --version | sed 1q | ./gawk '{print $$3}'` ; \
rm -f $$fullname; exit 0)
uninstall-recursive: uninstall-links
# force there to be a gawk executable before running tests
check-local: gawk pgawk
# A little extra clean up when making distributions.
# FIXME: most of this rule should go away upon switching to libtool.
dist-hook:
cd $(distdir)/extension ; rm -f *.o *.so
# Special rules for individual files
awkgram.c: awkgram.y
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && sed -f $(srcdir)/bisonfix.sed < y.tab.c > $*.c && $(RM) y.tab.c
if test -f y.tab.h; then \
if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
else :; fi
# these force version and patchlevel to be up to date based
# on what's in configure.in. No-one else but me should have
# to use them. So there.
patchlev.h: configure.in
./fixvers -p
version.c: configure.in version.in
./fixvers -v

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,131 @@
Changes from 3.0.6 to 3.1.0
---------------------------
1. A new PROCINFO array provides info about the process. The non-I/O /dev/xxx
files are now obsolete, and their use always generates a warning.
2. A new `mktime' builtin function was added for creating time stamps. The
`mktime' function written in awk was removed from the user's guide.
3. New `--gen-po' option creates GNU gettext .po files for strings marked
with a leading underscore.
4. Gawk now completely interprets special file names internally, ignoring the
existence of real /dev/stdin, /dev/stdout files, etc.
5. The mmap code was removed. It was a worthwhile experiment that just
didn't work out.
6. The BINMODE variable is new; on non-UNIX systems it affects how gawk
opens files for text vs. binary.
7. The atari port is now unsupported.
8. Gawk no longer supports `next file' as two words.
9. On systems that support it, gawk now sets the `close on exec' flag on all
files and pipes it opens. This makes sure that child processes run via
system() or pipes have plenty of file descriptors available.
10. New ports: Tandem and BeOS. The Tandem port is unsupported.
11. If `--posix' is in effect, newlines are not allowed after ?:.
12. Weird OFMT/CONVFMT formats no longer cause fatal errors.
13. Diagnostics about array parameters now include the parameter's name,
not just its number.
14. configure should now automatically add -D_SYSV3 for ISC Unix.
(This seems to have made it into the gawk 3.0.x line long ago.)
15. It is now possible to open a two-way pipe via the `|&' operator.
See the discussion in the manual about putting `sort' into such a pipeline,
though. (NOTE! This is borrowed from ksh: it is not the same as
the same operator in csh!)
16. The close() function now takes an optional second string argument
that allows closing one or the other end of the two-way pipe to
a co-process. This is needed to use `sort' in a co-process, see
the doc.
17. If TCP/IP is available, special file names beginning with `/inet'
can be used with `|&' for IPC. Thanks to Juergen Kahrs for the initial
code.
18. With `--enable-portals' on the configure command line, gawk will also
treat file names that start with `/p/' as a 4.4 BSD type portal file,
i.e., a two-way pipe for `|&'.
19. Unrecognized escapes, such as "\q" now always generate a warning.
20. The LINT variable is new; it provides dynamic control over the --lint
option.
21. Lint warnings can be made fatal by using --lint=fatal or `LINT = "fatal"'.
Use this if you're really serious about portable code.
22. Due to an enhanced sed script, there is no longer any need to worry
about finding or using alloca. alloca.c is thus now gone.
23. A number of lint warnings have been added. Most notably, gawk will
detect if a variable is used before assigned to. Warnings for
when a string that isn't a number gets converted to a number are
in the code but disabled; they seem to be too picky in practice.
Also, gawk will now warn about function parameter names that shadow
global variable names.
24. It is now possible to dynamically add builtin functions on systems
that support dlopen. This facility is not (yet) as portable or well
integrated as it might be. *** WARNING *** THIS FEATURE WILL EVOLVE!
25. There are *many* new tests in the test suite.
26. Profiling has been added! A separate version of gawk, named pgawk, is
built and generates a run-time execution profile. The --profile option
can be used to change the default output file. In regular gawk, this
option pretty-prints the parse tree.
27. Gawk has been internationalized, using GNU gettext. Translations for
future distributions are most welcome. Simultaneously, gawk was switched
over to using automake. You need Automake 1.4a (from the CVS archive)
if you want to muck with the Makefile.am files.
28. New asort() function for sorting arrays. See the doc for details.
29. The match function takes an optional array third argument to hold
the text matched by parenthesized sub-expressions.
30. The bit op functions and octal and hex source code constants are on by
default, no longer a configure-time option. Recognition of non-decimal
data is now enabled at runtime with --non-decimal-data command line option.
31. Internationalization features available at the awk level: new TEXTDOMAIN
variable and bindtextdomain() and dcgettext() functions. printf formats
may contain the "%2$3.5d" kind of notation for use in translations. See
the texinfo manual for details.
32. The return value from close() has been rationalized. Most notably,
closing something that wasn't open returns -1 but remains non-fatal.
33. The array effeciency change from 3.0.5 was reverted; the semantics were
not right. Additionally, index values of previously stored elements
can no longer change dynamically.
34. The new option --dump-variables dumps a list of all global variables and
their final types and values to a file you give, or to `awkvars.out'.
35. Gawk now uses a recent version of random.c courtesy of the FreeBSD
project.
36. The gawk source code now uses ANSI C function definitions (new style),
with ansi2knr to translate code for old compilers.
37. `for (iggy in foo)' loops should be more robust now in the face of
adding/deleting elements in the middle; they loop over just the elements
that are present in the array when the loop starts.
Changes from 3.0.5 to 3.0.6
---------------------------
@ -11,7 +139,7 @@ Bugs fixed and changes made:
2. Similarly, running a `for (iggy in foo)' loop where `foo' is a
function parameter now works correctly.
3. Similarly, `i = ""; v[i] = a; if (v in a) ...' now works again.
3. Similarly, `i = ""; v[i] = a; if (i in v) ...' now works again.
4. Gawk now special cases `for (iggy in foo) delete foo[iggy]' and
treats it as the moral equivalent of `delete foo'. This should be

View File

@ -1,3 +1,8 @@
March 2001:
It looks like the revised 1003.2 standard will actually follow the
rules given below. Hallelujah!
October 1998:
The 1003.2 work has been at a stand-still for ages. Who knows if or

View File

@ -1,7 +1,6 @@
This is a list of known problems in gawk 3.0.
Hopefully they will all be fixed in the next major release of gawk.
Please keep in mind that the code is still undergoing significant evolution.
This is a list of known problems in gawk 3.1.
I don't know when this will be fixed, if ever. See also FUTURES
and the gawk.texi doc for other things that need doing.
1. The interactions with the lexer and yyerror need reworking. It is possible
to get line numbers that are one line off if --compat or --posix is

View File

@ -1,74 +1,84 @@
README:
This is GNU Awk 3.0.6. It should be upwardly compatible with the Bell
Labs research version of awk. It is almost completely compliant with
the 1993 POSIX 1003.2 standard for awk. (See the note below about POSIX.)
This is GNU Awk 3.1.0. It is upwardly compatible with the Bell Labs
research version of awk. It is almost completely compliant with the
1993 POSIX 1003.2 standard for awk. (See the note below about POSIX.)
Patches 1 through 5 just fix bugs -- see NEWS and ChangeLog for details.
There are lots of new features -- see NEWS and ChangeLog for details.
See the file INSTALL for installation instructions.
Work to be done is described briefly in the FUTURES file. Changes in this
version are summarized in the NEWS file. Please read the LIMITATIONS file.
Known problems are given in the PROBLEMS file. Work to be done is
described briefly in the FUTURES file. Verified ports are listed in
the PORTS file. Changes in this version are summarized in the NEWS file.
Please read the LIMITATIONS and ACKNOWLEDGMENT files.
Read the file POSIX.STD for a discussion of how the standard says
comparisons should be done vs. how they really should be done and how
gawk does them.
Read the file POSIX for a discussion of how the standard says comparisons
should be done vs. how they really should be done and how gawk does them.
To format the documentation with TeX, use at least version 2.151 of
texinfo.tex. There is a usable copy of texinfo.tex in the doc directory.
The Info file now comes with the distribution.
The man page is up to date.
To format the documentation with TeX, use at least version 2000-10-27.17
of texinfo.tex. There is a usable copy of texinfo.tex in the doc directory.
INSTALLATION:
Check whether there is a system-specific README file for your system
under the `README_d' directory. If there's something there that you
should have read and didn't, and you bug me about it, I'm going to yell
at you.
Check whether there is a system-specific README file for your system under
the `README_d' directory. If there's something there that you should
have read and didn't, and you bug me about it, I'm going to yell at you.
See the file INSTALL.
See the file INSTALL for installation instructions.
If you have neither bison nor yacc, use the awktab.c file here. It was
generated with bison, and has no proprietary code in it. (Note that modifying
awk.y without bison or yacc will be difficult, at best. You might want
to get a copy of bison from the FSF too.)
If you have an MS-DOS or OS/2 system, use the stuff in the `pc' directory.
Similarly, there are separate directories for Ataris, Amigas, and VMS.
If you have neither bison nor yacc, use the awkgram.c file here. It was
generated with bison, and has no proprietary code in it. (Note that
modifying awkgram.y without bison or yacc will be difficult, at best.
You might want to get a copy of bison from the FSF too.)
Appendix B of The GNU Awk User's Guide discusses configuration in detail. The
configuration process is now based on Autoconf, so the whole business
should be considerably simpler than it was in gawk 2.X.Y.
If you have a Win32, MS-DOS or OS/2 system, use the stuff in the `pc'
directory. Similarly, there is a separate directory for VMS.
After successful compilation, do 'make check' to run a small test
suite. There should be no output from the 'cmp' invocations except in
the cases where there are small differences in floating point values,
and possibly in the case of strftime. Several of the tests ignore
errors on purpose; those are not a problem. If there are other
differences, please investigate and report the problem.
Ports for the Atari and Tandem are supplied, but they are unsupported.
Thus, their code appears in the `unsupported' directory.
Appendix B of ``GAWK: Effective Awk Programming'' discusses configuration
in detail. The configuration process is based on GNU Autoconf and
Automake.
After successful compilation, do `make check' to run the test suite.
There should be no output from the `cmp' invocations except in the
cases where there are small differences in floating point values, and
possibly in the case of strftime. Several of the tests ignore errors
on purpose; those are not a problem. If there are other differences,
please investigate and report the problem.
PRINTING THE MANUAL
The 'doc' directory contains a recent version of texinfo.tex, which will be
necessary for printing the manual. Use `make dvi' to get a DVI file from
the manual. In the `doc' directory, use `make postscript' to get a PostScript
version of the manual.
The `doc' directory contains a recent version of texinfo.tex, which will
be necessary for printing the manual. Use `make dvi' to get a DVI file
from the manual. In the `doc' directory, use `make postscript' to get
PostScript versions of the manual, the man page, and the reference card.
BUG REPORTS AND FIXES (Un*x systems):
Please coordinate changes through Arnold Robbins. In particular, see
the section in the manual on reporting bugs. Note that comp.lang.awk is
about the worst place to post a gawk bug report. Please, use the mechanisms
outlined in the manual.
the section in the manual on reporting bugs. Note that comp.lang.awk
is about the worst place to post a gawk bug report. Please, use the
mechanisms outlined in the manual.
Email should be sent to bug-gawk@gnu.org. This address sends mail to
Arnold Robbins and the general GNU utilities bug list. The advantage
to using this address is that bug reports are archived at GNU Central.
Arnold Robbins
INTERNET: arnold@gnu.org
BUG REPORTS AND FIXES (non-Unix ports):
BUG REPORTS AND FIXES, non-Unix systems:
Amiga:
Fred Fish
fnf@ninemoons.com
Alpha/Linux:
Michal Jaegermann
michal@gortel.phys.ualberta.ca
BeOS:
Martin Brown
mc@whoever.com
MS-DOS:
Scott Deifik
@ -77,18 +87,18 @@ MS-DOS:
Darrel Hankerson
hankedr@mail.auburn.edu
VMS:
Pat Rankin
rankin@eql.caltech.edu
Alpha/Linux:
Michal Jaegermann
michal@gortel.phys.ualberta.ca
MS-Windows:
Juan Grigera
juan@biophnet.unlp.edu.ar
OS/2:
Kai Uwe Rommel
rommel@ars.de
Amiga:
Fred Fish
fnf@ninemoons.com
Tandem:
Stephen Davies
scldad@sdc.com.au
VMS:
Pat Rankin
rankin@eql.caltech.edu

View File

@ -2,22 +2,22 @@
* acconfig.h -- configuration definitions for gawk.
*/
/*
* Copyright (C) 1995-2000 the Free Software Foundation, Inc.
*
/*
* Copyright (C) 1995-2001 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
*
*
* GAWK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* GAWK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
@ -25,14 +25,14 @@
@TOP@
#undef HAVE_STRINGIZE /* can use ANSI # operator in cpp */
#undef REGEX_MALLOC /* use malloc instead of alloca in regex.c */
#undef SPRINTF_RET /* return type of sprintf */
#undef BITOPS /* bitwise ops (undocumented feature) */
#undef NONDECDATA /* non-decimal input data (undocumented feature) */
#undef _FILE_OFFSET_BITS /* bits in a file offset, where this matters */
#undef _LARGEFILE_SOURCE /* makes fseeko etc. visible on some hosts */
#undef _LARGE_FILES /* emables large files on AIX-style hosts */
#undef HAVE_MKTIME /* we have the mktime function */
#undef HAVE_SOCKETS /* we have sockets on this system */
#undef HAVE_PORTALS /* we have portals on /p on this system */
#undef DYNAMIC /* allow dynamic addition of builtins */
#undef STRTOD_NOT_C89 /* strtod doesn't have C89 semantics */
#undef ssize_t /* signed version of size_t */
@BOTTOM@

View File

@ -3,7 +3,7 @@
*/
/*
* Copyright (C) 1986, 1988, 1989, 1991-2000 the Free Software Foundation, Inc.
* Copyright (C) 1986, 1988, 1989, 1991-2001 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@ -45,8 +45,7 @@ static void grow_table P((NODE *symbol));
/* concat_exp --- concatenate expression list into a single string */
NODE *
concat_exp(tree)
register NODE *tree;
concat_exp(register NODE *tree)
{
register NODE *r;
char *str;
@ -92,8 +91,7 @@ register NODE *tree;
/* assoc_clear --- flush all the values in symbol[] before doing a split() */
void
assoc_clear(symbol)
NODE *symbol;
assoc_clear(NODE *symbol)
{
int i;
NODE *bucket, *next;
@ -118,10 +116,7 @@ NODE *symbol;
/* hash --- calculate the hash function of the string in subs */
unsigned int
hash(s, len, hsize)
register const char *s;
register size_t len;
unsigned long hsize;
hash(register const char *s, register size_t len, unsigned long hsize)
{
register unsigned long h = 0;
@ -208,10 +203,7 @@ unsigned long hsize;
/* assoc_find --- locate symbol[subs] */
static NODE * /* NULL if not found */
assoc_find(symbol, subs, hash1)
NODE *symbol;
register NODE *subs;
int hash1;
assoc_find(NODE *symbol, register NODE *subs, int hash1)
{
register NODE *bucket;
NODE *s1, *s2;
@ -238,8 +230,7 @@ int hash1;
/* in_array --- test whether the array element symbol[subs] exists or not */
int
in_array(symbol, subs)
NODE *symbol, *subs;
in_array(NODE *symbol, NODE *subs)
{
register int hash1;
int ret;
@ -249,7 +240,7 @@ NODE *symbol, *subs;
if (symbol->type == Node_array_ref)
symbol = symbol->orig_array;
if ((symbol->flags & SCALAR) != 0)
fatal("attempt to use scalar as array");
fatal(_("attempt to use scalar `%s' as array"), symbol->vname);
/*
* evaluate subscript first, it could have side effects
*/
@ -274,8 +265,7 @@ NODE *symbol, *subs;
*/
NODE **
assoc_lookup(symbol, subs)
NODE *symbol, *subs;
assoc_lookup(NODE *symbol, NODE *subs, int reference)
{
register int hash1;
register NODE *bucket;
@ -285,7 +275,7 @@ NODE *symbol, *subs;
(void) force_string(subs);
if ((symbol->flags & SCALAR) != 0)
fatal("attempt to use scalar as array");
fatal(_("attempt to use scalar `%s' as array"), symbol->vname);
if (symbol->var_array == NULL) {
if (symbol->type != Node_var_array) {
@ -307,15 +297,21 @@ NODE *symbol, *subs;
}
}
if (do_lint && reference) {
subs->stptr[subs->stlen] = '\0';
lintwarn(_("reference to uninitialized element `%s[\"%s\"]'"),
symbol->vname, subs->stptr);
}
/* It's not there, install it. */
if (do_lint && subs->stlen == 0)
warning("subscript of array `%s' is null string",
lintwarn(_("subscript of array `%s' is null string"),
symbol->vname);
/* first see if we would need to grow the array, before installing */
symbol->table_size++;
if ((symbol->flags & ARRAYMAXED) == 0
&& symbol->table_size/symbol->array_size > AVG_CHAIN_MAX) {
&& (symbol->table_size / symbol->array_size) > AVG_CHAIN_MAX) {
grow_table(symbol);
/* have to recompute hash value for new size */
hash1 = hash(subs->stptr, subs->stlen,
@ -324,9 +320,28 @@ NODE *symbol, *subs;
getnode(bucket);
bucket->type = Node_ahash;
bucket->ahname = dupnode(subs);
/*
* Freeze this string value --- it must never
* change, no matter what happens to the value
* that created it or to CONVFMT, etc.
*
* One day: Use an atom table to track array indices,
* and avoid the extra memory overhead.
*/
if (subs->flags & TEMP)
bucket->ahname = dupnode(subs);
else
bucket->ahname = copynode(subs);
free_temp(subs);
/* array subscripts are strings */
bucket->ahname->flags &= ~(NUMBER|NUM);
bucket->ahname->flags |= (STRING|STR);
/* ensure that this string value never changes */
bucket->ahname->stfmt = -1;
bucket->ahvalue = Nnull_string;
bucket->ahnext = symbol->var_array[hash1];
symbol->var_array[hash1] = bucket;
@ -336,8 +351,7 @@ NODE *symbol, *subs;
/* do_delete --- perform `delete array[s]' */
void
do_delete(symbol, tree)
NODE *symbol, *tree;
do_delete(NODE *symbol, NODE *tree)
{
register int hash1;
register NODE *bucket, *last;
@ -354,7 +368,7 @@ NODE *symbol, *tree;
if (symbol->var_array == NULL)
return;
} else
fatal("delete: illegal use of variable `%s' as array",
fatal(_("delete: illegal use of variable `%s' as array"),
symbol->vname);
if (tree == NULL) { /* delete array */
@ -387,7 +401,7 @@ NODE *symbol, *tree;
if (bucket == NULL) {
if (do_lint)
warning("delete: index `%s' not in array `%s'",
lintwarn(_("delete: index `%s' not in array `%s'"),
subs->stptr, symbol->vname);
free_temp(subs);
return;
@ -420,11 +434,10 @@ NODE *symbol, *tree;
*/
void
do_delete_loop(symbol, tree)
NODE *symbol, *tree;
do_delete_loop(NODE *symbol, NODE *tree)
{
size_t i;
NODE *n, **lhs;
NODE **lhs;
Func_ptr after_assign = NULL;
if (symbol->type == Node_param_list) {
@ -438,13 +451,13 @@ NODE *symbol, *tree;
if (symbol->var_array == NULL)
return;
} else
fatal("delete: illegal use of variable `%s' as array",
fatal(_("delete: illegal use of variable `%s' as array"),
symbol->vname);
/* get first index value */
for (i = 0; i < symbol->array_size; i++) {
if (symbol->var_array[i] != NULL) {
lhs = get_lhs(tree->lnode, & after_assign);
lhs = get_lhs(tree->lnode, & after_assign, FALSE);
unref(*lhs);
*lhs = dupnode(symbol->var_array[i]->ahname);
break;
@ -455,71 +468,10 @@ NODE *symbol, *tree;
assoc_clear(symbol);
}
/* assoc_scan --- start a ``for (iggy in foo)'' loop */
void
assoc_scan(symbol, lookat)
NODE *symbol;
struct search *lookat;
{
lookat->sym = symbol;
lookat->idx = 0;
lookat->bucket = NULL;
lookat->retval = NULL;
if (symbol->var_array != NULL)
assoc_next(lookat);
}
/* assoc_next --- actually find the next element in array */
void
assoc_next(lookat)
struct search *lookat;
{
register NODE *symbol = lookat->sym;
if (symbol == NULL)
fatal("null symbol in assoc_next");
if (symbol->var_array == NULL || lookat->idx > symbol->array_size) {
lookat->retval = NULL;
return;
}
/*
* This is theoretically unsafe. The element bucket might have
* been freed if the body of the scan did a delete on the next
* element of the bucket. The only way to do that is by array
* reference, which is unlikely. Basically, if the user is doing
* anything other than an operation on the current element of an
* assoc array while walking through it sequentially, all bets are
* off. (The safe way is to register all search structs on an
* array with the array, and update all of them on a delete or
* insert)
*/
if (lookat->bucket != NULL) {
lookat->retval = lookat->bucket->ahname;
lookat->bucket = lookat->bucket->ahnext;
return;
}
for (; lookat->idx < symbol->array_size; lookat->idx++) {
NODE *bucket;
if ((bucket = symbol->var_array[lookat->idx]) != NULL) {
lookat->retval = bucket->ahname;
lookat->bucket = bucket->ahnext;
lookat->idx++;
return;
}
}
lookat->retval = NULL;
lookat->bucket = NULL;
return;
}
/* grow_table --- grow a hash table */
static void
grow_table(symbol)
NODE *symbol;
grow_table(NODE *symbol)
{
NODE **old, **new, *chain, *next;
int i, j;
@ -581,7 +533,6 @@ NODE *symbol;
/* remove from old list, add to new */
chain->ahnext = new[hash1];
new[hash1] = chain;
}
}
free(old);
@ -598,8 +549,7 @@ NODE *symbol;
/* pr_node --- print simple node info */
static void
pr_node(n)
NODE *n;
pr_node(NODE *n)
{
if ((n->flags & (NUM|NUMBER)) != 0)
printf("%g", n->numbr);
@ -610,24 +560,23 @@ NODE *n;
/* assoc_dump --- dump the contents of an array */
NODE *
assoc_dump(symbol)
NODE *symbol;
assoc_dump(NODE *symbol)
{
int i;
NODE *bucket;
if (symbol->var_array == NULL) {
printf("%s: empty (null)\n", symbol->vname);
printf(_("%s: empty (null)\n"), symbol->vname);
return tmp_number((AWKNUM) 0);
}
if (symbol->table_size == 0) {
printf("%s: empty (zero)\n", symbol->vname);
printf(_("%s: empty (zero)\n"), symbol->vname);
return tmp_number((AWKNUM) 0);
}
printf("%s: table_size = %d, array_size = %d\n", symbol->vname,
symbol->table_size, symbol->array_size);
printf(_("%s: table_size = %d, array_size = %d\n"), symbol->vname,
(int) symbol->table_size, (int) symbol->array_size);
for (i = 0; i < symbol->array_size; i++) {
for (bucket = symbol->var_array[i]; bucket != NULL;
@ -651,20 +600,19 @@ NODE *symbol;
/* do_adump --- dump an array: interface to assoc_dump */
NODE *
do_adump(tree)
NODE *tree;
do_adump(NODE *tree)
{
NODE *r, *a;
a = tree->lnode;
if (a->type == Node_param_list) {
printf("%s: is paramater\n", a->vname);
printf(_("%s: is paramater\n"), a->vname);
a = stack_ptr[a->param_cnt];
}
if (a->type == Node_array_ref) {
printf("%s: array_ref to %s\n", a->vname,
printf(_("%s: array_ref to %s\n"), a->vname,
a->orig_array->vname);
a = a->orig_array;
}
@ -673,3 +621,238 @@ NODE *tree;
return r;
}
/*
* The following functions implement the builtin
* asort function. Initial work by Alan J. Broder,
* ajb@woti.com.
*/
/* dup_table --- duplicate input symbol table "symbol" */
static void
dup_table(NODE *symbol, NODE *newsymb)
{
NODE **old, **new, *chain, *bucket;
int i;
unsigned long cursize;
/* find the current hash size */
cursize = symbol->array_size;
new = NULL;
/* input is a brand new hash table, so there's nothing to copy */
if (symbol->var_array == NULL)
newsymb->table_size = 0;
else {
/* old hash table there, dupnode stuff into a new table */
/* allocate new table */
emalloc(new, NODE **, cursize * sizeof(NODE *), "dup_table");
memset(new, '\0', cursize * sizeof(NODE *));
/* do the copying/dupnode'ing */
old = symbol->var_array;
for (i = 0; i < cursize; i++) {
if (old[i] != NULL) {
for (chain = old[i]; chain != NULL;
chain = chain->ahnext) {
/* get a node for the linked list */
getnode(bucket);
bucket->type = Node_ahash;
/*
* copy the corresponding name and
* value from the original input list
*/
bucket->ahname = dupnode(chain->ahname);
bucket->ahvalue = dupnode(chain->ahvalue);
/*
* put the node on the corresponding
* linked list in the new table
*/
bucket->ahnext = new[i];
new[i] = bucket;
}
}
}
newsymb->table_size = symbol->table_size;
}
newsymb->var_array = new;
newsymb->array_size = cursize;
}
/* merge --- do a merge of two sorted lists */
static NODE *
merge(NODE *left, NODE *right)
{
NODE *ans, *cur;
if (cmp_nodes(left->ahvalue, right->ahvalue) <= 0) {
ans = cur = left;
left = left->ahnext;
} else {
ans = cur = right;
right = right->ahnext;
}
while (left != NULL && right != NULL) {
if (cmp_nodes(left->ahvalue, right->ahvalue) <= 0) {
cur->ahnext = left;
cur = left;
left = left->ahnext;
} else {
cur->ahnext = right;
cur = right;
right = right->ahnext;
}
}
cur->ahnext = (left != NULL ? left : right);
return ans;
}
/* merge_sort --- recursively sort the left and right sides of a list */
static NODE *
merge_sort(NODE *left, int size)
{
NODE *right, *tmp;
int i, half;
if (size <= 1)
return left;
/* walk down the list, till just one before the midpoint */
tmp = left;
half = size / 2;
for (i = 0; i < half-1; i++)
tmp = tmp->ahnext;
/* split the list into two parts */
right = tmp->ahnext;
tmp->ahnext = NULL;
/* sort the left and right parts of the list */
left = merge_sort(left, half);
right = merge_sort(right, size-half);
/* merge the two sorted parts of the list */
return merge(left, right);
}
/*
* assoc_from_list -- Populate an array with the contents of a list of NODEs,
* using increasing integers as the key.
*/
static void
assoc_from_list(NODE *symbol, NODE *list)
{
NODE *next;
int i = 0;
register int hash1;
for (; list != NULL; list = next) {
next = list->ahnext;
/* make an int out of i++ */
i++;
list->ahname = make_number((AWKNUM) i);
(void) force_string(list->ahname);
/* find the bucket where it belongs */
hash1 = hash(list->ahname->stptr, list->ahname->stlen,
symbol->array_size);
/* link the node into the chain at that bucket */
list->ahnext = symbol->var_array[hash1];
symbol->var_array[hash1] = list;
}
}
/*
* assoc_sort_inplace --- sort all the values in symbol[], replacing
* the sorted values back into symbol[], indexed by integers starting with 1.
*/
static NODE *
assoc_sort_inplace(NODE *symbol)
{
int i, num;
NODE *bucket, *next, *list;
if (symbol->var_array == NULL
|| symbol->array_size <= 0
|| symbol->table_size <= 0)
return tmp_number((AWKNUM) 0);
/* build a linked list out of all the entries in the table */
list = NULL;
num = 0;
for (i = 0; i < symbol->array_size; i++) {
for (bucket = symbol->var_array[i]; bucket != NULL; bucket = next) {
next = bucket->ahnext;
unref(bucket->ahname);
bucket->ahnext = list;
list = bucket;
num++;
}
symbol->var_array[i] = NULL;
}
/*
* Sort the linked list of NODEs.
* (The especially nice thing about using a merge sort here is that
* we require absolutely no additional storage. This is handy if the
* array has grown to be very large.)
*/
list = merge_sort(list, num);
/*
* now repopulate the original array, using increasing
* integers as the key
*/
assoc_from_list(symbol, list);
return tmp_number((AWKNUM) num);
}
/* do_asort --- do the actual work to sort the input array */
NODE *
do_asort(NODE *tree)
{
NODE *src, *dest;
src = tree->lnode;
dest = NULL;
if (src->type == Node_param_list)
src = stack_ptr[src->param_cnt];
if (src->type == Node_array_ref)
src = src->orig_array;
if (src->type != Node_var_array)
fatal(_("asort: first argument is not an array"));
if (tree->rnode != NULL) { /* 2nd optional arg */
dest = tree->rnode->lnode;
if (dest->type == Node_param_list)
dest = stack_ptr[dest->param_cnt];
if (dest->type == Node_array_ref)
dest = dest->orig_array;
if (dest->type != Node_var && dest->type != Node_var_array)
fatal(_("asort: second argument is not an array"));
dest->type = Node_var_array;
assoc_clear(dest);
dup_table(src, dest);
}
return dest != NULL ? assoc_sort_inplace(dest) : assoc_sort_inplace(src);
}

2875
contrib/awk/awkgram.y Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,27 @@
Sun Jun 3 13:04:44 2001 Arnold D. Robbins <arnold@skeeve.com>
* Release 3.1.0: Release tar file made. And there was
rejoicing.
2001-02-26 Paul Eggert <eggert@twinsun.com>
* Makefile.am (stamp-eg): Use $(AWK), not awk, as the
native awk might not work.
2001-02-26 Andreas Schwab <schwab@suse.de>
* Makefile.am: Install igawk as script.
Mon Nov 6 15:29:08 2000 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am: Fixed to have all functionality from before
the switch to automake.
* extract.awk: Updated to match version in the doc.
Sat Jul 26 23:08:29 1997 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.in (install-strip): new target.
Mon Aug 7 15:23:00 2000 Arnold D. Robbins <arnold@skeeve.com>
* Release 3.0.6: Release tar file made.
@ -7,7 +31,7 @@ Sun Jun 25 15:08:19 2000 Arnold D. Robbins <arnold@skeeve.com>
* Release 3.0.5: Release tar file made.
Wed Jun 30 16:14:36 1999 Arnold D. Robbins <arnold@gnu.org>
* Release 3.0.4: Release tar file made. This time for sure.
Thu May 15 12:49:08 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>

View File

@ -0,0 +1,75 @@
#
# awklib/Makefile.am --- automake input file for gawk
#
# Copyright (C) 1995-2001 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
#
# GAWK is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GAWK is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
## process this file with automake to produce Makefile.in
EXTRA_DIST = ChangeLog extract.awk eg stamp-eg
datadir = @datadir@/awk
libexecdir = @libexecdir@/awk
bin_SCRIPTS = igawk
libexec_PROGRAMS = pwcat grcat
AUXAWK = passwd.awk group.awk
nodist_grcat_SOURCES = grcat.c
nodist_pwcat_SOURCES = pwcat.c
all: stamp-eg $(AUXPROGS) igawk $(AUXAWK)
install-exec-hook: $(AUXAWK)
$(mkinstalldirs) $(DESTDIR)$(datadir)
for i in $(AUXAWK) $(srcdir)/eg/lib/*.awk ; do \
progname=`echo $$i | sed 's;.*/;;'` ; \
$(INSTALL_DATA) $$i $(DESTDIR)$(datadir)/$$progname ; \
done
# libexecdir and datadir are removed in the top level Makefile's uninstall
uninstall-local:
rm -fr $(DESTDIR)$(libexecdir)/* $(DESTDIR)$(datadir)/*
rm -f $(DESTDIR)$(bindir)/igawk
clean-local:
rm -f $(AUXAWK) igawk
stamp-eg: $(srcdir)/../doc/gawk.texi $(srcdir)/../doc/gawkinet.texi
rm -fr eg stamp-eg
$(AWK) -f $(srcdir)/extract.awk $(srcdir)/../doc/gawk.texi $(srcdir)/../doc/gawkinet.texi
@echo 'some makes are stupid and will not check a directory' > stamp-eg
@echo 'against a file, so this file is a place holder. gack.' >> stamp-eg
pwcat: $(srcdir)/eg/lib/pwcat.c
$(CC) $(CFLAGS) $(srcdir)/eg/lib/pwcat.c $(LDFLAGS) -o $@
grcat: $(srcdir)/eg/lib/grcat.c
$(CC) $(CFLAGS) $(srcdir)/eg/lib/grcat.c $(LDFLAGS) -o $@
igawk: $(srcdir)/eg/prog/igawk.sh
cp $(srcdir)/eg/prog/igawk.sh $@ ; chmod 755 $@
passwd.awk: $(srcdir)/eg/lib/passwdawk.in
(cd $(srcdir)/eg/lib ; \
sed 's;/usr/local/libexec/awk;$(libexecdir);' < passwdawk.in) > passwd.awk
group.awk: $(srcdir)/eg/lib/groupawk.in
(cd $(srcdir)/eg/lib ; \
sed 's;/usr/local/libexec/awk;$(libexecdir);' < groupawk.in) > group.awk

View File

@ -1,57 +1,411 @@
# Makefile for GNU Awk support library.
#
# Copyright (C) 1995-1998 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
#
# GAWK is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GAWK is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
# Makefile.in generated automatically by automake 1.4a from Makefile.am
SHELL = /bin/sh
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_FLAG =
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
@SET_MAKE@
AMDEP = @AMDEP@
AMTAR = @AMTAR@
AWK = @AWK@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CFLAGS = @CFLAGS@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DATADIRNAME = @DATADIRNAME@
DEPDIR = @DEPDIR@
GENCAT = @GENCAT@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
INSTOBJEXT = @INSTOBJEXT@
INTLDEPS = @INTLDEPS@
INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
LN_S = @LN_S@
MAKEINFO = @MAKEINFO@
MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
PACKAGE = @PACKAGE@
POFILES = @POFILES@
POSUB = @POSUB@
RANLIB = @RANLIB@
SOCKET_LIBS = @SOCKET_LIBS@
U = @U@
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
YACC = @YACC@
install_sh = @install_sh@
l = @l@
prefix = @prefix@
exec_prefix = @exec_prefix@
binprefix =
manprefix =
#
# awklib/Makefile.am --- automake input file for gawk
#
# Copyright (C) 1995-2001 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
#
# GAWK is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GAWK is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
EXTRA_DIST = ChangeLog extract.awk eg stamp-eg
bindir = @bindir@
libdir = @libdir@
mandir = @mandir@/man1
manext = .1
infodir = @infodir@
datadir = @datadir@/awk
libexecdir = @libexecdir@/awk
AUXPROGS = pwcat grcat
bin_SCRIPTS = igawk
libexec_PROGRAMS = pwcat grcat
AUXAWK = passwd.awk group.awk
nodist_grcat_SOURCES = grcat.c
nodist_pwcat_SOURCES = pwcat.c
subdir = awklib
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
PROGRAMS = $(libexec_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir) -I..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
nodist_grcat_OBJECTS = grcat.o
grcat_OBJECTS = $(nodist_grcat_OBJECTS)
grcat_LDADD = $(LDADD)
grcat_DEPENDENCIES =
grcat_LDFLAGS =
nodist_pwcat_OBJECTS = pwcat.o
pwcat_OBJECTS = $(nodist_pwcat_OBJECTS)
pwcat_LDADD = $(LDADD)
pwcat_DEPENDENCIES =
pwcat_LDFLAGS =
SCRIPTS = $(bin_SCRIPTS)
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
DIST_SOURCES =
depcomp = $(SHELL) $(top_srcdir)/depcomp
DEP_FILES = @AMDEP@ $(DEPDIR)/grcat.Po $(DEPDIR)/pwcat.Po
DIST_COMMON = ChangeLog Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
GZIP_ENV = --best
SOURCES = $(nodist_grcat_SOURCES) $(nodist_pwcat_SOURCES)
OBJECTS = $(nodist_grcat_OBJECTS) $(nodist_pwcat_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .c .o
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu awklib/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-libexecPROGRAMS:
clean-libexecPROGRAMS:
-test -z "$(libexec_PROGRAMS)" || rm -f $(libexec_PROGRAMS)
distclean-libexecPROGRAMS:
maintainer-clean-libexecPROGRAMS:
install-libexecPROGRAMS: $(libexec_PROGRAMS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libexecdir)
@list='$(libexec_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \
f="`echo $$p|sed -e 's/$(EXEEXT)$$//' -e '$(transform)' -e 's/$$/$(EXEEXT)/'`"; \
echo " $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libexecdir)/$$f"; \
$(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libexecdir)/$$f; \
else :; fi; \
done
uninstall-libexecPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(libexec_PROGRAMS)'; for p in $$list; do \
f="`echo $$p|sed -e 's/$(EXEEXT)$$//' -e '$(transform)' -e 's/$$/$(EXEEXT)/'`"; \
echo " rm -f $(DESTDIR)$(libexecdir)/$$f"; \
rm -f $(DESTDIR)$(libexecdir)/$$f; \
done
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
install-binSCRIPTS: $(bin_SCRIPTS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_SCRIPTS)'; for p in $$list; do \
f="`echo $$p|sed '$(transform)'`"; \
if test -f $$p; then \
echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/$$f"; \
$(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/$$f; \
elif test -f $(srcdir)/$$p; then \
echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/$$f"; \
$(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/$$f; \
else :; fi; \
done
uninstall-binSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(bin_SCRIPTS)'; for p in $$list; do \
f="`echo $$p|sed '$(transform)'`"; \
echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
rm -f $(DESTDIR)$(bindir)/$$f; \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| etags $(ETAGS_ARGS) $$tags $$unique $(LISP)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
@AMDEP@include $(DEPDIR)/grcat.Po
@AMDEP@include $(DEPDIR)/pwcat.Po
mostlyclean-depend:
clean-depend:
distclean-depend:
-rm -rf $(DEPDIR)
maintainer-clean-depend:
@AMDEP@CCDEPMODE = @CCDEPMODE@
.c.o:
@AMDEP@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(COMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$<
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir) \
|| exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-libexecPROGRAMS install-binSCRIPTS
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-exec-hook
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libexecPROGRAMS uninstall-binSCRIPTS \
uninstall-local
uninstall: uninstall-am
all-am: Makefile $(PROGRAMS) $(SCRIPTS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libexecdir) $(DESTDIR)$(bindir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
-rm -f Makefile.in
mostlyclean-am: mostlyclean-libexecPROGRAMS mostlyclean-compile \
mostlyclean-tags mostlyclean-depend mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-libexecPROGRAMS clean-compile clean-tags clean-depend \
clean-generic mostlyclean-am clean-local
clean: clean-am
distclean-am: distclean-libexecPROGRAMS distclean-compile \
distclean-tags distclean-depend distclean-generic \
clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-libexecPROGRAMS \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-depend maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-libexecPROGRAMS distclean-libexecPROGRAMS \
clean-libexecPROGRAMS maintainer-clean-libexecPROGRAMS \
uninstall-libexecPROGRAMS install-libexecPROGRAMS mostlyclean-compile \
distclean-compile clean-compile maintainer-clean-compile \
uninstall-binSCRIPTS install-binSCRIPTS tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags mostlyclean-depend \
distclean-depend clean-depend maintainer-clean-depend distdir info-am \
info dvi-am dvi check check-am installcheck-am installcheck \
install-exec-am install-exec install-data-am install-data install-am \
install uninstall-local uninstall-am uninstall all-redirect all-am all \
install-strip installdirs mostlyclean-generic distclean-generic \
clean-generic maintainer-clean-generic clean mostlyclean distclean \
maintainer-clean
all: stamp-eg $(AUXPROGS) igawk $(AUXAWK)
stamp-eg: $(srcdir)/../doc/gawk.texi
install-exec-hook: $(AUXAWK)
$(mkinstalldirs) $(DESTDIR)$(datadir)
for i in $(AUXAWK) $(srcdir)/eg/lib/*.awk ; do \
progname=`echo $$i | sed 's;.*/;;'` ; \
$(INSTALL_DATA) $$i $(DESTDIR)$(datadir)/$$progname ; \
done
# libexecdir and datadir are removed in the top level Makefile's uninstall
uninstall-local:
rm -fr $(DESTDIR)$(libexecdir)/* $(DESTDIR)$(datadir)/*
rm -f $(DESTDIR)$(bindir)/igawk
clean-local:
rm -f $(AUXAWK) igawk
stamp-eg: $(srcdir)/../doc/gawk.texi $(srcdir)/../doc/gawkinet.texi
rm -fr eg stamp-eg
../gawk -f $(srcdir)/extract.awk $(srcdir)/../doc/gawk.texi
$(AWK) -f $(srcdir)/extract.awk $(srcdir)/../doc/gawk.texi $(srcdir)/../doc/gawkinet.texi
@echo 'some makes are stupid and will not check a directory' > stamp-eg
@echo 'against a file, so this file is a place holder. gack.' >> stamp-eg
@ -72,28 +426,6 @@ group.awk: $(srcdir)/eg/lib/groupawk.in
(cd $(srcdir)/eg/lib ; \
sed 's;/usr/local/libexec/awk;$(libexecdir);' < groupawk.in) > group.awk
install: igawk $(AUXPROGS) $(AUXAWK)
$(INSTALL_PROGRAM) igawk $(bindir)/igawk
for i in $(AUXPROGS) ; do \
$(INSTALL_PROGRAM) $$i $(libexecdir)/$$i ; \
done
for i in $(AUXAWK) $(srcdir)/eg/lib/*.awk ; do \
progname=`echo $$i | sed 's;.*/;;'` ; \
$(INSTALL_DATA) $$i $(datadir)/$$progname ; \
done
# libexecdir and datadir are removed in the top level Makefile's uninstall
uninstall:
rm -fr $(libexecdir)/* $(datadir)/*
rm -f $(bindir)/igawk
clean:
rm -f $(AUXPROGS) $(AUXAWK) igawk *~
distclean: clean
rm -f Makefile
maintainer-clean: distclean
@echo "This command is intended for maintainers to use; it"
@echo "deletes files that may require special tools to rebuild."
rm -fr eg stamp-eg
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1,4 +1,6 @@
# assert --- assert that a condition is true. Otherwise exit.
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May, 1993

View File

@ -0,0 +1,16 @@
# bits2str --- turn a byte into readable 1's and 0's
function bits2str(bits, data, mask)
{
if (bits == 0)
return "0"
mask = 1
for (; bits != 0; bits = rshift(bits, 1))
data = (and(bits, mask) ? "1" : "0") data
while ((length(data) % 8) != 0)
data = "0" data
return data
}

View File

@ -0,0 +1,14 @@
# cliff_rand.awk --- generate Cliff random numbers
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# December 2000
BEGIN { _cliff_seed = 0.1 }
function cliff_rand()
{
_cliff_seed = (100 * log(_cliff_seed)) % 1
if (_cliff_seed < 0)
_cliff_seed = - _cliff_seed
return _cliff_seed
}

View File

@ -2,8 +2,8 @@
#
# user supplies beginfile() and endfile() functions
#
# Arnold Robbins, arnold@gnu.org, November 1992
# Public Domain
# Arnold Robbins, arnold@gnu.org, Public Domain
# November 1992
FNR == 1 {
if (_filename_ != "")

View File

@ -1,28 +1,26 @@
# getopt --- do C library getopt(3) function in awk
# getopt.awk --- do C library getopt(3) function in awk
#
# arnold@gnu.org
# Public domain
# Arnold Robbins, arnold@gnu.org, Public Domain
#
# Initial version: March, 1991
# Revised: May, 1993
# External variables:
# Optind -- index of ARGV for first non-option argument
# Optind -- index in ARGV of first non-option argument
# Optarg -- string value of argument to current option
# Opterr -- if non-zero, print our own diagnostic
# Opterr -- if nonzero, print our own diagnostic
# Optopt -- current option letter
# Returns
# Returns:
# -1 at end of options
# ? for unrecognized option
# <c> a character representing the current option
# Private Data
# _opti index in multi-flag option, e.g., -abc
function getopt(argc, argv, options, optl, thisopt, i)
# Private Data:
# _opti -- index in multi-flag option, e.g., -abc
function getopt(argc, argv, options, thisopt, i)
{
optl = length(options)
if (optl == 0) # no options given
if (length(options) == 0) # no options given
return -1
if (argv[Optind] == "--") { # all done

View File

@ -1,6 +1,8 @@
# gettimeofday --- get the time of day in a usable format
# gettimeofday.awk --- get the time of day in a usable format
#
# Arnold Robbins, arnold@gnu.org, Public Domain, May 1993
#
# Returns a string in the format of output of date(1)
# Populates the array argument time with individual values:
# time["second"] -- seconds (0 - 59)
@ -11,17 +13,17 @@
# time["month"] -- month of year (1 - 12)
# time["monthname"] -- name of the month
# time["shortmonth"] -- short name of the month
# time["year"] -- year within century (0 - 99)
# time["fullyear"] -- year with century (19xx or 20xx)
# time["year"] -- year modulo 100 (0 - 99)
# time["fullyear"] -- full year
# time["weekday"] -- day of week (Sunday = 0)
# time["altweekday"] -- day of week (Monday = 0)
# time["weeknum"] -- week number, Sunday first day
# time["altweeknum"] -- week number, Monday first day
# time["dayname"] -- name of weekday
# time["shortdayname"] -- short name of weekday
# time["yearday"] -- day of year (0 - 365)
# time["timezone"] -- abbreviation of timezone name
# time["ampm"] -- AM or PM designation
# time["weeknum"] -- week number, Sunday first day
# time["altweeknum"] -- week number, Monday first day
function gettimeofday(time, ret, now, i)
{
@ -32,8 +34,7 @@ function gettimeofday(time, ret, now, i)
ret = strftime("%a %b %d %H:%M:%S %Z %Y", now)
# clear out target array
for (i in time)
delete time[i]
delete time
# fill in values, force numeric values to be
# numeric by adding 0

View File

@ -2,9 +2,9 @@
* grcat.c
*
* Generate a printable version of the group database
*
* Arnold Robbins, arnold@gnu.org
* May 1993
*/
/*
* Arnold Robbins, arnold@gnu.org, May 1993
* Public Domain
*/

View File

@ -1,13 +1,17 @@
# group.awk --- functions for dealing with the group file
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
# Revised October 2000
BEGIN \
{
# Change to suit your system
_gr_awklib = "/usr/local/libexec/awk/"
}
function _gr_init( oldfs, oldrs, olddol0, grcat, n, a, i)
function _gr_init( oldfs, oldrs, olddol0, grcat,
using_fw, n, a, i)
{
if (_gr_inited)
return
@ -15,6 +19,7 @@ function _gr_init( oldfs, oldrs, olddol0, grcat, n, a, i)
oldfs = FS
oldrs = RS
olddol0 = $0
using_fw = (PROCINFO["FS"] == "FIELDWIDTHS")
FS = ":"
RS = "\n"
@ -43,6 +48,8 @@ function _gr_init( oldfs, oldrs, olddol0, grcat, n, a, i)
_gr_count = 0
_gr_inited++
FS = oldfs
if (using_fw)
FIELDWIDTHS = FIELDWIDTHS
RS = oldrs
$0 = olddol0
}

View File

@ -1,4 +1,5 @@
# join.awk --- join an array into a string
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993

View File

@ -0,0 +1,9 @@
function bindtextdomain(dir, domain)
{
return dir
}
function dcgettext(string, domain, category)
{
return string
}

View File

@ -1,5 +1,6 @@
# nextfile --- skip remaining records in current file
# correctly handle successive occurrences of the same file
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May, 1993

View File

@ -0,0 +1,17 @@
# noassign.awk --- library file to avoid the need for a
# special option that disables command-line assignments
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# October 1999
function disable_assigns(argc, argv, i)
{
for (i = 1; i < argc; i++)
if (argv[i] ~ /^[A-Za-z_][A-Za-z_0-9]*=.*/)
argv[i] = ("./" argv[i])
}
BEGIN {
if (No_command_assign)
disable_assigns(ARGC, ARGV)
}

View File

@ -1,16 +1,15 @@
# ord.awk --- do ord and chr
#
# Global identifiers:
# _ord_: numerical values indexed by characters
# _ord_init: function to initialize _ord_
#
# Arnold Robbins
# arnold@gnu.org
# Public Domain
# Arnold Robbins, arnold@gnu.org, Public Domain
# 16 January, 1992
# 20 July, 1992, revised
BEGIN { _ord_init() }
function _ord_init( low, high, i, t)
{
low = sprintf("%c", 7) # BEL is ascii 7
@ -37,18 +36,9 @@ function ord(str, c)
c = substr(str, 1, 1)
return _ord_[c]
}
function chr(c)
{
# force c to be numeric by adding 0
return sprintf("%c", c + 0)
}
#### test code ####
# BEGIN \
# {
# for (;;) {
# printf("enter a character: ")
# if (getline var <= 0)
# break
# printf("ord(%s) = %d\n", var, ord(var))
# }
# }

View File

@ -1,21 +1,26 @@
# passwd.awk --- access password file information
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
# Revised October 2000
BEGIN {
# tailor this to suit your system
_pw_awklib = "/usr/local/libexec/awk/"
}
function _pw_init( oldfs, oldrs, olddol0, pwcat)
function _pw_init( oldfs, oldrs, olddol0, pwcat, using_fw)
{
if (_pw_inited)
return
oldfs = FS
oldrs = RS
olddol0 = $0
using_fw = (PROCINFO["FS"] == "FIELDWIDTHS")
FS = ":"
RS = "\n"
pwcat = _pw_awklib "pwcat"
while ((pwcat | getline) > 0) {
_pw_byname[$1] = $0
@ -26,6 +31,8 @@ function _pw_init( oldfs, oldrs, olddol0, pwcat)
_pw_count = 0
_pw_inited = 1
FS = oldfs
if (using_fw)
FIELDWIDTHS = FIELDWIDTHS
RS = oldrs
$0 = olddol0
}

View File

@ -2,10 +2,9 @@
* pwcat.c
*
* Generate a printable version of the password database
*
* Arnold Robbins
* arnold@gnu.org
* May 1993
*/
/*
* Arnold Robbins, arnold@gnu.org, May 1993
* Public Domain
*/

View File

@ -0,0 +1,16 @@
# readable.awk --- library file to skip over unreadable files
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# October 2000
BEGIN {
for (i = 1; i < ARGC; i++) {
if (ARGV[i] ~ /^[A-Za-z_][A-Za-z0-9_]*=.*/ \
|| ARGV[i] == "-")
continue # assignment or standard input
else if ((getline junk < ARGV[i]) < 0) # unreadable
delete ARGV[i]
else
close(ARGV[i])
}
}

View File

@ -0,0 +1,20 @@
# rewind.awk --- rewind the current file and start over
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# September 2000
function rewind( i)
{
# shift remaining arguments up
for (i = ARGC; i > ARGIND; i--)
ARGV[i] = ARGV[i-1]
# make sure gawk knows to keep going
ARGC++
# make current file next to get done
ARGV[ARGIND+1] = FILENAME
# do it
nextfile
}

View File

@ -1,7 +1,7 @@
# round --- do normal rounding
#
# Arnold Robbins, arnold@gnu.org, August, 1996
# Public Domain
# Arnold Robbins, arnold@gnu.org, Public Domain
# August, 1996
function round(x, ival, aval, fraction)
{

View File

@ -0,0 +1,10 @@
{
if ($1 == "FIND")
regex = $2
else {
where = match($0, regex)
if (where != 0)
print "Match of", regex, "found at",
where, "in", $0
}
}

View File

@ -0,0 +1,9 @@
#!/bin/sh
MobAg=/tmp/MobileAgent.$$
# direct script to mobile agent file
cat > $MobAg
# execute agent concurrently
gawk -f $MobAg $MobAg > /dev/null &
# HTTP header, terminator and body
gawk 'BEGIN { print "\r\nAgent started" }'
rm $MobAg # delete script file of agent

View File

@ -0,0 +1,113 @@
# CGI Library and core of a web server
#
# Juergen Kahrs, Juergen.Kahrs@vr-web.de
# with Arnold Robbins, arnold@gnu.org
# September 2000
# Global arrays
# GETARG --- arguments to CGI GET command
# MENU --- menu items (path names)
# PARAM --- parameters of form x=y
# Optional variable MyHost contains host address
# Optional variable MyPort contains port number
# Needs TopHeader, TopDoc, TopFooter
# Sets MyPrefix, HttpService, Status, Reason
BEGIN {
if (MyHost == "") {
"uname -n" | getline MyHost
close("uname -n")
}
if (MyPort == 0) MyPort = 8080
HttpService = "/inet/tcp/" MyPort "/0/0"
MyPrefix = "http://" MyHost ":" MyPort
SetUpServer()
while ("awk" != "complex") {
# header lines are terminated this way
RS = ORS = "\r\n"
Status = 200 # this means OK
Reason = "OK"
Header = TopHeader
Document = TopDoc
Footer = TopFooter
if (GETARG["Method"] == "GET") {
HandleGET()
} else if (GETARG["Method"] == "HEAD") {
# not yet implemented
} else if (GETARG["Method"] != "") {
print "bad method", GETARG["Method"]
}
Prompt = Header Document Footer
print "HTTP/1.0", Status, Reason |& HttpService
print "Connection: Close" |& HttpService
print "Pragma: no-cache" |& HttpService
len = length(Prompt) + length(ORS)
print "Content-length:", len |& HttpService
print ORS Prompt |& HttpService
# ignore all the header lines
while ((HttpService |& getline) > 0)
continue
# stop talking to this client
close(HttpService)
# wait for new client request
HttpService |& getline
# do some logging
print systime(), strftime(), $0
CGI_setup($1, $2, $3)
}
}
function CGI_setup( method, uri, version, i)
{
delete GETARG
delete MENU
delete PARAM
GETARG["Method"] = method
GETARG["URI"] = uri
GETARG["Version"] = version
i = index(uri, "?")
if (i > 0) { # is there a "?" indicating a CGI request?
split(substr(uri, 1, i-1), MENU, "[/:]")
split(substr(uri, i+1), PARAM, "&")
for (i in PARAM) {
PARAM[i] = _CGI_decode(PARAM[i])
j = index(PARAM[i], "=")
GETARG[substr(PARAM[i], 1, j-1)] = \
substr(PARAM[i], j+1)
}
} else { # there is no "?", no need for splitting PARAMs
split(uri, MENU, "[/:]")
}
for (i in MENU) # decode characters in path
if (i > 4) # but not those in host name
MENU[i] = _CGI_decode(MENU[i])
}
function _CGI_decode(str, hexdigs, i, pre, code1, code2,
val, result)
{
hexdigs = "123456789abcdef"
i = index(str, "%")
if (i == 0) # no work to do
return str
do {
pre = substr(str, 1, i-1) # part before %xx
code1 = substr(str, i+1, 1) # first hex digit
code2 = substr(str, i+2, 1) # second hex digit
str = substr(str, i+3) # rest of string
code1 = tolower(code1)
code2 = tolower(code2)
val = index(hexdigs, code1) * 16 \
+ index(hexdigs, code2)
result = result pre sprintf("%c", val)
i = index(str, "%")
} while (i != 0)
if (length(str) > 0)
result = result str
return result
}

View File

@ -0,0 +1,270 @@
function SetUpServer() {
SetUpEliza()
TopHeader = \
"<HTML><title>An HTTP-based System with GAWK</title>\
<HEAD><META HTTP-EQUIV=\"Content-Type\"\
CONTENT=\"text/html; charset=iso-8859-1\"></HEAD>\
<BODY BGCOLOR=\"#ffffff\" TEXT=\"#000000\"\
LINK=\"#0000ff\" VLINK=\"#0000ff\"\
ALINK=\"#0000ff\"> <A NAME=\"top\">"
TopDoc = "\
<h2>Please choose one of the following actions:</h2>\
<UL>\
<LI>\
<A HREF=" MyPrefix "/AboutServer>About this server</A>\
</LI><LI>\
<A HREF=" MyPrefix "/AboutELIZA>About Eliza</A></LI>\
<LI>\
<A HREF=" MyPrefix \
"/StartELIZA>Start talking to Eliza</A></LI></UL>"
TopFooter = "</BODY></HTML>"
}
function HandleGET() {
# A real HTTP server would treat some parts of the URI as a file name.
# We take parts of the URI as menu choices and go on accordingly.
if(MENU[2] == "AboutServer") {
Document = "This is not a CGI script.\
This is an httpd, an HTML file, and a CGI script all \
in one GAWK script. It needs no separate www-server, \
no installation, and no root privileges.\
<p>To run it, do this:</p><ul>\
<li> start this script with \"gawk -f httpserver.awk\",</li>\
<li> and on the same host let your www browser open location\
\"http://localhost:8080\"</li>\
</ul>\<p>\ Details of HTTP come from:</p><ul>\
<li>Hethmon: Illustrated Guide to HTTP</p>\
<li>RFC 2068</li></ul><p>JK 14.9.1997</p>"
} else if (MENU[2] == "AboutELIZA") {
Document = "This is an implementation of the famous ELIZA\
program by Joseph Weizenbaum. It is written in GAWK and\
/bin/sh: expad: command not found
} else if (MENU[2] == "StartELIZA") {
gsub(/\+/, " ", GETARG["YouSay"])
# Here we also have to substitute coded special characters
Document = "<form method=GET>" \
"<h3>" ElizaSays(GETARG["YouSay"]) "</h3>\
<p><input type=text name=YouSay value=\"\" size=60>\
<br><input type=submit value=\"Tell her about it\"></p></form>"
}
}
function ElizaSays(YouSay) {
if (YouSay == "") {
cost = 0
answer = "HI, IM ELIZA, TELL ME YOUR PROBLEM"
} else {
q = toupper(YouSay)
gsub("'", "", q)
if(q == qold) {
answer = "PLEASE DONT REPEAT YOURSELF !"
} else {
if (index(q, "SHUT UP") > 0) {
answer = "WELL, PLEASE PAY YOUR BILL. ITS EXACTLY ... $"\
int(100*rand()+30+cost/100)
} else {
qold = q
w = "-" # no keyword recognized yet
for (i in k) { # search for keywords
if (index(q, i) > 0) {
w = i
break
}
}
if (w == "-") { # no keyword, take old subject
w = wold
subj = subjold
} else { # find subject
subj = substr(q, index(q, w) + length(w)+1)
wold = w
subjold = subj # remember keyword and subject
}
for (i in conj)
gsub(i, conj[i], q) # conjugation
# from all answers to this keyword, select one randomly
answer = r[indices[int(split(k[w], indices) * rand()) + 1]]
# insert subject into answer
gsub("_", subj, answer)
}
}
}
cost += length(answer) # for later payment : 1 cent per character
return answer
}
function SetUpEliza() {
srand()
wold = "-"
subjold = " "
# table for conjugation
conj[" ARE " ] = " AM "
conj["WERE " ] = "WAS "
conj[" YOU " ] = " I "
conj["YOUR " ] = "MY "
conj[" IVE " ] =\
conj[" I HAVE " ] = " YOU HAVE "
conj[" YOUVE " ] =\
conj[" YOU HAVE "] = " I HAVE "
conj[" IM " ] =\
conj[" I AM " ] = " YOU ARE "
conj[" YOURE " ] =\
conj[" YOU ARE " ] = " I AM "
# table of all answers
r[1] = "DONT YOU BELIEVE THAT I CAN _"
r[2] = "PERHAPS YOU WOULD LIKE TO BE ABLE TO _ ?"
r[3] = "YOU WANT ME TO BE ABLE TO _ ?"
r[4] = "PERHAPS YOU DONT WANT TO _ "
r[5] = "DO YOU WANT TO BE ABLE TO _ ?"
r[6] = "WHAT MAKES YOU THINK I AM _ ?"
r[7] = "DOES IT PLEASE YOU TO BELIEVE I AM _ ?"
r[8] = "PERHAPS YOU WOULD LIKE TO BE _ ?"
r[9] = "DO YOU SOMETIMES WISH YOU WERE _ ?"
r[10] = "DONT YOU REALLY _ ?"
r[11] = "WHY DONT YOU _ ?"
r[12] = "DO YOU WISH TO BE ABLE TO _ ?"
r[13] = "DOES THAT TROUBLE YOU ?"
r[14] = "TELL ME MORE ABOUT SUCH FEELINGS"
r[15] = "DO YOU OFTEN FEEL _ ?"
r[16] = "DO YOU ENJOY FEELING _ ?"
r[17] = "DO YOU REALLY BELIEVE I DONT _ ?"
r[18] = "PERHAPS IN GOOD TIME I WILL _ "
r[19] = "DO YOU WANT ME TO _ ?"
r[20] = "DO YOU THINK YOU SHOULD BE ABLE TO _ ?"
r[21] = "WHY CANT YOU _ ?"
r[22] = "WHY ARE YOU INTERESTED IN WHETHER OR NOT I AM _ ?"
r[23] = "WOULD YOU PREFER IF I WERE NOT _ ?"
r[24] = "PERHAPS IN YOUR FANTASIES I AM _ "
r[25] = "HOW DO YOU KNOW YOU CANT _ ?"
r[26] = "HAVE YOU TRIED ?"
r[27] = "PERHAPS YOU CAN NOW _ "
r[28] = "DID YOU COME TO ME BECAUSE YOU ARE _ ?"
r[29] = "HOW LONG HAVE YOU BEEN _ ?"
r[30] = "DO YOU BELIEVE ITS NORMAL TO BE _ ?"
r[31] = "DO YOU ENJOY BEING _ ?"
r[32] = "WE WERE DISCUSSING YOU -- NOT ME"
r[33] = "Oh, I _"
r[34] = "YOU'RE NOT REALLY TALKING ABOUT ME, ARE YOU ?"
r[35] = "WHAT WOULD IT MEAN TO YOU, IF YOU GOT _ ?"
r[36] = "WHY DO YOU WANT _ ?"
r[37] = "SUPPOSE YOU SOON GOT _"
r[38] = "WHAT IF YOU NEVER GOT _ ?"
r[39] = "I SOMETIMES ALSO WANT _"
r[40] = "WHY DO YOU ASK ?"
r[41] = "DOES THAT QUESTION INTEREST YOU ?"
r[42] = "WHAT ANSWER WOULD PLEASE YOU THE MOST ?"
r[43] = "WHAT DO YOU THINK ?"
r[44] = "ARE SUCH QUESTIONS IN YOUR MIND OFTEN ?"
r[45] = "WHAT IS IT THAT YOU REALLY WANT TO KNOW ?"
r[46] = "HAVE YOU ASKED ANYONE ELSE ?"
r[47] = "HAVE YOU ASKED SUCH QUESTIONS BEFORE ?"
r[48] = "WHAT ELSE COMES TO MIND WHEN YOU ASK THAT ?"
r[49] = "NAMES DON'T INTEREST ME"
r[50] = "I DONT CARE ABOUT NAMES -- PLEASE GO ON"
r[51] = "IS THAT THE REAL REASON ?"
r[52] = "DONT ANY OTHER REASONS COME TO MIND ?"
r[53] = "DOES THAT REASON EXPLAIN ANYTHING ELSE ?"
r[54] = "WHAT OTHER REASONS MIGHT THERE BE ?"
r[55] = "PLEASE DON'T APOLOGIZE !"
r[56] = "APOLOGIES ARE NOT NECESSARY"
r[57] = "WHAT FEELINGS DO YOU HAVE WHEN YOU APOLOGIZE ?"
r[58] = "DON'T BE SO DEFENSIVE"
r[59] = "WHAT DOES THAT DREAM SUGGEST TO YOU ?"
r[60] = "DO YOU DREAM OFTEN ?"
r[61] = "WHAT PERSONS APPEAR IN YOUR DREAMS ?"
r[62] = "ARE YOU DISTURBED BY YOUR DREAMS ?"
r[63] = "HOW DO YOU DO ... PLEASE STATE YOUR PROBLEM"
r[64] = "YOU DON'T SEEM QUITE CERTAIN"
r[65] = "WHY THE UNCERTAIN TONE ?"
r[66] = "CAN'T YOU BE MORE POSITIVE ?"
r[67] = "YOU AREN'T SURE ?"
r[68] = "DON'T YOU KNOW ?"
r[69] = "WHY NO _ ?"
r[70] = "DON'T SAY NO, IT'S ALWAYS SO NEGATIVE"
r[71] = "WHY NOT ?"
r[72] = "ARE YOU SURE ?"
r[73] = "WHY NO ?"
r[74] = "WHY ARE YOU CONCERNED ABOUT MY _ ?"
r[75] = "WHAT ABOUT YOUR OWN _ ?"
r[76] = "CAN'T YOU THINK ABOUT A SPECIFIC EXAMPLE ?"
r[77] = "WHEN ?"
r[78] = "WHAT ARE YOU THINKING OF ?"
r[79] = "REALLY, ALWAYS ?"
r[80] = "DO YOU REALLY THINK SO ?"
r[81] = "BUT YOU ARE NOT SURE YOU _ "
r[82] = "DO YOU DOUBT YOU _ ?"
r[83] = "IN WHAT WAY ?"
r[84] = "WHAT RESEMBLANCE DO YOU SEE ?"
r[85] = "WHAT DOES THE SIMILARITY SUGGEST TO YOU ?"
r[86] = "WHAT OTHER CONNECTION DO YOU SEE ?"
r[87] = "COULD THERE REALLY BE SOME CONNECTIONS ?"
r[88] = "HOW ?"
r[89] = "YOU SEEM QUITE POSITIVE"
r[90] = "ARE YOU SURE ?"
r[91] = "I SEE"
r[92] = "I UNDERSTAND"
r[93] = "WHY DO YOU BRING UP THE TOPIC OF FRIENDS ?"
r[94] = "DO YOUR FRIENDS WORRY YOU ?"
r[95] = "DO YOUR FRIENDS PICK ON YOU ?"
r[96] = "ARE YOU SURE YOU HAVE ANY FRIENDS ?"
r[97] = "DO YOU IMPOSE ON YOUR FRIENDS ?"
r[98] = "PERHAPS YOUR LOVE FOR FRIENDS WORRIES YOU"
r[99] = "DO COMPUTERS WORRY YOU ?"
r[100] = "ARE YOU TALKING ABOUT ME IN PARTICULAR ?"
r[101] = "ARE YOU FRIGHTENED BY MACHINES ?"
r[102] = "WHY DO YOU MENTION COMPUTERS ?"
r[103] = "WHAT DO YOU THINK MACHINES HAVE TO DO WITH YOUR PROBLEMS ?"
r[104] = "DON'T YOU THINK COMPUTERS CAN HELP PEOPLE ?"
r[105] = "WHAT IS IT ABOUT MACHINES THAT WORRIES YOU ?"
r[106] = "SAY, DO YOU HAVE ANY PSYCHOLOGICAL PROBLEMS ?"
r[107] = "WHAT DOES THAT SUGGEST TO YOU ?"
r[108] = "I SEE"
r[109] = "IM NOT SURE I UNDERSTAND YOU FULLY"
r[110] = "COME COME ELUCIDATE YOUR THOUGHTS"
r[111] = "CAN YOU ELABORATE ON THAT ?"
r[112] = "THAT IS QUITE INTERESTING"
r[113] = "WHY DO YOU HAVE PROBLEMS WITH MONEY ?"
r[114] = "DO YOU THINK MONEY IS EVERYTHING ?"
r[115] = "ARE YOU SURE THAT MONEY IS THE PROBLEM ?"
r[116] = "I THINK WE WANT TO TALK ABOUT YOU, NOT ABOUT ME"
r[117] = "WHAT'S ABOUT ME ?"
r[118] = "WHY DO YOU ALWAYS BRING UP MY NAME ?"
# table for looking up answers that
# fit to a certain keyword
k["CAN YOU"] = "1 2 3"
k["CAN I"] = "4 5"
k["YOU ARE"] =\
k["YOURE"] = "6 7 8 9"
k["I DONT"] = "10 11 12 13"
k["I FEEL"] = "14 15 16"
k["WHY DONT YOU"] = "17 18 19"
k["WHY CANT I"] = "20 21"
k["ARE YOU"] = "22 23 24"
k["I CANT"] = "25 26 27"
k["I AM"] =\
k["IM "] = "28 29 30 31"
k["YOU "] = "32 33 34"
k["I WANT"] = "35 36 37 38 39"
k["WHAT"] =\
k["HOW"] =\
k["WHO"] =\
k["WHERE"] =\
k["WHEN"] =\
k["WHY"] = "40 41 42 43 44 45 46 47 48"
k["NAME"] = "49 50"
k["CAUSE"] = "51 52 53 54"
k["SORRY"] = "55 56 57 58"
k["DREAM"] = "59 60 61 62"
k["HELLO"] =\
k["HI "] = "63"
k["MAYBE"] = "64 65 66 67 68"
k[" NO "] = "69 70 71 72 73"
k["YOUR"] = "74 75"
k["ALWAYS"] = "76 77 78 79"
k["THINK"] = "80 81 82"
k["LIKE"] = "83 84 85 86 87 88 89"
k["YES"] = "90 91 92"
k["FRIEND"] = "93 94 95 96 97 98"
k["COMPUTER"] = "99 100 101 102 103 104 105"
k["-"] = "106 107 108 109 110 111 112"
k["MONEY"] = "113 114 115"
k["ELIZA"] = "116 117 118"
}

View File

@ -0,0 +1,7 @@
BEGIN {
NetService = "/inet/tcp/0/localhost/finger"
print "var{name}" |& NetService
while ((NetService |& getline) > 0)
print $0
close(NetService)
}

View File

@ -0,0 +1,24 @@
BEGIN {
if (ARGC != 2) {
print "GETURL - retrieve Web page via HTTP 1.0"
print "IN:\n the URL as a command-line parameter"
print "PARAM(S):\n -v Proxy=MyProxy"
print "OUT:\n the page content on stdout"
print " the page header on stderr"
print "JK 16.05.1997"
print "ADR 13.08.2000"
exit
}
URL = ARGV[1]; ARGV[1] = ""
if (Proxy == "") Proxy = "127.0.0.1"
if (ProxyPort == 0) ProxyPort = 80
if (Method == "") Method = "GET"
HttpService = "/inet/tcp/0/" Proxy "/" ProxyPort
ORS = RS = "\r\n\r\n"
print Method " " URL " HTTP/1.0" |& HttpService
HttpService |& getline Header
print Header > "/dev/stderr"
while ((HttpService |& getline) > 0)
printf "%s", $0
close(HttpService)
}

View File

@ -0,0 +1,14 @@
BEGIN {
RS = ORS = "\r\n"
HttpService = "/inet/tcp/8080/0/0"
Hello = "<HTML><HEAD>" \
"<TITLE>A Famous Greeting</TITLE></HEAD>" \
"<BODY><H1>Hello, world</H1></BODY></HTML>"
Len = length(Hello) + length(ORS)
print "HTTP/1.0 200 OK" |& HttpService
print "Content-Length: " Len ORS |& HttpService
print Hello |& HttpService
while ((HttpService |& getline) > 0)
continue;
close(HttpService)
}

View File

@ -0,0 +1,73 @@
function SetUpServer() {
TopHeader = "<HTML><title>Walk through a maze</title>"
TopDoc = "\
<h2>Please choose one of the following actions:</h2>\
<UL>\
<LI><A HREF=" MyPrefix "/AboutServer>About this server</A>\
<LI><A HREF=" MyPrefix "/VRMLtest>Watch a simple VRML scene</A>\
</UL>"
TopFooter = "</HTML>"
srand()
}
function HandleGET() {
if (MENU[2] == "AboutServer") {
Document = "If your browser has a VRML 2 plugin,\
this server shows you a simple VRML scene."
} else if (MENU[2] == "VRMLtest") {
XSIZE = YSIZE = 11 # initially, everything is wall
for (y = 0; y < YSIZE; y++)
for (x = 0; x < XSIZE; x++)
Maze[x, y] = "#"
delete Maze[0, 1] # entry is not wall
delete Maze[XSIZE-1, YSIZE-2] # exit is not wall
MakeMaze(1, 1)
Document = "\
#VRML V2.0 utf8\n\
Group {\n\
children [\n\
PointLight {\n\
ambientIntensity 0.2\n\
color 0.7 0.7 0.7\n\
location 0.0 8.0 10.0\n\
}\n\
DEF B1 Background {\n\
skyColor [0 0 0, 1.0 1.0 1.0 ]\n\
skyAngle 1.6\n\
groundColor [1 1 1, 0.8 0.8 0.8, 0.2 0.2 0.2 ]\n\
groundAngle [ 1.2 1.57 ]\n\
}\n\
DEF Wall Shape {\n\
geometry Box {size 1 1 1}\n\
appearance Appearance { material Material { diffuseColor 0 0 1 } }\n\
}\n\
DEF Entry Viewpoint {\n\
position 0.5 1.0 5.0\n\
orientation 0.0 0.0 -1.0 0.52\n\
}\n"
for (i in Maze) {
split(i, t, SUBSEP)
Document = Document " Transform { translation "
Document = Document t[1] " 0 -" t[2] " children USE Wall }\n"
}
Document = Document " ] # end of group for world\n}"
Reason = "OK" ORS "Content-type: model/vrml"
Header = Footer = ""
}
}
function MakeMaze(x, y) {
delete Maze[x, y] # here we are, we have no wall here
p = 0 # count unvisited fields in all directions
if (x-2 SUBSEP y in Maze) d[p++] = "-x"
if (x SUBSEP y-2 in Maze) d[p++] = "-y"
if (x+2 SUBSEP y in Maze) d[p++] = "+x"
if (x SUBSEP y+2 in Maze) d[p++] = "+y"
if (p>0) { # if there are univisited fields, go there
p = int(p*rand()) # choose one unvisited field at random
if (d[p] == "-x") { delete Maze[x - 1, y]; MakeMaze(x - 2, y)
} else if (d[p] == "-y") { delete Maze[x, y - 1]; MakeMaze(x, y - 2)
} else if (d[p] == "+x") { delete Maze[x + 1, y]; MakeMaze(x + 2, y)
} else if (d[p] == "+y") { delete Maze[x, y + 1]; MakeMaze(x, y + 2)
} # we are back from recursion
MakeMaze(x, y); # try again while there are unvisited fields
}
}

View File

@ -0,0 +1,72 @@
BEGIN {
if (ARGC != 2) {
print "MOBAG - a simple mobile agent"
print "CALL:\n gawk -f mobag.awk mobag.awk"
print "IN:\n the name of this script as a command-line parameter"
print "PARAM:\n -v MyOrigin=myhost.com"
print "OUT:\n the result on stdout"
print "JK 29.03.1998 01.04.1998"
exit
}
if (MyOrigin == "") {
"uname -n" | getline MyOrigin
close("uname -n")
}
}
#ReadMySelf
/^function / { FUNC = $2 }
/^END/ || /^#ReadMySelf/ { FUNC = $1 }
FUNC != "" { MOBFUN[FUNC] = MOBFUN[FUNC] RS $0 }
(FUNC != "") && (/^}/ || /^#EndOfMySelf/) \
{ FUNC = "" }
#EndOfMySelf
function migrate(Destination, MobCode, Label) {
MOBVAR["Label"] = Label
MOBVAR["Destination"] = Destination
RS = ORS = "\r\n"
HttpService = "/inet/tcp/0/" Destination
for (i in MOBFUN)
MobCode = (MobCode "\n" MOBFUN[i])
MobCode = MobCode "\n\nBEGIN {"
for (i in MOBVAR)
MobCode = (MobCode "\n MOBVAR[\"" i "\"] = \"" MOBVAR[i] "\"")
MobCode = MobCode "\n}\n"
print "POST /cgi-bin/PostAgent.sh HTTP/1.0" |& HttpService
print "Content-length:", length(MobCode) ORS |& HttpService
printf "%s", MobCode |& HttpService
while ((HttpService |& getline) > 0)
print $0
close(HttpService)
}
END {
if (ARGC != 2) exit # stop when called with wrong parameters
if (MyOrigin != "") # is this the originating host?
MyInit() # if so, initialize the application
else # we are on a host with migrated data
MyJob() # so we do our job
}
function MyInit() {
MOBVAR["MyOrigin"] = MyOrigin
MOBVAR["Machines"] = "localhost/80 max/80 moritz/80 castor/80"
split(MOBVAR["Machines"], Machines) # which host is the first?
migrate(Machines[1], "", "") # go to the first host
while (("/inet/tcp/8080/0/0" |& getline) > 0) # wait for result
print $0 # print result
close("/inet/tcp/8080/0/0")
}
function MyJob() {
# forget this host
sub(MOBVAR["Destination"], "", MOBVAR["Machines"])
MOBVAR["Result"]=MOBVAR["Result"] SUBSEP SUBSEP MOBVAR["Destination"] ":"
while (("who" | getline) > 0) # who is logged in?
MOBVAR["Result"] = MOBVAR["Result"] SUBSEP $0
close("who")
if (index(MOBVAR["Machines"], "/") > 0) { # any more machines to visit?
split(MOBVAR["Machines"], Machines) # which host is next?
migrate(Machines[1], "", "") # go there
} else { # no more machines
gsub(SUBSEP, "\n", MOBVAR["Result"]) # send result to origin
print MOBVAR["Result"] |& "/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080"
close("/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080")
}
}

View File

@ -0,0 +1,18 @@
BEGIN {
RS = ORS = "\r\n"
if (MyPort == 0) MyPort = 8080
HttpService = "/inet/tcp/" MyPort "/0/0"
Hello = "<HTML><HEAD><TITLE>Out Of Service</TITLE>" \
"</HEAD><BODY><H1>" \
"This site is temporarily out of service." \
"</H1></BODY></HTML>"
Len = length(Hello) + length(ORS)
while ("awk" != "complex") {
print "HTTP/1.0 200 OK" |& HttpService
print "Content-Length: " Len ORS |& HttpService
print Hello |& HttpService
while ((HttpService |& getline) > 0)
continue;
close(HttpService)
}
}

View File

@ -0,0 +1,11 @@
{ request = request "\n" $0 }
END {
BLASTService = "/inet/tcp/0/www.ncbi.nlm.nih.gov/80"
printf "POST /cgi-bin/BLAST/nph-blast_report HTTP/1.0\n" |& BLASTService
printf "Content-Length: " length(request) "\n\n" |& BLASTService
printf request |& BLASTService
while ((BLASTService |& getline) > 0)
print $0
close(BLASTService)
}

View File

@ -0,0 +1,7 @@
PROGRAM blastn
DATALIB month
EXPECT 0.75
BEGIN
>GAWK310 the gawking gene GNU AWK
tgcttggctgaggagccataggacgagagcttcctggtgaagtgtgtttcttgaaatcat
caccaccatggacagcaaa

View File

@ -0,0 +1,9 @@
Sequences producing significant alignments: (bits) Value
gb|AC021182.14|AC021182 Homo sapiens chromosome 7 clone RP11-733... 38 0.20
gb|AC021056.12|AC021056 Homo sapiens chromosome 3 clone RP11-115... 38 0.20
emb|AL160278.10|AL160278 Homo sapiens chromosome 9 clone RP11-57... 38 0.20
emb|AL391139.11|AL391139 Homo sapiens chromosome X clone RP11-35... 38 0.20
emb|AL365192.6|AL365192 Homo sapiens chromosome 6 clone RP3-421H... 38 0.20
emb|AL138812.9|AL138812 Homo sapiens chromosome 11 clone RP1-276... 38 0.20
gb|AC073881.3|AC073881 Homo sapiens chromosome 15 clone CTD-2169... 38 0.20

View File

@ -0,0 +1,54 @@
function SetUpServer() {
TopHeader = "<HTML><title>Remote Configuration</title>"
TopDoc = "<BODY>\
<h2>Please choose one of the following actions:</h2>\
<UL>\
<LI><A HREF=" MyPrefix "/AboutServer>About this server</A></LI>\
<LI><A HREF=" MyPrefix "/ReadConfig>Read Configuration</A></LI>\
<LI><A HREF=" MyPrefix "/CheckConfig>Check Configuration</A></LI>\
<LI><A HREF=" MyPrefix "/ChangeConfig>Change Configuration</A></LI>\
<LI><A HREF=" MyPrefix "/SaveConfig>Save Configuration</A></LI>\
</UL>"
TopFooter = "</BODY></HTML>"
if (ConfigFile == "") ConfigFile = "config.asc"
}
function HandleGET() {
if(MENU[2] == "AboutServer") {
Document = "This is a GUI for remote configuration of an\
embedded system. It is is implemented as one GAWK script."
} else if (MENU[2] == "ReadConfig") {
RS = "\n"
while ((getline < ConfigFile) > 0)
config[$1] = $2;
close(ConfigFile)
RS = "\r\n"
Document = "Configuration has been read."
} else if (MENU[2] == "CheckConfig") {
Document = "<TABLE BORDER=1 CELLPADDING=5>"
for (i in config)
Document = Document "<TR><TD>" i "</TD>" \
"<TD>" config[i] "</TD></TR>"
Document = Document "</TABLE>"
} else if (MENU[2] == "ChangeConfig") {
if ("Param" in GETARG) { # any parameter to set?
if (GETARG["Param"] in config) { # is parameter valid?
config[GETARG["Param"]] = GETARG["Value"]
Document = (GETARG["Param"] " = " GETARG["Value"] ".")
} else {
Document = "Parameter <b>" GETARG["Param"] "</b> is invalid."
}
} else {
Document = "<FORM method=GET><h4>Change one parameter</h4>\
<TABLE BORDER CELLPADDING=5>\
<TR><TD>Parameter</TD><TD>Value</TD></TR>\
<TR><TD><input type=text name=Param value=\"\" size=20></TD>\
<TD><input type=text name=Value value=\"\" size=40></TD>\
</TR></TABLE><input type=submit value=\"Set\"></FORM>"
}
} else if (MENU[2] == "SaveConfig") {
for (i in config)
printf("%s %s\n", i, config[i]) > ConfigFile
close(ConfigFile)
Document = "Configuration has been saved."
}
}

View File

@ -0,0 +1,85 @@
function SetUpServer() {
TopHeader = "<HTML><title>Statistics with GAWK</title>"
TopDoc = "<BODY>\
<h2>Please choose one of the following actions:</h2>\
<UL>\
<LI><A HREF=" MyPrefix "/AboutServer>About this server</A></LI>\
<LI><A HREF=" MyPrefix "/EnterParameters>Enter Parameters</A></LI>\
</UL>"
TopFooter = "</BODY></HTML>"
GnuPlot = "gnuplot 2>&1"
m1=m2=0; v1=v2=1; n1=n2=10
}
function HandleGET() {
if(MENU[2] == "AboutServer") {
Document = "This is a GUI for a statistical computation.\
It compares means and variances of two distributions.\
It is implemented as one GAWK script and uses GNUPLOT."
} else if (MENU[2] == "EnterParameters") {
Document = ""
if ("m1" in GETARG) { # are there parameters to compare?
Document = Document "<SCRIPT LANGUAGE=\"JavaScript\">\
setTimeout(\"window.open(\\\"" MyPrefix "/Image" systime()\
"\\\",\\\"dist\\\", \\\"status=no\\\");\", 1000); </SCRIPT>"
m1 = GETARG["m1"]; v1 = GETARG["v1"]; n1 = GETARG["n1"]
m2 = GETARG["m2"]; v2 = GETARG["v2"]; n2 = GETARG["n2"]
t = (m1-m2)/sqrt(v1/n1+v2/n2)
df = (v1/n1+v2/n2)*(v1/n1+v2/n2)/((v1/n1)*(v1/n1)/(n1-1) \
+ (v2/n2)*(v2/n2) /(n2-1))
if (v1>v2) {
f = v1/v2
df1 = n1 - 1
df2 = n2 - 1
} else {
f = v2/v1
df1 = n2 - 1
df2 = n1 - 1
}
print "pt=ibeta(" df/2 ",0.5," df/(df+t*t) ")" |& GnuPlot
print "pF=2.0*ibeta(" df2/2 "," df1/2 "," \
df2/(df2+df1*f) ")" |& GnuPlot
print "print pt, pF" |& GnuPlot
RS="\n"; GnuPlot |& getline; RS="\r\n" # $1 is pt, $2 is pF
print "invsqrt2pi=1.0/sqrt(2.0*pi)" |& GnuPlot
print "nd(x)=invsqrt2pi/sd*exp(-0.5*((x-mu)/sd)**2)" |& GnuPlot
print "set term png small color" |& GnuPlot
#print "set term postscript color" |& GnuPlot
#print "set term gif medium size 320,240" |& GnuPlot
print "set yrange[-0.3:]" |& GnuPlot
print "set label 'p(m1=m2) =" $1 "' at 0,-0.1 left" |& GnuPlot
print "set label 'p(v1=v2) =" $2 "' at 0,-0.2 left" |& GnuPlot
print "plot mu=" m1 ",sd=" sqrt(v1) ", nd(x) title 'sample 1',\
mu=" m2 ",sd=" sqrt(v2) ", nd(x) title 'sample 2'" |& GnuPlot
print "quit" |& GnuPlot
GnuPlot |& getline Image
while ((GnuPlot |& getline) > 0)
Image = Image RS $0
close(GnuPlot)
}
Document = Document "\
<h3>Do these samples have the same Gaussian distribution?</h3>\
<FORM METHOD=GET> <TABLE BORDER CELLPADDING=5>\
<TR>\
<TD>1. Mean </TD>
<TD><input type=text name=m1 value=" m1 " size=8></TD>\
<TD>1. Variance</TD>
<TD><input type=text name=v1 value=" v1 " size=8></TD>\
<TD>1. Count </TD>
<TD><input type=text name=n1 value=" n1 " size=8></TD>\
</TR><TR>\
<TD>2. Mean </TD>
<TD><input type=text name=m2 value=" m2 " size=8></TD>\
<TD>2. Variance</TD>
<TD><input type=text name=v2 value=" v2 " size=8></TD>\
<TD>2. Count </TD>
<TD><input type=text name=n2 value=" n2 " size=8></TD>\
</TR> <input type=submit value=\"Compute\">\
</TABLE></FORM><BR>"
} else if (MENU[2] ~ "Image") {
Reason = "OK" ORS "Content-type: image/png"
#Reason = "OK" ORS "Content-type: application/x-postscript"
#Reason = "OK" ORS "Content-type: image/gif"
Header = Footer = ""
Document = Image
}
}

View File

@ -0,0 +1,4 @@
Date,Open,High,Low,Close,Volume
9-Oct-00,22.75,22.75,21.375,22.375,7888500
6-Oct-00,23.8125,24.9375,21.5625,22,10701100
5-Oct-00,24.4375,24.625,23.125,23.50,5810300

View File

@ -0,0 +1,116 @@
function ReadQuotes() {
# Retrieve historical data for each ticker symbol
FS = ","
for (stock = 1; stock <= StockCount; stock++) {
URL = "http://chart.yahoo.com/table.csv?s=" name[stock] \
"&a=" month "&b=" day "&c=" year-1 \
"&d=" month "&e=" day "&f=" year \
"g=d&q=q&y=0&z=" name[stock] "&x=.csv"
printf("GET " URL " HTTP/1.0\r\n\r\n") |& YahooData
while ((YahooData |& getline) > 0) {
if (NF == 6 && $1 ~ /Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/) {
if (stock == 1)
days[++daycount] = $1;
quote[$1, stock] = $5
}
}
close(YahooData)
}
FS = " "
}
function CleanUp() {
# clean up time series; eliminate incomplete data sets
for (d = 1; d <= daycount; d++) {
for (stock = 1; stock <= StockCount; stock++)
if (! ((days[d], stock) in quote))
stock = StockCount + 10
if (stock > StockCount + 1)
continue
datacount++
for (stock = 1; stock <= StockCount; stock++)
data[datacount, stock] = int(0.5 + quote[days[d], stock])
}
delete quote
delete days
}
function Prediction() {
# Predict each ticker symbol by prolonging yesterday's trend
for (stock = 1; stock <= StockCount; stock++) {
if (data[1, stock] > data[2, stock]) {
predict[stock] = "up"
} else if (data[1, stock] < data[2, stock]) {
predict[stock] = "down"
} else {
predict[stock] = "neutral"
}
if ((data[1, stock] > data[2, stock]) && (data[2, stock] > data[3, stock]))
hot[stock] = 1
if ((data[1, stock] < data[2, stock]) && (data[2, stock] < data[3, stock]))
avoid[stock] = 1
}
# Do a plausibility check: how many predictions proved correct?
for (s = 1; s <= StockCount; s++) {
for (d = 1; d <= datacount-2; d++) {
if (data[d+1, s] > data[d+2, s]) {
UpCount++
} else if (data[d+1, s] < data[d+2, s]) {
DownCount++
} else {
NeutralCount++
}
if (((data[d, s] > data[d+1, s]) && (data[d+1, s] > data[d+2, s])) ||
((data[d, s] < data[d+1, s]) && (data[d+1, s] < data[d+2, s])) ||
((data[d, s] == data[d+1, s]) && (data[d+1, s] == data[d+2, s])))
CorrectCount++
}
}
}
function Report() {
# Generate report
report = "\nThis is your daily "
report = report "stock market report for "strftime("%A, %B %d, %Y")".\n"
report = report "Here are the predictions for today:\n\n"
for (stock = 1; stock <= StockCount; stock++)
report = report "\t" name[stock] "\t" predict[stock] "\n"
for (stock in hot) {
if (HotCount++ == 0)
report = report "\nThe most promising shares for today are these:\n\n"
report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \
tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock]) ".html\n"
}
for (stock in avoid) {
if (AvoidCount++ == 0)
report = report "\nThe stock shares to avoid today are these:\n\n"
report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \
tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock]) ".html\n"
}
report = report "\nThis sums up to " HotCount+0 " winners and " AvoidCount+0
report = report " losers. When using this kind\nof prediction scheme for"
report = report " the 12 months which lie behind us,\nwe get " UpCount
report = report " 'ups' and " DownCount " 'downs' and " NeutralCount
report = report " 'neutrals'. Of all\nthese " UpCount+DownCount+NeutralCount
report = report " predictions " CorrectCount " proved correct next day.\n"
report = report "A success rate of "\
int(100*CorrectCount/(UpCount+DownCount+NeutralCount)) "%.\n"
report = report "Random choice would have produced a 33% success rate.\n"
report = report "Disclaimer: Like every other prediction of the stock\n"
report = report "market, this report is, of course, complete nonsense.\n"
report = report "If you are stupid enough to believe these predictions\n"
report = report "you should visit a doctor who can treat your ailment."
}
function SendMail() {
# send report to customers
customer["uncle.scrooge@ducktown.gov"] = "Uncle Scrooge"
customer["more@utopia.org" ] = "Sir Thomas More"
customer["spinoza@denhaag.nl" ] = "Baruch de Spinoza"
customer["marx@highgate.uk" ] = "Karl Marx"
customer["keynes@the.long.run" ] = "John Maynard Keynes"
customer["bierce@devil.hell.org" ] = "Ambrose Bierce"
customer["laplace@paris.fr" ] = "Pierre Simon de Laplace"
for (c in customer) {
MailPipe = "mail -s 'Daily Stock Prediction Newsletter'" c
print "Good morning " customer[c] "," | MailPipe
print report "\n.\n" | MailPipe
close(MailPipe)
}
}

View File

@ -0,0 +1,12 @@
BEGIN {
CGI_setup("GET",
"http://www.gnu.org/cgi-bin/foo?p1=stuff&p2=stuff%26junk" \
"&percent=a %25 sign",
"1.0")
for (i in MENU)
printf "MENU[\"%s\"] = %s\n", i, MENU[i]
for (i in PARAM)
printf "PARAM[\"%s\"] = %s\n", i, PARAM[i]
for (i in GETARG)
printf "GETARG[\"%s\"] = %s\n", i, GETARG[i]
}

View File

@ -0,0 +1,28 @@
BEGIN {
if (ARGC != 2) {
print "URLCHK - check if URLs have changed"
print "IN:\n the file with URLs as a command-line parameter"
print " file contains URL, old length, new length"
print "PARAMS:\n -v Proxy=MyProxy -v ProxyPort=8080"
print "OUT:\n same as file with URLs"
print "JK 02.03.1998"
exit
}
URLfile = ARGV[1]; ARGV[1] = ""
if (Proxy != "") Proxy = " -v Proxy=" Proxy
if (ProxyPort != "") ProxyPort = " -v ProxyPort=" ProxyPort
while ((getline < URLfile) > 0)
Length[$1] = $3 + 0
close(URLfile) # now, URLfile is read in and can be updated
GetHeader = "gawk " Proxy ProxyPort " -v Method=\"HEAD\" -f geturl.awk "
for (i in Length) {
GetThisHeader = GetHeader i " 2>&1"
while ((GetThisHeader | getline) > 0)
if (toupper($0) ~ /CONTENT-LENGTH/) NewLength = $2 + 0
close(GetThisHeader)
print i, Length[i], NewLength > URLfile
if (Length[i] != NewLength) # report only changed URLs
print i, Length[i], NewLength
}
close(URLfile)
}

View File

@ -0,0 +1,6 @@
BEGIN { RS = "http://[#%&\\+\\-\\./0-9\\:;\\?A-Z_a-z\\~]*" }
RT != "" {
command = ("gawk -v Proxy=MyProxy -f geturl.awk " RT \
" > doc" NR ".html")
print command
}

View File

@ -1,4 +1,7 @@
# alarm --- set an alarm
# alarm.awk --- set an alarm
#
# Requires gettimeofday library function
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
@ -11,7 +14,8 @@ BEGIN \
usage2 = sprintf("\t(%s) time ::= hh:mm", ARGV[1])
if (ARGC < 2) {
print usage > "/dev/stderr"
print usage1 > "/dev/stderr"
print usage2 > "/dev/stderr"
exit 1
} else if (ARGC == 5) {
delay = ARGV[4] + 0
@ -37,7 +41,7 @@ BEGIN \
message = sprintf("\aIt is now %s!\a", ARGV[1])
else if (index(message, "\a") == 0)
message = "\a" message "\a"
# split up dest time
# split up alarm time
split(ARGV[1], atime, ":")
hour = atime[1] + 0 # force numeric
minute = atime[2] + 0 # force numeric

View File

@ -1,6 +1,6 @@
# awksed.awk --- do s/foo/bar/g using just print
# Thanks to Michael Brennan for the idea
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# August 1995

View File

@ -1,13 +1,16 @@
# cut.awk --- implement cut in awk
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
# Options:
# -f list Cut fields
# -d c Field delimiter character
# -c list Cut characters
# -f list Cut fields
# -d c Field delimiter character
# -c list Cut characters
#
# -s Suppress lines without the delimiter character
# -s Suppress lines without the delimiter
#
# Requires getopt and join library functions
function usage( e1, e2)
{
@ -122,7 +125,7 @@ function set_charlist( field, i, j, f, g, t,
nfields = j - 1
}
{
if (by_fields && suppress && $0 !~ FS)
if (by_fields && suppress && index($0, FS) != 0)
next
for (i = 1; i <= nfields; i++) {

View File

@ -1,10 +1,15 @@
# dupword --- find duplicate words in text
# dupword.awk --- find duplicate words in text
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# December 1991
# Revised October 2000
{
$0 = tolower($0)
gsub(/[^A-Za-z0-9 \t]/, "");
gsub(/[^[:alnum:][:blank:]]/, " ");
$0 = $0 # re-split
if (NF == 0)
next
if ($1 == prev)
printf("%s:%d: duplicate %s\n",
FILENAME, FNR, $1)

View File

@ -1,4 +1,5 @@
# egrep.awk --- simulate egrep in awk
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
@ -9,6 +10,8 @@
# -i ignore case
# -l print filenames only
# -e argument is pattern
#
# Requires getopt and file transition library functions
BEGIN {
while ((c = getopt(ARGC, ARGV, "ce:svil")) != -1) {
@ -69,18 +72,20 @@ function endfile(file)
if (! matches)
next
if (no_print && ! count_only)
nextfile
if (! count_only) {
if (no_print)
nextfile
if (filenames_only && ! count_only) {
print FILENAME
nextfile
if (filenames_only) {
print FILENAME
nextfile
}
if (do_filenames)
print FILENAME ":" $0
else
print
}
if (do_filenames && ! count_only)
print FILENAME ":" $0
else if (! count_only)
print
}
END \
{
@ -91,6 +96,7 @@ END \
function usage( e)
{
e = "Usage: egrep [-csvil] [-e pat] [files ...]"
e = e "\n\tegrep [-csvil] pat [files ...]"
print e > "/dev/stderr"
exit 1
}

View File

@ -1,6 +1,9 @@
# extract.awk --- extract files and run programs
# from texinfo files
# Arnold Robbins, arnold@gnu.org, Public Domain, May 1993
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
# Revised September 2000
BEGIN { IGNORECASE = 1 }
@ -41,6 +44,8 @@ BEGIN { IGNORECASE = 1 }
break
else if (line ~ /^@(end[ \t]+)?group/)
continue
else if (line ~ /^@c(omment+)?[ \t]+/)
continue
if (index(line, "@") == 0) {
print line > curfile
continue
@ -58,9 +63,8 @@ BEGIN { IGNORECASE = 1 }
print join(a, 1, n, SUBSEP) > curfile
}
}
function unexpected_eof()
{
printf("%s:%d: unexpected EOF or error\n", \
function unexpected_eof() {
printf("%s:%d: unexpected EOF or error\n",
FILENAME, FNR) > "/dev/stderr"
exit 1
}

View File

@ -0,0 +1,7 @@
BEGIN {
TEXTDOMAIN = "guide"
bindtextdomain(".") # for testing
print _"Don't Panic"
print _"The Answer Is", 42
print "Pardon me, Zaphod who?"
}

View File

@ -1,8 +1,9 @@
# histsort.awk --- compact a shell history file
# Thanks to Byron Rakitzis for the general idea
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
# Thanks to Byron Rakitzis for the general idea
{
if (data[$0]++ == 0)
lines[++count] = $0

View File

@ -1,6 +1,10 @@
# id.awk --- implement id in awk
#
# Requires user and group library functions
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
# Revised February 1996
# output is:
# uid=12(foo) euid=34(bar) gid=3(baz) \
@ -8,17 +12,10 @@
BEGIN \
{
if ((getline < "/dev/user") < 0) {
err = "id: no /dev/user support - cannot run"
print err > "/dev/stderr"
exit 1
}
close("/dev/user")
uid = $1
euid = $2
gid = $3
egid = $4
uid = PROCINFO["uid"]
euid = PROCINFO["euid"]
gid = PROCINFO["gid"]
egid = PROCINFO["egid"]
printf("uid=%d", uid)
pw = getpwuid(uid)
@ -52,18 +49,19 @@ BEGIN \
}
}
if (NF > 4) {
printf(" groups=");
for (i = 5; i <= NF; i++) {
printf("%d", $i)
pw = getgrgid($i)
if (pw != "") {
split(pw, a, ":")
printf("(%s)", a[1])
}
if (i < NF)
printf(",")
for (i = 1; ("group" i) in PROCINFO; i++) {
if (i == 1)
printf(" groups=")
group = PROCINFO["group" i]
printf("%d", group)
pw = getgrgid(group)
if (pw != "") {
split(pw, a, ":")
printf("(%s)", a[1])
}
if (("group" (i+1)) in PROCINFO)
printf(",")
}
print ""
}

View File

@ -1,6 +1,6 @@
#! /bin/sh
# igawk --- like gawk but do @include processing
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# July 1993
@ -37,15 +37,15 @@ do
f=`echo "$1" | sed 's/-.file=//'`
echo @include "$f" >> /tmp/ig.s.$$ ;;
-?file) # get arg, $2
-?file) # get arg, $2
echo @include "$2" >> /tmp/ig.s.$$
shift;;
-?source=*) # -Wsource or --source
-?source=*) # -Wsource or --source
t=`echo "$1" | sed 's/-.source=//'`
echo "$t" >> /tmp/ig.s.$$ ;;
-?source) # get arg, $2
-?source) # get arg, $2
echo "$2" >> /tmp/ig.s.$$
shift;;
@ -54,7 +54,7 @@ do
gawk --version
exit 0 ;;
-[W-]*) opts="$opts '$1'" ;;
-[W-]*) opts="$opts '$1'" ;;
*) break;;
esac
@ -76,6 +76,7 @@ fi
# at this point, /tmp/ig.s.$$ has the program
gawk -- '
# process @include directives
function pathto(file, i, t, junk)
{
if (index(file, "/") != 0)
@ -109,16 +110,16 @@ BEGIN {
}
fpath = pathto($2)
if (fpath == "") {
printf("igawk:%s:%d: cannot find %s\n", \
printf("igawk:%s:%d: cannot find %s\n",
input[stackptr], FNR, $2) > "/dev/stderr"
continue
}
if (! (fpath in processed)) {
processed[fpath] = input[stackptr]
input[++stackptr] = fpath
input[++stackptr] = fpath # push onto stack
} else
print $2, "included in", input[stackptr], \
"already included in", \
print $2, "included in", input[stackptr],
"already included in",
processed[fpath] > "/dev/stderr"
}
close(input[stackptr])

View File

@ -1,10 +1,11 @@
# labels.awk
# labels.awk --- print mailing labels
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# June 1992
# Program to print labels. Each label is 5 lines of data
# that may have blank lines. The label sheets have 2
# blank lines at the top and 2 at the bottom.
# Each label is 5 lines of data that may have blank lines.
# The label sheets have 2 blank lines at the top and 2 at
# the bottom.
BEGIN { RS = "" ; MAXLINES = 100 }

View File

@ -1,4 +1,7 @@
# split.awk --- do split in awk
#
# Requires ord and chr library functions
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
@ -32,13 +35,14 @@ BEGIN {
close(out)
if (s2 == "z") {
if (s1 == "z") {
printf("split: %s is too large to split\n", \
printf("split: %s is too large to split\n",
FILENAME) > "/dev/stderr"
exit 1
}
s1 = chr(ord(s1) + 1)
s2 = "a"
} else
}
else
s2 = chr(ord(s2) + 1)
out = (outfile s1 s2)
tcount = 1

View File

@ -1,4 +1,5 @@
# tee.awk --- tee in awk
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
# Revised December 1995

View File

@ -0,0 +1,27 @@
# bits2str --- turn a byte into readable 1's and 0's
function bits2str(bits, data, mask)
{
if (bits == 0)
return "0"
mask = 1
for (; bits != 0; bits = rshift(bits, 1))
data = (and(bits, mask) ? "1" : "0") data
while ((length(data) % 8) != 0)
data = "0" data
return data
}
BEGIN {
printf "123 = %s\n", bits2str(123)
printf "0123 = %s\n", bits2str(0123)
printf "0x99 = %s\n", bits2str(0x99)
comp = compl(0x99)
printf "compl(0x99) = %#x = %s\n", comp, bits2str(comp)
shift = lshift(0x99, 2)
printf "lshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift)
shift = rshift(0x99, 2)
printf "rshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift)
}

View File

@ -1,8 +1,9 @@
# translate --- do tr like stuff
# translate.awk --- do tr-like stuff
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# August 1989
# bugs: does not handle things like: tr A-Z a-z, it has
# Bugs: does not handle things like: tr A-Z a-z, it has
# to be spelled out. However, if `to' is shorter than `from',
# the last character in `to' is used for the rest of `from'.

View File

@ -1,4 +1,7 @@
# uniq.awk --- do uniq in awk
#
# Requires getopt and join library functions
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
@ -81,7 +84,7 @@ NR == 1 {
last = $0
next
}
{
equal = are_equal()

View File

@ -1,4 +1,5 @@
# wc.awk --- count lines, words, characters
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
@ -8,6 +9,8 @@
# -c only count characters
#
# Default is to count lines, words, characters
#
# Requires getopt and file transition library functions
BEGIN {
# let getopt print a message about
@ -29,11 +32,11 @@ BEGIN {
print_total = (ARGC - i > 2)
}
function beginfile(file) {
function beginfile(file)
{
chars = lines = words = 0
fname = FILENAME
}
function endfile(file)
{
tchars += chars
@ -53,7 +56,6 @@ function endfile(file)
lines++
words += NF
}
END {
if (print_total) {
if (do_lines)

View File

@ -1,10 +1,17 @@
# Print list of word frequencies
# wordfreq.awk --- print list of word frequencies
{
$0 = tolower($0) # remove case distinctions
gsub(/[^a-z0-9_ \t]/, "", $0) # remove punctuation
# remove punctuation
gsub(/[^[:alnum:]_[:blank:]]/, "", $0)
for (i = 1; i <= NF; i++)
freq[$i]++
}
END {
for (word in freq)
printf "%s\t%d\n", word, freq[word]
}
END {
sort = "sort +1 -nr"
for (word in freq)

View File

@ -1,7 +1,9 @@
# extract.awk --- extract files and run programs
# from texinfo files
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993
# Revised September 2000
BEGIN { IGNORECASE = 1 }
@ -42,6 +44,8 @@ BEGIN { IGNORECASE = 1 }
break
else if (line ~ /^@(end[ \t]+)?group/)
continue
else if (line ~ /^@c(omment+)?[ \t]+/)
continue
if (index(line, "@") == 0) {
print line > curfile
continue
@ -61,7 +65,7 @@ BEGIN { IGNORECASE = 1 }
}
function unexpected_eof()
{
printf("%s:%d: unexpected EOF or error\n", \
printf("%s:%d: unexpected EOF or error\n",
FILENAME, FNR) > "/dev/stderr"
exit 1
}
@ -71,6 +75,7 @@ END {
close(curfile)
}
# join.awk --- join an array into a string
#
# Arnold Robbins, arnold@gnu.org, Public Domain
# May 1993

View File

@ -3,22 +3,22 @@
* acconfig.h -- configuration definitions for gawk.
*/
/*
* Copyright (C) 1995-2000 the Free Software Foundation, Inc.
*
/*
* Copyright (C) 1995-2001 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
*
*
* GAWK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* GAWK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
@ -88,9 +88,15 @@
/* Define if you have the vprintf function. */
#undef HAVE_VPRINTF
/* Define as __inline if that's what the C compiler calls it. */
#undef inline
/* Define if on MINIX. */
#undef _MINIX
/* Define to `long' if <sys/types.h> doesn't define. */
#undef off_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef pid_t
@ -128,24 +134,39 @@
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
#undef HAVE_STRINGIZE /* can use ANSI # operator in cpp */
#undef REGEX_MALLOC /* use malloc instead of alloca in regex.c */
#undef SPRINTF_RET /* return type of sprintf */
#undef BITOPS /* bitwise ops (undocumented feature) */
#undef NONDECDATA /* non-decimal input data (undocumented feature) */
#undef _FILE_OFFSET_BITS /* bits in a file offset, where this matters */
#undef _LARGEFILE_SOURCE /* makes fseeko etc. visible on some hosts */
#undef _LARGE_FILES /* emables large files on AIX-style hosts */
#undef HAVE_MKTIME /* we have the mktime function */
#undef HAVE_SOCKETS /* we have sockets on this system */
#undef HAVE_PORTALS /* we have portals on /p on this system */
#undef DYNAMIC /* allow dynamic addition of builtins */
#undef STRTOD_NOT_C89 /* strtod doesn't have C89 semantics */
#undef ssize_t /* signed version of size_t */
/* Define if you have the __argz_count function. */
#undef HAVE___ARGZ_COUNT
/* Define if you have the __argz_next function. */
#undef HAVE___ARGZ_NEXT
/* Define if you have the __argz_stringify function. */
#undef HAVE___ARGZ_STRINGIFY
/* Define if you have the alarm function. */
#undef HAVE_ALARM
/* Define if you have the dcgettext function. */
#undef HAVE_DCGETTEXT
/* Define if you have the fmod function. */
#undef HAVE_FMOD
/* Define if you have the getcwd function. */
#undef HAVE_GETCWD
/* Define if you have the getpagesize function. */
#undef HAVE_GETPAGESIZE
/* Define if you have the madvise function. */
#undef HAVE_MADVISE
/* Define if you have the memcmp function. */
#undef HAVE_MEMCMP
@ -155,12 +176,30 @@
/* Define if you have the memset function. */
#undef HAVE_MEMSET
/* Define if you have the munmap function. */
#undef HAVE_MUNMAP
/* Define if you have the putenv function. */
#undef HAVE_PUTENV
/* Define if you have the setenv function. */
#undef HAVE_SETENV
/* Define if you have the setlocale function. */
#undef HAVE_SETLOCALE
/* Define if you have the stpcpy function. */
#undef HAVE_STPCPY
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the strchr function. */
#undef HAVE_STRCHR
/* Define if you have the strdup function. */
#undef HAVE_STRDUP
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
@ -179,21 +218,48 @@
/* Define if you have the tzset function. */
#undef HAVE_TZSET
/* Define if you have the <argz.h> header file. */
#undef HAVE_ARGZ_H
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define if you have the <mcheck.h> header file. */
#undef HAVE_MCHECK_H
/* Define if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if you have the <netdb.h> header file. */
#undef HAVE_NETDB_H
/* Define if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define if you have the <nl_types.h> header file. */
#undef HAVE_NL_TYPES_H
/* Define if you have the <signum.h> header file. */
#undef HAVE_SIGNUM_H
/* Define if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
@ -203,23 +269,53 @@
/* Define if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the i library (-li). */
#undef HAVE_LIBI
/* Define if you have the intl library (-lintl). */
#undef HAVE_LIBINTL
/* Define if you have the m library (-lm). */
#undef HAVE_LIBM
/* Name of package */
#undef PACKAGE
/* Version number of package */
#undef VERSION
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define to make ftello visible on some hosts (e.g. HP-UX 10.20). */
#undef _LARGEFILE_SOURCE
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to make ftello visible on some hosts (e.g. glibc 2.1.3). */
#undef _XOPEN_SOURCE
/* Define if compiler has function prototypes */
#undef PROTOTYPES
/* Define to 1 if you have the stpcpy function. */
#undef HAVE_STPCPY
/* Define if your locale.h file contains LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
/* Define to 1 if NLS is requested. */
#undef ENABLE_NLS
/* Define to 1 if you have gettext and don't want to use GNU gettext. */
#undef HAVE_GETTEXT
/* Define as 1 if you have catgets and don't want to use GNU gettext. */
#undef HAVE_CATGETS
#include <custom.h> /* overrides for stuff autoconf can't deal with */

4853
contrib/awk/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,21 @@
dnl
dnl configure.in --- autoconf input file for gawk
dnl
dnl Copyright (C) 1995-2000 the Free Software Foundation, Inc.
dnl
dnl
dnl Copyright (C) 1995-2001 the Free Software Foundation, Inc.
dnl
dnl This file is part of GAWK, the GNU implementation of the
dnl AWK Programming Language.
dnl
dnl
dnl GAWK is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl
dnl GAWK is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
@ -23,50 +23,50 @@ dnl
dnl Process this file with autoconf to produce a configure script.
dnl this makes sure that the local install-sh gets found
dnl define(AC_CONFIG_AUX_DIR,)
dnl This is the configure.in script proper
AC_INIT(awk.h)
AC_PREREQ(2.12)
AC_CONFIG_HEADER(config.h:configh.in)
AC_PREREQ(2.13)
AM_INIT_AUTOMAKE(gawk, 3.1.0)
AM_CONFIG_HEADER(config.h:configh.in)
dnl Additional argument stuff
AC_ARG_ENABLE(bitops, [ --enable-bitops Enable Octal and Hex constants and bit functions], AC_DEFINE(BITOPS))
AC_ARG_ENABLE(non-decimal-data, [ --enable-non-decimal-data Enable Octal and Hex constants as valid input data], AC_DEFINE(NONDECDATA))
AC_ARG_ENABLE(portals, [ --enable-portals Enable /p as path prefix for portals], AC_DEFINE(HAVE_PORTALS))
dnl checks for programs
AC_PROG_YACC
AC_PROG_LN_S
AC_PROG_CC
AC_PROG_CPP
AC_PROG_RANLIB
# This is a hack. Different versions of install on different systems
# are just too different. Chuck it and use install-sh.
INSTALL="$srcdir/install-sh -c"; export INSTALL
#
# If the user supplies $INSTALL, figure they know what they're doing.
if test "x$INSTALL" = "x"
then
INSTALL="$srcdir/install-sh -c"
export INSTALL
fi
AC_PROG_INSTALL
AC_PROG_MAKE_SET
if test "$CFLAGS" = ""
then
dnl no user provided CFLAGS, feel free to do this our way
if test "$GCC" = yes
then
CFLAGS="-g -O"
else
dnl go for speed, not debugging. :-)
CFLAGS="-O"
fi
fi
# This is mainly for my use during testing and development.
# Yes, it's a bit of a hack.
AC_MSG_CHECKING([for special development options])
if test -f $srcdir/.developing
then
AC_DEFINE(BITOPS)
AC_DEFINE(NONDECDATA)
# add other debug flags as appropriate, save GAWKDEBUG for emergencies
CFLAGS="$CFLAGS -DARRAYDEBUG"
# turn on compiler warnings if we're doing development
if test "$GCC" = yes
then
CFLAGS="$CFLAGS -Wall"
fi
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_SUBST(CFLAGS)
@ -75,8 +75,9 @@ dnl checks for systems
AC_AIX
AC_ISC_POSIX
AC_MINIX
GAWK_AC_SYS_LARGEFILE
AC_SYS_LARGEFILE
GAWK_AC_AIX_TWEAK
GAWK_AC_LINUX_ALPHA
if test "$ISC" = 1 # will be set by test for ISC
then
@ -84,10 +85,20 @@ dnl need -D_SYSV3 for ISC
CFLAGS="$CFLAGS -D_SYSV3"
fi
dnl check for C compiler for automake
AM_PROG_CC_STDC
AM_C_PROTOTYPES
ALL_LINGUAS="he"
AM_GNU_GETTEXT
dnl checks for header files
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(limits.h locale.h stdarg.h unistd.h signum.h sys/param.h string.h)
AC_CHECK_HEADERS(fcntl.h limits.h locale.h libintl.h mcheck.h \
netdb.h netinet/in.h signum.h stdarg.h string.h \
sys/param.h sys/socket.h unistd.h)
if test "$ac_cv_header_string_h" = yes
then
AC_CHECK_HEADERS(memory.h)
@ -100,56 +111,56 @@ AC_TYPE_PID_T
AC_TYPE_SIGNAL
AC_SIZE_T
AC_TYPE_GETGROUPS
GAWK_AC_TYPE_SSIZE_T
AC_EGREP_HEADER([int.*sprintf], stdio.h,
AC_DEFINE(SPRINTF_RET, int),
AC_DEFINE(SPRINTF_RET, char *))
dnl checks for functions
if test "$YACC" = "bison -y" ||
{ test -f $srcdir/awktab.c && grep 'alloca *(' $srcdir/awktab.c > /dev/null; }
then
AC_FUNC_ALLOCA
fi
AC_DEFINE(REGEX_MALLOC)
AC_FUNC_VPRINTF
dnl one day use [ AC_CHECK_TYPE(ssize_t, int) ]
GAWK_AC_FUNC_STRTOD_C89
AC_FUNC_MKTIME
case "$ac_cv_func_working_mktime" in
yes) AC_DEFINE(HAVE_MKTIME)
;;
esac
AC_CHECK_LIB(m, fmod)
AC_CHECK_FUNCS(madvise memset memcpy memcmp fmod setlocale strchr strerror \
strftime strncasecmp strtod system tzset)
AC_CHECK_FUNCS(memset memcpy memcmp fmod setlocale strchr strerror \
strftime strncasecmp strtod system tzset)
dnl see if we have mmap
AC_FUNC_MMAP
dnl check for dynamic linking
dnl This is known to be very primitive
AC_CHECK_HEADER(dlfcn.h,
AC_CHECK_LIB(dl, dlopen,
AC_DEFINE(DYNAMIC)
LIBS="$LIBS -ldl"
if test "$GCC" = yes
then
# Add others here as appropriate,
# one day use GNU libtool.
if uname | egrep -i linux > /dev/null
then
LDFLAGS="$LDFLAGS -rdynamic"
fi
fi
))
dnl check for how to use getpgrp
dnl have to hardwire it for VMS POSIX. Sigh.
if (uname) > /dev/null 2>&1
then
case `uname` in
*VMS*|*BeOS*)
AC_DEFINE(GETPGRP_VOID)
;;
*HP-UX*) # not getpgrp related
if test "$GCC" = yes
then
:
else
# stupid HP linker leaves the output file
# around even when a link fails. This confuses
# the alloca tests, so we have to do this
# manually. Sucks big time.
LIBS="$LIBS -lPW"
fi
dnl ditto for BeOS.
case `(uname) 2> /dev/null` in
*VMS*|*BeOS*)
AC_DEFINE(GETPGRP_VOID)
;;
*) AC_FUNC_GETPGRP
;;
esac
# have to do the getpgrp test since won't
# fall into the default
AC_FUNC_GETPGRP
;;
*) AC_FUNC_GETPGRP
;;
esac
else
AC_FUNC_GETPGRP
fi
dnl check for sockets
GAWK_AC_LIB_SOCKETS
dnl checks for structure members
AC_STRUCT_ST_BLKSIZE
@ -160,6 +171,12 @@ AC_STRUCT_TIMEZONE
dnl checks for compiler characteristics
AC_C_CHAR_UNSIGNED
AC_C_CONST
GAWK_AC_C_STRINGIZE
AC_C_INLINE
AC_C_STRINGIZE
AC_OUTPUT(Makefile doc/Makefile test/Makefile awklib/Makefile, [date > stamp-h])
AC_OUTPUT(Makefile \
awklib/Makefile \
doc/Makefile \
intl/Makefile \
po/Makefile.in \
test/Makefile)

View File

@ -11,7 +11,7 @@
*/
/*
* Copyright (C) 1995-2000 the Free Software Foundation, Inc.
* Copyright (C) 1995-2001 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@ -53,14 +53,35 @@
#define fork vfork
#endif
/* For sequent, based on email with Aron Griffis <agriffis@calypso.coat.com> */
#ifdef _SEQUENT_
#undef HAVE_MMAP
#endif
/* For BeOS, from mc@whoever.com */
#if defined(__dest_os) && __dest_os == __be_os
#define BROKEN_STRNCASECMP
#define ELIDE_CODE
#include <alloca.h>
#endif
/* For Tandems, based on code from scldad@sdc.com.au */
#ifdef TANDEM
#define tempnam(a,b) tmpnam(NULL)
#define variable(a,b,c) variabl(a,b,c)
#define srandom srand
#define random rand
#include <cextdecs(PROCESS_GETINFO_)>
#endif
/* For 16-bit DOS */
#if defined(MSC_VER) && defined(MSDOS)
#define NO_PROFILING 1
#endif
/* For MacOS X, which is almost BSD Unix */
#ifdef __APPLE__
#define HAVE_MKTIME 1
#endif
/* For ULTRIX 4.3 */
#ifdef ultrix
#define HAVE_MKTIME 1
#endif

View File

@ -1,5 +1,5 @@
/* dfa.h - declarations for GNU deterministic regexp compiler
Copyright (C) 1988 Free Software Foundation, Inc.
Copyright (C) 1988, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -22,6 +22,21 @@
In addition to clobbering modularity, we eat up valuable
name space. */
# undef PARAMS
#if __STDC__
# ifndef _PTR_T
# define _PTR_T
typedef void * ptr_t;
# endif
# define PARAMS(x) x
#else
# ifndef _PTR_T
# define _PTR_T
typedef char * ptr_t;
# endif
# define PARAMS(x) ()
#endif
/* Number of bits in an unsigned char. */
#ifndef CHARBITS
#define CHARBITS 8
@ -305,16 +320,15 @@ struct dfa
/* Entry points. */
#ifdef __STDC__
/* dfasyntax() takes two arguments; the first sets the syntax bits described
earlier in this file, and the second sets the case-folding flag. */
extern void dfasyntax(reg_syntax_t, int);
/* dfasyntax() takes three arguments; the first sets the syntax bits described
earlier in this file, the second sets the case-folding flag, and the
third specifies the line terminator. */
extern void dfasyntax PARAMS ((reg_syntax_t, int, int));
/* Compile the given string of the given length into the given struct dfa.
Final argument is a flag specifying whether to build a searching or an
exact matcher. */
extern void dfacomp(char *, size_t, struct dfa *, int);
extern void dfacomp PARAMS ((char *, size_t, struct dfa *, int));
/* Execute the given struct dfa on the buffer of characters. The
first char * points to the beginning, and the second points to the
@ -328,26 +342,26 @@ extern void dfacomp(char *, size_t, struct dfa *, int);
order to verify backreferencing; otherwise the flag will be cleared.
Returns NULL if no match is found, or a pointer to the first
character after the first & shortest matching string in the buffer. */
extern char *dfaexec(struct dfa *, char *, char *, int, int *, int *);
extern char *dfaexec PARAMS ((struct dfa *, char *, char *, int, int *, int *));
/* Free the storage held by the components of a struct dfa. */
extern void dfafree(struct dfa *);
extern void dfafree PARAMS ((struct dfa *));
/* Entry points for people who know what they're doing. */
/* Initialize the components of a struct dfa. */
extern void dfainit(struct dfa *);
extern void dfainit PARAMS ((struct dfa *));
/* Incrementally parse a string of given length into a struct dfa. */
extern void dfaparse(char *, size_t, struct dfa *);
extern void dfaparse PARAMS ((char *, size_t, struct dfa *));
/* Analyze a parsed regexp; second argument tells whether to build a searching
or an exact matcher. */
extern void dfaanalyze(struct dfa *, int);
extern void dfaanalyze PARAMS ((struct dfa *, int));
/* Compute, for each possible character, the transitions out of a given
state, storing them in an array of integers. */
extern void dfastate(int, struct dfa *, int []);
extern void dfastate PARAMS ((int, struct dfa *, int []));
/* Error handling. */
@ -355,10 +369,4 @@ extern void dfastate(int, struct dfa *, int []);
takes a single argument, a NUL-terminated string describing the error.
The default dfaerror() prints the error message to stderr and exits.
The user can provide a different dfafree() if so desired. */
extern void dfaerror(const char *);
#else /* ! __STDC__ */
extern void dfasyntax(), dfacomp(), dfafree(), dfainit(), dfaparse();
extern void dfaanalyze(), dfastate(), dfaerror();
extern char *dfaexec();
#endif /* ! __STDC__ */
extern void dfaerror PARAMS ((const char *));

View File

@ -1,3 +1,44 @@
Sun Jun 3 13:04:44 2001 Arnold D. Robbins <arnold@skeeve.com>
* Release 3.1.0: Release tar file made. And there was
rejoicing.
Mon May 14 19:57:31 2001 Arnold D. Robbins <arnold@skeeve.com>
* gawk.texi, gawkinet.texi: Versions for distribution
put in place.
* gawk.1, awkcard.in: Minor edits for consistency of
usage, formatting.
Wed Nov 22 14:57:59 2000 Arnold D. Robbins <arnold@skeeve.com>
* gawk.texi, gawk.1, awkcard.in: Removed all documentation
of abort.
Sun Aug 13 11:23:50 2000 Arnold D. Robbins <arnold@skeeve.com>
* gawk.texi, gawk.1, awkcard.in: documented sort function
and optional third argument to match.
Sun Aug 13 00:40:41 2000 Arnold D. Robbins <arnold@skeeve.com>
* gawk.texi: hardwired publisher info.
* publisher.texi: Removed. Not needed any more.
* gawkinet.texi: Added title page stuff.
Thu Jul 5 21:05:57 2000 Arnold D. Robbins <arnold@skeeve.com>
* gawk.texi: moved to use of @command, @option everywhere
appropriate. Removed all @page and @group in anticipation
of re-page breaking. Updated stuff for install-info.
Added FDL.
Tue Nov 10 11:42:26 1998 Arnold D. Robbins <arnold@gnu.org>
* publisher.texi: new file with publisher related info.
* Makefile.in: updated dvi and postscript targets to make
them lots smarter about not reformatting if need be.
Mon Aug 7 15:23:00 2000 Arnold D. Robbins <arnold@skeeve.com>
* Release 3.0.6: Release tar file made.
@ -52,7 +93,7 @@ Thu Jul 29 23:15:34 1999 Arnold D. Robbins <arnold@skeeve.com>
install it directly.
Wed Jun 30 16:14:36 1999 Arnold D. Robbins <arnold@gnu.org>
* Release 3.0.4: Release tar file made. This time for sure.
Wed Oct 7 21:59:33 1998 Arnold D. Robbins <arnold@gnu.org>

View File

@ -0,0 +1,80 @@
#
# doc/Makefile.am --- automake input file for gawk
#
# Copyright (C) 2000, 2001 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
#
# GAWK is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GAWK is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
## process this file with automake to produce Makefile.in
info_TEXINFOS = gawk.texi gawkinet.texi
man_MANS = gawk.1 igawk.1
EXTRA_DIST = ChangeLog README.card ad.block setter.outline \
awkcard.in awkforai.txt texinfo.tex cardfonts \
macros colors no.colors $(man_MANS) \
uf002331.eps uf002331.jpg lflashlight.eps rflashlight.eps \
statist.jpg statist.eps
MAKEINFO = @MAKEINFO@ --no-split
TROFF = groff -t -Tps
SEDME = sed -e "s/^level0 restore/level0 restore flashme 100 72 moveto (Copyright `date '+%m-%d-%y %T'`, FSF, Inc. (all)) show/" \
-e "s/^\/level0 save def/\/level0 save def 30 -48 translate/"
CARDSRC = $(srcdir)/macros $(srcdir)/cardfonts $(srcdir)/colors awkcard.tr
CARDSRC_N = $(srcdir)/macros $(srcdir)/cardfonts $(srcdir)/no.colors awkcard.tr
CARDFILES= $(CARDSRC) ad.block awkcard.in setter.outline
# Use this if your troff can correctly handle macros from 'colors' file
AWKCARD = awkcard.ps
# Uncomment the following definition of AWKCARD if your troff can produce
# Postscript but still has troubles with macros from 'colors'. As this
# is not groff you will have to change TROFF macro as well. Do not forget
# to ensure that awkcard.tr is processed by tbl.
#AWKCARD = awkcard.nc
postscript: gawk.ps gawkinet.ps gawk.1.ps igawk.1.ps $(AWKCARD)
gawk.ps: gawk.dvi
dvips -o gawk.ps gawk.dvi
gawkinet.ps: gawkinet.dvi
dvips -o gawkinet.ps gawkinet.dvi
gawk.1.ps: gawk.1
-groff -man $(srcdir)/gawk.1 > gawk.1.ps
igawk.1.ps: igawk.1
-groff -man $(srcdir)/igawk.1 > igawk.1.ps
awkcard.tr: awkcard.in
sed 's:SRCDIR:$(srcdir):' < $(srcdir)/awkcard.in > awkcard.tr
awkcard.ps: $(CARDFILES)
$(TROFF) $(CARDSRC) | $(SEDME) | cat $(srcdir)/setter.outline - > awkcard.ps
awkcard.nc: $(CARDFILES)
$(TROFF) $(CARDSRC_N) | $(SEDME) | cat $(srcdir)/setter.outline - > awkcard.ps && touch awkcard.nc
clean:
rm -f *.ps *~ awkcard.nc

View File

@ -1,65 +1,430 @@
# Makefile for GNU Awk documentation.
#
# Copyright (C) 1993-2000 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
#
# GAWK is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GAWK is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
# Makefile.in generated automatically by automake 1.4a from Makefile.am
SHELL = /bin/sh
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_FLAG =
transform = @program_transform_name@
prefix = @prefix@
exec_prefix = @exec_prefix@
binprefix =
manprefix =
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
bindir = @bindir@
libdir = @libdir@
mandir = @mandir@/man1
manext = .1
infodir = @infodir@
datadir = @datadir@/awk
@SET_MAKE@
AMDEP = @AMDEP@
AMTAR = @AMTAR@
AWK = @AWK@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CFLAGS = @CFLAGS@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DATADIRNAME = @DATADIRNAME@
DEPDIR = @DEPDIR@
GENCAT = @GENCAT@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
INSTOBJEXT = @INSTOBJEXT@
INTLDEPS = @INTLDEPS@
INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
LN_S = @LN_S@
MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
PACKAGE = @PACKAGE@
POFILES = @POFILES@
POSUB = @POSUB@
RANLIB = @RANLIB@
SOCKET_LIBS = @SOCKET_LIBS@
U = @U@
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
YACC = @YACC@
install_sh = @install_sh@
l = @l@
#
# doc/Makefile.am --- automake input file for gawk
#
# Copyright (C) 2000, 2001 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
#
# GAWK is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GAWK is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
info_TEXINFOS = gawk.texi gawkinet.texi
man_MANS = gawk.1 igawk.1
EXTRA_DIST = ChangeLog README.card ad.block setter.outline \
awkcard.in awkforai.txt texinfo.tex cardfonts \
macros colors no.colors $(man_MANS) \
uf002331.eps uf002331.jpg lflashlight.eps rflashlight.eps \
statist.jpg statist.eps
MAKEINFO = @MAKEINFO@ --no-split
TEXI2DVI = texi2dvi
TEX = tex
MAKEINFO = makeinfo --no-split
TROFF = groff -t -Tps
SEDME = sed -e "s/^level0 restore/level0 restore flashme 100 72 moveto (Copyright `date '+%m-%d-%y %T'`, FSF, Inc. (all)) show/" \
-e "s/^\/level0 save def/\/level0 save def 30 -48 translate/"
DOCS= gawk.1 igawk.1 gawk.texi
TEXFILES= gawk.aux gawk.cp gawk.cps gawk.fn gawk.fns gawk.ky gawk.kys \
gawk.pg gawk.pgs gawk.toc gawk.tp gawk.tps gawk.vr gawk.vrs
ALLDOC= gawk.dvi $(TEXFILES) gawk.log awkcard.tr
CARDSRC = $(srcdir)/macros $(srcdir)/cardfonts $(srcdir)/colors awkcard.tr
CARDSRC_N = $(srcdir)/macros $(srcdir)/cardfonts $(srcdir)/no.colors awkcard.tr
CARDFILES= $(CARDSRC) ad.block awkcard.in setter.outline
CARDFILES = $(CARDSRC) ad.block awkcard.in setter.outline
# Use this if your troff can correctly handle macros from 'colors' file
AWKCARD = awkcard.ps
subdir = doc
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
DIST_SOURCES =
TEXI2DVI = texi2dvi
INFO_DEPS = gawk.info gawkinet.info
DVIS = gawk.dvi gawkinet.dvi
TEXINFOS = gawk.texi gawkinet.texi
man1dir = $(mandir)/man1
MANS = $(man_MANS)
NROFF = nroff
DIST_COMMON = ChangeLog Makefile.am Makefile.in texinfo.tex
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
.SUFFIXES: .dvi .info .ps .texi .texinfo .txi
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
gawk.info: gawk.texi
gawk.dvi: gawk.texi
gawkinet.info: gawkinet.texi
gawkinet.dvi: gawkinet.texi
DVIPS = dvips
.texi.info:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.texi.dvi:
TEXINPUTS=$(srcdir):$$TEXINPUTS \
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
.texi:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.texinfo.info:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.texinfo:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.texinfo.dvi:
TEXINPUTS=$(srcdir):$$TEXINPUTS \
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
.txi.info:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.txi.dvi:
TEXINPUTS=$(srcdir):$$TEXINPUTS \
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
.txi:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.dvi.ps:
$(DVIPS) $< -o $@
install-info-am: $(INFO_DEPS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(infodir)
@list='$(INFO_DEPS)'; \
for file in $$list; do \
d=$(srcdir); \
for ifile in `CDPATH=: && cd $$d && echo $$file $$file-[0-9] $$file-[0-9][0-9]`; do \
if test -f $$d/$$ifile; then \
echo " $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile"; \
$(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile; \
else : ; fi; \
done; \
done
@$(POST_INSTALL)
@if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
list='$(INFO_DEPS)'; \
for file in $$list; do \
echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";\
install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :;\
done; \
else : ; fi
uninstall-info:
$(PRE_UNINSTALL)
@if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
list='$(INFO_DEPS)'; \
for file in $$list; do \
echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$file"; \
install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$file; \
done; \
else :; fi
@$(NORMAL_UNINSTALL)
@list='$(INFO_DEPS)'; \
for file in $$list; do \
(if cd $(DESTDIR)$(infodir); then \
echo " rm -f $$file $$file-[0-9] $$file-[0-9][0-9])"; \
rm -f $$file $$file-[0-9] $$file-[0-9][0-9]; \
else :; fi); \
done
dist-info: $(INFO_DEPS)
list='$(INFO_DEPS)'; \
for base in $$list; do \
d=$(srcdir); \
for file in `CDPATH=: && cd $$d && eval echo $$base*`; do \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file; \
done; \
done
mostlyclean-aminfo:
-rm -f gawk.aux gawk.cp gawk.cps gawk.dvi gawk.fn gawk.fns gawk.pgs \
gawk.ky gawk.kys gawk.ps gawk.log gawk.pg gawk.toc gawk.tp \
gawk.tps gawk.vr gawk.vrs gawk.op gawk.tr gawk.cv gawk.cn \
gawk.cm gawk.ov gawkinet.aux gawkinet.cp gawkinet.cps \
gawkinet.dvi gawkinet.fn gawkinet.fns gawkinet.pgs \
gawkinet.ky gawkinet.kys gawkinet.ps gawkinet.log gawkinet.pg \
gawkinet.toc gawkinet.tp gawkinet.tps gawkinet.vr \
gawkinet.vrs gawkinet.op gawkinet.tr gawkinet.cv gawkinet.cn \
gawkinet.cm gawkinet.ov
clean-aminfo:
distclean-aminfo:
maintainer-clean-aminfo:
cd $(srcdir) && for i in $(INFO_DEPS); do \
rm -f $$i; \
if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \
rm -f $$i-[0-9]*; \
fi; \
done
install-man1:
$(mkinstalldirs) $(DESTDIR)$(man1dir)
@list='$(man1_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \
$(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \
done
uninstall-man1:
@list='$(man1_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \
rm -f $(DESTDIR)$(man1dir)/$$inst; \
done
install-man: $(MANS)
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-man1
uninstall-man:
@$(NORMAL_UNINSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-man1
tags: TAGS
TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir) \
|| exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
$(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-info
info-am: $(INFO_DEPS)
info: info-am
dvi-am: $(DVIS)
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am
install-data-am: install-info-am install-man
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-info uninstall-man
uninstall: uninstall-am
all-am: Makefile $(INFO_DEPS) $(MANS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(infodir) $(DESTDIR)$(mandir)/man1
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
-rm -f Makefile.in
mostlyclean-am: mostlyclean-aminfo mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-aminfo clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-aminfo distclean-generic clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-aminfo maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: install-info-am uninstall-info mostlyclean-aminfo \
distclean-aminfo clean-aminfo maintainer-clean-aminfo install-man1 \
uninstall-man1 install-man uninstall-man tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all install-strip \
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Uncomment the following definition of AWKCARD if your troff can produce
# Postscript but still has troubles with macros from 'colors'. As this
@ -67,47 +432,20 @@ AWKCARD = awkcard.ps
# to ensure that awkcard.tr is processed by tbl.
#AWKCARD = awkcard.nc
all: $(DOCS) info
postscript: gawk.ps gawkinet.ps gawk.1.ps igawk.1.ps $(AWKCARD)
install: $(mandir)/gawk$(manext) $(mandir)/igawk$(manext) $(infodir)/gawk.info
$(infodir)/gawk.info::
-if test -f gawk.info; then d=.; \
else d=$(srcdir); fi; \
if [ -f $(infodir)/dir -a -f $(infodir)/gawk.info ] \
&& cmp $$d/gawk.info $(infodir)/gawk.info > /dev/null \
&& grep '(gawk)' $(infodir)/dir > /dev/null; then \
exit 0; \
fi; \
$(INSTALL_DATA) $$d/gawk.info $(infodir)/gawk.info ; \
if $(SHELL) -c 'install-info --version' > /dev/null 2>&1 ; \
then install-info --info-dir=$(infodir) gawk.info ; \
else true ; fi; exit 0
$(mandir)/gawk$(manext):: gawk.1
$(INSTALL_DATA) $(srcdir)/gawk.1 $(mandir)/gawk$(manext)
$(mandir)/igawk$(manext):: igawk.1
$(INSTALL_DATA) $(srcdir)/igawk.1 $(mandir)/igawk$(manext)
uninstall:
rm -f $(mandir)/gawk$(manext) $(mandir)/igawk$(manext) $(infodir)/gawk.info*
dvi: gawk.dvi
gawk.dvi: gawk.texi
-TEXINPUTS=$(srcdir):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/gawk.texi
info: gawk.info
gawk.info: gawk.texi
$(MAKEINFO) $(srcdir)/gawk.texi
postscript: dvi gawk.1 igawk.1 $(AWKCARD)
-groff -man $(srcdir)/gawk.1 > gawk.1.ps
-groff -man $(srcdir)/igawk.1 > igawk.1.ps
gawk.ps: gawk.dvi
dvips -o gawk.ps gawk.dvi
gawkinet.ps: gawkinet.dvi
dvips -o gawkinet.ps gawkinet.dvi
gawk.1.ps: gawk.1
-groff -man $(srcdir)/gawk.1 > gawk.1.ps
igawk.1.ps: igawk.1
-groff -man $(srcdir)/igawk.1 > igawk.1.ps
awkcard.tr: awkcard.in
sed 's:SRCDIR:$(srcdir):' < $(srcdir)/awkcard.in > awkcard.tr
@ -118,12 +456,8 @@ awkcard.nc: $(CARDFILES)
$(TROFF) $(CARDSRC_N) | $(SEDME) | cat $(srcdir)/setter.outline - > awkcard.ps && touch awkcard.nc
clean:
rm -f *.ps $(ALLDOC) *~ awkcard.nc
rm -f *.ps *~ awkcard.nc
distclean: clean
rm -f Makefile
maintainer-clean: distclean
@echo "This command is intended for maintainers to use; it"
@echo "deletes files that may require special tools to rebuild."
rm -f gawk.info
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1,7 +1,7 @@
.\" AWK Reference Card --- Arnold Robbins, arnold@gnu.org
.\" This file is the Ad block (included in cover)
.\"
.\" Copyright (C) 1996, 98 Free Software Foundation, Inc.
.\" Copyright (C) 1996, 1998, 2000, 2001 Free Software Foundation, Inc.
.\"
.\" Permission is granted to make and distribute verbatim copies of
.\" this reference card provided the copyright notice and this permission
@ -37,10 +37,9 @@ Fax (including Japan): +1-617-542-2652
E-mail: gnu@gnu.org
URL: http://www.gnu.org
.ce 7
.ce 5
.ft HB
\*(CGFree Software
Source Distributions on CD-ROM
\*(CGSource Distributions on CD-ROM
Deluxe Distributions
Emacs, Gawk, Make and GDB Manuals
Emacs and GDB References\*(CX

File diff suppressed because it is too large Load Diff

View File

@ -34,4 +34,4 @@ FC - font courier
.ds RN Times Roman
.ds IN Times Italic
.ds CN Courier Bold
.ds AM \fIThe GNU Awk User's Guide\fP
.ds AM \fIGAWK: Effective AWK Programming\fP

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
.\" AWK Reference Card --- Arnold Robbins, arnold@gnu.org
.\" This file is for troff which does not know what to do
.\" with a literal Poscript and cannot use macros from 'colors'.
.\" with literal Poscript and cannot use the macros from 'colors'.
.\"
.\" Copyright (C) 1996 Free Software Foundation, Inc.
.\"

View File

@ -3,10 +3,10 @@
% Load plain if necessary, i.e., if running under initex.
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
%
\def\texinfoversion{1999-10-01.07}
\def\texinfoversion{2001-03-28.08}
%
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
% Free Software Foundation, Inc.
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
% 2000, 01 Free Software Foundation, Inc.
%
% This texinfo.tex file is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License as
@ -214,6 +214,9 @@
\normalturnoffactive % \ in index entries must not stay \, e.g., if
% the page break happens to be in the middle of an example.
\shipout\vbox{%
% Do this early so pdf references go to the beginning of the page.
\ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi
%
\ifcropmarks \vbox to \outervsize\bgroup
\hsize = \outerhsize
\vskip-\topandbottommargin
@ -243,8 +246,6 @@
\unvbox\footlinebox
\fi
%
\ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi
%
\ifcropmarks
\egroup % end of \vbox\bgroup
\hfil\egroup % end of (centering) \line\bgroup
@ -687,16 +688,54 @@ where each line of input produces a line of output.}
\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
\leftline{\hskip\leftskip{\rm#1}}}}
% @inmargin{TEXT} puts TEXT in the margin next to the current paragraph.
\def\inmargin#1{%
\strut\vadjust{\nobreak\kern-\strutdepth
\vtop to \strutdepth{\baselineskip\strutdepth\vss
\llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}}
% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
% paragraph. For more general purposes, use the \margin insertion
% class. WHICH is `l' or `r'.
%
\newskip\inmarginspacing \inmarginspacing=1cm
\def\strutdepth{\dp\strutbox}
%\hbox{{\rm#1}}\hfil\break}}
%
\def\doinmargin#1#2{\strut\vadjust{%
\nobreak
\kern-\strutdepth
\vtop to \strutdepth{%
\baselineskip=\strutdepth
\vss
% if you have multiple lines of stuff to put here, you'll need to
% make the vbox yourself of the appropriate size.
\ifx#1l%
\llap{\ignorespaces #2\hskip\inmarginspacing}%
\else
\rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
\fi
\null
}%
}}
\def\inleftmargin{\doinmargin l}
\def\inrightmargin{\doinmargin r}
%
% @inmargin{TEXT [, RIGHT-TEXT]}
% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
% else use TEXT for both).
%
\def\inmargin#1{\parseinmargin #1,,\finish}
\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
\setbox0 = \hbox{\ignorespaces #2}%
\ifdim\wd0 > 0pt
\def\lefttext{#1}% have both texts
\def\righttext{#2}%
\else
\def\lefttext{#1}% have only one text
\def\righttext{#1}%
\fi
%
\ifodd\pageno
\def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
\else
\def\temp{\inleftmargin\lefttext}%
\fi
\temp
}
% @include file insert text of that file as input.
% Allow normal characters that we make active in the argument (a file name).
@ -885,13 +924,17 @@ where each line of input produces a line of output.}
\fi
\ifx\empty\imagewidth\else width \imagewidth \fi
\ifx\empty\imageheight\else height \imageheight \fi
{#1.pdf}%
\ifnum\pdftexversion<13
#1.pdf%
\else
{#1.pdf}%
\fi
\ifnum\pdftexversion < 14 \else
\pdfrefximage \pdflastximage
\fi}
\def\pdfmkdest#1{\pdfdest name{#1@} xyz}
\def\pdfmkdest#1{\pdfdest name{#1} xyz}
\def\pdfmkpgn#1{#1@}
\let\linkcolor = \Cyan
\let\linkcolor = \Blue % was Cyan, but that seems light?
\def\endlink{\Black\pdfendlink}
% Adding outlines to PDF; macros for calculating structure of outlines
% come from Petr Olsak
@ -906,7 +949,8 @@ where each line of input produces a line of output.}
\closein 1
\indexnofonts
\def\tt{}
% thanh's hack / proper braces in bookmarks
\let\_ = \normalunderscore
% Thanh's hack / proper braces in bookmarks
\edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
\edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
%
@ -1670,7 +1714,10 @@ where each line of input produces a line of output.}
}
% Subroutines used in generating headings
% Produces Day Month Year style of output.
% This produces Day Month Year style of output.
% Only define if not already defined, in case a txi-??.tex file has set
% up a different format (e.g., txi-cs.tex does this).
\ifx\today\undefined
\def\today{%
\number\day\space
\ifcase\month
@ -1679,6 +1726,7 @@ where each line of input produces a line of output.}
\or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
\fi
\space\number\year}
\fi
% @settitle line... specifies the title of the document, for headings.
% It generates no output of its own.
@ -2587,42 +2635,48 @@ width0pt\relax} \fi
}
% @defindex foo == \newindex{foo}
%
\def\defindex{\parsearg\newindex}
% Define @defcodeindex, like @defindex except put all entries in @code.
%
\def\defcodeindex{\parsearg\newcodeindex}
%
\def\newcodeindex#1{%
\iflinks
\expandafter\newwrite \csname#1indfile\endcsname
\openout \csname#1indfile\endcsname \jobname.#1
\fi
\expandafter\xdef\csname#1index\endcsname{%
\noexpand\docodeindex{#1}}
\noexpand\docodeindex{#1}}%
}
\def\defcodeindex{\parsearg\newcodeindex}
% @synindex foo bar makes index foo feed into index bar.
% Do this instead of @defindex foo if you don't want it as a separate index.
% The \closeout helps reduce unnecessary open files; the limit on the
% Acorn RISC OS is a mere 16 files.
\def\synindex#1 #2 {%
\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
\expandafter\closeout\csname#1indfile\endcsname
\expandafter\let\csname#1indfile\endcsname=\synindexfoo
\expandafter\xdef\csname#1index\endcsname{% define \xxxindex
\noexpand\doindex{#2}}%
}
%
% @syncodeindex foo bar similar, but put all entries made for index foo
% inside @code.
\def\syncodeindex#1 #2 {%
\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
\expandafter\closeout\csname#1indfile\endcsname
\expandafter\let\csname#1indfile\endcsname=\synindexfoo
\expandafter\xdef\csname#1index\endcsname{% define \xxxindex
\noexpand\docodeindex{#2}}%
%
\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
% #3 the target index (bar).
\def\dosynindex#1#2#3{%
% Only do \closeout if we haven't already done it, else we'll end up
% closing the target index.
\expandafter \ifx\csname donesynindex#2\endcsname \undefined
% The \closeout helps reduce unnecessary open files; the limit on the
% Acorn RISC OS is a mere 16 files.
\expandafter\closeout\csname#2indfile\endcsname
\expandafter\let\csname\donesynindex#2\endcsname = 1
\fi
% redefine \fooindfile:
\expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
\expandafter\let\csname#2indfile\endcsname=\temp
% redefine \fooindex:
\expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
}
% Define \doindex, the driver for all \fooindex macros.
@ -2854,16 +2908,17 @@ width0pt\relax} \fi
% Now the real index entry with the fonts.
\toks0 = {#2}%
%
% If third (subentry) arg is present, add it to the index
% string. And include a space.
% If the third (subentry) arg is present, add it to the index
% line to write.
\ifx\thirdarg\emptymacro \else
\toks0 = \expandafter{\the\toks0 \space #3}%
\toks0 = \expandafter{\the\toks0{#3}}%
\fi
%
% Set up the complete index entry, with both the sort key
% and the original text, including any font commands. We write
% three arguments to \entry to the .?? file, texindex reduces to
% two when writing the .??s sorted result.
% Set up the complete index entry, with both the sort key and
% the original text, including any font commands. We write
% three arguments to \entry to the .?? file (four in the
% subentry case), texindex reduces to two when writing the .??s
% sorted result.
\edef\temp{%
\write\csname#1indfile\endcsname{%
\realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
@ -3085,11 +3140,18 @@ width0pt\relax} \fi
\def\primary #1{\line{#1\hfil}}
\newskip\secondaryindent \secondaryindent=0.5cm
\def\secondary #1#2{
{\parfillskip=0in \parskip=0in
\hangindent =1in \hangafter=1
\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
\def\secondary#1#2{{%
\parfillskip=0in
\parskip=0in
\hangindent=1in
\hangafter=1
\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
\ifpdf
\pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
\else
#2
\fi
\par
}}
% Define two-column mode, which we use to typeset indexes.
@ -3149,7 +3211,6 @@ width0pt\relax} \fi
%
% Double the \vsize as well. (We don't need a separate register here,
% since nobody clobbers \vsize.)
\advance\vsize by -\ht\partialpage
\vsize = 2\vsize
}
@ -3163,6 +3224,7 @@ width0pt\relax} \fi
% previous page.
\dimen@ = \vsize
\divide\dimen@ by 2
\advance\dimen@ by -\ht\partialpage
%
% box0 will be the left-hand column, box2 the right.
\setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
@ -3170,15 +3232,18 @@ width0pt\relax} \fi
\unvbox255
\penalty\outputpenalty
}
%
% Re-output the contents of the output page -- any previous material,
% followed by the two boxes we just split, in box0 and box2.
\def\pagesofar{%
% Re-output the contents of the output page -- any previous material,
% followed by the two boxes we just split, in box0 and box2.
\unvbox\partialpage
%
\hsize = \doublecolumnhsize
\wd0=\hsize \wd2=\hsize
\hbox to\pagewidth{\box0\hfil\box2}%
}
%
% All done with double columns.
\def\enddoublecolumns{%
\output = {%
% Split the last of the double-column material. Leave it on the
@ -3203,8 +3268,9 @@ width0pt\relax} \fi
% \endgroup where \vsize got restored).
\pagegoal = \vsize
}
%
% Called at the end of the double column material.
\def\balancecolumns{%
% Called at the end of the double column material.
\setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
\dimen@ = \ht0
\advance\dimen@ by \topskip
@ -4265,6 +4331,7 @@ width0pt\relax} \fi
\gobble
}
% @quotation does normal linebreaking (hence we can't use \nonfillstart)
% and narrows the margins.
%
@ -4287,6 +4354,158 @@ width0pt\relax} \fi
}
% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
% If we want to allow any <char> as delimiter,
% we need the curly braces so that makeinfo sees the @verb command, eg:
% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
%
% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
%
% [Knuth] p. 344; only we need to do '@' too
\def\dospecials{%
\do\ \do\\\do\@\do\{\do\}\do\$\do\&%
\do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~}
%
% [Knuth] p. 380
\def\uncatcodespecials{%
\def\do##1{\catcode`##1=12}\dospecials}
%
% [Knuth] pp. 380,381,391
% Disable Spanish ligatures ?` and !` of \tt font
\begingroup
\catcode`\`=\active\gdef`{\relax\lq}
\endgroup
%
% Setup for the @verb command.
%
% Eight spaces for a tab
\begingroup
\catcode`\^^I=\active
\gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
\endgroup
%
\def\setupverb{%
\tt % easiest (and conventionally used) font for verbatim
\def\par{\leavevmode\endgraf}%
\catcode`\`=\active
\tabeightspaces
% Respect line breaks,
% print special symbols as themselves, and
% make each space count
% must do in this order:
\obeylines \uncatcodespecials \sepspaces
}
% Setup for the @verbatim environment
%
% Real tab expansion
\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
%
\def\starttabbox{\setbox0=\hbox\bgroup}
\begingroup
\catcode`\^^I=\active
\gdef\tabexpand{%
\catcode`\^^I=\active
\def^^I{\leavevmode\egroup
\dimen0=\wd0 % the width so far, or since the previous tab
\divide\dimen0 by\tabw
\multiply\dimen0 by\tabw % compute previous multiple of \tabw
\advance\dimen0 by\tabw % advance to next multiple of \tabw
\wd0=\dimen0 \box0 \starttabbox
}%
}
\endgroup
\def\setupverbatim{%
% Easiest (and conventionally used) font for verbatim
\tt
\def\par{\leavevmode\egroup\box0\endgraf}%
\catcode`\`=\active
\tabexpand
% Respect line breaks,
% print special symbols as themselves, and
% make each space count
% must do in this order:
\obeylines \uncatcodespecials \sepspaces
\everypar{\starttabbox}%
}
% Do the @verb magic: verbatim text is quoted by unique
% delimiter characters. Before first delimiter expect a
% right brace, after last delimiter expect closing brace:
%
% \def\doverb'{'<char>#1<char>'}'{#1}
%
% [Knuth] p. 382; only eat outer {}
\begingroup
\catcode`[=1\catcode`]=2\catcode`\{=12\catcode`\}=12
\gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
\endgroup
%
\def\verb{\begingroup\setupverb\doverb}
%
%
% Do the @verbatim magic: define the macro \doverbatim so that
% the (first) argument ends when '@end verbatim' is reached, ie:
%
% \def\doverbatim#1@end verbatim{#1}
%
% For Texinfo it's a lot easier than for LaTeX,
% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
% we need not redefine '\', '{' and '}'
%
% Inspired by LaTeX's verbatim command set [latex.ltx]
%% Include LaTeX hack for completeness -- never know
%% \begingroup
%% \catcode`|=0 \catcode`[=1
%% \catcode`]=2\catcode`\{=12\catcode`\}=12\catcode`\ =\active
%% \catcode`\\=12|gdef|doverbatim#1@end verbatim[
%% #1|endgroup|def|Everbatim[]|end[verbatim]]
%% |endgroup
\begingroup
\catcode`\ =\active
\gdef\doverbatim#1@end verbatim{#1\end{verbatim}}
\endgroup
%
\def\verbatim{%
\def\Everbatim{\nonfillfinish\endgroup}%
\begingroup
\nonfillstart
\advance\leftskip by -\defbodyindent
\begingroup\setupverbatim\doverbatim
}
% @verbatiminclude FILE - insert text of file in verbatim environment.
%
% Allow normal characters that we make active in the argument (a file name).
\def\verbatiminclude{%
\begingroup
\catcode`\\=12
\catcode`~=12
\catcode`^=12
\catcode`_=12
\catcode`|=12
\catcode`<=12
\catcode`>=12
\catcode`+=12
\parsearg\doverbatiminclude
}
\def\setupverbatiminclude{%
\begingroup
\nonfillstart
\advance\leftskip by -\defbodyindent
\begingroup\setupverbatim
}
%
\def\doverbatiminclude#1{%
% Restore active chars for included file.
\endgroup
\begingroup
\def\thisfile{#1}%
\expandafter\expandafter\setupverbatiminclude\input\thisfile
\endgroup\nonfillfinish\endgroup
}
\message{defuns,}
% @defun etc.
@ -4710,7 +4929,8 @@ width0pt\relax} \fi
\def\deftypeivarheader#1#2#3{%
\dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index
\begingroup
\defname{#3}{\putwordInstanceVariableof\ \code{#1}}%
\defname{\defheaderxcond#2\relax$$$#3}
{\putwordInstanceVariableof\ \code{#1}}%
\defvarargs{#3}%
\endgroup
}
@ -5628,7 +5848,8 @@ width0pt\relax} \fi
\setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
\setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
\begingroup
\catcode`\^^M = 5 % in case we're inside an example
\catcode`\^^M = 5 % in case we're inside an example
\normalturnoffactive % allow _ et al. in names
% If the image is by itself, center it.
\ifvmode
\nobreak\bigskip
@ -5740,6 +5961,15 @@ should work if nowhere else does.}
\setemergencystretch
}
% Use `small' versions.
%
\def\smallenvironments{%
\let\smalldisplay = \smalldisplayx
\let\smallexample = \smalllispx
\let\smallformat = \smallformatx
\let\smalllisp = \smalllispx
}
% @letterpaper (the default).
\def\letterpaper{{\globaldefs = 1
\parskip = 3pt plus 2pt minus 1pt
@ -5762,11 +5992,7 @@ should work if nowhere else does.}
\contentsrightmargin = 0pt
\deftypemargin = 0pt
\defbodyindent = .5cm
%
\let\smalldisplay = \smalldisplayx
\let\smallexample = \smalllispx
\let\smallformat = \smallformatx
\let\smalllisp = \smalllispx
\smallenvironments
}}
% Use @afourpaper to print on European A4 paper.
@ -5780,6 +6006,26 @@ should work if nowhere else does.}
\hfuzz = 1pt
}}
% Use @afivepaper to print on European A5 paper.
% From romildo@urano.iceb.ufop.br, 2 July 2000.
% He also recommends making @example and @lisp be small.
\def\afivepaper{{\globaldefs = 1
\setleading{12.5pt}%
\parskip = 2pt plus 1pt minus 0.1pt
%
\internalpagesizes{166mm}{120mm}{\voffset}{-8mm}{\bindingoffset}{8pt}%
%
\lispnarrowing = 0.2in
\tolerance = 800
\hfuzz = 1.2pt
\contentsrightmargin = 0mm
\deftypemargin = 0pt
\defbodyindent = 2mm
\tableindent = 12mm
%
\smallenvironments
}}
% A specific text layout, 24x15cm overall, intended for A4 paper. Top margin
% 29mm, hence bottom margin 28mm, nominal side margin 3cm.
\def\afourlatex{{\globaldefs = 1

27
contrib/awk/eval_p.c Normal file
View File

@ -0,0 +1,27 @@
/*
* eval_p.c - compile eval.c with profiling turned on.
*/
/*
* Copyright (C) 2001 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
*
* GAWK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GAWK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#define PROFILING 1
#include "eval.c"

186
contrib/awk/ext.c Normal file
View File

@ -0,0 +1,186 @@
/*
* ext.c - Builtin function that links external gawk functions and related
* utilities.
*
* Christos Zoulas, Thu Jun 29 17:40:41 EDT 1995
* Arnold Robbins, update for 3.1, Mon Nov 23 12:53:39 EST 1998
*/
/*
* Copyright (C) 1995 - 2001 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
*
* GAWK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GAWK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "awk.h"
#ifdef DYNAMIC
#include <dlfcn.h>
#ifdef __GNUC__
static unsigned long long dummy; /* fake out gcc for dynamic loading? */
#endif
extern int errcount;
/* do_ext --- load an extension */
NODE *
do_ext(NODE *tree)
{
NODE *obj;
NODE *fun;
NODE *(*func) P((NODE *, void *));
void *dl;
int flags = RTLD_LAZY;
#ifdef __GNUC__
AWKNUM junk;
junk = (AWKNUM) dummy;
#endif
if (do_lint)
lintwarn(_("`extension' is a gawk extension"));
if (do_traditional || do_posix) {
errcount++;
error(_("`extension' is a gawk extension"));
}
obj = tree_eval(tree->lnode);
force_string(obj);
#ifdef RTLD_GLOBAL
flags |= RTLD_GLOBAL;
#endif
if ((dl = dlopen(obj->stptr, flags)) == NULL)
fatal(_("extension: cannot open `%s' (%s)\n"), obj->stptr,
dlerror());
fun = tree_eval(tree->rnode->lnode);
force_string(fun);
func = (NODE *(*) P((NODE *, void *))) dlsym(dl, fun->stptr);
if (func == NULL)
fatal(_("extension: library `%s': cannot call function `%s' (%s)\n"),
obj->stptr, fun->stptr, dlerror());
free_temp(obj);
free_temp(fun);
return (*func)(tree, dl);
}
/* make_builtin --- register name to be called as func with a builtin body */
void
make_builtin(char *name, NODE *(*func) P((NODE *)), int count)
{
NODE *p, *b, *f;
char **vnames, *parm_names, *sp;
char buf[200];
int space_needed, i;
/* count parameters, create artificial list of param names */
space_needed = 0;
for (i = 0; i < count; i++) {
sprintf(buf, "p%d", i);
space_needed += strlen(buf) + 1;
}
emalloc(parm_names, char *, space_needed, "make_builtin");
emalloc(vnames, char **, count * sizeof(char *), "make_builtin");
sp = parm_names;
for (i = 0; i < count; i++) {
sprintf(sp, "p%d",i);
vnames[i] = sp;
sp += strlen(sp) + 1;
}
getnode(p);
p->type = Node_param_list;
p->rnode = NULL;
p->param = name;
p->param_cnt = count;
#if 0
/* setting these blows away the param_cnt. dang unions! */
p->source_line = __LINE__;
p->source_file = __FILE__;
#endif
getnode(b);
b->type = Node_builtin;
b->proc = func;
b->subnode = p;
b->source_line = __LINE__;
b->source_file = __FILE__;
f = node(p, Node_func, b);
f->parmlist = vnames;
install(name, f);
}
/* get_argument --- Get the n'th argument of a dynamically linked function */
NODE *
get_argument(NODE *tree, int i)
{
extern NODE **stack_ptr;
if (i < 0 || i >= tree->param_cnt)
return NULL;
tree = stack_ptr[i];
if (tree->lnode == Nnull_string)
return NULL;
if (tree->type == Node_array_ref)
tree = tree->orig_array;
if (tree->type == Node_var_array)
return tree;
return tree->lnode;
}
/* set_value --- set the return value of a dynamically linked function */
void
set_value(NODE *tree)
{
extern NODE *ret_node;
if (tree)
ret_node = tree;
else
ret_node = Nnull_string;
}
#else
/* do_ext --- dummy version if extensions not available */
NODE *
do_ext(NODE *tree)
{
char *emsg = _("Operation Not Supported");
unref(ERRNO_node->var_value);
ERRNO_node->var_value = make_string(emsg, strlen(emsg));
return tmp_number((AWKNUM) -1);
}
#endif

View File

@ -0,0 +1,96 @@
/*
* dl.c - Example of adding a new builtin function to gawk.
*
* Christos Zoulas, Thu Jun 29 17:40:41 EDT 1995
* Arnold Robbins, update for 3.1, Wed Sep 13 09:38:56 2000
*/
/*
* Copyright (C) 1995 - 2001 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
*
* GAWK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GAWK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "awk.h"
#include <dlfcn.h>
static void *sdl = NULL;
static NODE *
zaxxon(tree)
NODE *tree;
{
NODE *obj;
int i;
int comma = 0;
/*
* Print the arguments
*/
printf("External linkage %s(", tree->param);
for (i = 0; i < tree->param_cnt; i++) {
obj = get_argument(tree, i);
if (obj == NULL)
break;
force_string(obj);
printf(comma ? ", %s" : "%s", obj->stptr);
free_temp(obj);
comma = 1;
}
printf(");\n");
/*
* Do something useful
*/
obj = get_argument(tree, 0);
if (obj != NULL) {
force_string(obj);
if (strcmp(obj->stptr, "unload") == 0 && sdl) {
/*
* XXX: How to clean up the function?
* I would like the ability to remove a function...
*/
dlclose(sdl);
sdl = NULL;
}
free_temp(obj);
}
/* Set the return value */
set_value(tmp_number((AWKNUM) 3.14));
/* Just to make the interpreter happy */
return tmp_number((AWKNUM) 0);
}
NODE *
dlload(tree, dl)
NODE *tree;
void *dl;
{
sdl = dl;
make_builtin("zaxxon", zaxxon, 4);
return tmp_number((AWKNUM) 0);
}

1
contrib/awk/extension/doit Executable file
View File

@ -0,0 +1 @@
../gawk -f foo.awk

View File

@ -0,0 +1,339 @@
/*
* filefuncs.c - Builtin functions that provide initial minimal iterface
* to the file system.
*
* Arnold Robbins, update for 3.1, Mon Nov 23 12:53:39 EST 1998
*/
/*
* Copyright (C) 2001 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
*
* GAWK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GAWK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "awk.h"
#include <sys/sysmacros.h>
/* do_chdir --- provide dynamically loaded chdir() builtin for gawk */
static NODE *
do_chdir(tree)
NODE *tree;
{
NODE *newdir;
int ret = -1;
if (do_lint && tree->param_cnt > 1)
lintwarn("chdir: called with too many arguments");
newdir = get_argument(tree, 0);
if (newdir != NULL) {
(void) force_string(newdir);
ret = chdir(newdir->stptr);
if (ret < 0)
update_ERRNO();
free_temp(newdir);
} else if (do_lint)
lintwarn("chdir: called with no arguments");
/* Set the return value */
set_value(tmp_number((AWKNUM) ret));
/* Just to make the interpreter happy */
return tmp_number((AWKNUM) 0);
}
/* format_mode --- turn a stat mode field into something readable */
static char *
format_mode(fmode)
unsigned long fmode;
{
static char outbuf[12];
int i;
strcpy(outbuf, "----------");
/* first, get the file type */
i = 0;
switch (fmode & S_IFMT) {
#ifdef S_IFSOCK
case S_IFSOCK:
outbuf[i] = 's';
break;
#endif
#ifdef S_IFLNK
case S_IFLNK:
outbuf[i] = 'l';
break;
#endif
case S_IFREG:
outbuf[i] = '-'; /* redundant */
break;
case S_IFBLK:
outbuf[i] = 'b';
break;
case S_IFDIR:
outbuf[i] = 'd';
break;
#ifdef S_IFDOOR /* Solaris weirdness */
case S_IFDOOR:
outbuf[i] = 'D';
break;
#endif /* S_IFDOOR */
case S_IFCHR:
outbuf[i] = 'c';
break;
#ifdef S_IFIFO
case S_IFIFO:
outbuf[i] = 'p';
break;
#endif
}
i++;
if ((fmode & S_IRUSR) != 0)
outbuf[i] = 'r';
i++;
if ((fmode & S_IWUSR) != 0)
outbuf[i] = 'w';
i++;
if ((fmode & S_IXUSR) != 0)
outbuf[i] = 'x';
i++;
if ((fmode & S_IRGRP) != 0)
outbuf[i] = 'r';
i++;
if ((fmode & S_IWGRP) != 0)
outbuf[i] = 'w';
i++;
if ((fmode & S_IXGRP) != 0)
outbuf[i] = 'x';
i++;
if ((fmode & S_IROTH) != 0)
outbuf[i] = 'r';
i++;
if ((fmode & S_IWOTH) != 0)
outbuf[i] = 'w';
i++;
if ((fmode & S_IXOTH) != 0)
outbuf[i] = 'x';
i++;
outbuf[i] = '\0';
if ((fmode & S_ISUID) != 0) {
if (outbuf[3] == 'x')
outbuf[3] = 's';
else
outbuf[3] = 'S';
}
/* setgid without execute == locking */
if ((fmode & S_ISGID) != 0) {
if (outbuf[6] == 'x')
outbuf[6] = 's';
else
outbuf[6] = 'l';
}
if ((fmode & S_ISVTX) != 0) {
if (outbuf[9] == 'x')
outbuf[9] = 't';
else
outbuf[9] = 'T';
}
return outbuf;
}
/* do_stat --- provide a stat() function for gawk */
static NODE *
do_stat(tree)
NODE *tree;
{
NODE *file, *array;
struct stat sbuf;
int ret;
NODE **aptr;
char *pmode; /* printable mode */
char *type = "unknown";
/* check arg count */
if (tree->param_cnt != 2)
fatal(
"stat: called with incorrect number of arguments (%d), should be 2",
tree->param_cnt);
/* directory is first arg, array to hold results is second */
file = get_argument(tree, 0);
array = get_argument(tree, 1);
/* empty out the array */
assoc_clear(array);
/* lstat the file, if error, set ERRNO and return */
(void) force_string(file);
ret = lstat(file->stptr, & sbuf);
if (ret < 0) {
update_ERRNO();
set_value(tmp_number((AWKNUM) ret));
free_temp(file);
return tmp_number((AWKNUM) 0);
}
/* fill in the array */
aptr = assoc_lookup(array, tmp_string("name", 4), FALSE);
*aptr = dupnode(file);
aptr = assoc_lookup(array, tmp_string("dev", 3), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_dev);
aptr = assoc_lookup(array, tmp_string("ino", 3), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_ino);
aptr = assoc_lookup(array, tmp_string("mode", 4), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_mode);
aptr = assoc_lookup(array, tmp_string("nlink", 5), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_nlink);
aptr = assoc_lookup(array, tmp_string("uid", 3), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_uid);
aptr = assoc_lookup(array, tmp_string("gid", 3), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_gid);
aptr = assoc_lookup(array, tmp_string("size", 4), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_size);
aptr = assoc_lookup(array, tmp_string("blocks", 6), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_blocks);
aptr = assoc_lookup(array, tmp_string("atime", 5), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_atime);
aptr = assoc_lookup(array, tmp_string("mtime", 5), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_mtime);
aptr = assoc_lookup(array, tmp_string("ctime", 5), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_ctime);
/* for block and character devices, add rdev, major and minor numbers */
if (S_ISBLK(sbuf.st_mode) || S_ISCHR(sbuf.st_mode)) {
aptr = assoc_lookup(array, tmp_string("rdev", 4), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_rdev);
aptr = assoc_lookup(array, tmp_string("major", 5), FALSE);
*aptr = make_number((AWKNUM) major(sbuf.st_rdev));
aptr = assoc_lookup(array, tmp_string("minor", 5), FALSE);
*aptr = make_number((AWKNUM) minor(sbuf.st_rdev));
}
#ifdef HAVE_ST_BLKSIZE
aptr = assoc_lookup(array, tmp_string("blksize", 7), FALSE);
*aptr = make_number((AWKNUM) sbuf.st_blksize);
#endif /* HAVE_ST_BLKSIZE */
aptr = assoc_lookup(array, tmp_string("pmode", 5), FALSE);
pmode = format_mode(sbuf.st_mode);
*aptr = make_string(pmode, strlen(pmode));
/* for symbolic links, add a linkval field */
if (S_ISLNK(sbuf.st_mode)) {
char buf[BUFSIZ*2];
int linksize;
linksize = readlink(file->stptr, buf, sizeof buf);
/* should make this smarter */
if (linksize == sizeof(buf))
fatal("size of symbolic link too big");
buf[linksize] = '\0';
aptr = assoc_lookup(array, tmp_string("linkval", 7), FALSE);
*aptr = make_string(buf, linksize);
}
/* add a type field */
switch (sbuf.st_mode & S_IFMT) {
#ifdef S_IFSOCK
case S_IFSOCK:
type = "socket";
break;
#endif
#ifdef S_IFLNK
case S_IFLNK:
type = "symlink";
break;
#endif
case S_IFREG:
type = "file";
break;
case S_IFBLK:
type = "blockdev";
break;
case S_IFDIR:
type = "directory";
break;
#ifdef S_IFDOOR
case S_IFDOOR:
type = "door";
break;
#endif
case S_IFCHR:
type = "chardev";
break;
#ifdef S_IFIFO
case S_IFIFO:
type = "fifo";
break;
#endif
}
aptr = assoc_lookup(array, tmp_string("type", 4), FALSE);
*aptr = make_string(type, strlen(type));
free_temp(file);
/* Set the return value */
set_value(tmp_number((AWKNUM) ret));
/* Just to make the interpreter happy */
return tmp_number((AWKNUM) 0);
}
/* dlload --- load new builtins in this library */
NODE *
dlload(tree, dl)
NODE *tree;
void *dl;
{
make_builtin("chdir", do_chdir, 1);
make_builtin("stat", do_stat, 2);
return tmp_number((AWKNUM) 0);
}

View File

@ -0,0 +1,9 @@
BEGIN {
extension("./dl.so","dlload")
zaxxon("hi there", "this is", "a test", "of argument passing")
zaxxon(1)
zaxxon(1,2)
z = zaxxon(1,2,3,4)
z = zaxxon(1,zaxxon(zaxxon("foo")),3,4)
print z
}

View File

@ -0,0 +1,106 @@
/*
* fork.c - Provide fork and waitpid functions for gawk.
*/
/*
* Copyright (C) 2001 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
*
* GAWK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GAWK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "awk.h"
#include <sys/wait.h>
/* do_fork --- provide dynamically loaded fork() builtin for gawk */
static NODE *
do_fork(tree)
NODE *tree;
{
int ret = -1;
NODE **aptr;
if (do_lint && tree->param_cnt > 0)
lintwarn("fork: called with too many arguments");
ret = fork();
if (ret < 0)
update_ERRNO();
else if (ret == 0) {
/* update PROCINFO in the child */
aptr = assoc_lookup(PROCINFO_node, tmp_string("pid", 3), FALSE);
(*aptr)->numbr = (AWKNUM) getpid();
aptr = assoc_lookup(PROCINFO_node, tmp_string("ppid", 4), FALSE);
(*aptr)->numbr = (AWKNUM) getppid();
}
/* Set the return value */
set_value(tmp_number((AWKNUM) ret));
/* Just to make the interpreter happy */
return tmp_number((AWKNUM) 0);
}
/* do_waitpid --- provide dynamically loaded waitpid() builtin for gawk */
static NODE *
do_waitpid(tree)
NODE *tree;
{
NODE *pidnode;
int ret = -1;
double pidval;
pid_t pid;
int options = 0;
if (do_lint && tree->param_cnt > 1)
lintwarn("waitpid: called with too many arguments");
pidnode = get_argument(tree, 0);
if (pidnode != NULL) {
pidval = force_number(pidnode);
pid = (int) pidval;
options = WNOHANG|WUNTRACED;
ret = waitpid(pid, NULL, options);
if (ret < 0)
update_ERRNO();
} else if (do_lint)
lintwarn("wait: called with no arguments");
/* Set the return value */
set_value(tmp_number((AWKNUM) ret));
/* Just to make the interpreter happy */
return tmp_number((AWKNUM) 0);
}
/* dlload --- load new builtins in this library */
NODE *
dlload(tree, dl)
NODE *tree;
void *dl;
{
make_builtin("fork", do_fork, 0);
make_builtin("waitpid", do_waitpid, 1);
return tmp_number((AWKNUM) 0);
}

9
contrib/awk/extension/steps Executable file
View File

@ -0,0 +1,9 @@
# what to do under linux to make dl.so
# Tue Nov 24 15:04:14 EST 1998
gcc -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. dl.c
gcc -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. filefuncs.c
gcc -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. fork.c
ld -o dl.so -shared dl.o
ld -o filefuncs.so -shared filefuncs.o
ld -o fork.so -shared fork.o

View File

@ -0,0 +1,30 @@
BEGIN {
extension("./filefuncs.so", "dlload")
# printf "before: "
# fflush()
# system("pwd")
#
# chdir("..")
#
# printf "after: "
# fflush()
# system("pwd")
chdir(".")
data[1] = 1
print "Info for testff.awk"
ret = stat("testff.awk", data)
print "ret =", ret
for (i in data)
printf "data[\"%s\"] = %s\n", i, data[i]
print "testff.awk modified:", strftime("%m %d %y %H:%M:%S", data["mtime"])
print "\nInfo for JUNK"
ret = stat("JUNK", data)
print "ret =", ret
for (i in data)
printf "data[\"%s\"] = %s\n", i, data[i]
print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"])
}

View File

@ -0,0 +1,20 @@
BEGIN {
extension("./fork.so", "dlload")
printf "before fork, pid = %d, ppid = %d\n", PROCINFO["pid"],
PROCINFO["ppid"]
fflush()
ret = fork()
if (ret < 0)
printf("ret = %d, ERRNO = %s\n", ret, ERRNO)
else if (ret == 0)
printf "child, pid = %d, ppid = %d\n", PROCINFO["pid"],
PROCINFO["ppid"]
else {
system("sleep 3")
printf "parent, ret = %d\n", ret
printf "parent, pid = %d, ppid = %d\n", PROCINFO["pid"],
PROCINFO["ppid"]
}
}

58
contrib/awk/fixvers Executable file
View File

@ -0,0 +1,58 @@
#! /bin/sh
# fixvers --- make sure version.c and patchlev.h reflect
# the reality in configure.in
#
# Copyright (C) 2001 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
#
# GAWK is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GAWK is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
line=`grep AM_INIT_AUTOMAKE configure.in`
case $1 in
-v)
VERS=`echo $line | sed 's/.*, *\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\))/\1.\2/'`
sed "s/X\.Y/$VERS/" < version.in > version.new
if cmp version.c version.new
then
:
else
mv version.new version.c
fi
touch version.c
;;
-p)
LEV=`echo $line | sed 's/.*, *\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\))/\3/'`
echo "#define PATCHLEVEL $LEV" > patchlev.new
if cmp patchlev.h patchlev.new
then
:
else
mv patchlev.new patchlev.h
fi
touch patchlev.h
;;
*)
echo "usage: $0 -v|-p" 1>&2
exit 1
;;
esac
exit 0

Some files were not shown because too many files have changed in this diff Show More