Skip to content

Commit 0efd9e7

Browse files
committed
glibc/libbsd and musl port of 6.0
1 parent 2d6b8f5 commit 0efd9e7

9 files changed

Lines changed: 3905 additions & 118 deletions

File tree

Makefile

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
1-
# $OpenBSD: Makefile,v 1.14 2013/08/18 22:06:44 miod Exp $
1+
# $OpenBSD: Makefile,v 1.13 2013/07/28 18:10:16 miod Exp $
22

33
PROG= awk
4-
SRCS= ytab.c lex.c b.c main.c parse.c proctab.c tran.c lib.c run.c
4+
SRCS= ytab.c lex.c b.c main.c parse.c proctab.c tran.c lib.c run.c reallocarray.c
5+
PKG_CONFIG?= pkg-config
56
LDADD= -lm
67
DPADD= ${LIBM}
78
CLEANFILES+=proctab.c maketab ytab.c ytab.h
8-
CFLAGS+=-I. -I${.CURDIR} -DHAS_ISBLANK -DNDEBUG
9-
HOSTCFLAGS+=-I. -I${.CURDIR} -DHAS_ISBLANK -DNDEBUG
9+
CURDIR= $(shell pwd)
10+
CC?= cc
11+
HOSTCC?= $(CC)
12+
CFLAGS+=-I. -I${CURDIR} -DHAS_ISBLANK -DNDEBUG
13+
HOSTCFLAGS+=-I. -I${CURDIR} -DHAS_ISBLANK -DNDEBUG
14+
DESTDIR?=
15+
PREFIX?=/usr
16+
BINDIR=$(PREFIX)/bin
17+
MANDIR=$(PREFIX)/man
18+
19+
all: $(PROG)
20+
21+
$(PROG): proctab.c
22+
$(CC) $(CFLAGS) $(SRCS) $(LDFLAGS) $(LDADD) -o $(PROG)
1023

1124
ytab.c ytab.h: awkgram.y
12-
${YACC} -d ${.CURDIR}/awkgram.y
25+
${YACC} -d ${CURDIR}/awkgram.y
1326
mv y.tab.c ytab.c
1427
mv y.tab.h ytab.h
1528

16-
proctab.c: maketab
29+
proctab.c: ytab.h maketab.c
30+
${HOSTCC} ${HOSTCFLAGS} ${CURDIR}/maketab.c -o maketab
1731
./maketab >proctab.c
1832

19-
maketab: ytab.h maketab.c
20-
${HOSTCC} ${HOSTCFLAGS} ${.CURDIR}/maketab.c -o $@
21-
22-
.include <bsd.prog.mk>
33+
install: $(PROG)
34+
install -D -m 755 $(PROG) $(DESTDIR)/$(BINDIR)/$(PROG)
35+
install -D -m 644 $(PROG).1 $(DESTDIR)/$(MANDIR)/man1/$(PROG).1

README

Lines changed: 14 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,18 @@
1-
/* $OpenBSD: README,v 1.7 2011/09/28 19:27:18 millert Exp $ */
2-
/****************************************************************
3-
Copyright (C) Lucent Technologies 1997
4-
All Rights Reserved
1+
_ _
2+
| | ___ | | __
3+
| |/ _ \| |/ /
4+
| | (_) | <
5+
|_|\___/|_|\_\
6+
7+
Overview
8+
========
59

6-
Permission to use, copy, modify, and distribute this software and
7-
its documentation for any purpose and without fee is hereby
8-
granted, provided that the above copyright notice appear in all
9-
copies and that both that the copyright notice and this
10-
permission notice and warranty disclaimer appear in supporting
11-
documentation, and that the name Lucent Technologies or any of
12-
its entities not be used in advertising or publicity pertaining
13-
to distribution of the software without specific, written prior
14-
permission.
10+
lok is a Linux (https://www.kernel.org/) port of OpenBSD's
11+
(http://www.openbsd.org/) awk.
1512

16-
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17-
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
18-
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
19-
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
21-
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
22-
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
23-
THIS SOFTWARE.
24-
****************************************************************/
13+
Legal Information
14+
=================
2515

