CVS commit: othersrc/external/historical/eawk/doc

2020-08-02 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Mon Aug  3 02:09:49 UTC 2020

Modified Files:
othersrc/external/historical/eawk/doc: extensions

Log Message:
Fix typo - thanks to Brad Harder (yukonbob)!


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/doc/extensions

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk/doc

2020-08-02 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Mon Aug  3 02:09:49 UTC 2020

Modified Files:
othersrc/external/historical/eawk/doc: extensions

Log Message:
Fix typo - thanks to Brad Harder (yukonbob)!


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/doc/extensions

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/historical/eawk/doc/extensions
diff -u othersrc/external/historical/eawk/doc/extensions:1.1 othersrc/external/historical/eawk/doc/extensions:1.2
--- othersrc/external/historical/eawk/doc/extensions:1.1	Sat Jun  1 22:27:32 2013
+++ othersrc/external/historical/eawk/doc/extensions	Mon Aug  3 02:09:49 2020
@@ -2,7 +2,7 @@ Extending eawk
 ==
 
 To add new functionality to eawk, extensions are used. They can be layered
-on top of each other, and provide access to thirs-party libraries. To write
+on top of each other, and provide access to third-party libraries. To write
 and use an extensions, we'll look at the base64 encoding extension in eawk:
 
 -- see extend/base64/base64.c



CVS commit: othersrc/external/historical/eawk

2020-08-02 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Mon Aug  3 00:43:12 UTC 2020

Modified Files:
othersrc/external/historical/eawk/dist: ext.c
othersrc/external/historical/eawk/lib: Makefile

Log Message:
Make this compile with gcc 8.4.0


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/dist/ext.c
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/lib/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk

2020-08-02 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Mon Aug  3 00:43:12 UTC 2020

Modified Files:
othersrc/external/historical/eawk/dist: ext.c
othersrc/external/historical/eawk/lib: Makefile

Log Message:
Make this compile with gcc 8.4.0


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/dist/ext.c
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/lib/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/historical/eawk/dist/ext.c
diff -u othersrc/external/historical/eawk/dist/ext.c:1.1 othersrc/external/historical/eawk/dist/ext.c:1.2
--- othersrc/external/historical/eawk/dist/ext.c:1.1	Fri May 31 05:56:36 2013
+++ othersrc/external/historical/eawk/dist/ext.c	Mon Aug  3 00:43:12 2020
@@ -100,7 +100,8 @@ eawk_use_module(eawk_t *eawk, const char
 	void		*init;
 	void		*lib;
 	char		 path[MAXPATHLEN];
-	char		 buf[64];
+	char		 buf[MAXPATHLEN * 2];
+	char		 funcname[64];
 	int		(*func)(eawk_t *);
 
 	if (eawk_find_lib(eawk, module) < 0) {
@@ -110,9 +111,9 @@ eawk_use_module(eawk_t *eawk, const char
 			fprintf(stderr, "%s\n", buf);
 			return 0;
 		}
-		snprintf(buf, sizeof(buf), "eawk_use_%s", module);
-		if ((init = dlsym(lib, buf)) == NULL) {
-			snprintf(buf, sizeof(buf), "lib \"%s\" func %s not found", path, buf);
+		snprintf(funcname, sizeof(funcname), "eawk_use_%s", module);
+		if ((init = dlsym(lib, funcname)) == NULL) {
+			snprintf(buf, sizeof(buf), "lib \"%s\" func %s not found", path, funcname);
 			fprintf(stderr, "%s\n", buf);
 			return 0;
 		}

Index: othersrc/external/historical/eawk/lib/Makefile
diff -u othersrc/external/historical/eawk/lib/Makefile:1.2 othersrc/external/historical/eawk/lib/Makefile:1.3
--- othersrc/external/historical/eawk/lib/Makefile:1.2	Wed Jan 17 01:38:37 2018
+++ othersrc/external/historical/eawk/lib/Makefile	Mon Aug  3 00:43:12 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2018/01/17 01:38:37 agc Exp $
+#	$NetBSD: Makefile,v 1.3 2020/08/03 00:43:12 agc Exp $
 
 .include 
 
@@ -11,6 +11,7 @@ CPPFLAGS+=	-I. -I${DIST} -DHAS_ISBLANK
 YFLAGS+= -p eawk_ -d 
 CPPFLAGS.run.c+= -Wno-format-nonliteral
 CPPFLAGS.tran.c+= -Wno-format-nonliteral
+CPPFLAGS.lex.c+= -Wno-multistatement-macros
 #CPPFLAGS+= -DYYPARSE_PARAM_TYPE='void *'
 #CPPFLAGS+= -DYYPARSE_PARAM=awkp
 #CPPFLAGS+= -DYYLEX_PARAM=awkp



CVS commit: othersrc/external/historical/eawk

2018-01-16 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed Jan 17 01:38:37 UTC 2018

Modified Files:
othersrc/external/historical/eawk/bin: expected
othersrc/external/historical/eawk/dist: awkgram.y
othersrc/external/historical/eawk/extend: Makefile
othersrc/external/historical/eawk/extend/archive: archive.c
othersrc/external/historical/eawk/extend/netpgpverify: netpgpverify.c
othersrc/external/historical/eawk/lib: Makefile

Log Message:
Bring eawk up to date, it's had no real love since 2013.

1. Don't use bison, just use standard yacc to build
2. Use pure-parser directive, rather than %pure_parser
3. libarchive has changed its API since 2013 - adapt
4. netpgpverify has also changed its API since 2013 - adapt also
5. There is no sqlite3 sub-directory, so don't descend into it

With thanks to yukonbob for the nudge.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 othersrc/external/historical/eawk/bin/expected
cvs rdiff -u -r1.3 -r1.4 othersrc/external/historical/eawk/dist/awkgram.y
cvs rdiff -u -r1.5 -r1.6 othersrc/external/historical/eawk/extend/Makefile
cvs rdiff -u -r1.1 -r1.2 \
othersrc/external/historical/eawk/extend/archive/archive.c
cvs rdiff -u -r1.1 -r1.2 \
othersrc/external/historical/eawk/extend/netpgpverify/netpgpverify.c
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/lib/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/historical/eawk/bin/expected
diff -u othersrc/external/historical/eawk/bin/expected:1.4 othersrc/external/historical/eawk/bin/expected:1.5
--- othersrc/external/historical/eawk/bin/expected:1.4	Thu Jun  6 01:45:56 2013
+++ othersrc/external/historical/eawk/bin/expected	Wed Jan 17 01:38:36 2018
@@ -20,23 +20,14 @@ _mdnsd
 _tests
 _tcpdump
 _tss
+_rtadvd
+_unbound
 uucp
 nobody
 agc
-prosody
-quagga
-cjparker
-dirmngr
 dbus
 lp
-avahi
-polkit
-haldaemon
-pulse
 cyrus
-distcc
-varnish
-stud
 2. Testing FS, non-first field, print and next
 root:Charlie &
 toor:Bourne-again Superuser
@@ -58,23 +49,14 @@ _mdnsd:& pseudo-user
 _tests:& pseudo-user
 _tcpdump:& pseudo-user
 _tss:& pseudo-user
+_rtadvd:& pseudo-user
+_unbound:& pseudo-user
 uucp:UNIX-to-UNIX Copy
 nobody:Unprivileged user
 agc:
-prosody:Prosody daemon user
-quagga:quagga user
-cjparker:
-dirmngr:dirmngr user
 dbus:System message bus
 lp:Common UNIX Printing System user
-avahi:Avahi user
-polkit:policykit polkit user
-haldaemon:hal haldaemon user
-pulse:pulseaudio pulse user
 cyrus:cyrus-sasl cyrus user
-distcc:distcc user
-varnish:Varnish daemon user
-stud:stud daemon user
 3. Testing BEGIN printing
 hello world
 4. Testing bit arith
@@ -114,7 +96,7 @@ ddaf35a193617abacc417349ae20413112e6fa4e
 15. Testing stat
 mode 100644
 16. Testing stat
-mode 2123
+mode 1576
 16. Testing time
 17. Testing ctime
 wrong ctime!
@@ -130,9 +112,9 @@ WARNS=		5
 21. Testing getaddrinfo
 17
 21. Testing getaddrinfo address returned
-1002005095143556
+10020050c7e9d9cd
 22. Testing getaddrinfo address returned
-1002005095143556
+10020050c7e9d9cd
 23. Testing soundex
 abortion a163 BRXN
 acrimony a265 KRMNY
@@ -199,550 +181,11 @@ output
 27. Testing fnmatch
 Makefile
 28. Testing http
-http://www.w3.org/TR/html4/loose.dtd;>
-
-
-  
-
-
-
-
-
-http://www.NetBSD.org/changes/rss-netbsd.xml;>
-The NetBSD Project
-
-
-
-
-
-
-
-
-
-
-
-  
-
-  
-
-Skip to main content.
-
-
-	
-		
-		The NetBSD Project
-		Of course it runs NetBSD
-	
-	
-	http://www.NetBSD.org/cgi-bin/redirect.cgi;>
-	  
-		http://www.NetBSD.org/;>- WWW mirrors -
-		
-		
-		http://www.au.NetBSD.org/;>Australia
-		http://www2.be.NetBSD.org/;>Belgium (IPv4,IPv6)
-		http://www.fr.NetBSD.org/;>France (IPv4,IPv6)
-		http://netbsd.mcom.fr/;>France/2
-		http://www.de.NetBSD.org/;>Germany (IPv4,IPv6)
-		http://netbsd.mirrors.treibsand.com/;>Germany/2
-		http://www.it.NetBSD.org/;>Italy
-		http://www.jp.NetBSD.org/index.html;>Japan
-		http://www.za.NetBSD.org/;>South Africa
-		http://www.se.NetBSD.org/;>Sweden
-		http://www.uk.NetBSD.org/;>UK
-		http://netbsd.planetunix.net/;>USA (IPv4,IPv6)
-		
-		http://www.NetBSD.org/;>Master Site, USA (IPv4, IPv6)
-		http://www6.NetBSD.org/;>Master Site, USA (IPv6 only)
-	  
-	  
-	
-
-	 
-
-
-
-
-
-
-	Google custom search
-	http://www.google.com/jsapi"; type="text/javascript"> 
-	google.load('search', '1', {language : 'en'});
-	google.setOnLoadCallback(function() {
-		var header_customSearchControl = new 

CVS commit: othersrc/external/historical/eawk

2018-01-16 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed Jan 17 01:38:37 UTC 2018

Modified Files:
othersrc/external/historical/eawk/bin: expected
othersrc/external/historical/eawk/dist: awkgram.y
othersrc/external/historical/eawk/extend: Makefile
othersrc/external/historical/eawk/extend/archive: archive.c
othersrc/external/historical/eawk/extend/netpgpverify: netpgpverify.c
othersrc/external/historical/eawk/lib: Makefile

Log Message:
Bring eawk up to date, it's had no real love since 2013.

1. Don't use bison, just use standard yacc to build
2. Use pure-parser directive, rather than %pure_parser
3. libarchive has changed its API since 2013 - adapt
4. netpgpverify has also changed its API since 2013 - adapt also
5. There is no sqlite3 sub-directory, so don't descend into it

With thanks to yukonbob for the nudge.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 othersrc/external/historical/eawk/bin/expected
cvs rdiff -u -r1.3 -r1.4 othersrc/external/historical/eawk/dist/awkgram.y
cvs rdiff -u -r1.5 -r1.6 othersrc/external/historical/eawk/extend/Makefile
cvs rdiff -u -r1.1 -r1.2 \
othersrc/external/historical/eawk/extend/archive/archive.c
cvs rdiff -u -r1.1 -r1.2 \
othersrc/external/historical/eawk/extend/netpgpverify/netpgpverify.c
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/lib/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk

2013-06-08 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Sat Jun  8 10:48:57 UTC 2013

Modified Files:
othersrc/external/historical/eawk/extend: Makefile
Added Files:
othersrc/external/historical/eawk/extend/httpd: Makefile httpd.c
shlib_version tiny.c tiny.h
othersrc/external/historical/eawk/scripts: httpd.sh json.sh

Log Message:
Changes to eawk:

+ add a small script to do some basic json printing

+ add a small http daemon library - which only does GET requests,
  but still useful. Also add an eawk script, which acts as a web server
  in 9 lines of awk:

env LD_LIBRARY_PATH=lib:extend/httpd bin/eawk -v port=${port} '
BEGIN { use(httpd)
server = httpd_bind_server(localhost, port, ipv4)
while (1) {
client = httpd_get_connection(server);
uri = httpd_read_request(client);
filename = httpd_parse_uri(uri)
httpd_serve_static_content(client, filename);
httpd_close_client_connection(client);
}
}'

and in use:

% sh scripts/httpd.sh 12345
Client request from: 127.0.0.1
GET /CHANGES HTTP/1.0
Host: localhost:12345
Accept: text/html, text/plain, text/css, text/sgml, */*;q=0.01
Accept-Encoding: gzip, compress, bzip2
Accept-Language: en
User-Agent: Lynx/2.8.7rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/1.0.1-stable


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 othersrc/external/historical/eawk/extend/Makefile
cvs rdiff -u -r0 -r1.1 \
othersrc/external/historical/eawk/extend/httpd/Makefile \
othersrc/external/historical/eawk/extend/httpd/httpd.c \
othersrc/external/historical/eawk/extend/httpd/shlib_version \
othersrc/external/historical/eawk/extend/httpd/tiny.c \
othersrc/external/historical/eawk/extend/httpd/tiny.h
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/scripts/httpd.sh \
othersrc/external/historical/eawk/scripts/json.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/historical/eawk/extend/Makefile
diff -u othersrc/external/historical/eawk/extend/Makefile:1.4 othersrc/external/historical/eawk/extend/Makefile:1.5
--- othersrc/external/historical/eawk/extend/Makefile:1.4	Thu Jun  6 01:45:56 2013
+++ othersrc/external/historical/eawk/extend/Makefile	Sat Jun  8 10:48:57 2013
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2013/06/06 01:45:56 agc Exp $
+# $NetBSD: Makefile,v 1.5 2013/06/08 10:48:57 agc Exp $
 
 SUBDIR+=	archive
 SUBDIR+=	base64
@@ -23,6 +23,7 @@ SUBDIR+=	hmac
 .if exists(/usr/include/http.h)
 SUBDIR+=	http
 .endif
+SUBDIR+=	httpd
 .if exists(/usr/include/mat.h)
 SUBDIR+=	mat
 .endif

Added files:

Index: othersrc/external/historical/eawk/extend/httpd/Makefile
diff -u /dev/null othersrc/external/historical/eawk/extend/httpd/Makefile:1.1
--- /dev/null	Sat Jun  8 10:48:57 2013
+++ othersrc/external/historical/eawk/extend/httpd/Makefile	Sat Jun  8 10:48:57 2013
@@ -0,0 +1,15 @@
+#	$NetBSD: Makefile,v 1.1 2013/06/08 10:48:57 agc Exp $
+
+.include bsd.own.mk
+
+DIST=	${.CURDIR}/../../dist
+.PATH:	${DIST}
+
+LIB=	eawk-httpd
+SRCS=	httpd.c tiny.c
+CPPFLAGS+=	-I. -I${DIST}
+MKMAN=	no
+
+WARNS=	5
+
+.include bsd.lib.mk
Index: othersrc/external/historical/eawk/extend/httpd/httpd.c
diff -u /dev/null othersrc/external/historical/eawk/extend/httpd/httpd.c:1.1
--- /dev/null	Sat Jun  8 10:48:57 2013
+++ othersrc/external/historical/eawk/extend/httpd/httpd.c	Sat Jun  8 10:48:57 2013
@@ -0,0 +1,279 @@
+/*-
+ * Copyright (c) 2013 Alistair Crooks a...@netbsd.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */

CVS commit: othersrc/external/historical/eawk

2013-06-08 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Sat Jun  8 10:48:57 UTC 2013

Modified Files:
othersrc/external/historical/eawk/extend: Makefile
Added Files:
othersrc/external/historical/eawk/extend/httpd: Makefile httpd.c
shlib_version tiny.c tiny.h
othersrc/external/historical/eawk/scripts: httpd.sh json.sh

Log Message:
Changes to eawk:

+ add a small script to do some basic json printing

+ add a small http daemon library - which only does GET requests,
  but still useful. Also add an eawk script, which acts as a web server
  in 9 lines of awk:

env LD_LIBRARY_PATH=lib:extend/httpd bin/eawk -v port=${port} '
BEGIN { use(httpd)
server = httpd_bind_server(localhost, port, ipv4)
while (1) {
client = httpd_get_connection(server);
uri = httpd_read_request(client);
filename = httpd_parse_uri(uri)
httpd_serve_static_content(client, filename);
httpd_close_client_connection(client);
}
}'

and in use:

% sh scripts/httpd.sh 12345
Client request from: 127.0.0.1
GET /CHANGES HTTP/1.0
Host: localhost:12345
Accept: text/html, text/plain, text/css, text/sgml, */*;q=0.01
Accept-Encoding: gzip, compress, bzip2
Accept-Language: en
User-Agent: Lynx/2.8.7rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/1.0.1-stable


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 othersrc/external/historical/eawk/extend/Makefile
cvs rdiff -u -r0 -r1.1 \
othersrc/external/historical/eawk/extend/httpd/Makefile \
othersrc/external/historical/eawk/extend/httpd/httpd.c \
othersrc/external/historical/eawk/extend/httpd/shlib_version \
othersrc/external/historical/eawk/extend/httpd/tiny.c \
othersrc/external/historical/eawk/extend/httpd/tiny.h
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/scripts/httpd.sh \
othersrc/external/historical/eawk/scripts/json.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk

2013-06-05 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Thu Jun  6 01:45:57 UTC 2013

Modified Files:
othersrc/external/historical/eawk/bin: Makefile expected
othersrc/external/historical/eawk/dist: run.c tran.c
othersrc/external/historical/eawk/extend: Makefile
othersrc/external/historical/eawk/extend/db: db.c
othersrc/external/historical/eawk/scripts: tart.sh
Added Files:
othersrc/external/historical/eawk/extend/curses: Makefile curses.c
shlib_version
othersrc/external/historical/eawk/extend/threshold: Makefile
shlib_version threshold.c
othersrc/external/historical/eawk/scripts: rain.sh test-thresh.sh
threshold.sh

Log Message:
Changes to eawk:

+ reworked the db interface to be easier to use - results are now
returned as part of key and value arrays, which both have data and
size fields, to mirror the DBT struct

+ added initial curses bindings

+ fixed a bug in numeric array field names which I introduced

+ added scripts/rain.sh awk script which does what /usr/games/rain
does, and which exercises numeric array field names, and curses. It's
also much smaller than the equivalent C source.

+ added bindings for threshold algorithms, and a script to exercise
them


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 othersrc/external/historical/eawk/bin/Makefile \
othersrc/external/historical/eawk/bin/expected
cvs rdiff -u -r1.6 -r1.7 othersrc/external/historical/eawk/dist/run.c
cvs rdiff -u -r1.5 -r1.6 othersrc/external/historical/eawk/dist/tran.c
cvs rdiff -u -r1.3 -r1.4 othersrc/external/historical/eawk/extend/Makefile
cvs rdiff -u -r0 -r1.1 \
othersrc/external/historical/eawk/extend/curses/Makefile \
othersrc/external/historical/eawk/extend/curses/curses.c \
othersrc/external/historical/eawk/extend/curses/shlib_version
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/extend/db/db.c
cvs rdiff -u -r0 -r1.1 \
othersrc/external/historical/eawk/extend/threshold/Makefile \
othersrc/external/historical/eawk/extend/threshold/shlib_version \
othersrc/external/historical/eawk/extend/threshold/threshold.c
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/scripts/rain.sh \
othersrc/external/historical/eawk/scripts/test-thresh.sh \
othersrc/external/historical/eawk/scripts/threshold.sh
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/scripts/tart.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/historical/eawk/bin/Makefile
diff -u othersrc/external/historical/eawk/bin/Makefile:1.3 othersrc/external/historical/eawk/bin/Makefile:1.4
--- othersrc/external/historical/eawk/bin/Makefile:1.3	Wed Jun  5 00:55:25 2013
+++ othersrc/external/historical/eawk/bin/Makefile	Thu Jun  6 01:45:56 2013
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2013/06/05 00:55:25 agc Exp $
+# $NetBSD: Makefile,v 1.4 2013/06/06 01:45:56 agc Exp $
 
 .include bsd.own.mk
 
@@ -108,7 +108,7 @@ t test: ${PROG}
 	@echo 31. Testing hmac
 	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_HMAC} ./${PROG} 'BEGIN { use(hmac); mac = hmac(sha1, akey, the quick brown fox jumps over the lazy dog); print hmac_bin2str(mac) }'
 	@echo 32. Testing db
-	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_DB} ./${PROG} 'BEGIN { use(db); db = dbopen(/etc/pwd.db, O_RDONLY, 0666, hash); for (f = R_FIRST ; s = dbseq(db, s, f) ; f = R_NEXT) print s; }'
+	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_DB}:${LIB_C} ./${PROG} 'BEGIN { use(db); use(c); info[type] = hash; db = dbopen(/etc/pwd.db, O_RDONLY, 0666, info); while (dbseq(db, key, val, R_NEXT) == 0) print val[data]; }'
 	@echo 33. Testing hex strings
 	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_DB} ./${PROG} 'BEGIN { s=\x20a\x20b\x20c; printf(,%s,\n, s) }'
 	@echo 34. Testing zlib
Index: othersrc/external/historical/eawk/bin/expected
diff -u othersrc/external/historical/eawk/bin/expected:1.3 othersrc/external/historical/eawk/bin/expected:1.4
--- othersrc/external/historical/eawk/bin/expected:1.3	Wed Jun  5 00:55:25 2013
+++ othersrc/external/historical/eawk/bin/expected	Thu Jun  6 01:45:56 2013
@@ -711,7 +711,7 @@ Makefile
 
 
 !-- # Footer # --
-!-- $NetBSD: expected,v 1.3 2013/06/05 00:55:25 agc Exp $ --
+!-- $NetBSD: expected,v 1.4 2013/06/06 01:45:56 agc Exp $ --
 div class=rowOfBoxes
   div id=footer
 	div id=footerLogo
@@ -742,7 +742,7 @@ Makefile
 29. Testing netdiff
 30. Testing netdiff with diffs
 ---
- # $NetBSD: expected,v 1.3 2013/06/05 00:55:25 agc Exp $
+ # $NetBSD: expected,v 1.4 2013/06/06 01:45:56 agc Exp $
 5c5
  PROG=		eawk
 ---
@@ -914,8 +914,8 @@ Makefile
 
 30. Testing unidiff with diffs
 @@ -1,8 +1,8 @@
--# $NetBSD: expected,v 1.3 2013/06/05 00:55:25 agc Exp $
-+# $NetBSD: expected,v 1.3 2013/06/05 00:55:25 agc Exp $
+-# $NetBSD: expected,v 1.4 2013/06/06 01:45:56 agc Exp $
++# $NetBSD: expected,v 1.4 2013/06/06 

CVS commit: othersrc/external/historical/eawk

2013-06-05 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Thu Jun  6 01:45:57 UTC 2013

Modified Files:
othersrc/external/historical/eawk/bin: Makefile expected
othersrc/external/historical/eawk/dist: run.c tran.c
othersrc/external/historical/eawk/extend: Makefile
othersrc/external/historical/eawk/extend/db: db.c
othersrc/external/historical/eawk/scripts: tart.sh
Added Files:
othersrc/external/historical/eawk/extend/curses: Makefile curses.c
shlib_version
othersrc/external/historical/eawk/extend/threshold: Makefile
shlib_version threshold.c
othersrc/external/historical/eawk/scripts: rain.sh test-thresh.sh
threshold.sh

Log Message:
Changes to eawk:

+ reworked the db interface to be easier to use - results are now
returned as part of key and value arrays, which both have data and
size fields, to mirror the DBT struct

+ added initial curses bindings

+ fixed a bug in numeric array field names which I introduced

+ added scripts/rain.sh awk script which does what /usr/games/rain
does, and which exercises numeric array field names, and curses. It's
also much smaller than the equivalent C source.

+ added bindings for threshold algorithms, and a script to exercise
them


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 othersrc/external/historical/eawk/bin/Makefile \
othersrc/external/historical/eawk/bin/expected
cvs rdiff -u -r1.6 -r1.7 othersrc/external/historical/eawk/dist/run.c
cvs rdiff -u -r1.5 -r1.6 othersrc/external/historical/eawk/dist/tran.c
cvs rdiff -u -r1.3 -r1.4 othersrc/external/historical/eawk/extend/Makefile
cvs rdiff -u -r0 -r1.1 \
othersrc/external/historical/eawk/extend/curses/Makefile \
othersrc/external/historical/eawk/extend/curses/curses.c \
othersrc/external/historical/eawk/extend/curses/shlib_version
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/extend/db/db.c
cvs rdiff -u -r0 -r1.1 \
othersrc/external/historical/eawk/extend/threshold/Makefile \
othersrc/external/historical/eawk/extend/threshold/shlib_version \
othersrc/external/historical/eawk/extend/threshold/threshold.c
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/scripts/rain.sh \
othersrc/external/historical/eawk/scripts/test-thresh.sh \
othersrc/external/historical/eawk/scripts/threshold.sh
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/scripts/tart.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk

2013-06-04 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed Jun  5 02:59:48 UTC 2013

Modified Files:
othersrc/external/historical/eawk/dist: b.c eawk.h lib.c run.c tran.c
othersrc/external/historical/eawk/extend/bzlib: bzlib.c
othersrc/external/historical/eawk/extend/c: c.c
othersrc/external/historical/eawk/extend/dirent: dirent.c
othersrc/external/historical/eawk/extend/zlib: zlib.c

Log Message:
modify the name eawk_lookup to be eawk_array_lookup

change the function's signature so that the array comes first, followed
by the name of the entry.

fix up all uses of eawk_array_lookup()


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/dist/b.c
cvs rdiff -u -r1.3 -r1.4 othersrc/external/historical/eawk/dist/eawk.h \
othersrc/external/historical/eawk/dist/lib.c
cvs rdiff -u -r1.5 -r1.6 othersrc/external/historical/eawk/dist/run.c
cvs rdiff -u -r1.4 -r1.5 othersrc/external/historical/eawk/dist/tran.c
cvs rdiff -u -r1.1 -r1.2 \
othersrc/external/historical/eawk/extend/bzlib/bzlib.c
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/extend/c/c.c
cvs rdiff -u -r1.1 -r1.2 \
othersrc/external/historical/eawk/extend/dirent/dirent.c
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/extend/zlib/zlib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/historical/eawk/dist/b.c
diff -u othersrc/external/historical/eawk/dist/b.c:1.2 othersrc/external/historical/eawk/dist/b.c:1.3
--- othersrc/external/historical/eawk/dist/b.c:1.2	Fri May 31 05:56:36 2013
+++ othersrc/external/historical/eawk/dist/b.c	Wed Jun  5 02:59:47 2013
@@ -946,7 +946,7 @@ eawk_regcomp(eawk_t *eawk, const char *s
 		}
 	}
 
-	if (strcmp(eawk_getsval(eawk, eawk_lookup(stage, eawk-control)), compiling) == 0) {
+	if (strcmp(eawk_getsval(eawk, eawk_array_lookup(eawk-control, stage)), compiling) == 0) {
 		/* a constant for sure */
 		return mkdfa(eawk, s, anchor);
 	}

Index: othersrc/external/historical/eawk/dist/eawk.h
diff -u othersrc/external/historical/eawk/dist/eawk.h:1.3 othersrc/external/historical/eawk/dist/eawk.h:1.4
--- othersrc/external/historical/eawk/dist/eawk.h:1.3	Wed Jun  5 00:55:25 2013
+++ othersrc/external/historical/eawk/dist/eawk.h	Wed Jun  5 02:59:47 2013
@@ -289,7 +289,7 @@ char	*eawk_setsvalN(eawk_t */*eawk*/, aw
 
 awkarray_t *eawk_asort(eawk_t */*eawk*/, awkarray_t */*array*/, int /*asorti*/, int */*sortc*/);
 awkcell_t	*eawk_new_array(eawk_t */*eawk*/, awkcell_t */*arrayname*/);
-awkcell_t	*eawk_lookup(const char */*name*/, awkarray_t */*array*/);
+awkcell_t	*eawk_array_lookup(awkarray_t */*array*/, const char */*name*/);
 int	eawk_define_constant(eawk_t */*eawk*/, const char */*name*/, int64_t /*valnum*/);
 
 __END_DECLS
Index: othersrc/external/historical/eawk/dist/lib.c
diff -u othersrc/external/historical/eawk/dist/lib.c:1.3 othersrc/external/historical/eawk/dist/lib.c:1.4
--- othersrc/external/historical/eawk/dist/lib.c:1.3	Wed Jun  5 00:55:25 2013
+++ othersrc/external/historical/eawk/dist/lib.c	Wed Jun  5 02:59:47 2013
@@ -59,7 +59,7 @@ initgetrec(eawk_t *eawk)
 
 	for (i = 1; i  *eawk-ARGC; i++) {
 		if (!eawk_isclvar(p = getargv(eawk, i))) {	/* find 1st real filename */
-			eawk_setsval(eawk, eawk_lookup(FILENAME, eawk-symtab), getargv(eawk, i));
+			eawk_setsval(eawk, eawk_array_lookup(eawk-symtab, FILENAME), getargv(eawk, i));
 			return;
 		}
 		eawk_setclvar(eawk, p);	/* a commandline assignment before filename */
@@ -181,7 +181,7 @@ eprint(eawk_t *eawk)
 	char	*stage;
 	char *p, *q;
 
-	stage = eawk_getsval(eawk, eawk_lookup(stage, eawk-control));
+	stage = eawk_getsval(eawk, eawk_array_lookup(eawk-control, stage));
 	if (strcmp(stage, error display) == 0 || strcmp(stage, running) == 0 || eawk-eprintc++  0) {
 		return;
 	}
@@ -252,7 +252,7 @@ error(eawk_t *eawk)
 {
 	char	*stage;
 
-	stage = eawk_getsval(eawk, eawk_lookup(stage, eawk-control));
+	stage = eawk_getsval(eawk, eawk_array_lookup(eawk-control, stage));
 	(void) fprintf(stderr, \n);
 	if (strcmp(stage, error display) == 0  eawk-NR  *eawk-NR  0) {
 		(void) fprintf(stderr,  input record number %d, (int) (*eawk-FNR));
@@ -688,14 +688,14 @@ eawk_syntax(eawk_t *eawk, const char *fm
 
 	if (eawk-syntaxc++  2)
 		return;
-	(void) fprintf(stderr, %s: , eawk_getsval(eawk, eawk_lookup(cmdname, eawk-control)));
+	(void) fprintf(stderr, %s: , eawk_getsval(eawk, eawk_array_lookup(eawk-control, cmdname)));
 	va_start(varg, fmt);
 	vfprintf(stderr, fmt, varg);
 	va_end(varg);
 	(void) fprintf(stderr,  at source line %d, eawk-lineno);
 	if (eawk-curfname != NULL)
 		(void) fprintf(stderr,  in function %s, eawk-curfname);
-	stage = eawk_getsval(eawk, eawk_lookup(stage, eawk-control));
+	stage = eawk_getsval(eawk, eawk_array_lookup(eawk-control, stage));
 	if (strcmp(stage, compiling) == 0  cursource(eawk) != NULL)
 		(void) fprintf(stderr,  

CVS commit: othersrc/external/historical/eawk

2013-06-04 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed Jun  5 00:55:26 UTC 2013

Modified Files:
othersrc/external/historical/eawk/bin: Makefile expected
othersrc/external/historical/eawk/dist: eawk.h lib.c run.c tran.c
othersrc/external/historical/eawk/extend: Makefile
othersrc/external/historical/eawk/scripts: bg.sh
Added Files:
othersrc/external/historical/eawk/extend/archive: Makefile archive.c
shlib_version
othersrc/external/historical/eawk/extend/bzlib: Makefile bzlib.c
shlib_version
othersrc/external/historical/eawk/extend/netpgpverify: Makefile
netpgpverify.c shlib_version
othersrc/external/historical/eawk/extend/zlib: Makefile shlib_version
zlib.c
othersrc/external/historical/eawk/scripts: catvfy.sh tart.sh vfy.sh

Log Message:
More changes to eawk:

+ changed the type of the awkcell str field to be void *, since it's
  overloaded for so much. Fix up uses of 'str' everywhere.
+ added extension bindings for zlib
+ added extension bindings for bzlib
+ added extension bindings for libarchive
+ added extension bindings for libnetpgpverify

netpgpverify


% cat scripts/vfy.sh
#! /bin/sh

pubring=${HOME}/.gnupg/pubring.gpg
if [ $# -lt 1 ]; then
echo Usage: vfy signed-file 2
exit 1
fi
env LD_LIBRARY_PATH=lib:extend/netpgpverify bin/eawk -v f=$1 -v 
pubring=${pubring} '
BEGIN { use(netpgpverify);
pgp = pgpv_alloc(pgpv);
pgpv_read_pubring(pgp, pubring);
if (pgpv_verify(pgp, f, sig))
print Good signature for  f, \n strftime(%a %b %e %H:%M:%S 
%Z %Y, sig[time]), \n sig[signer]
}'
% sh scripts/vfy.sh 
/usr/pkgsrc/security/netpgpverify/files/NetBSD-6.0_RC1_hashes.asc
Good signature for 
/usr/pkgsrc/security/netpgpverify/files/NetBSD-6.0_RC1_hashes.asc
Thu Aug 23 11:47:50 PDT 2012
signature  4096/RSA (Encrypt or Sign) 064973ac4c4a706e 2009-06-23
fingerprint:  ddee 2bdb 9c98 a0d1 d4fb dbf7 0649 73ac 4c4a 706e
uid  NetBSD Security Officer security-offi...@netbsd.org
encryption 4096/RSA (Encrypt or Sign) 9ff2c24fdf2ce620 2009-06-23 [Expiry 
2019-06-21]
fingerprint:  1915 0801 fbd8 f45d 89f2 0205 9ff2 c24f df2c e620

libarchive
==

% cat scripts/tart.sh
#! /bin/sh

if [ $# -lt 1 ]; then
echo Usage: $0 archive 2
exit 1
fi
env LD_LIBRARY_PATH=lib:extend/archive bin/eawk -v f=$1 '
BEGIN {
use(archive);
arch = archive_read_new();
if (archive_read_open_filename(arch, f) != ARCHIVE_OK) 
printf(phooey#1\n)
while (archive_read_next_header(arch, ent) == ARCHIVE_OK)
print ent[strmode], ent[nlink], ent[uname], ent[gname], 
ent[size], ent[pathname]
archive_read_finish(arch)
}'
% sh scripts/tart.sh /usr/pkgsrc/packages/All/digest-2004.tgz
-rw-r--r--  0 root wheel 345 +CONTENTS
-r--r--r--  0 root wheel 31 +COMMENT
-r--r--r--  0 root wheel 212 +DESC
-rw-r--r--  0 root wheel 1468 +BUILD_VERSION
-rw-r--r--  0 root wheel 2769 +BUILD_INFO
-rw-r--r--  0 root wheel 6 +SIZE_PKG
-rw-r--r--  0 root wheel 6 +SIZE_ALL
-rwxr-xr-x  0 root wheel 71568 bin/digest
-rw-r--r--  0 root wheel 2950 man/man1/digest.1


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/bin/Makefile \
othersrc/external/historical/eawk/bin/expected
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/dist/eawk.h \
othersrc/external/historical/eawk/dist/lib.c
cvs rdiff -u -r1.4 -r1.5 othersrc/external/historical/eawk/dist/run.c
cvs rdiff -u -r1.3 -r1.4 othersrc/external/historical/eawk/dist/tran.c
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/extend/Makefile
cvs rdiff -u -r0 -r1.1 \
othersrc/external/historical/eawk/extend/archive/Makefile \
othersrc/external/historical/eawk/extend/archive/archive.c \
othersrc/external/historical/eawk/extend/archive/shlib_version
cvs rdiff -u -r0 -r1.1 \
othersrc/external/historical/eawk/extend/bzlib/Makefile \
othersrc/external/historical/eawk/extend/bzlib/bzlib.c \
othersrc/external/historical/eawk/extend/bzlib/shlib_version
cvs rdiff -u -r0 -r1.1 \
othersrc/external/historical/eawk/extend/netpgpverify/Makefile \
othersrc/external/historical/eawk/extend/netpgpverify/netpgpverify.c \
othersrc/external/historical/eawk/extend/netpgpverify/shlib_version
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/extend/zlib/Makefile \
othersrc/external/historical/eawk/extend/zlib/shlib_version \
othersrc/external/historical/eawk/extend/zlib/zlib.c
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/scripts/bg.sh
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/scripts/catvfy.sh \
othersrc/external/historical/eawk/scripts/tart.sh \
othersrc/external/historical/eawk/scripts/vfy.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk

2013-06-04 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed Jun  5 02:59:48 UTC 2013

Modified Files:
othersrc/external/historical/eawk/dist: b.c eawk.h lib.c run.c tran.c
othersrc/external/historical/eawk/extend/bzlib: bzlib.c
othersrc/external/historical/eawk/extend/c: c.c
othersrc/external/historical/eawk/extend/dirent: dirent.c
othersrc/external/historical/eawk/extend/zlib: zlib.c

Log Message:
modify the name eawk_lookup to be eawk_array_lookup

change the function's signature so that the array comes first, followed
by the name of the entry.

fix up all uses of eawk_array_lookup()


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/dist/b.c
cvs rdiff -u -r1.3 -r1.4 othersrc/external/historical/eawk/dist/eawk.h \
othersrc/external/historical/eawk/dist/lib.c
cvs rdiff -u -r1.5 -r1.6 othersrc/external/historical/eawk/dist/run.c
cvs rdiff -u -r1.4 -r1.5 othersrc/external/historical/eawk/dist/tran.c
cvs rdiff -u -r1.1 -r1.2 \
othersrc/external/historical/eawk/extend/bzlib/bzlib.c
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/extend/c/c.c
cvs rdiff -u -r1.1 -r1.2 \
othersrc/external/historical/eawk/extend/dirent/dirent.c
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/extend/zlib/zlib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk/dist

2013-06-01 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Sat Jun  1 22:22:30 UTC 2013

Modified Files:
othersrc/external/historical/eawk/dist: tran.c

Log Message:
sync with a bugfix in awk sources - check we don't have a NULL value when
setting a string value


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/dist/tran.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/historical/eawk/dist/tran.c
diff -u othersrc/external/historical/eawk/dist/tran.c:1.2 othersrc/external/historical/eawk/dist/tran.c:1.3
--- othersrc/external/historical/eawk/dist/tran.c:1.2	Fri May 31 05:56:36 2013
+++ othersrc/external/historical/eawk/dist/tran.c	Sat Jun  1 22:22:30 2013
@@ -529,7 +529,8 @@ eawk_setsvalN(eawk_t *eawk, awkcell_t *c
 		eawk-donefld = 0;	/* mark $1... invalid */
 		eawk-donerec = 1;
 	}
-	t = eawk_tostringN(eawk, s, size);	/* in case it's self-assign */
+	/* in case it's self-assign */
+	t = (s) ? eawk_tostringN(eawk, s, size) : eawk_tostringN(eawk, , 1);
 	cell-binsize = (uint32_t)size;
 	cell-type = ~EAWK_NUM;
 	cell-type |= EAWK_STR;



CVS commit: othersrc/external/historical/eawk

2013-06-01 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Sat Jun  1 22:25:10 UTC 2013

Modified Files:
othersrc/external/historical/eawk/bin: Makefile expected
othersrc/external/historical/eawk/extend: Makefile
Added Files:
othersrc/external/historical/eawk/extend/bufgap: Makefile bufgap.c
shlib_version

Log Message:
Add a bufgap extension, based on the buffer gap routines in othersrc.

Only compile in extensinos if we have the appropriate infrastructure in place -
needs to be revisited for cross-building (if ever that were to happen).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/bin/Makefile \
othersrc/external/historical/eawk/bin/expected
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/extend/Makefile
cvs rdiff -u -r0 -r1.1 \
othersrc/external/historical/eawk/extend/bufgap/Makefile \
othersrc/external/historical/eawk/extend/bufgap/bufgap.c \
othersrc/external/historical/eawk/extend/bufgap/shlib_version

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/historical/eawk/bin/Makefile
diff -u othersrc/external/historical/eawk/bin/Makefile:1.1 othersrc/external/historical/eawk/bin/Makefile:1.2
--- othersrc/external/historical/eawk/bin/Makefile:1.1	Fri May 31 05:56:36 2013
+++ othersrc/external/historical/eawk/bin/Makefile	Sat Jun  1 22:25:10 2013
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2013/05/31 05:56:36 agc Exp $
+# $NetBSD: Makefile,v 1.2 2013/06/01 22:25:10 agc Exp $
 
 .include bsd.own.mk
 
@@ -60,9 +60,9 @@ t test: ${PROG}
 	@echo 13. Testing foreign external call
 	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_DIGEST} ./${PROG} 'BEGIN { use(digest); buf = abc; print SHA512_Data(buf, 3) }'
 	@echo 14. Testing regexps
-	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C} ./${PROG} 'BEGIN { use(c); r = alloc(regex_t); regcomp(r, PROG, REG_EXTENDED); } { if (regexec(r, $$0) == 0) print }' Makefile
+	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C} ./${PROG} 'BEGIN { use(c); r = alloc(regex_t); regcomp(r, PROG, REG_EXTENDED); } { if (regexec(r, $$0) == 0) print }' m2
 	@echo 14. Testing regexps with offsets
-	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C} ./${PROG} 'BEGIN { use(c); r = alloc(regex_t); regcomp(r, PROG); } { if (regexec(r, $$0, a) == 0) printf(a[0] %d, a[1] %d: %s\n, a[0], a[1], $$0)}' Makefile
+	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C} ./${PROG} 'BEGIN { use(c); r = alloc(regex_t); regcomp(r, PROG); } { if (regexec(r, $$0, a) == 0) printf(a[0] %d, a[1] %d: %s\n, a[0], a[1], $$0)}' m2
 	@echo 15. Testing stat
 	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C} ./${PROG} 'BEGIN { use(c); ok = stat(/etc/passwd, st); printf(mode %o\n, st[st_mode])}'
 	@echo 16. Testing stat
@@ -74,9 +74,9 @@ t test: ${PROG}
 	@echo 18. Testing bitwise and and octal constants
 	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C} ./${PROG} 'BEGIN { use(c); stat(/etc/passwd, st); printf(%o\n, and(st[st_mode], 0777)) }'
 	@echo 19. Testing constants and basic regexps
-	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C} ./${PROG} 'BEGIN { use(c); r = alloc(regex_t); regcomp(r, S+=, REG_BASIC); } { if (regexec(r, $$0) == 0) print }' Makefile
+	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C} ./${PROG} 'BEGIN { use(c); r = alloc(regex_t); regcomp(r, S+=, REG_BASIC); } { if (regexec(r, $$0) == 0) print }' m2
 	@echo 20. Testing constants and extended regexps
-	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C} ./${PROG} 'BEGIN { use(c); r = alloc(regex_t); regcomp(r, S+=, REG_EXTENDED); } { if (regexec(r, $$0) == 0) print }' Makefile
+	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C} ./${PROG} 'BEGIN { use(c); r = alloc(regex_t); regcomp(r, S+=, REG_EXTENDED); } { if (regexec(r, $$0) == 0) print }' m2
 	@echo 21. Testing getaddrinfo
 	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C} ./${PROG} 'BEGIN { use(c); addr[ai_family] = PF_UNSPEC; if (getaddrinfo(www.netbsd.org, http, addr) == 0) print addr[ai_protocol] }'
 	@echo 21. Testing getaddrinfo address returned
@@ -98,9 +98,9 @@ t test: ${PROG}
 	@echo 28. Testing http
 	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_C}:${LIB_HTTP} ./${PROG} 'BEGIN { use(c); use(http); http = http_alloc(); url = http_asget(http, http://www.netbsd.org/index.html;, 0, 4); print url}'
 	@echo 29. Testing netdiff