26-
This is the version of awk described in "The AWK Programming Language",
27-
by Al Aho, Brian Kernighan, and Peter Weinberger
28-
(Addison-Wesley, 1988, ISBN 0-201-07981-X).
16+
lok is licensed under the same license as the upstream code it is based on.
2917

30-
Changes, mostly bug fixes and occasional enhancements, are listed
31-
in FIXES. If you distribute this code further, please please please
32-
distribute FIXES with it. If you find errors, please report them
33-
to bwk@cs.princeton.edu. Thanks.
34-
35-
The program itself is created by
36-
make
37-
which should produce a sequence of messages roughly like this:
38-
39-
yacc -d awkgram.y
40-
41-
conflicts: 43 shift/reduce, 85 reduce/reduce
42-
mv y.tab.c ytab.c
43-
mv y.tab.h ytab.h
44-
cc -c ytab.c
45-
cc -c b.c
46-
cc -c main.c
47-
cc -c parse.c
48-
cc maketab.c -o maketab
49-
./maketab >proctab.c
50-
cc -c proctab.c
51-
cc -c tran.c
52-
cc -c lib.c
53-
cc -c run.c
54-
cc -c lex.c
55-
cc ytab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -lm
56-
57-
This produces an executable a.out; you will eventually want to
58-
move this to some place like /usr/bin/awk.
59-
60-
If your system does not have yacc or bison (the GNU
61-
equivalent), you must compile the pieces manually. We have
62-
included yacc output in ytab.c and ytab.h, and backup copies in
63-
case you overwrite them. We have also included a copy of
64-
proctab.c so you do not need to run maketab.
65-
66-
NOTE: This version uses ANSI C, as you should also. We have
67-
compiled this without any changes using gcc -Wall and/or local C
68-
compilers on a variety of systems, but new systems or compilers
69-
may raise some new complaint; reports of difficulties are
70-
welcome.
71-
72-
This also compiles with Visual C++ on all flavors of Windows,
73-
*if* you provide versions of popen and pclose. The file
74-
missing95.c contains versions that can be used to get started
75-
with, though the underlying support has mysterious properties,
76-
the symptom of which can be truncated pipe output. Beware. The
77-
file makefile.win gives hints on how to proceed; if you run
78-
vcvars32.bat, it will set up necessary paths and parameters so
79-
you can subsequently run nmake -f makefile.win. Beware also that
80-
when running on Windows under command.com, various quoting
81-
conventions are different from Unix systems: single quotes won't
82-
work around arguments, and various characters like % are
83-
interpreted within double quotes.
84-
85-
This compiles without change on Macintosh OS X using gcc and
86-
the standard developer tools.
87-
88-
This is also said to compile on Macintosh OS 9 systems, using the
89-
file "buildmac" provided by Dan Allen (danallen@microsoft.com),
90-
to whom many thanks.
91-
92-
The version of malloc that comes with some systems is sometimes
93-
astonishly slow. If awk seems slow, you might try fixing that.
94-
More generally, turning on optimization can significantly improve
95-
awk's speed, perhaps by 1/3 for highest levels.
18+
The ASCII art logo at the top was made using FIGlet (http://www.figlet.org/).

README.upstream

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/* $OpenBSD: README,v 1.7 2011/09/28 19:27:18 millert Exp $ */
2+
/****************************************************************
3+
Copyright (C) Lucent Technologies 1997
4+
All Rights Reserved
5+
6+
Permission to use, copy, modify, and distribute this software and
7+
its documentation for any purpose and without fee is hereby
8+
granted, provided that the above copyright notice appear in all
9+
copies and that both that the copyright notice and this
10+
permission notice and warranty disclaimer appear in supporting
11+
documentation, and that the name Lucent Technologies or any of
12+
its entities not be used in advertising or publicity pertaining
13+
to distribution of the software without specific, written prior
14+
permission.
15+
16+
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17+
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
18+
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
19+
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
21+
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
22+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
23+
THIS SOFTWARE.
24+
****************************************************************/
25+
26+
This is the version of awk described in "The AWK Programming Language",
27+
by Al Aho, Brian Kernighan, and Peter Weinberger
28+
(Addison-Wesley, 1988, ISBN 0-201-07981-X).
29+
30+
Changes, mostly bug fixes and occasional enhancements, are listed
31+
in FIXES. If you distribute this code further, please please please
32+
distribute FIXES with it. If you find errors, please report them
33+
to bwk@cs.princeton.edu. Thanks.
34+
35+
The program itself is created by
36+
make
37+
which should produce a sequence of messages roughly like this:
38+
39+
yacc -d awkgram.y
40+
41+
conflicts: 43 shift/reduce, 85 reduce/reduce
42+
mv y.tab.c ytab.c
43+
mv y.tab.h ytab.h
44+
cc -c ytab.c
45+
cc -c b.c
46+
cc -c main.c
47+
cc -c parse.c
48+
cc maketab.c -o maketab
49+
./maketab >proctab.c
50+
cc -c proctab.c
51+
cc -c tran.c
52+
cc -c lib.c
53+
cc -c run.c
54+
cc -c lex.c
55+
cc ytab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -lm
56+
57+
This produces an executable a.out; you will eventually want to
58+
move this to some place like /usr/bin/awk.
59+
60+
If your system does not have yacc or bison (the GNU
61+
equivalent), you must compile the pieces manually. We have
62+
included yacc output in ytab.c and ytab.h, and backup copies in
63+
case you overwrite them. We have also included a copy of
64+
proctab.c so you do not need to run maketab.
65+
66+
NOTE: This version uses ANSI C, as you should also. We have
67+
compiled this without any changes using gcc -Wall and/or local C
68+
compilers on a variety of systems, but new systems or compilers
69+
may raise some new complaint; reports of difficulties are
70+
welcome.
71+
72+
This also compiles with Visual C++ on all flavors of Windows,
73+
*if* you provide versions of popen and pclose. The file
74+
missing95.c contains versions that can be used to get started
75+
with, though the underlying support has mysterious properties,
76+
the symptom of which can be truncated pipe output. Beware. The
77+
file makefile.win gives hints on how to proceed; if you run
78+
vcvars32.bat, it will set up necessary paths and parameters so
79+
you can subsequently run nmake -f makefile.win. Beware also that
80+
when running on Windows under command.com, various quoting
81+
conventions are different from Unix systems: single quotes won't
82+
work around arguments, and various characters like % are
83+
interpreted within double quotes.
84+
85+
This compiles without change on Macintosh OS X using gcc and
86+
the standard developer tools.
87+
88+
This is also said to compile on Macintosh OS 9 systems, using the
89+
file "buildmac" provided by Dan Allen (danallen@microsoft.com),
90+
to whom many thanks.
91+
92+
The version of malloc that comes with some systems is sometimes
93+
astonishly slow. If awk seems slow, you might try fixing that.
94+
More generally, turning on optimization can significantly improve
95+
awk's speed, perhaps by 1/3 for highest levels.

main.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ int main(int argc, char *argv[])
6464
setlocale(LC_ALL, "");
6565
setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
6666

67-
if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1) {
68-
fprintf(stderr, "%s: pledge: incorrect arguments\n",
69-
cmdname);
70-
exit(1);
71-
}
72-
7367
cmdname = __progname;
7468
if (argc == 1) {
7569
fprintf(stderr, "usage: %s [-safe] [-V] [-d[n]] [-F fs] "
@@ -156,14 +150,6 @@ int main(int argc, char *argv[])
156150
argv++;
157151
}
158152

159-
if (safe) {
160-
if (pledge("stdio rpath", NULL) == -1) {
161-
fprintf(stderr, "%s: pledge: incorrect arguments\n",
162-
cmdname);
163-
exit(1);
164-
}
165-
}
166-
167153
/* argv[1] is now the first argument */
168154
if (npfile == 0) { /* no -f; first argument is program */
169155
if (argc <= 1) {

0 commit comments

Comments
 (0)