-	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_NETDIFF} ./${PROG} 'BEGIN { use(netdiff); d = diff_init(); diff_file(d, Makefile, Makefile, 0); }'
+	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_NETDIFF} ./${PROG} 'BEGIN { use(netdiff); d = diff_init(); diff_file(d, m2, m2, 0); }'
 	@echo 30. Testing netdiff with diffs
-	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_NETDIFF} ./${PROG} 'BEGIN { use(netdiff); d = diff_init(); if (diff_file(d, Makefile, m2, 0)) { s = diff_get_diffs(d); print s } }'
+	@env LD_LIBRARY_PATH=${LIBEAWKDIR}:${LIB_NETDIFF} ./${PROG} 'BEGIN { use(netdiff); d = diff_init(); if (diff_file(d, Makefile, m2, 0)) { s = 

CVS commit: othersrc/external/historical/eawk/scripts

2013-06-01 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Sat Jun  1 22:26:11 UTC 2013

Added Files:
othersrc/external/historical/eawk/scripts: bg.sh

Log Message:
add a script to exercise the buffer gap routines


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/scripts/bg.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: othersrc/external/historical/eawk/scripts/bg.sh
diff -u /dev/null othersrc/external/historical/eawk/scripts/bg.sh:1.1
--- /dev/null	Sat Jun  1 22:26:11 2013
+++ othersrc/external/historical/eawk/scripts/bg.sh	Sat Jun  1 22:26:11 2013
@@ -0,0 +1,23 @@
+#! /bin/sh
+
+env LD_LIBRARY_PATH=lib:extend/bufgap bin/eawk -v f=$1 '
+BEGIN {
+	use(bufgap);
+	gap = bufgap_alloc();
+	if (bufgap_open(gap, f) == 0) print phooey#1;
+	for (i = bufgap_size(gap, BGByte) - 1 ; i = 0 ; --i) {
+		printf(%c, bufgap_peek(gap, 0));
+		bufgap_seek(gap, 1, BGFromHere, BGByte);
+	}
+	printf(\n===\n);
+	for (i = bufgap_size(gap, BGByte) - 1 ; i = 0 ; --i) {
+		printf(%c, bufgap_peek(gap, 0));
+		(void) bufgap_seek(gap, -1, BGFromHere, BGByte);
+	}
+	printf(\n===\n);
+	for (i = bufgap_size(gap, BGByte) - 1 ; i = 0 ; --i) {
+		printf(%c, bufgap_peek(gap, 0));
+		(void) bufgap_seek(gap, 1, BGFromHere, BGByte);
+	}
+	printf(\n===\n);
+}'



CVS commit: othersrc/external/historical/eawk/doc

2013-06-01 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Sat Jun  1 22:27:32 UTC 2013

Added Files:
othersrc/external/historical/eawk/doc: embedding extensions

Log Message:
add preliminary documentation for both extending, and embedding, eawk.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/doc/embedding \
othersrc/external/historical/eawk/doc/extensions

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: othersrc/external/historical/eawk/doc/embedding
diff -u /dev/null othersrc/external/historical/eawk/doc/embedding:1.1
--- /dev/null	Sat Jun  1 22:27:32 2013
+++ othersrc/external/historical/eawk/doc/embedding	Sat Jun  1 22:27:32 2013
@@ -0,0 +1,76 @@
+Embedding eawk in other programs
+
+
+It's now possible to use awk from within other programs, such as editors
+and shells, to provide full awk parsing, string manipulation and other
+benefits.
+
+The easiest way to accomplish this is to look at the source in dist/main.c
+
+1. set the defaults with:
+
+	eawk_t		  awk;
+
+	...
+	eawk_setdefaults(awk, *argv);
+
+2. Set up the file names of any scripts with:
+
+	eawk_setup_scripts(awk, argc, argv);
+
+(where argc is the number of scripts, and argv are the names of them).
+
+3. And set up the runtime args
+
+	eawk_setup_environment(awk, argc, argv);
+
+4. Parse awk scripts
+
+	eawk_parse(awk);
+
+5. Set up any read or write callbacks:
+
+	eawk_set_write_callback(awk, writerec);
+	eawk_set_read_callback(awk, readrec, NULL);
+
+The callbacks had previously been declared with:
+
+	/* callback for fetching output text */
+	static ssize_t
+	writerec(char *buf, size_t size)
+	{
+		ssize_t	wc;
+
+		wc = fwrite(buf, 1, size, stdout);
+		fflush(stdout);
+		return wc;
+	}
+
+The writerec callback is called when there is output from eawk. Normally
+this would just be printed on stdout -- and is what this callback does.
+However, it's also possible to send this through other processing, or
+hand to other threads or processes)
+
+	/* callback for fetching input text */
+	static ssize_t
+	readrec(eawk_t *eawk, FILE *fp, void *vp)
+	{
+		char	 buf[BUFSIZ];
+
+		USE_ARG(vp);
+		if (fgets(buf, sizeof(buf), fp) != NULL) {
+			eawk-incc = strlen(buf);
+			memcpy(eawk-inbuf, buf, eawk-incc);
+			return eawk-incc;
+		}
+		return 0;
+	}
+
+The readrec callback is called when eawk is to be given input. There is an
+opaque object in the function signature, in case this is needed to retrieve
+characters. In our case, we are simply taking input from the fp file
+descriptor, and transferring it to (a fixed-size buffer in) eawk.
+
+6. Call eawk_run() to do all the processing work:
+
+	eawk_run(awk);
Index: othersrc/external/historical/eawk/doc/extensions
diff -u /dev/null othersrc/external/historical/eawk/doc/extensions:1.1
--- /dev/null	Sat Jun  1 22:27:32 2013
+++ othersrc/external/historical/eawk/doc/extensions	Sat Jun  1 22:27:32 2013
@@ -0,0 +1,96 @@
+Extending eawk
+==
+
+To add new functionality to eawk, extensions are used. They can be layered
+on top of each other, and provide access to thirs-party libraries. To write
+and use an extensions, we'll look at the base64 encoding extension in eawk:
+
+-- see extend/base64/base64.c
+
+1. include the header to get definitions
+
+#include eawk.h
+
+2. write wrapper functions for every function you want to call from eawk:
+
+	/* base64 encode function */
+	static awkcell_t *
+	eawk_base64_b64encode(void *veawk, char *name, int argc, awkcell_t **a)
+	{
+		eawk_t		*eawk = (eawk_t *)veawk;
+		size_t		 outsize;
+		size_t		 insize;
+		char		*out;
+		char		*in;
+
+		USE_ARG(name);
+		if (argc  1 || argc  2) {
+			eawk_setsval(eawk, eawk-fp-retval, );
+			return eawk-fp-retval;
+		}
+		/* get data off stack */
+		in = eawk_getsval(eawk, a[0]);
+		insize = (argc  1) ? (size_t)eawk_getfval(eawk, a[1]) : strlen(in);
+		outsize = ((insize * 4) / 3) + 32;
+		out = calloc(1, outsize);
+		outsize = b64encode(in, insize, out, outsize, 0);
+		/* return code */
+		eawk_setsvalN(eawk, eawk-fp-retval, out, outsize);
+		free(out);
+		return eawk-fp-retval;
+	}
+
+argc gives the number of args the awk script used when calling your function
+
+string data is retrieved from the runtime stack with eawk_getsval, args are
+numbered from 0 (and the function name and return value are not counted).
+Numeric data can be retried with eawk_getfval.
+
+When returning args, eawk_setsval is used for strings (and eawk_setsvalN for
+fixed length strings). eawk_setfval is used for numeric data. Arrays can be
+used to receive and send back values, see the regexec() wrapper for an example
+of this.
+
+3.  Finally, the extension mechanism loads the wrapper functions from
+a .so, and the function is accessed using this mechanism.
+
+	int eawk_use_base64(eawk_t */*eawk*/);
+
+	/* register base64 functions */
+	int
+	eawk_use_base64(eawk_t *eawk)

CVS commit: othersrc/external/historical/eawk/dist

2013-06-01 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Sat Jun  1 22:22:30 UTC 2013

Modified Files:
othersrc/external/historical/eawk/dist: tran.c

Log Message:
sync with a bugfix in awk sources - check we don't have a NULL value when
setting a string value


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/dist/tran.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk

2013-06-01 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Sat Jun  1 22:25:10 UTC 2013

Modified Files:
othersrc/external/historical/eawk/bin: Makefile expected
othersrc/external/historical/eawk/extend: Makefile
Added Files:
othersrc/external/historical/eawk/extend/bufgap: Makefile bufgap.c
shlib_version

Log Message:
Add a bufgap extension, based on the buffer gap routines in othersrc.

Only compile in extensinos if we have the appropriate infrastructure in place -
needs to be revisited for cross-building (if ever that were to happen).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/bin/Makefile \
othersrc/external/historical/eawk/bin/expected
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/extend/Makefile
cvs rdiff -u -r0 -r1.1 \
othersrc/external/historical/eawk/extend/bufgap/Makefile \
othersrc/external/historical/eawk/extend/bufgap/bufgap.c \
othersrc/external/historical/eawk/extend/bufgap/shlib_version

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk/scripts

2013-06-01 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Sat Jun  1 22:26:11 UTC 2013

Added Files:
othersrc/external/historical/eawk/scripts: bg.sh

Log Message:
add a script to exercise the buffer gap routines


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/scripts/bg.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk/doc

2013-06-01 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Sat Jun  1 22:27:32 UTC 2013

Added Files:
othersrc/external/historical/eawk/doc: embedding extensions

Log Message:
add preliminary documentation for both extending, and embedding, eawk.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/doc/embedding \
othersrc/external/historical/eawk/doc/extensions

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




CVS commit: othersrc/external/historical/eawk

2013-05-30 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Fri May 31 05:56:38 UTC 2013

Modified Files:
othersrc/external/historical/eawk: Makefile
othersrc/external/historical/eawk/dist: Makefile awkgram.y awkre.h b.c
eawk.h lex.c lib.c main.c parse.c proctab.c proto.h run.c tran.c
Added Files:
othersrc/external/historical/eawk/bin: Makefile expected in1 m2
othersrc/external/historical/eawk/dist: ext.c
othersrc/external/historical/eawk/extend: Makefile
othersrc/external/historical/eawk/extend/base64: Makefile b64.c b64.h
base64.c shlib_version
othersrc/external/historical/eawk/extend/c: Makefile c.c shlib_version
othersrc/external/historical/eawk/extend/circa: Makefile circa.c
shlib_version
othersrc/external/historical/eawk/extend/db: Makefile db.c
shlib_version
othersrc/external/historical/eawk/extend/digest: Makefile crc32c.c
crc32c.h digest.c shlib_version
othersrc/external/historical/eawk/extend/dirent: Makefile dirent.c
shlib_version
othersrc/external/historical/eawk/extend/getopt2: Makefile getopt2.c
shlib_version
othersrc/external/historical/eawk/extend/hmac: Makefile hmac.c
shlib_version
othersrc/external/historical/eawk/extend/http: Makefile http.c
shlib_version
othersrc/external/historical/eawk/extend/mat: Makefile mat.c
shlib_version
othersrc/external/historical/eawk/extend/netdiff: Makefile netdiff.c
shlib_version
othersrc/external/historical/eawk/extend/netpgp: Makefile netpgp.c
shlib_version
othersrc/external/historical/eawk/extend/progress: Makefile progress.c
shlib_version
othersrc/external/historical/eawk/extend/rs: Makefile rs.c
shlib_version
othersrc/external/historical/eawk/extend/soundex: Makefile
shlib_version soundex.c words
othersrc/external/historical/eawk/extend/termcap: Makefile
shlib_version termcap.c
othersrc/external/historical/eawk/lib: Makefile shlib_version
othersrc/external/historical/eawk/scripts: conn.sh conn2.sh n.sh
progress.sh y.awk
Removed Files:
othersrc/external/historical/eawk/dist: EAWK dl.sh dl2.sh dl3.sh dl4.sh
dl5.sh dl6.sh dl7.sh dl8.sh dl9.sh dlA.sh dlB.sh dlC.sh
othersrc/external/historical/eawk/eawk: Makefile expected
othersrc/external/historical/eawk/libeawk: Makefile shlib_version

Log Message:
Re-do completely the way that external modules are loaded in eawk.
For now, use a

use(digest)

style statement in the script to enable the bindings in a
libeawk-digest.so to be loaded via dlopen(3).

Also add readrec() and writerec() callbacks for use in embedded
programs, so that eawk can really be deeply embedded in other things,
and used as a command interpreter, etc.

Other headline changes include:
+ added gawk-style bit arithmetic ops
+ added gawk-style asort/asorti
+ added eawk_readrec() and eawk_writerec() callbacks for use
  in embedded operations
+ added extension use via use() command
+ added extensions for
base64
c
circa
db
digests
dirent
getopt2
hmac
http
mat
netdiff
netpgp
progress
rs
soundex
termcap

The upshot is that we can extend awk quite easily, as shown by this example
script:

% cat scripts/conn2.sh
#! /bin/sh

env LD_LIBRARY_PATH=lib:extend/c bin/eawk -v host=$1 '
BEGIN {
use(c);
if (host == ) print phooey#0;
addr[ai_family] = PF_INET;
if (getaddrinfo(host, http, addr) != 0) print phooey#1;
sd = socket(PF_INET, SOCK_STREAM, 0);
if (connect(sd, addr[ai_addr], addr[ai_addrlen]) != 0) print 
phooey#2;
s = sprintf(GET / HTTP/1.1\r\nHost: %s\r\nUser-Agent: 
eawk-2.1\r\n\r\n, host);
write(sd, s, length(s));
url = read(sd, 4096);
print url;
close(sd);
}'
% sh scripts/conn2.sh www.netbsd.org
HTTP/1.1 200 OK
Date: Fri, 31 May 2013 05:49:44 GMT
Server: Apache/2.2.24 (Unix)
Last-Modified: Sun, 19 May 2013 17:44:20 GMT
ETag: 83765-4fd9-4dd15c40bc500
Accept-Ranges:  none
Content-Length: 20441
Content-Type: text/html; charset=ISO-8859-1

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/html4/loose.dtd;

html
  head
meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1
!-- Copyright (c) 1994-2011
 The NetBSD Foundation, Inc.  ALL RIGHTS RESERVED. --
link rev=made href=mailto:w...@netbsd.org;
link rel=shortcut icon href=./favicon.ico type=image/x-icon
link rel=stylesheet href=global.css type=text/css
link rel=alternate type=application/rss+xml title=NetBSD news
  href=http://www.NetBSD.org/changes/rss-netbsd.xml;

CVS commit: othersrc/external/historical/eawk/dist

2011-08-31 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Thu Sep  1 05:03:18 UTC 2011

Modified Files:
othersrc/external/historical/eawk/dist: run.c

Log Message:
especially on LE platforms, we need to be careful to set the size of
the format specifier in awk printf() for integer output.  this was
being done for 'd' and 'i' formats, but not for 'o', 'x', 'X' and 'u'
formats.  rectify that.

allows hex patterns like 0xff00 to be printed


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/historical/eawk/dist/run.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/historical/eawk/dist/run.c
diff -u othersrc/external/historical/eawk/dist/run.c:1.1.1.1 othersrc/external/historical/eawk/dist/run.c:1.2
--- othersrc/external/historical/eawk/dist/run.c:1.1.1.1	Wed Aug 31 04:19:41 2011
+++ othersrc/external/historical/eawk/dist/run.c	Thu Sep  1 05:03:18 2011
@@ -1114,16 +1114,15 @@
 		case 'f': case 'e': case 'g': case 'E': case 'G':
 			flag = 'f';
 			break;
+		case 'o': case 'u':
+		case 'x': case 'X':
 		case 'd': case 'i':
 			flag = 'd';
 			if(*(s-1) == 'l') break;
 			*(t-1) = 'l';
-			*t = 'd';
+			*t = *s;
 			*++t = '\0';
 			break;
-		case 'o': case 'x': case 'X': case 'u':
-			flag = *(s-1) == 'l' ? 'd' : 'u';
-			break;
 		case 's':
 			flag = 's';
 			break;
@@ -1954,7 +1953,8 @@
 			u = fflush(fp);
 		break;
 	case FSYSTIME:
-		u = time((time_t *) 0); break;
+		u = time(NULL);
+		break;
 	case FSTRFTIME:
 		/* strftime([format [,timestamp]]) */
 		if (nextarg) {
@@ -1962,7 +1962,7 @@
 			tv = (time_t) eawk_getfval(eawk, y);
 			TEMPFREE(eawk, y);
 		} else
-			tv = time((time_t *) 0);
+			tv = time(NULL);
 		tm = localtime(tv);
 
 		if (ISREC(x)) {



CVS commit: othersrc/external/historical/eawk

2011-08-31 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Thu Sep  1 05:07:13 UTC 2011

Modified Files:
othersrc/external/historical/eawk/dist: awkgram.y lex.c proctab.c
proto.h run.c
othersrc/external/historical/eawk/eawk: Makefile expected

Log Message:
add bit arithmetic operations to eawk (implementation based on the gawk
man page). this provides:

and(x, y)   (in C, x  y)
or(x, y)(in C, x | y)
xor(x, y)   (in C, x ^ y)
lshift(x, n)(in C, x  n)
rshift(x, n)(in C, x  n)
compl(x)(in C, ~x)

operations, with exactly the same calling conventions as gawk.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/historical/eawk/dist/awkgram.y \
othersrc/external/historical/eawk/dist/lex.c \
othersrc/external/historical/eawk/dist/proctab.c \
othersrc/external/historical/eawk/dist/proto.h
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/dist/run.c
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/historical/eawk/eawk/Makefile \
othersrc/external/historical/eawk/eawk/expected

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/historical/eawk/dist/awkgram.y
diff -u othersrc/external/historical/eawk/dist/awkgram.y:1.1.1.1 othersrc/external/historical/eawk/dist/awkgram.y:1.2
--- othersrc/external/historical/eawk/dist/awkgram.y:1.1.1.1	Wed Aug 31 04:19:39 2011
+++ othersrc/external/historical/eawk/dist/awkgram.y	Thu Sep  1 05:07:12 2011
@@ -96,6 +96,8 @@
 %right	POWER
 %right	DECR INCR
 %left	INDIRECT
+%token	i BITCOMPL BITLSHIFT BITRSHIFT BITAND BITOR BITXOR
+%type	i bitop
 %token	LASTTOKEN	/* must be last */
 
 %%
@@ -354,6 +356,9 @@
 	  SUB | GSUB
 	;
 
+bitop:
+	  BITLSHIFT | BITRSHIFT | BITAND | BITOR | BITXOR 
+	;
 term:
  	  term '/' ASGNOP term		{ $$ = eawk_op2(eawk, DIVEQ, $1, $4); }
  	| term '+' term			{ $$ = eawk_op2(eawk, ADD, $1, $3); }
@@ -446,6 +451,10 @@
 		{ $$ = eawk_op3(eawk, SUBSTR, $3, $5, $7); }
 	| SUBSTR '(' pattern comma pattern ')'
 		{ $$ = eawk_op3(eawk, SUBSTR, $3, $5, NIL); }
+	| BITCOMPL '(' pattern ')'
+		{ $$ = eawk_op1(eawk, BITCOMPL, $3); }
+	| bitop '(' pattern comma pattern ')'
+		{ $$ = eawk_op2(eawk, $1, $3, (awknode_t*)$5); }
 	| var
 	;
 
Index: othersrc/external/historical/eawk/dist/lex.c
diff -u othersrc/external/historical/eawk/dist/lex.c:1.1.1.1 othersrc/external/historical/eawk/dist/lex.c:1.2
--- othersrc/external/historical/eawk/dist/lex.c:1.1.1.1	Wed Aug 31 04:19:40 2011
+++ othersrc/external/historical/eawk/dist/lex.c	Thu Sep  1 05:07:12 2011
@@ -45,9 +45,11 @@
 	{ BEGIN,	XBEGIN,		XBEGIN },
 	{ END,	XEND,		XEND },
 	{ NF,		VARNF,		VARNF },
+	{ and,	BITAND,		BITAND },
 	{ atan2,	FATAN,		BLTIN },
 	{ break,	BREAK,		BREAK },
 	{ close,	CLOSE,		CLOSE },
+	{ compl,	BITCOMPL,	BITCOMPL },
 	{ continue,	CONTINUE,	CONTINUE },
 	{ cos,	FCOS,		BLTIN },
 	{ delete,	DELETE,		DELETE },
@@ -75,13 +77,16 @@
 	{ int,	FINT,		BLTIN },
 	{ length,	FLENGTH,	BLTIN },
 	{ log,	FLOG,		BLTIN },
+	{ lshift,	BITLSHIFT,	BITLSHIFT },
 	{ match,	MATCHFCN,	MATCHFCN },
 	{ next,	NEXT,		NEXT },
 	{ nextfile,	NEXTFILE,	NEXTFILE },
+	{ or,		BITOR,		BITOR },
 	{ print,	PRINT,		PRINT },
 	{ printf,	PRINTF,		PRINTF },
 	{ rand,	FRAND,		BLTIN },
 	{ return,	RETURN,		RETURN },
+	{ rshift,	BITRSHIFT,	BITRSHIFT },
 	{ sin,	FSIN,		BLTIN },
 	{ split,	SPLIT,		SPLIT },
 	{ sprintf,	SPRINTF,	SPRINTF },
@@ -95,6 +100,7 @@
 	{ tolower,	FTOLOWER,	BLTIN },
 	{ toupper,	FTOUPPER,	BLTIN },
 	{ while,	WHILE,		WHILE },
+	{ xor,	BITXOR,		BITXOR }
 };
 
 #define	RET(eawk, x)			\
Index: othersrc/external/historical/eawk/dist/proctab.c
diff -u othersrc/external/historical/eawk/dist/proctab.c:1.1.1.1 othersrc/external/historical/eawk/dist/proctab.c:1.2
--- othersrc/external/historical/eawk/dist/proctab.c:1.1.1.1	Wed Aug 31 04:19:40 2011
+++ othersrc/external/historical/eawk/dist/proctab.c	Thu Sep  1 05:07:12 2011
@@ -4,7 +4,7 @@
 #include awkgram.h
 #include proto.h
 
-static const char * const printname[101] = {
+static const char * const printname[107] = {
 	FIRSTTOKEN,	/* 258 */
 	PROGRAM,	/* 259 */
 	PASTAT,	/* 260 */
@@ -105,11 +105,17 @@
 	DECR,		/* 355 */
 	INCR,		/* 356 */
 	INDIRECT,	/* 357 */
-	LASTTOKEN,	/* 358 */
+	BITCOMPL,	/* 358 */
+	BITLSHIFT,	/* 359 */
+	BITRSHIFT,	/* 360 */
+	BITAND,	/* 361 */
+	BITOR,	/* 362 */
+	BITXOR,	/* 363 */
+	LASTTOKEN,	/* 364 */
 };
 
 
-awkcell_t *(*eawk_proctab[101])(eawk_t *, awknode_t **, int) = {
+awkcell_t *(*eawk_proctab[107])(eawk_t *, awknode_t **, int) = {
 	eawk_nullproc,	/* FIRSTTOKEN */
 	eawk_program,	/* PROGRAM */
 	eawk_pastat,	/* PASTAT */
@@ -210,6 +216,12 @@
 	eawk_nullproc,	/* DECR */
 	eawk_nullproc,	/* INCR */
 	eawk_indirect,	/* INDIRECT */
+	eawk_bitarith,	/* BITCOMPL */
+	eawk_bitarith,	/* BITLSHIFT */
+	eawk_bitarith,	/* BITRSHIFT */
+	eawk_bitarith,	/* BITAND */
+	eawk_bitarith,	/* BITOR 

CVS commit: othersrc/external/historical/eawk/dist

2011-08-31 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Thu Sep  1 05:08:06 UTC 2011

Added Files:
othersrc/external/historical/eawk/dist: bit1.sh

Log Message:
add a small file forgotten in previous


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/dist/bit1.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: othersrc/external/historical/eawk/dist/bit1.sh
diff -u /dev/null othersrc/external/historical/eawk/dist/bit1.sh:1.1
--- /dev/null	Thu Sep  1 05:08:06 2011
+++ othersrc/external/historical/eawk/dist/bit1.sh	Thu Sep  1 05:08:06 2011
@@ -0,0 +1,28 @@
+#! /bin/sh
+
+# executable in $1
+
+case $# in
+1)	exe=$1 ;;
+*)	exe=eawk ;;
+esac
+
+${exe} '
+BEGIN {
+	x = 255
+	comp = compl(x)
+	printf(x %#x, compl %x\n, x, comp)
+	y = lshift(x, 2)
+	printf(x %#x, y %#x\n, x, y)
+	z = rshift(y, 2)
+	printf(x %#x, y %#x, z %#x\n, x, y, z)
+	a = 98
+	b = xor(a, 255)
+	printf(a %#x, b %#x\n, a, b)
+	c = 65537
+	printf(c  b = %x  %x = %x\n, c, b, and(c, b))
+	printf(c | b = %x | %x = %x\n, c, b, or(c, b))
+	c = 3579
+	printf(c  b = %x  %x = %x\n, c, b, and(c, b))
+	printf(c | b = %x | %x = %x\n, c, b, or(c, b))
+}' /dev/null



CVS commit: othersrc/external/historical/eawk/dist

2011-08-31 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Thu Sep  1 05:03:18 UTC 2011

Modified Files:
othersrc/external/historical/eawk/dist: run.c

Log Message:
especially on LE platforms, we need to be careful to set the size of
the format specifier in awk printf() for integer output.  this was
being done for 'd' and 'i' formats, but not for 'o', 'x', 'X' and 'u'
formats.  rectify that.

allows hex patterns like 0xff00 to be printed


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/historical/eawk/dist/run.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk

2011-08-31 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Thu Sep  1 05:07:13 UTC 2011

Modified Files:
othersrc/external/historical/eawk/dist: awkgram.y lex.c proctab.c
proto.h run.c
othersrc/external/historical/eawk/eawk: Makefile expected

Log Message:
add bit arithmetic operations to eawk (implementation based on the gawk
man page). this provides:

and(x, y)   (in C, x  y)
or(x, y)(in C, x | y)
xor(x, y)   (in C, x ^ y)
lshift(x, n)(in C, x  n)
rshift(x, n)(in C, x  n)
compl(x)(in C, ~x)

operations, with exactly the same calling conventions as gawk.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/historical/eawk/dist/awkgram.y \
othersrc/external/historical/eawk/dist/lex.c \
othersrc/external/historical/eawk/dist/proctab.c \
othersrc/external/historical/eawk/dist/proto.h
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/dist/run.c
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/historical/eawk/eawk/Makefile \
othersrc/external/historical/eawk/eawk/expected

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk/dist

2011-08-31 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Thu Sep  1 05:08:06 UTC 2011

Added Files:
othersrc/external/historical/eawk/dist: bit1.sh

Log Message:
add a small file forgotten in previous


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/historical/eawk/dist/bit1.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/historical/eawk

2011-08-30 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed Aug 31 04:19:41 UTC 2011

Update of /cvsroot/othersrc/external/historical/eawk
In directory ivanova.netbsd.org:/tmp/cvs-serv23294

Log Message:
Embedded Awk


This is a heresy I have done, of my own free will and volition, and
which I now know as being a sin.

Firstly, I have butchered the one true awk source code, made
it re-entrant and embeddable in C programs, and now present it
as a library (libeawk) and a small driver program (eawk).  The
driver program now uses getopt_long, and gives a good idea of
how to use eawk in embedded code.

Furthermore, I have added to the one true language.  The
additions are 4 functions:

dlopen(handle, shared object name)
dlproto(handle, C function prototype as a string)
dlcall(handle, function, function args...)
dlclose(handle)

which allows you to do such abominations as:

dlopen(libc, libc);
dlproto(libc, long write(int, awkptr, long))
dlcall(libc, write, 1, hi\n, 3)
dlclose(libc)

(i.e. allows interfacing to shared libraries and shared objects without
any C glue or other shim in between the scripting language and the
compiled library).

Please note that you can specify the prototype at the same time as the
foreign function call, with dlcall:

dlopen(libc, libc);
dlcall(libc, long write(int, awkptr, long), 1, hi\n, 3)

and then:

% eawk 'BEGIN { dlopen(libc, libc); dlcall(libc, int printf(awkptr), Hello 
world\n) }' /dev/null
Hello world
%

In fact, the following scripts are all equivalent:

% eawk 'BEGIN { dlopen(libc, libc); dlcall(libc, long write(int, awkptr, 
long), 1, Hello world\n, 12) }' /dev/null
Hello world
% eawk 'BEGIN { dlopen(libc, libc); dlcall(libc, int printf(awkptr), Hello 
world\n) }' /dev/null
Hello world
% eawk 'BEGIN { dlopen(libc, libc); dlcall(libc, int fprintf(cvar, awkptr), 
stdout, Hello world\n) }' /dev/null
Hello world

The type of arguments, and the return type, given in the dlproto()
calls is important:

awkptr - a string as passed from the eawk script
cptr - a pointer to an object in the compiled shared object
cref - the address of a pointer to an object in the compiled
shared object. this is used to map the construct:
cp
into an awk string
cvar - the awk string which maps to a compiled well-known
variable in the compiled shared object, typically
stdin, stdout and stderr
void - no return type
bool - the boolean type
int - standard integer type on this machine
long - native long on this machine
int64 - 64-bit data type

In order to support foreign functions which typically use a structure
passed into every function as a handle (very much like the eawk
implementation here), I'd also added two other functions which can be
called from scripts:

buf = dlalloc(size)
dlfree(buf)

and also a new prototype keyword called cptr - this is functionally
equivalent to long, but more intuitively obvious that the argument should
be pre-allocated storage (at the native layer).

% eawk 'BEGIN {
dlopen(libc, libc)
size = 1024
buf = dlalloc(size)
dlcall(libc, int snprintf(cptr, int, awkptr, int), buf, size, 
allocated size is %d\n, size)
dlcall(libc, int printf(cptr), buf)
dlfree(buf)
}' /dev/null
allocated size is 1024
%

Finally, we need a way to get information back from C structures and
storage into an awk script, and we do that with the

var = dlfield(storage, offset, type)

function. This can be used as follows:

% eawk 'BEGIN {
dlopen(libc, libc)
st = dlalloc(1024)
dlcall(libc, int stat(awkptr, cptr), /etc/group, st)
mode = dlfield(st, 8, int16)
printf(%s mode is %o\n, /etc/group, mode)
dlfree(st)
}' /dev/null
mode is 100644
%

To illustrate some of the dlcall features a bit further, this script
will print out the keys in the user's keyring, by direct calling of
exported frunctionality from libnetpgp:

% eawk '
BEGIN {
dlopen(libc, libc)
dlopen(libnetpgp, libnetpgp)
netpgp = dlalloc(2048)
ret = dlcall(libnetpgp, int netpgp_set_homedir(cptr, awkptr, awkptr, 
int), netpgp, ENVIRON[HOME], /.gnupg, quiet = 1)
ret = dlcall(libnetpgp, int netpgp_init(cptr), netpgp)
}
END {
ret = dlcall(libnetpgp, int netpgp_list_keys_json(cptr, cref, int), 
netpgp, json, psigs = 0)
ret = dlcall(libnetpgp, int netpgp_format_json(cvar, cptr, int), 
stdout, json, psigs = 0)
}' /dev/null
126 keys found
signature  2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12
Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823 
uid  Alistair Crooks alist...@hockley-crooks.com 
uid  Alistair Crooks a...@pkgsrc.org 
uid  Alistair Crooks a...@netbsd.org 

CVS commit: othersrc/external/historical/eawk

2011-08-30 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed Aug 31 04:19:41 UTC 2011

Update of /cvsroot/othersrc/external/historical/eawk
In directory ivanova.netbsd.org:/tmp/cvs-serv23294

Log Message:
Embedded Awk


This is a heresy I have done, of my own free will and volition, and
which I now know as being a sin.

Firstly, I have butchered the one true awk source code, made
it re-entrant and embeddable in C programs, and now present it
as a library (libeawk) and a small driver program (eawk).  The
driver program now uses getopt_long, and gives a good idea of
how to use eawk in embedded code.

Furthermore, I have added to the one true language.  The
additions are 4 functions:

dlopen(handle, shared object name)
dlproto(handle, C function prototype as a string)
dlcall(handle, function, function args...)
dlclose(handle)

which allows you to do such abominations as:

dlopen(libc, libc);
dlproto(libc, long write(int, awkptr, long))
dlcall(libc, write, 1, hi\n, 3)
dlclose(libc)

(i.e. allows interfacing to shared libraries and shared objects without
any C glue or other shim in between the scripting language and the
compiled library).

Please note that you can specify the prototype at the same time as the
foreign function call, with dlcall:

dlopen(libc, libc);
dlcall(libc, long write(int, awkptr, long), 1, hi\n, 3)

and then:

% eawk 'BEGIN { dlopen(libc, libc); dlcall(libc, int printf(awkptr), Hello 
world\n) }' /dev/null
Hello world
%

In fact, the following scripts are all equivalent:

% eawk 'BEGIN { dlopen(libc, libc); dlcall(libc, long write(int, awkptr, 
long), 1, Hello world\n, 12) }' /dev/null
Hello world
% eawk 'BEGIN { dlopen(libc, libc); dlcall(libc, int printf(awkptr), Hello 
world\n) }' /dev/null
Hello world
% eawk 'BEGIN { dlopen(libc, libc); dlcall(libc, int fprintf(cvar, awkptr), 
stdout, Hello world\n) }' /dev/null
Hello world

The type of arguments, and the return type, given in the dlproto()
calls is important:

awkptr - a string as passed from the eawk script
cptr - a pointer to an object in the compiled shared object
cref - the address of a pointer to an object in the compiled
shared object. this is used to map the construct:
cp
into an awk string
cvar - the awk string which maps to a compiled well-known
variable in the compiled shared object, typically
stdin, stdout and stderr
void - no return type
bool - the boolean type
int - standard integer type on this machine
long - native long on this machine
int64 - 64-bit data type

In order to support foreign functions which typically use a structure
passed into every function as a handle (very much like the eawk
implementation here), I'd also added two other functions which can be
called from scripts:

buf = dlalloc(size)
dlfree(buf)

and also a new prototype keyword called cptr - this is functionally
equivalent to long, but more intuitively obvious that the argument should
be pre-allocated storage (at the native layer).

% eawk 'BEGIN {
dlopen(libc, libc)
size = 1024
buf = dlalloc(size)
dlcall(libc, int snprintf(cptr, int, awkptr, int), buf, size, 
allocated size is %d\n, size)
dlcall(libc, int printf(cptr), buf)
dlfree(buf)
}' /dev/null
allocated size is 1024
%

Finally, we need a way to get information back from C structures and
storage into an awk script, and we do that with the

var = dlfield(storage, offset, type)

function. This can be used as follows:

% eawk 'BEGIN {
dlopen(libc, libc)
st = dlalloc(1024)
dlcall(libc, int stat(awkptr, cptr), /etc/group, st)
mode = dlfield(st, 8, int16)
printf(%s mode is %o\n, /etc/group, mode)
dlfree(st)
}' /dev/null
mode is 100644
%

To illustrate some of the dlcall features a bit further, this script
will print out the keys in the user's keyring, by direct calling of
exported frunctionality from libnetpgp:

% eawk '
BEGIN {
dlopen(libc, libc)
dlopen(libnetpgp, libnetpgp)
netpgp = dlalloc(2048)
ret = dlcall(libnetpgp, int netpgp_set_homedir(cptr, awkptr, awkptr, 
int), netpgp, ENVIRON[HOME], /.gnupg, quiet = 1)
ret = dlcall(libnetpgp, int netpgp_init(cptr), netpgp)
}
END {
ret = dlcall(libnetpgp, int netpgp_list_keys_json(cptr, cref, int), 
netpgp, json, psigs = 0)
ret = dlcall(libnetpgp, int netpgp_format_json(cvar, cptr, int), 
stdout, json, psigs = 0)
}' /dev/null
126 keys found
signature  2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12
Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823 
uid  Alistair Crooks alist...@hockley-crooks.com 
uid  Alistair Crooks a...@pkgsrc.org 
uid  Alistair Crooks a...@netbsd.org