CVS commit: src/usr.bin/m4

2020-06-27 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Jun 27 19:18:58 UTC 2020

Modified Files:
src/usr.bin/m4: eval.c

Log Message:
eval: Make radix optional even if minimum result width is specified.
This is what GNU m4 does too.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/m4/eval.c

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

Modified files:

Index: src/usr.bin/m4/eval.c
diff -u src/usr.bin/m4/eval.c:1.27 src/usr.bin/m4/eval.c:1.28
--- src/usr.bin/m4/eval.c:1.27	Mon Jul 30 22:58:09 2018
+++ src/usr.bin/m4/eval.c	Sat Jun 27 19:18:58 2020
@@ -1,5 +1,5 @@
 /*	$OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $	*/
-/*	$NetBSD: eval.c,v 1.27 2018/07/30 22:58:09 kre Exp $	*/
+/*	$NetBSD: eval.c,v 1.28 2020/06/27 19:18:58 uwe Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: eval.c,v 1.27 2018/07/30 22:58:09 kre Exp $");
+__RCSID("$NetBSD: eval.c,v 1.28 2020/06/27 19:18:58 uwe Exp $");
 
 #include 
 #include 
@@ -184,7 +184,7 @@ expand_builtin(const char *argv[], int a
 		int maxdigits = 0;
 		int e;
 
-		if (argc > 3) {
+		if (argc > 3 && *argv[3] != '\0') {
 			base = strtoi(argv[3], NULL, 0, 2, 36, );
 			if (e) {
 m4errx(1, "expr: base %s invalid.", argv[3]);



CVS commit: src/usr.bin/m4

2020-06-27 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Jun 27 19:07:15 UTC 2020

Modified Files:
src/usr.bin/m4: m4.1

Log Message:
Improve markup for better PostScript output.
Make sure quotes are right and copy-pastable even in UTF-8 output.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/m4/m4.1

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

Modified files:

Index: src/usr.bin/m4/m4.1
diff -u src/usr.bin/m4/m4.1:1.30 src/usr.bin/m4/m4.1:1.31
--- src/usr.bin/m4/m4.1:1.30	Thu Jun 25 02:59:20 2020
+++ src/usr.bin/m4/m4.1	Sat Jun 27 19:07:15 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: m4.1,v 1.30 2020/06/25 02:59:20 uwe Exp $
+.\"	$NetBSD: m4.1,v 1.31 2020/06/27 19:07:15 uwe Exp $
 .\"	@(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
 .\"
 .\" Copyright (c) 1989, 1993
@@ -38,11 +38,11 @@
 .Nm m4
 .Nd macro language processor
 .Sh SYNOPSIS
-.Nm m4
+.Nm
 .Op Fl EGgiPQsv
 .Oo
 .Sm off
-.Fl D Ar name Op No = Ar value
+.Fl D Ar name Op Cm = Ar value
 .Sm on
 .Oc
 .Op Fl d Ar flags
@@ -56,42 +56,49 @@
 .Op Ar
 .Sh DESCRIPTION
 The
-.Nm m4
+.Nm
 utility is a macro processor that can be used as a front end to any
 language (e.g., C, ratfor, fortran, lex, and yacc).
 If no input files are given,
-.Nm m4
+.Nm
 reads from the standard input,
 otherwise files specified on the command line are
 processed in the given order.
-Input files can be regular files, files in the m4 include paths, or a
+Input files can be regular files, files in the
+.Nm
+include paths, or a
 single dash
-.Pq Sq - ,
+.Pq Sq Fl ,
 denoting standard input.
-.Nm m4
+.Nm
 writes
 the processed text to the standard output, unless told otherwise.
 .Pp
-Macro calls have the form name(argument1[, argument2, ..., argumentN]).
+Macro calls have the form
+.Fo name
+.Fa argument1\|
+.Bo \" should be Oo/Oc but mandoc chokes on it
+.Fa argument2
+.Fa \&...
+.Fa argumentN\|
+.Bc Ns Fc
 .Pp
 There cannot be any space following the macro name and the open
 parenthesis
-.Sq \&( .
+.Ql \&( .
 If the macro name is not followed by an open
 parenthesis it is processed with no arguments.
 .Pp
 Macro names consist of a leading alphabetic or underscore
-possibly followed by alphanumeric or underscore characters, e.g.,
-valid macro names match the pattern
-.Dq [a-zA-Z_][a-zA-Z0-9_]* .
+possibly followed by alphanumeric or underscore characters,
+i.e. valid macro names match the pattern
+.Dq Li [a-zA-Z_][a-zA-Z0-9_]*\| .
 .Pp
 In arguments to macros, leading unquoted space, tab, and newline
 .Pq Sq \en
 characters are ignored.
-To quote strings, use left and right single quotes
-.Po e.g.,\ \&
-.Sq "\ this is a string with a leading space"
-.Pc .
+To quote strings, use left and right single quotes, e.g.\&
+.Li "\` this is a string with a leading space\(aq" .
 You can change the quote characters with the
 .Ic changequote
 built-in macro.
@@ -100,39 +107,41 @@ Most built-ins don't make any sense with
 recognized as special when not followed by an open parenthesis.
 .Pp
 The options are as follows:
-.Bl -tag -width Ds
-.It Fl D , Fl Fl define Ar name Ns Op Pf = Ns Ar value
+.Bl -tag -width Fl
+.It Fl D , Fl Fl define Ar name Ns Op Ns Cm = Ns Ar value
 Define the symbol
 .Ar name
-to have some value (or
-.Dv NULL ) .
+to have
+.Ar value
+or to be a null string.
 .It Fl d , Fl Fl debug Ar "flags"
 Set trace flags.
 .Ar flags
 may hold the following:
-.Bl -tag -width Ds
-.It Ar a
+.Pp
+.Bl -tag -width ".Li XX" -compact
+.It Cm a
 print macro arguments.
-.It Ar c
+.It Cm c
 print macro expansion over several lines.
-.It Ar e
+.It Cm e
 print result of macro expansion.
-.It Ar f
+.It Cm f
 print filename location.
-.It Ar l
+.It Cm l
 print line number.
-.It Ar q
+.It Cm q
 quote arguments and expansion with the current quotes.
-.It Ar t
+.It Cm t
 start with all macros traced.
-.It Ar x
+.It Cm x
 number macro expansions.
-.It Ar V
-turn on all options.
+.It Cm V
+turn on all trace flags.
 .El
 .Pp
 By default, trace is set to
-.Qq eq .
+.Ql eq .
 .It Fl E , Fl Fl fatal-warnings
 Warnings make
 .Nm
@@ -141,16 +150,24 @@ exit.
 Save the input state to
 .Ar filename .
 .It Fl G , Fl Fl traditional
-Disable GNU-m4 extensions.
+Disable GNU\~m4 extensions.
 .It Fl g , Fl Fl gnu
-Activate GNU-m4 compatibility mode.
-In this mode, translit handles simple character
-ranges (e.g., a-z), regular expressions mimic emacs behavior,
-multiple m4wrap calls are handled as a stack,
+Activate GNU\~m4 compatibility mode.
+In this mode
+.Ic translit
+handles simple character
+ranges (e.g., 
+.Sq Li a-z ) ,
+regular expressions mimic emacs behavior,
+multiple
+.Ic m4wrap
+calls are handled as a stack,
 the number of diversions is unlimited,
 empty names for macro definitions are allowed,
-and eval understands
-.Sq 0rbase:value
+and
+.Ic eval
+understands
+.Sq Ic 0r Ns Ar base Ns Cm \&: Ns Ar value
 numbers.
 .It Fl Fl help
 Print help message and exit.
@@ -168,7 +185,7 @@ Send trace output to
 

CVS commit: src/usr.bin/m4

2020-06-24 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Jun 25 02:59:20 UTC 2020

Modified Files:
src/usr.bin/m4: m4.1

Log Message:
Use a date that is actually a real date.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/m4/m4.1

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

Modified files:

Index: src/usr.bin/m4/m4.1
diff -u src/usr.bin/m4/m4.1:1.29 src/usr.bin/m4/m4.1:1.30
--- src/usr.bin/m4/m4.1:1.29	Thu Jun 25 02:58:16 2020
+++ src/usr.bin/m4/m4.1	Thu Jun 25 02:59:20 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: m4.1,v 1.29 2020/06/25 02:58:16 uwe Exp $
+.\"	$NetBSD: m4.1,v 1.30 2020/06/25 02:59:20 uwe Exp $
 .\"	@(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
 .\"
 .\" Copyright (c) 1989, 1993
@@ -31,7 +31,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd June 25 16, 2020
+.Dd June 25, 2020
 .Dt M4 1
 .Os
 .Sh NAME



CVS commit: src/usr.bin/m4

2020-06-24 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Jun 25 02:58:16 UTC 2020

Modified Files:
src/usr.bin/m4: m4.1

Log Message:
Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/m4/m4.1

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

Modified files:

Index: src/usr.bin/m4/m4.1
diff -u src/usr.bin/m4/m4.1:1.28 src/usr.bin/m4/m4.1:1.29
--- src/usr.bin/m4/m4.1:1.28	Thu Jun 25 02:54:50 2020
+++ src/usr.bin/m4/m4.1	Thu Jun 25 02:58:16 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: m4.1,v 1.28 2020/06/25 02:54:50 uwe Exp $
+.\"	$NetBSD: m4.1,v 1.29 2020/06/25 02:58:16 uwe Exp $
 .\"	@(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
 .\"
 .\" Copyright (c) 1989, 1993
@@ -31,7 +31,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd January 16, 2015
+.Dd June 25 16, 2020
 .Dt M4 1
 .Os
 .Sh NAME



CVS commit: src/usr.bin/m4

2020-06-24 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Jun 25 02:54:50 UTC 2020

Modified Files:
src/usr.bin/m4: m4.1

Log Message:
Fix --error-output to be more like GNU m4.  It's a long version of -o.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/m4/m4.1

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

Modified files:

Index: src/usr.bin/m4/m4.1
diff -u src/usr.bin/m4/m4.1:1.27 src/usr.bin/m4/m4.1:1.28
--- src/usr.bin/m4/m4.1:1.27	Sun Jan 17 11:24:28 2016
+++ src/usr.bin/m4/m4.1	Thu Jun 25 02:54:50 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: m4.1,v 1.27 2016/01/17 11:24:28 wiz Exp $
+.\"	$NetBSD: m4.1,v 1.28 2020/06/25 02:54:50 uwe Exp $
 .\"	@(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
 .\"
 .\" Copyright (c) 1989, 1993
@@ -46,7 +46,6 @@
 .Sm on
 .Oc
 .Op Fl d Ar flags
-.Op Fl e Ar filename
 .Op Fl F Ar filename
 .Op Fl I Ar dirname
 .Op Fl L Ar number
@@ -138,8 +137,6 @@ By default, trace is set to
 Warnings make
 .Nm
 exit.
-.It Fl e , Fl Fl error-output Ar filename
-Redirect error output to filename.
 .It Fl F , Fl Fl freeze-state Ar filename
 Save the input state to
 .Ar filename .
@@ -166,7 +163,7 @@ Set unbuffered output, disable tty signa
 .It Fl L , Fl Fl nesting-limit
 Set the nesting limit in macro expansions.
 This is unimplemented and unlimited.
-.It Fl o Ar filename
+.It Fl o , Fl Fl error-output Ar filename
 Send trace output to
 .Ar filename .
 .It Fl P , Fl Fl prefix-builtins



CVS commit: src/usr.bin/m4

2020-06-24 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Jun 25 02:25:53 UTC 2020

Modified Files:
src/usr.bin/m4: extern.h main.c trace.c

Log Message:
Fix --error-output to be more like GNU m4.

GNU m4 --error-output is the same as -o despite the name.  It does NOT
affect warnings, error messages, and 'errprint' output so drop the
misguided bit of code that tried to freopen stderr without closing it
on failure.  Drop -e (which was our local invention) and make merge
--error-output with -o so that both set traceout.  Make trace_file()
preserve the old traceout on error and return error status so that the
caller can emit appropriate warning.

Do not yet support disabling tracing with an empty name, the rest of
the code is not ready, we don't do -o positionally and we don't have
`debugfile'.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/m4/extern.h
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/m4/main.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/m4/trace.c

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

Modified files:

Index: src/usr.bin/m4/extern.h
diff -u src/usr.bin/m4/extern.h:1.19 src/usr.bin/m4/extern.h:1.20
--- src/usr.bin/m4/extern.h:1.19	Sat Jan 16 18:30:57 2016
+++ src/usr.bin/m4/extern.h	Thu Jun 25 02:25:53 2020
@@ -1,5 +1,5 @@
 /*	$OpenBSD: extern.h,v 1.49 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: extern.h,v 1.19 2016/01/16 18:30:57 christos Exp $	*/
+/*	$NetBSD: extern.h,v 1.20 2020/06/25 02:25:53 uwe Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -146,7 +146,7 @@ extern char *endest;
 /* trace.c */
 extern unsigned int trace_flags;
 #define TRACE_ALL	512
-extern void trace_file(const char *);
+extern int trace_file(const char *);
 extern size_t trace(const char **, int, struct input_file *);
 extern void finish_trace(size_t);
 extern void set_trace_flags(const char *);

Index: src/usr.bin/m4/main.c
diff -u src/usr.bin/m4/main.c:1.49 src/usr.bin/m4/main.c:1.50
--- src/usr.bin/m4/main.c:1.49	Wed Jun 24 16:49:30 2020
+++ src/usr.bin/m4/main.c	Thu Jun 25 02:25:53 2020
@@ -1,5 +1,5 @@
 /*	$OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: main.c,v 1.49 2020/06/24 16:49:30 uwe Exp $	*/
+/*	$NetBSD: main.c,v 1.50 2020/06/25 02:25:53 uwe Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: main.c,v 1.49 2020/06/24 16:49:30 uwe Exp $");
+__RCSID("$NetBSD: main.c,v 1.50 2020/06/25 02:25:53 uwe Exp $");
 #include 
 #include 
 #include 
@@ -196,7 +196,7 @@ onintr(int signo)
 struct option longopts[] = {
 	{ "debug",		optional_argument,	0, 'd' },
 	{ "define",		required_argument,	0, 'D' },
-	{ "error-output",	required_argument,	0, 'e' },
+	{ "error-output",	required_argument,	0, 'o' }, /* sic */
 	{ "fatal-warnings",	no_argument,		0, 'E' },
 	{ "freeze-state",	required_argument,	0, 'F' },
 	{ "gnu",		no_argument,		0, 'g' },
@@ -227,8 +227,8 @@ main(int argc, char *argv[])
 {
 	int c;
 	int n;
+	int error;
 	char *p;
-	FILE *sfp;
 
 	setprogname(argv[0]);
 
@@ -246,7 +246,7 @@ main(int argc, char *argv[])
 	outfile = NULL;
 	resizedivs(MAXOUT);
 
-	while ((c = getopt_long(argc, argv, "D:d:e:EF:GgI:iL:o:PR:Qst:U:v",
+	while ((c = getopt_long(argc, argv, "D:d:EF:GgI:iL:o:PR:Qst:U:v",
 	longopts, NULL)) != -1)
 		switch(c) {
 		case 'D':   /* define something..*/
@@ -263,29 +263,6 @@ main(int argc, char *argv[])
 		case 'E':
 			fatal_warnings++;
 			break;
-		case 'e':
-			/*
-			 * Don't use freopen here because if it fails
-			 * we lose stderr, instead trash it.
-			 */
-			if ((sfp = fopen(optarg, "w+")) == NULL) {
-warn("Can't redirect errors to `%s'", optarg);
-break;
-			}
-			fclose(stderr);
-			memcpy(stderr, sfp, sizeof(*sfp));
-			/*
-			 * XXX: try to avoid the trap set up by the
-			 * kludge above.  When exit flushes and closes
-			 * open streams it may close sfp first and
-			 * when it comes about to flush and close
-			 * stderr, the descriptor is already gone and
-			 * we lose any buffered output.  This actually
-			 * happens on some hosts, breaking autoconf
-			 * tracing.
-			 */
-			setvbuf(stderr, (char *)NULL, _IOLBF, 0);
-			break;
 		case 'F':
 			freeze = optarg;
 #ifndef REAL_FREEZE
@@ -310,7 +287,9 @@ main(int argc, char *argv[])
 			nesting_limit = atoi(optarg);
 			break;
 		case 'o':
-			trace_file(optarg);
+			error = trace_file(optarg);
+			if (error)
+warn("%s", optarg);
 break;
 		case 'P':
 			prefix_builtins = 1;

Index: src/usr.bin/m4/trace.c
diff -u src/usr.bin/m4/trace.c:1.8 src/usr.bin/m4/trace.c:1.9
--- src/usr.bin/m4/trace.c:1.8	Tue Mar 20 20:34:58 2012
+++ src/usr.bin/m4/trace.c	Thu Jun 25 02:25:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trace.c,v 1.8 2012/03/20 20:34:58 matt Exp $	*/
+/*	$NetBSD: trace.c,v 1.9 2020/06/25 02:25:53 uwe Exp $	*/
 /* $OpenBSD: trace.c,v 1.15 2006/03/24 08:03:44 espie Exp $ */
 /*
  * 

CVS commit: src/usr.bin/m4

2020-06-24 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Jun 24 16:49:30 UTC 2020

Modified Files:
src/usr.bin/m4: main.c

Log Message:
Try not to lose error output with --error-output.

Try to avoid the trap we set up ourselves while avoiding freopen(3).
When exit flushes and closes open streams it may close sfp first and
when it comes about to flush and close stderr, the descriptor is
already gone and we lose any buffered error output.  This actually
happens on some hosts, breaking --trace output used by autoconf.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/m4/main.c

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

Modified files:

Index: src/usr.bin/m4/main.c
diff -u src/usr.bin/m4/main.c:1.48 src/usr.bin/m4/main.c:1.49
--- src/usr.bin/m4/main.c:1.48	Tue Mar 26 16:41:06 2019
+++ src/usr.bin/m4/main.c	Wed Jun 24 16:49:30 2020
@@ -1,5 +1,5 @@
 /*	$OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: main.c,v 1.48 2019/03/26 16:41:06 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.49 2020/06/24 16:49:30 uwe Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: main.c,v 1.48 2019/03/26 16:41:06 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.49 2020/06/24 16:49:30 uwe Exp $");
 #include 
 #include 
 #include 
@@ -274,6 +274,17 @@ main(int argc, char *argv[])
 			}
 			fclose(stderr);
 			memcpy(stderr, sfp, sizeof(*sfp));
+			/*
+			 * XXX: try to avoid the trap set up by the
+			 * kludge above.  When exit flushes and closes
+			 * open streams it may close sfp first and
+			 * when it comes about to flush and close
+			 * stderr, the descriptor is already gone and
+			 * we lose any buffered output.  This actually
+			 * happens on some hosts, breaking autoconf
+			 * tracing.
+			 */
+			setvbuf(stderr, (char *)NULL, _IOLBF, 0);
 			break;
 		case 'F':
 			freeze = optarg;



CVS commit: src/usr.bin/m4

2019-03-26 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Mar 26 23:31:45 UTC 2019

Modified Files:
src/usr.bin/m4: expr.c

Log Message:
Use correct printf format for (struct input_file *)->lineno
SHould unbreak 32 bit host builds.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/m4/expr.c

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

Modified files:

Index: src/usr.bin/m4/expr.c
diff -u src/usr.bin/m4/expr.c:1.20 src/usr.bin/m4/expr.c:1.21
--- src/usr.bin/m4/expr.c:1.20	Tue Mar 26 16:39:50 2019
+++ src/usr.bin/m4/expr.c	Tue Mar 26 23:31:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr.c,v 1.20 2019/03/26 16:39:50 christos Exp $	*/
+/*	$NetBSD: expr.c,v 1.21 2019/03/26 23:31:45 kre Exp $	*/
 /* $OpenBSD: expr.c,v 1.17 2006/01/20 23:10:19 espie Exp $ */
 /*
  * Copyright (c) 2004 Marc Espie 
@@ -19,7 +19,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: expr.c,v 1.20 2019/03/26 16:39:50 christos Exp $");
+__RCSID("$NetBSD: expr.c,v 1.21 2019/03/26 23:31:45 kre Exp $");
 #include 
 #include 
 #include 
@@ -36,7 +36,7 @@ extern int yyerror(const char *);
 int
 yyerror(const char *msg)
 {
-	fprintf(stderr, "m4:%s:%zu: %s in expr %s\n", infile[ilevel].name,
+	fprintf(stderr, "m4:%s:%lu: %s in expr %s\n", infile[ilevel].name,
 	infile[ilevel].lineno, msg, copy_toeval);
 	return(0);
 }



CVS commit: src/usr.bin/m4

2019-03-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 26 16:41:06 UTC 2019

Modified Files:
src/usr.bin/m4: main.c

Log Message:
fix use-after-free issue.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/m4/main.c

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

Modified files:

Index: src/usr.bin/m4/main.c
diff -u src/usr.bin/m4/main.c:1.47 src/usr.bin/m4/main.c:1.48
--- src/usr.bin/m4/main.c:1.47	Tue Mar 26 11:00:34 2019
+++ src/usr.bin/m4/main.c	Tue Mar 26 12:41:06 2019
@@ -1,5 +1,5 @@
 /*	$OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: main.c,v 1.47 2019/03/26 15:00:34 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.48 2019/03/26 16:41:06 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: main.c,v 1.47 2019/03/26 15:00:34 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.48 2019/03/26 16:41:06 christos Exp $");
 #include 
 #include 
 #include 
@@ -540,8 +540,14 @@ macro(void)
 fp = sp;	/* new frame pointer */
 		/*
 		 * now push the string arguments:
+		 * XXX: Copy the macro definition. This leaks, but too
+		 * lazy to fix properly.
+		 * The problem is that if we evaluate a pushdef'ed
+		 * macro and then popdef it while it the definition 
+		 * is still on the stack we are going to reference
+		 * free memory.
 		 */
-pushs1(macro_getdef(p)->defn);	/* defn string */
+pushs1(xstrdup(macro_getdef(p)->defn));	/* defn string */
 pushs1((char *)macro_name(p));	/* macro name  */
 pushs(ep);	  	/* start next..*/
 



CVS commit: src/usr.bin/m4

2019-03-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 26 16:39:50 UTC 2019

Modified Files:
src/usr.bin/m4: expr.c

Log Message:
print the source line and file where the error happened.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/m4/expr.c

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

Modified files:

Index: src/usr.bin/m4/expr.c
diff -u src/usr.bin/m4/expr.c:1.19 src/usr.bin/m4/expr.c:1.20
--- src/usr.bin/m4/expr.c:1.19	Mon Oct 26 17:11:28 2009
+++ src/usr.bin/m4/expr.c	Tue Mar 26 12:39:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr.c,v 1.19 2009/10/26 21:11:28 christos Exp $	*/
+/*	$NetBSD: expr.c,v 1.20 2019/03/26 16:39:50 christos Exp $	*/
 /* $OpenBSD: expr.c,v 1.17 2006/01/20 23:10:19 espie Exp $ */
 /*
  * Copyright (c) 2004 Marc Espie 
@@ -19,7 +19,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: expr.c,v 1.19 2009/10/26 21:11:28 christos Exp $");
+__RCSID("$NetBSD: expr.c,v 1.20 2019/03/26 16:39:50 christos Exp $");
 #include 
 #include 
 #include 
@@ -36,7 +36,8 @@ extern int yyerror(const char *);
 int
 yyerror(const char *msg)
 {
-	fprintf(stderr, "m4: %s in expr %s\n", msg, copy_toeval);
+	fprintf(stderr, "m4:%s:%zu: %s in expr %s\n", infile[ilevel].name,
+	infile[ilevel].lineno, msg, copy_toeval);
 	return(0);
 }
 



CVS commit: src/usr.bin/m4

2019-03-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 26 15:00:34 UTC 2019

Modified Files:
src/usr.bin/m4: main.c

Log Message:
Behave like gnu m4; when the error output file cannot be opened, just warn
and keep going.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/m4/main.c

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

Modified files:

Index: src/usr.bin/m4/main.c
diff -u src/usr.bin/m4/main.c:1.46 src/usr.bin/m4/main.c:1.47
--- src/usr.bin/m4/main.c:1.46	Sat Jan 23 09:24:43 2016
+++ src/usr.bin/m4/main.c	Tue Mar 26 11:00:34 2019
@@ -1,5 +1,5 @@
 /*	$OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: main.c,v 1.46 2016/01/23 14:24:43 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.47 2019/03/26 15:00:34 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: main.c,v 1.46 2016/01/23 14:24:43 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.47 2019/03/26 15:00:34 christos Exp $");
 #include 
 #include 
 #include 
@@ -228,6 +228,7 @@ main(int argc, char *argv[])
 	int c;
 	int n;
 	char *p;
+	FILE *sfp;
 
 	setprogname(argv[0]);
 
@@ -263,9 +264,16 @@ main(int argc, char *argv[])
 			fatal_warnings++;
 			break;
 		case 'e':
-			if (freopen(optarg, "w+", stderr) == NULL)
-err(EXIT_FAILURE, "Can't redirect errors to `%s'",
-optarg);
+			/*
+			 * Don't use freopen here because if it fails
+			 * we lose stderr, instead trash it.
+			 */
+			if ((sfp = fopen(optarg, "w+")) == NULL) {
+warn("Can't redirect errors to `%s'", optarg);
+break;
+			}
+			fclose(stderr);
+			memcpy(stderr, sfp, sizeof(*sfp));
 			break;
 		case 'F':
 			freeze = optarg;



CVS commit: src/usr.bin/m4

2018-07-30 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Jul 30 22:58:09 UTC 2018

Modified Files:
src/usr.bin/m4: eval.c

Log Message:
Avoid an infinite loop caused by a line accidentally dropped
in 1.22 (almost 30 months ago!)

[ Discovered by rhialto@ ]


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/m4/eval.c

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

Modified files:

Index: src/usr.bin/m4/eval.c
diff -u src/usr.bin/m4/eval.c:1.26 src/usr.bin/m4/eval.c:1.27
--- src/usr.bin/m4/eval.c:1.26	Mon Oct 23 02:38:46 2017
+++ src/usr.bin/m4/eval.c	Mon Jul 30 22:58:09 2018
@@ -1,5 +1,5 @@
 /*	$OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $	*/
-/*	$NetBSD: eval.c,v 1.26 2017/10/23 02:38:46 christos Exp $	*/
+/*	$NetBSD: eval.c,v 1.27 2018/07/30 22:58:09 kre Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: eval.c,v 1.26 2017/10/23 02:38:46 christos Exp $");
+__RCSID("$NetBSD: eval.c,v 1.27 2018/07/30 22:58:09 kre Exp $");
 
 #include 
 #include 
@@ -987,6 +987,7 @@ map(char *dest, const char *src, const c
 			}
 		} else {
 			while (*src) {
+sch = (unsigned char)(*src++);
 dch = mapvec[sch];
 while (dch != sch) {
 	sch = dch;



CVS commit: src/usr.bin/m4

2017-10-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Oct 23 02:38:46 UTC 2017

Modified Files:
src/usr.bin/m4: eval.c

Log Message:
remove the braces I accidentally added.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/m4/eval.c

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

Modified files:

Index: src/usr.bin/m4/eval.c
diff -u src/usr.bin/m4/eval.c:1.25 src/usr.bin/m4/eval.c:1.26
--- src/usr.bin/m4/eval.c:1.25	Sun Oct 22 19:01:34 2017
+++ src/usr.bin/m4/eval.c	Sun Oct 22 22:38:46 2017
@@ -1,5 +1,5 @@
 /*	$OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $	*/
-/*	$NetBSD: eval.c,v 1.25 2017/10/22 23:01:34 christos Exp $	*/
+/*	$NetBSD: eval.c,v 1.26 2017/10/23 02:38:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: eval.c,v 1.25 2017/10/22 23:01:34 christos Exp $");
+__RCSID("$NetBSD: eval.c,v 1.26 2017/10/23 02:38:46 christos Exp $");
 
 #include 
 #include 
@@ -700,9 +700,9 @@ doifelse(const char *argv[], int argc)
 	cycle {
 		if (argc < 5)
 			m4errx(1, "wrong number of args for ifelse");
-		if (STREQ(argv[2], argv[3])) {
+		if (STREQ(argv[2], argv[3]))
 			pbstr(argv[4]);
-		} else if (argc == 6)
+		else if (argc == 6)
 			pbstr(argv[5]);
 		else if (argc > 6) {
 			argv += 3;



CVS commit: src/usr.bin/m4

2017-10-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct 22 23:01:34 UTC 2017

Modified Files:
src/usr.bin/m4: eval.c

Log Message:
PR/52638: matthew green: missing argument check causes m4 to core in ifelse()


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/m4/eval.c

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

Modified files:

Index: src/usr.bin/m4/eval.c
diff -u src/usr.bin/m4/eval.c:1.24 src/usr.bin/m4/eval.c:1.25
--- src/usr.bin/m4/eval.c:1.24	Sat Jan 16 11:56:21 2016
+++ src/usr.bin/m4/eval.c	Sun Oct 22 19:01:34 2017
@@ -1,5 +1,5 @@
 /*	$OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $	*/
-/*	$NetBSD: eval.c,v 1.24 2016/01/16 16:56:21 christos Exp $	*/
+/*	$NetBSD: eval.c,v 1.25 2017/10/22 23:01:34 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: eval.c,v 1.24 2016/01/16 16:56:21 christos Exp $");
+__RCSID("$NetBSD: eval.c,v 1.25 2017/10/22 23:01:34 christos Exp $");
 
 #include 
 #include 
@@ -698,9 +698,11 @@ static void
 doifelse(const char *argv[], int argc)
 {
 	cycle {
-		if (STREQ(argv[2], argv[3]))
+		if (argc < 5)
+			m4errx(1, "wrong number of args for ifelse");
+		if (STREQ(argv[2], argv[3])) {
 			pbstr(argv[4]);
-		else if (argc == 6)
+		} else if (argc == 6)
 			pbstr(argv[5]);
 		else if (argc > 6) {
 			argv += 3;



CVS commit: src/usr.bin/m4

2016-01-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 23 14:24:43 UTC 2016

Modified Files:
src/usr.bin/m4: main.c

Log Message:
Explain what REDIRECT is for.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/m4/main.c

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

Modified files:

Index: src/usr.bin/m4/main.c
diff -u src/usr.bin/m4/main.c:1.45 src/usr.bin/m4/main.c:1.46
--- src/usr.bin/m4/main.c:1.45	Sat Jan 16 16:12:27 2016
+++ src/usr.bin/m4/main.c	Sat Jan 23 09:24:43 2016
@@ -1,5 +1,5 @@
 /*	$OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: main.c,v 1.45 2016/01/16 21:12:27 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.46 2016/01/23 14:24:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: main.c,v 1.45 2016/01/16 21:12:27 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.46 2016/01/23 14:24:43 christos Exp $");
 #include 
 #include 
 #include 
@@ -325,6 +325,11 @@ main(int argc, char *argv[])
 		}
 
 #ifdef REDIRECT
+	/*
+	 * This is meant only for debugging; it makes all output
+	 * go to a known file, even if the command line options
+	 * send it elsewhere. It should not be turned of in production code.
+	 */
 	if (freopen("/tmp/m4", "w+", stderr) == NULL)
 		err(EXIT_FAILURE, "Can't redirect errors to `%s'",
 		"/tmp/m4");



CVS commit: src/usr.bin/m4

2016-01-17 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Jan 17 11:24:28 UTC 2016

Modified Files:
src/usr.bin/m4: m4.1

Log Message:
Fix some macros. Sort stuff some more.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/m4/m4.1

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

Modified files:

Index: src/usr.bin/m4/m4.1
diff -u src/usr.bin/m4/m4.1:1.26 src/usr.bin/m4/m4.1:1.27
--- src/usr.bin/m4/m4.1:1.26	Sat Jan 16 21:15:51 2016
+++ src/usr.bin/m4/m4.1	Sun Jan 17 11:24:28 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: m4.1,v 1.26 2016/01/16 21:15:51 christos Exp $
+.\"	$NetBSD: m4.1,v 1.27 2016/01/17 11:24:28 wiz Exp $
 .\"	@(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
 .\"
 .\" Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
 .Nd macro language processor
 .Sh SYNOPSIS
 .Nm m4
-.Op Fl EgGiPQsv
+.Op Fl EGgiPQsv
 .Oo
 .Sm off
 .Fl D Ar name Op No = Ar value
@@ -134,16 +134,16 @@ turn on all options.
 .Pp
 By default, trace is set to
 .Qq eq .
-.If Fl E , Fl Fl fatal-warnings
+.It Fl E , Fl Fl fatal-warnings
 Warnings make
 .Nm
 exit.
-.If Fl e , Fl Fl error-output Ar filename
+.It Fl e , Fl Fl error-output Ar filename
 Redirect error output to filename.
-.If Fl F , Fl Fl freeze-state Ar filename
+.It Fl F , Fl Fl freeze-state Ar filename
 Save the input state to
 .Ar filename .
-.If Fl G , Fl Fl traditional
+.It Fl G , Fl Fl traditional
 Disable GNU-m4 extensions.
 .It Fl g , Fl Fl gnu
 Activate GNU-m4 compatibility mode.
@@ -161,14 +161,14 @@ Print help message and exit.
 Add directory
 .Ar dirname
 to the include path.
-.It Fl o Ar filename
-Send trace output to
-.Ar filename .
 .It Fl i , Fl Fl interactive
 Set unbuffered output, disable tty signals.
 .It Fl L , Fl Fl nesting-limit
 Set the nesting limit in macro expansions.
 This is unimplemented and unlimited.
+.It Fl o Ar filename
+Send trace output to
+.Ar filename .
 .It Fl P , Fl Fl prefix-builtins
 Prefix all built-in macros with
 .Sq m4_ .



CVS commit: src/usr.bin/m4

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 16:59:18 UTC 2016

Modified Files:
src/usr.bin/m4: gnum4.c

Log Message:
- don't eat the rest of the string when no match in patsubst
- include the pattern in the error printing of regex
- handle 3 argument and empty patterns the gnu way
- add support for freezing and thawing state (not working yet)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/m4/gnum4.c

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

Modified files:

Index: src/usr.bin/m4/gnum4.c
diff -u src/usr.bin/m4/gnum4.c:1.9 src/usr.bin/m4/gnum4.c:1.10
--- src/usr.bin/m4/gnum4.c:1.9	Tue Mar 20 16:34:58 2012
+++ src/usr.bin/m4/gnum4.c	Sat Jan 16 11:59:18 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: gnum4.c,v 1.9 2012/03/20 20:34:58 matt Exp $ */
+/* $NetBSD: gnum4.c,v 1.10 2016/01/16 16:59:18 christos Exp $ */
 /* $OpenBSD: gnum4.c,v 1.39 2008/08/21 21:01:04 espie Exp $ */
 
 /*
@@ -33,7 +33,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: gnum4.c,v 1.9 2012/03/20 20:34:58 matt Exp $");
+__RCSID("$NetBSD: gnum4.c,v 1.10 2016/01/16 16:59:18 christos Exp $");
 
 #include 
 #include 
@@ -203,10 +203,11 @@ static void addchars(const char *, size_
 static void addchar(int);
 static char *twiddle(const char *);
 static char *getstring(void);
-static void exit_regerror(int, regex_t *) __dead;
-static void do_subst(const char *, regex_t *, const char *, regmatch_t *);
-static void do_regexpindex(const char *, regex_t *, regmatch_t *);
-static void do_regexp(const char *, regex_t *, const char *, regmatch_t *);
+static void exit_regerror(int, const char *, regex_t *) __dead;
+static void do_subst(const char *, const char *, regex_t *, const char *,
+regmatch_t *);
+static void do_regexpindex(const char *, const char *, regex_t *, regmatch_t *);
+static void do_regexp(const char *, const char *, regex_t *, const char *, regmatch_t *);
 static void add_sub(size_t, const char *, regex_t *, regmatch_t *);
 static void add_replace(const char *, regex_t *, const char *, regmatch_t *);
 #define addconstantstring(s) addchars((s), sizeof(s)-1)
@@ -250,7 +251,7 @@ getstring(void)
 
 
 static void 
-exit_regerror(int er, regex_t *re)
+exit_regerror(int er, const char *pat, regex_t *re)
 {
 	size_t 	errlen;
 	char 	*errbuf;
@@ -259,14 +260,18 @@ exit_regerror(int er, regex_t *re)
 	errbuf = xalloc(errlen, 
 	"malloc in regerror: %lu", (unsigned long)errlen);
 	regerror(er, re, errbuf, errlen);
-	m4errx(1, "regular expression error: %s.", errbuf);
+	m4errx(1, "regular expression error: %s for: `%s'", errbuf, pat);
 }
 
 static void
 add_sub(size_t n, const char *string, regex_t *re, regmatch_t *pm)
 {
-	if (n > re->re_nsub)
-		warnx("No subexpression %zu", n);
+	if (n > re->re_nsub) {
+		if (!quiet)
+			warnx("No subexpression %zu", n);
+		if (fatal_warnings)
+			exit(EXIT_FAILURE);
+	}
 	/* Subexpressions that did not match are
 	 * not an error.  */
 	else if (pm[n].rm_so != -1 &&
@@ -313,7 +318,8 @@ add_replace(const char *string, regex_t 
 }
 
 static void 
-do_subst(const char *string, regex_t *re, const char *replace, regmatch_t *pm)
+do_subst(const char *pat, const char *string, regex_t *re, const char *replace,
+regmatch_t *pm)
 {
 	int error;
 	int flags = 0;
@@ -346,14 +352,18 @@ do_subst(const char *string, regex_t *re
 		addchars(string, pm[0].rm_so);
 		add_replace(string, re, replace, pm);
 		string += pm[0].rm_eo;
+		buffer[current] = '\0';
 	}
+	while (*string)
+		addchar(*string++);
 	if (error != REG_NOMATCH)
-		exit_regerror(error, re);
+		exit_regerror(error, pat, re);
 	pbstr(string);
 }
 
 static void 
-do_regexp(const char *string, regex_t *re, const char *replace, regmatch_t *pm)
+do_regexp(const char *pat, const char *string, regex_t *re, const char *replace,
+regmatch_t *pm)
 {
 	int error;
 
@@ -365,12 +375,12 @@ do_regexp(const char *string, regex_t *r
 	case REG_NOMATCH:
 		break;
 	default:
-		exit_regerror(error, re);
+		exit_regerror(error, pat, re);
 	}
 }
 
 static void 
-do_regexpindex(const char *string, regex_t *re, regmatch_t *pm)
+do_regexpindex(const char *pat, const char *string, regex_t *re, regmatch_t *pm)
 {
 	int error;
 
@@ -382,7 +392,7 @@ do_regexpindex(const char *string, regex
 		pbnum(-1);
 		break;
 	default:
-		exit_regerror(error, re);
+		exit_regerror(error, pat, re);
 	}
 }
 
@@ -437,6 +447,33 @@ twiddle(const char *p)
 	return getstring();
 }
 
+static int
+checkempty(const char *argv[], int argc)
+{
+	const char *s;
+	size_t len;
+
+	if (argc != 3 && argv[3][0] != '\0')
+		return 0;
+
+	if (argc == 3) {
+		if (!quiet)
+			warnx("Too few arguments to patsubst");
+		if (fatal_warnings)
+			exit(EXIT_FAILURE);
+	}
+			
+	if (argv[4] && argc > 4) 
+		len = strlen(argv[4]);
+	else
+		len = 0;
+	for (s = argv[2]; *s != '\0'; s++) {
+		addchars(argv[4], len);
+		addchar(*s);
+	}
+	return 1;
+}
+
 /* patsubst(string, 

CVS commit: src/usr.bin/m4

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 17:00:07 UTC 2016

Modified Files:
src/usr.bin/m4: look.c

Log Message:
Add disabled support for saving and restoring the symbol table.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/m4/look.c

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

Modified files:

Index: src/usr.bin/m4/look.c
diff -u src/usr.bin/m4/look.c:1.12 src/usr.bin/m4/look.c:1.13
--- src/usr.bin/m4/look.c:1.12	Tue Mar 20 16:34:58 2012
+++ src/usr.bin/m4/look.c	Sat Jan 16 12:00:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: look.c,v 1.12 2012/03/20 20:34:58 matt Exp $	*/
+/*	$NetBSD: look.c,v 1.13 2016/01/16 17:00:07 christos Exp $	*/
 /*	$OpenBSD: look.c,v 1.21 2009/10/14 17:23:17 sthen Exp $	*/
 
 /*
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: look.c,v 1.12 2012/03/20 20:34:58 matt Exp $");
+__RCSID("$NetBSD: look.c,v 1.13 2016/01/16 17:00:07 christos Exp $");
 #include 
 #include 
 #include 
@@ -278,3 +278,38 @@ macro_getbuiltin(const char *name)
 		return p;
 }
 
+#ifdef REAL_FREEZE
+static void
+recurse(FILE *f, ndptr n, struct macro_definition *d)
+{
+	if (d->next != NULL)
+		recurse(f, n, d->next);
+
+	// skip built-ins, because it is cheaper to do so
+	// and initialize them manually
+	if (d->type & (NOARGS|NEEDARGS))
+		return;
+	fprintf(f, "%c%zu,%zu\n%s%s\n",
+	(d->type & (NOARGS|NEEDARGS)) ? 'F' : 'T',
+	strlen(n->name), strlen(d->defn),
+	n->name, d->defn);
+}
+
+static void
+dump_entry(FILE *f, ndptr n)
+{
+	if (n->d == NULL)
+		return;
+	recurse(f, n, n->d);
+}
+
+void
+dump_state(FILE *f)
+{
+	ndptr n;
+	unsigned int i;
+	for (n = ohash_first(, ); n != NULL; 
+	n = ohash_next(, ))
+		dump_entry(f, n);
+}
+#endif



CVS commit: src/usr.bin/m4

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 16:56:21 UTC 2016

Modified Files:
src/usr.bin/m4: eval.c

Log Message:
More gnu compatibility:
- handle macros > $9
- handle character remapping the the gnu way.
Add a shortcut for the "fake freeze" files to not expand include macros
during thawing.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/m4/eval.c

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

Modified files:

Index: src/usr.bin/m4/eval.c
diff -u src/usr.bin/m4/eval.c:1.23 src/usr.bin/m4/eval.c:1.24
--- src/usr.bin/m4/eval.c:1.23	Thu Jan 29 14:26:20 2015
+++ src/usr.bin/m4/eval.c	Sat Jan 16 11:56:21 2016
@@ -1,5 +1,5 @@
 /*	$OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $	*/
-/*	$NetBSD: eval.c,v 1.23 2015/01/29 19:26:20 christos Exp $	*/
+/*	$NetBSD: eval.c,v 1.24 2016/01/16 16:56:21 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,9 +42,10 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: eval.c,v 1.23 2015/01/29 19:26:20 christos Exp $");
+__RCSID("$NetBSD: eval.c,v 1.24 2016/01/16 16:56:21 christos Exp $");
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -541,7 +542,16 @@ expand_macro(const char *argv[], int arg
 			case '7':
 			case '8':
 			case '9':
-if ((argno = *p - '0') < argc - 1)
+argno = *p - '0';
+if (mimic_gnu) {
+	const unsigned char *q =
+	(const unsigned char *)p;
+	while (isdigit(*++q)) {
+		bp--;
+		argno = argno * 10 + *q - '0';
+	}
+}
+if (argno < argc - 1)
 	pbstr(argv[argno + 1]);
 break;
 			case '*':
@@ -707,6 +717,10 @@ doifelse(const char *argv[], int argc)
 static int
 doincl(const char *ifile)
 {
+#ifndef REAL_FREEZE
+	if (thawing)
+		return 1;
+#endif
 	if (ilevel + 1 == MAXINP)
 		m4errx(1, "too many include files.");
 	if (fopen_trypath(infile+ilevel+1, ifile) != NULL) {
@@ -915,6 +929,7 @@ map(char *dest, const char *src, const c
 {
 	const char *tmp;
 	unsigned char sch, dch;
+	unsigned char found[256];
 	static char frombis[257];
 	static char tobis[257];
 	static unsigned char mapvec[256] = {
@@ -951,19 +966,33 @@ map(char *dest, const char *src, const c
 	 * create a mapping between "from" and
 	 * "to"
 	 */
-		while (*from)
-			mapvec[(unsigned char)(*from++)] = (*to) ? 
-(unsigned char)(*to++) : 0;
-
-		while (*src) {
-			sch = (unsigned char)(*src++);
-			dch = mapvec[sch];
-			while (dch != sch) {
-sch = dch;
+		memset(found, 0, sizeof(found));
+		for (; (sch = (unsigned char)*from) != '\0'; from++) {
+			if (!mimic_gnu || !found[sch]) {
+found[sch] = 1;
+mapvec[sch] = *to;
+			}
+			if (*to)
+to++;
+		}
+
+		if (mimic_gnu) {
+			for (; (sch = (unsigned char)*src) != '\0'; src++) {
+if (!found[sch])
+	*dest++ = sch;
+else if ((dch = mapvec[sch]) != '\0')
+	*dest++ = dch;
+			}
+		} else {
+			while (*src) {
 dch = mapvec[sch];
+while (dch != sch) {
+	sch = dch;
+	dch = mapvec[sch];
+}
+if ((*dest = (char)dch))
+	dest++;
 			}
-			if ((*dest = (char)dch))
-dest++;
 		}
 	/*
 	 * restore all the changed characters



CVS commit: src/usr.bin/m4

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 16:57:29 UTC 2016

Modified Files:
src/usr.bin/m4: extern.h

Log Message:
- declarations for real/fake freeze
- add new flags


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/m4/extern.h

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

Modified files:

Index: src/usr.bin/m4/extern.h
diff -u src/usr.bin/m4/extern.h:1.17 src/usr.bin/m4/extern.h:1.18
--- src/usr.bin/m4/extern.h:1.17	Wed Jan 28 22:27:06 2015
+++ src/usr.bin/m4/extern.h	Sat Jan 16 11:57:29 2016
@@ -1,5 +1,5 @@
 /*	$OpenBSD: extern.h,v 1.49 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: extern.h,v 1.17 2015/01/29 03:27:06 christos Exp $	*/
+/*	$NetBSD: extern.h,v 1.18 2016/01/16 16:57:29 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -57,6 +57,10 @@ extern void doprintfilename(struct input
 extern void doesyscmd(const char *);
 extern void getdivfile(const char *);
 extern void doformat(const char *[], int);
+#ifdef REAL_FREEZE
+extern void freeze_state(const char *);
+extern void thaw_state(const char *);
+#endif
  
 
 /* look.c */
@@ -83,6 +87,10 @@ extern void 	macro_for_all(void (*)(cons
 #define is_traced(p) ((p)->trace_flags == FLAG_NO_TRACE ? (trace_flags & TRACE_ALL) : (p)->trace_flags)
 
 extern ndptr macro_getbuiltin(const char *);
+#ifdef REAL_FREEZE
+extern void  dump_state(FILE *);
+extern void  restore_state(FILE *);
+#endif
 
 /* main.c */
 extern void outputstr(const char *);
@@ -165,6 +173,12 @@ extern char lquote[MAXCCHARS+1];/* left 
 extern char **m4wraps;		/* m4wrap string default. */
 extern int maxwraps;		/* size of m4wraps array */
 extern int wrapindex;		/* current index in m4wraps */
+extern int fatal_warnings;	/* exit on warning */
+extern int quiet;		/* no warnings */
+#ifndef REAL_FREEZE
+extern FILE *freezef;		/* copy of input */
+extern int thawing;		/* don't process includes during thaw */
+#endif
 
 extern const char *null;	/* as it says.. just a null. */
 extern char rquote[MAXCCHARS+1];/* right quote character (') */



CVS commit: src/usr.bin/m4

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 18:31:29 UTC 2016

Modified Files:
src/usr.bin/m4: main.c mdef.h

Log Message:
add most gnu m4 long options


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/m4/main.c
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/m4/mdef.h

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

Modified files:

Index: src/usr.bin/m4/main.c
diff -u src/usr.bin/m4/main.c:1.42 src/usr.bin/m4/main.c:1.43
--- src/usr.bin/m4/main.c:1.42	Wed Apr 25 14:23:58 2012
+++ src/usr.bin/m4/main.c	Sat Jan 16 13:31:29 2016
@@ -1,5 +1,5 @@
 /*	$OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: main.c,v 1.42 2012/04/25 18:23:58 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.43 2016/01/16 18:31:29 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,9 +42,10 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: main.c,v 1.42 2012/04/25 18:23:58 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.43 2016/01/16 18:31:29 christos Exp $");
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -82,6 +83,15 @@ char scommt[MAXCCHARS+1] = {SCOMMT};	/* 
 char ecommt[MAXCCHARS+1] = {ECOMMT};	/* end character for comment   */
 int  synch_lines = 0;		/* line synchronisation for C preprocessor */
 int  prefix_builtins = 0;	/* -P option to prefix builtin keywords */
+int  fatal_warnings = 0;	/* -E option to exit on warnings */
+int  quiet = 0;			/* -Q option to silence warnings */
+int  nesting_limit = -1;	/* -L for nesting limit */
+const char *freeze = NULL;	/* -F to freeze state */
+const char *reload = NULL;	/* -R to reload state */
+#ifndef REAL_FREEZE
+FILE *freezef = NULL;
+int thawing = 0;
+#endif
 
 struct keyblk {
 const char *knam;	/* keyword name */
@@ -146,9 +156,6 @@ struct keyblk keywrds[] = {	/* m4 keywor
 
 #define MAXKEYS	(sizeof(keywrds)/sizeof(struct keyblk))
 
-extern int optind;
-extern char *optarg;
-
 #define MAXRECORD 50
 static struct position {
 	char *name;
@@ -166,14 +173,14 @@ static void reallyoutputstr(const char *
 static void reallyputchar(int);
 
 static void enlarge_stack(void);
+static void help(void);
 
-__dead static void
-usage(void)
+static void
+usage(FILE *f)
 {
-	fprintf(stderr, "usage: %s [-gPs] [-Dname[=value]] [-d flags] "
-			"[-I dirname] [-o filename]\n"
-			"\t[-t macro] [-Uname] [file ...]\n", getprogname());
-	exit(1);
+	fprintf(f, "Usage: %s [-EGgiPQsv] [-Dname[=value]] [-d flags] "
+	"[-I dirname] [-o filename] [-L limit]\n"
+	"\t[-t macro] [-Uname] [file ...]\n", getprogname());
 }
 
 __dead static void
@@ -184,6 +191,37 @@ onintr(int signo)
 	_exit(1);
 }
 
+#define OPT_HELP 1
+
+struct option longopts[] = {
+	{ "debug",		optional_argument,	0, 'd' },
+	{ "define",		required_argument,	0, 'D' },
+	{ "error-output",	required_argument,	0, 'e' },
+	{ "fatal-warnings",	no_argument,		0, 'E' },
+	{ "freeze-state",	required_argument,	0, 'F' },
+	{ "gnu",		no_argument,		0, 'g' },
+	{ "help",		no_argument,		0, OPT_HELP },
+	{ "include",		required_argument,	0, 'I' },
+	{ "interactive",	no_argument,		0, 'i' },
+	{ "nesting-limit",	required_argument,	0, 'L' },
+	{ "prefix-builtins",	no_argument,		0, 'P' },
+	{ "quiet",		no_argument,		0, 'Q' },
+	{ "reload-state",	required_argument,	0, 'R' },
+	{ "silent",		no_argument,		0, 'Q' },
+	{ "synclines",		no_argument,		0, 's' },
+	{ "trace",		required_argument,	0, 't' },
+	{ "traditional",	no_argument,		0, 'G' },
+	{ "undefine",		required_argument,	0, 'U' },
+	{ "version",		no_argument,		0, 'v' },
+#ifdef notyet
+	{ "arglength",		required_argument,	0, 'l' },
+	{ "debugfile",		optional_argument, 	0, OPT_DEBUGFILE },
+	{ "hashsize",		required_argument,	0, 'H' },
+	{ "warn-macro-sequence",optional_argument,	0, OPT_WARN_SEQUENCE },
+#endif
+	{ 0,			0,			0, 0 },
+};
+
 int
 main(int argc, char *argv[])
 {
@@ -207,9 +245,9 @@ main(int argc, char *argv[])
 	outfile = NULL;
 	resizedivs(MAXOUT);
 
-	while ((c = getopt(argc, argv, "gst:d:D:U:o:I:P")) != -1)
+	while ((c = getopt_long(argc, argv, "D:d:e:EF:GgIi:L:o:PR:Qst:U:v",
+	longopts, NULL)) != -1)
 		switch(c) {
-
 		case 'D':   /* define something..*/
 			for (p = optarg; *p; p++)
 if (*p == '=')
@@ -218,20 +256,51 @@ main(int argc, char *argv[])
 *p++ = EOS;
 			dodefine(optarg, p);
 			break;
+		case 'd':
+			set_trace_flags(optarg);
+			break;
+		case 'E':
+			fatal_warnings++;
+			break;
+		case 'e':
+			if (freopen(optarg, "w+", stderr) == NULL)
+err(EXIT_FAILURE, "Can't redirect errors to `%s'",
+optarg);
+			break;
+		case 'F':
+			freeze = optarg;
+#ifndef REAL_FREEZE
+			if ((freezef = fopen(freeze, "w")) == NULL)
+err(EXIT_FAILURE, "Can't open `%s'", freeze);
+#endif
+			break;
 		case 'I':
 			addtoincludepath(optarg);
 			break;
-		case 'P':
-			prefix_builtins = 1;
+		case 'i':
+			setvbuf(stdout, NULL, _IONBF, 0);
+			signal(SIGINT, SIG_IGN);
 			break;

CVS commit: src/usr.bin/m4

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 18:30:57 UTC 2016

Modified Files:
src/usr.bin/m4: extern.h

Log Message:
add nesting_limit


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/m4/extern.h

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

Modified files:

Index: src/usr.bin/m4/extern.h
diff -u src/usr.bin/m4/extern.h:1.18 src/usr.bin/m4/extern.h:1.19
--- src/usr.bin/m4/extern.h:1.18	Sat Jan 16 11:57:29 2016
+++ src/usr.bin/m4/extern.h	Sat Jan 16 13:30:57 2016
@@ -1,5 +1,5 @@
 /*	$OpenBSD: extern.h,v 1.49 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: extern.h,v 1.18 2016/01/16 16:57:29 christos Exp $	*/
+/*	$NetBSD: extern.h,v 1.19 2016/01/16 18:30:57 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -175,6 +175,7 @@ extern int maxwraps;		/* size of m4wraps
 extern int wrapindex;		/* current index in m4wraps */
 extern int fatal_warnings;	/* exit on warning */
 extern int quiet;		/* no warnings */
+extern int nesting_limit;	/* macro expansion nesting limit */
 #ifndef REAL_FREEZE
 extern FILE *freezef;		/* copy of input */
 extern int thawing;		/* don't process includes during thaw */



CVS commit: src/usr.bin/m4

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 18:33:35 UTC 2016

Modified Files:
src/usr.bin/m4: main.c

Log Message:
mention that nesting limit is unimplemented


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/m4/main.c

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

Modified files:

Index: src/usr.bin/m4/main.c
diff -u src/usr.bin/m4/main.c:1.43 src/usr.bin/m4/main.c:1.44
--- src/usr.bin/m4/main.c:1.43	Sat Jan 16 13:31:29 2016
+++ src/usr.bin/m4/main.c	Sat Jan 16 13:33:35 2016
@@ -1,5 +1,5 @@
 /*	$OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: main.c,v 1.43 2016/01/16 18:31:29 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.44 2016/01/16 18:33:35 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: main.c,v 1.43 2016/01/16 18:31:29 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.44 2016/01/16 18:33:35 christos Exp $");
 #include 
 #include 
 #include 
@@ -781,7 +781,7 @@ static const struct {
 { "--help",			"print this message and exit" },
 { "-I, --include=file",		"include file" },
 { "-i, --interactive",		"unbuffer output, ignore tty signals" },
-{ "-L, --nesting-limit=num",	"macro expansion nesting limit (-1 disable)" },
+{ "-L, --nesting-limit=num",	"macro expansion nesting limit (unimpl)" },
 { "-P, --prefix-builtins",	"prefix builtins with m4_" },
 { "-Q, --quiet",		"don't print warnings" },
 { "-R, --reload-state=file",	"restore state from file" },



CVS commit: src/usr.bin/m4

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 17:01:01 UTC 2016

Modified Files:
src/usr.bin/m4: mdef.h

Log Message:
Use hex for masks.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/m4/mdef.h

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

Modified files:

Index: src/usr.bin/m4/mdef.h
diff -u src/usr.bin/m4/mdef.h:1.15 src/usr.bin/m4/mdef.h:1.16
--- src/usr.bin/m4/mdef.h:1.15	Fri Oct 18 16:19:36 2013
+++ src/usr.bin/m4/mdef.h	Sat Jan 16 12:01:01 2016
@@ -1,5 +1,5 @@
 /*	$OpenBSD: mdef.h,v 1.29 2006/03/20 20:27:45 espie Exp $	*/
-/*	$NetBSD: mdef.h,v 1.15 2013/10/18 20:19:36 christos Exp $	*/
+/*	$NetBSD: mdef.h,v 1.16 2016/01/16 17:01:01 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -88,10 +88,10 @@
 
 #define BUILTIN_MARKER	"__builtin_"
  
-#define TYPEMASK	63	/* Keep bits really corresponding to a type. */
-#define RECDEF		256	/* Pure recursive def, don't expand it */
-#define NOARGS		512	/* builtin needs no args */
-#define NEEDARGS	1024	/* mark builtin that need args with this */
+#define TYPEMASK	0xff	/* Keep bits really corresponding to a type. */
+#define RECDEF		0x100	/* Pure recursive def, don't expand it */
+#define NOARGS		0x200	/* builtin needs no args */
+#define NEEDARGS	0x400	/* mark builtin that need args with this */
 
 /*
  * m4 special characters



CVS commit: src/usr.bin/m4

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 17:01:22 UTC 2016

Modified Files:
src/usr.bin/m4: misc.c

Log Message:
record all input for fake freeze


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/m4/misc.c

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

Modified files:

Index: src/usr.bin/m4/misc.c
diff -u src/usr.bin/m4/misc.c:1.23 src/usr.bin/m4/misc.c:1.24
--- src/usr.bin/m4/misc.c:1.23	Tue Mar 20 16:34:58 2012
+++ src/usr.bin/m4/misc.c	Sat Jan 16 12:01:22 2016
@@ -1,5 +1,5 @@
 /*	$OpenBSD: misc.c,v 1.41 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: misc.c,v 1.23 2012/03/20 20:34:58 matt Exp $	*/
+/*	$NetBSD: misc.c,v 1.24 2016/01/16 17:01:22 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -36,7 +36,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: misc.c,v 1.23 2012/03/20 20:34:58 matt Exp $");
+__RCSID("$NetBSD: misc.c,v 1.24 2016/01/16 17:01:22 christos Exp $");
 #include 
 #include 
 #include 
@@ -339,6 +339,10 @@ obtain_char(struct input_file *f)
 		return EOF;
 
 	f->c = fgetc(f->file);
+#ifndef REAL_FREEZE
+	if (freezef)
+		fputc(f->c, freezef);
+#endif
 	if (f->c == '\n')
 		f->lineno++;
 



CVS commit: src/usr.bin/m4

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 21:15:51 UTC 2016

Modified Files:
src/usr.bin/m4: m4.1

Log Message:
Update documentation.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/m4/m4.1

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

Modified files:

Index: src/usr.bin/m4/m4.1
diff -u src/usr.bin/m4/m4.1:1.25 src/usr.bin/m4/m4.1:1.26
--- src/usr.bin/m4/m4.1:1.25	Tue Jan  7 08:32:21 2014
+++ src/usr.bin/m4/m4.1	Sat Jan 16 16:15:51 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: m4.1,v 1.25 2014/01/07 13:32:21 wiz Exp $
+.\"	$NetBSD: m4.1,v 1.26 2016/01/16 21:15:51 christos Exp $
 .\"	@(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
 .\"
 .\" Copyright (c) 1989, 1993
@@ -31,7 +31,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd January 7, 2014
+.Dd January 16, 2015
 .Dt M4 1
 .Os
 .Sh NAME
@@ -39,15 +39,19 @@
 .Nd macro language processor
 .Sh SYNOPSIS
 .Nm m4
-.Op Fl gPs
+.Op Fl EgGiPQsv
 .Oo
 .Sm off
 .Fl D Ar name Op No = Ar value
 .Sm on
 .Oc
 .Op Fl d Ar flags
+.Op Fl e Ar filename
+.Op Fl F Ar filename
 .Op Fl I Ar dirname
+.Op Fl L Ar number
 .Op Fl o Ar filename
+.Op Fl R Ar filename
 .Op Fl t Ar macro
 .Op Fl U Ns Ar name
 .Op Ar
@@ -98,12 +102,12 @@ recognized as special when not followed 
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
-.It Fl D Ns Ar name Ns Op Pf = Ns Ar value
+.It Fl D , Fl Fl define Ar name Ns Op Pf = Ns Ar value
 Define the symbol
 .Ar name
 to have some value (or
 .Dv NULL ) .
-.It Fl d Ar "flags"
+.It Fl d , Fl Fl debug Ar "flags"
 Set trace flags.
 .Ar flags
 may hold the following:
@@ -130,7 +134,18 @@ turn on all options.
 .Pp
 By default, trace is set to
 .Qq eq .
-.It Fl g
+.If Fl E , Fl Fl fatal-warnings
+Warnings make
+.Nm
+exit.
+.If Fl e , Fl Fl error-output Ar filename
+Redirect error output to filename.
+.If Fl F , Fl Fl freeze-state Ar filename
+Save the input state to
+.Ar filename .
+.If Fl G , Fl Fl traditional
+Disable GNU-m4 extensions.
+.It Fl g , Fl Fl gnu
 Activate GNU-m4 compatibility mode.
 In this mode, translit handles simple character
 ranges (e.g., a-z), regular expressions mimic emacs behavior,
@@ -140,29 +155,43 @@ empty names for macro definitions are al
 and eval understands
 .Sq 0rbase:value
 numbers.
-.It Fl I Ar "dirname"
+.It Fl Fl help
+Print help message and exit.
+.It Fl I , Fl Fl include Ar "dirname"
 Add directory
 .Ar dirname
 to the include path.
 .It Fl o Ar filename
 Send trace output to
 .Ar filename .
-.It Fl P
+.It Fl i , Fl Fl interactive
+Set unbuffered output, disable tty signals.
+.It Fl L , Fl Fl nesting-limit
+Set the nesting limit in macro expansions.
+This is unimplemented and unlimited.
+.It Fl P , Fl Fl prefix-builtins
 Prefix all built-in macros with
 .Sq m4_ .
 For example, instead of writing
 .Ic define ,
 use
 .Ic m4_define .
-.It Fl s
+.It Fl Q , Fl Fl quiet , Fl Fl silent
+Don't print warnings.
+.It Fl R , Fl Fl reload-state Ar filename
+Reload a previously saved state from
+.Ar filename .
+.It Fl s , Fl Fl synclines
 Output line synchronization directives, suitable for
 .Xr cpp 1 .
-.It Fl t Ar macro
+.It Fl t , Fl Fl trace Ar macro
 Turn tracing on for
 .Ar macro .
-.It Fl "U" Ns Ar "name"
+.It Fl U , Fl Fl undefine Ar "name"
 Undefine the symbol
 .Ar name .
+.It Fl v , Fl Fl version
+Print the version and exit.
 .El
 .Sh SYNTAX
 .Nm m4



CVS commit: src/usr.bin/m4

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 21:12:27 UTC 2016

Modified Files:
src/usr.bin/m4: main.c

Log Message:
fix the option string.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.bin/m4/main.c

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

Modified files:

Index: src/usr.bin/m4/main.c
diff -u src/usr.bin/m4/main.c:1.44 src/usr.bin/m4/main.c:1.45
--- src/usr.bin/m4/main.c:1.44	Sat Jan 16 13:33:35 2016
+++ src/usr.bin/m4/main.c	Sat Jan 16 16:12:27 2016
@@ -1,5 +1,5 @@
 /*	$OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: main.c,v 1.44 2016/01/16 18:33:35 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.45 2016/01/16 21:12:27 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: main.c,v 1.44 2016/01/16 18:33:35 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.45 2016/01/16 21:12:27 christos Exp $");
 #include 
 #include 
 #include 
@@ -245,7 +245,7 @@ main(int argc, char *argv[])
 	outfile = NULL;
 	resizedivs(MAXOUT);
 
-	while ((c = getopt_long(argc, argv, "D:d:e:EF:GgIi:L:o:PR:Qst:U:v",
+	while ((c = getopt_long(argc, argv, "D:d:e:EF:GgI:iL:o:PR:Qst:U:v",
 	longopts, NULL)) != -1)
 		switch(c) {
 		case 'D':   /* define something..*/



CVS commit: src/usr.bin/m4

2015-01-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 29 13:20:51 UTC 2015

Modified Files:
src/usr.bin/m4: Makefile

Log Message:
latent strtonum removal.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/m4/Makefile

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

Modified files:

Index: src/usr.bin/m4/Makefile
diff -u src/usr.bin/m4/Makefile:1.17 src/usr.bin/m4/Makefile:1.18
--- src/usr.bin/m4/Makefile:1.17	Sun Aug 14 08:59:25 2011
+++ src/usr.bin/m4/Makefile	Thu Jan 29 08:20:51 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.17 2011/08/14 12:59:25 christos Exp $
+#	$NetBSD: Makefile,v 1.18 2015/01/29 13:20:51 christos Exp $
 #
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
@@ -8,12 +8,13 @@
 
 PROG=		m4
 CPPFLAGS+=	-DEXTENDED -I${.CURDIR}/lib
+CPPFLAGS+=	-D_OPENBSD_SOURCE
 SRCS=	parser.y tokenizer.l eval.c expr.c look.c main.c misc.c gnum4.c trace.c
 .PATH: ${.CURDIR}/lib
 SRCS+=	ohash_create_entry.c ohash_delete.c ohash_do.c ohash_entries.c \
 	ohash_enum.c ohash_init.c ohash_int.h ohash_interval.c \
 	ohash_lookup_interval.c ohash_lookup_memory.c ohash_qlookup.c \
-	ohash_qlookupi.c strtonum.c
+	ohash_qlookupi.c
 YHEADER=1
 .if (${HOSTPROG:U} == )
 DPADD+=		${LIBUTIL} ${LIBL}



CVS commit: src/usr.bin/m4

2015-01-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 29 19:26:20 UTC 2015

Modified Files:
src/usr.bin/m4: Makefile eval.c

Log Message:
use strtoi instead of strtonum, since this is a tool.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/m4/Makefile
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/m4/eval.c

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

Modified files:

Index: src/usr.bin/m4/Makefile
diff -u src/usr.bin/m4/Makefile:1.18 src/usr.bin/m4/Makefile:1.19
--- src/usr.bin/m4/Makefile:1.18	Thu Jan 29 08:20:51 2015
+++ src/usr.bin/m4/Makefile	Thu Jan 29 14:26:20 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.18 2015/01/29 13:20:51 christos Exp $
+#	$NetBSD: Makefile,v 1.19 2015/01/29 19:26:20 christos Exp $
 #
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
@@ -8,7 +8,6 @@
 
 PROG=		m4
 CPPFLAGS+=	-DEXTENDED -I${.CURDIR}/lib
-CPPFLAGS+=	-D_OPENBSD_SOURCE
 SRCS=	parser.y tokenizer.l eval.c expr.c look.c main.c misc.c gnum4.c trace.c
 .PATH: ${.CURDIR}/lib
 SRCS+=	ohash_create_entry.c ohash_delete.c ohash_do.c ohash_entries.c \

Index: src/usr.bin/m4/eval.c
diff -u src/usr.bin/m4/eval.c:1.22 src/usr.bin/m4/eval.c:1.23
--- src/usr.bin/m4/eval.c:1.22	Sun Aug 21 19:38:43 2011
+++ src/usr.bin/m4/eval.c	Thu Jan 29 14:26:20 2015
@@ -1,5 +1,5 @@
 /*	$OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $	*/
-/*	$NetBSD: eval.c,v 1.22 2011/08/21 23:38:43 dholland Exp $	*/
+/*	$NetBSD: eval.c,v 1.23 2015/01/29 19:26:20 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include nbtool_config.h
 #endif
 #include sys/cdefs.h
-__RCSID($NetBSD: eval.c,v 1.22 2011/08/21 23:38:43 dholland Exp $);
+__RCSID($NetBSD: eval.c,v 1.23 2015/01/29 19:26:20 christos Exp $);
 
 #include sys/types.h
 #include err.h
@@ -54,6 +54,7 @@ __RCSID($NetBSD: eval.c,v 1.22 2011/08/
 #include stddef.h
 #include stdint.h
 #include string.h
+#include inttypes.h
 #include fcntl.h
 #include mdef.h
 #include stdd.h
@@ -180,17 +181,17 @@ expand_builtin(const char *argv[], int a
 	{
 		int base = 10;
 		int maxdigits = 0;
-		const char *errstr;
+		int e;
 
 		if (argc  3) {
-			base = strtonum(argv[3], 2, 36, errstr);
-			if (errstr) {
+			base = strtoi(argv[3], NULL, 0, 2, 36, e);
+			if (e) {
 m4errx(1, expr: base %s invalid., argv[3]);
 			}
 		}
 		if (argc  4) {
-			maxdigits = strtonum(argv[4], 0, INT_MAX, errstr);
-			if (errstr) {
+			maxdigits = strtoi(argv[4], NULL, 0, 0, INT_MAX, e);
+			if (e) {
 m4errx(1, expr: maxdigits %s invalid., argv[4]);
 			}
 		}
@@ -840,9 +841,9 @@ doundiv(const char *argv[], int argc)
 
 	if (argc  2) {
 		for (ind = 2; ind  argc; ind++) {
-			const char *errstr;
-			n = strtonum(argv[ind], 1, INT_MAX, errstr);
-			if (errstr) {
+			int e;
+			n = strtoi(argv[ind], NULL, 0, 1, INT_MAX, e);
+			if (e) {
 if (errno == EINVAL  mimic_gnu)
 	getdivfile(argv[ind]);
 			} else {



CVS commit: src/usr.bin/m4

2015-01-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 29 03:27:06 UTC 2015

Modified Files:
src/usr.bin/m4: extern.h

Log Message:
delete extern


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/m4/extern.h

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

Modified files:

Index: src/usr.bin/m4/extern.h
diff -u src/usr.bin/m4/extern.h:1.16 src/usr.bin/m4/extern.h:1.17
--- src/usr.bin/m4/extern.h:1.16	Wed Mar 14 22:02:23 2012
+++ src/usr.bin/m4/extern.h	Wed Jan 28 22:27:06 2015
@@ -1,5 +1,5 @@
 /*	$OpenBSD: extern.h,v 1.49 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: extern.h,v 1.16 2012/03/15 02:02:23 joerg Exp $	*/
+/*	$NetBSD: extern.h,v 1.17 2015/01/29 03:27:06 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -173,5 +173,3 @@ extern int  synch_lines;	/* line synchro
 
 extern int mimic_gnu;		/* behaves like gnu-m4 */
 extern int prefix_builtins;	/* prefix builtin macros with m4_ */
-
-extern long long strtonum(const char *, long long, long long, const char **);



CVS commit: src/usr.bin/m4

2015-01-04 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Jan  4 18:31:09 UTC 2015

Modified Files:
src/usr.bin/m4: parser.y

Log Message:
Don't depend on yacc skeleton to include sys/cdefs.h early.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/m4/parser.y

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

Modified files:

Index: src/usr.bin/m4/parser.y
diff -u src/usr.bin/m4/parser.y:1.2 src/usr.bin/m4/parser.y:1.3
--- src/usr.bin/m4/parser.y:1.2	Mon Oct 26 21:11:28 2009
+++ src/usr.bin/m4/parser.y	Sun Jan  4 18:31:09 2015
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: parser.y,v 1.2 2009/10/26 21:11:28 christos Exp $ */
+/* $NetBSD: parser.y,v 1.3 2015/01/04 18:31:09 joerg Exp $ */
 /* $OpenBSD: parser.y,v 1.6 2008/08/21 21:00:14 espie Exp $ */
 /*
  * Copyright (c) 2004 Marc Espie es...@cvs.openbsd.org
@@ -19,7 +19,8 @@
 #if HAVE_NBTOOL_CONFIG_H
 #include nbtool_config.h
 #endif
-__RCSID($NetBSD: parser.y,v 1.2 2009/10/26 21:11:28 christos Exp $);
+#include sys/cdefs.h
+__RCSID($NetBSD: parser.y,v 1.3 2015/01/04 18:31:09 joerg Exp $);
 #include stdint.h
 #define YYSTYPE	int32_t
 extern int32_t end_result;



CVS commit: src/usr.bin/m4

2014-01-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jan  7 13:32:21 UTC 2014

Modified Files:
src/usr.bin/m4: m4.1

Log Message:
Better document eval, mentioning optional second and third arguments.
Requested by martin.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/m4/m4.1

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

Modified files:

Index: src/usr.bin/m4/m4.1
diff -u src/usr.bin/m4/m4.1:1.24 src/usr.bin/m4/m4.1:1.25
--- src/usr.bin/m4/m4.1:1.24	Sat Jul 20 21:40:00 2013
+++ src/usr.bin/m4/m4.1	Tue Jan  7 13:32:21 2014
@@ -1,4 +1,4 @@
-.\	$NetBSD: m4.1,v 1.24 2013/07/20 21:40:00 wiz Exp $
+.\	$NetBSD: m4.1,v 1.25 2014/01/07 13:32:21 wiz Exp $
 .\	@(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
 .\
 .\ Copyright (c) 1989, 1993
@@ -31,7 +31,7 @@
 .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\ SUCH DAMAGE.
 .\
-.Dd October 14, 2009
+.Dd January 7, 2014
 .Dt M4 1
 .Os
 .Sh NAME
@@ -256,15 +256,17 @@ Prints the first argument on the standar
 Passes its first argument to a shell and returns the shell's standard output.
 Note that the shell shares its standard input and standard error with
 .Nm m4 .
-.It Fn eval expr
+.It Fn eval expr[,radix[,minimum]]
 Computes the first argument as an arithmetic expression using 32-bit
 arithmetic.
 Operators are the standard C ternary, arithmetic, logical,
 shift, relational, bitwise, and parentheses operators.
 You can specify
 octal, decimal, and hexadecimal numbers as in C.
-The second argument (if any)
-specifies the radix for the result and the third argument (if any)
+The optional second argument
+.Fa radix
+specifies the radix for the result and the optional third argument
+.Fa minimum
 specifies the minimum number of digits in the result.
 .It Fn expr expr
 This is an alias for



CVS commit: src/usr.bin/m4

2012-04-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 25 18:23:58 UTC 2012

Modified Files:
src/usr.bin/m4: main.c

Log Message:
Fix wrong loop index leading to infinite loop
ifdef(`FOO',
# FOO
)
XXX: Pullup to 6.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/m4/main.c

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

Modified files:

Index: src/usr.bin/m4/main.c
diff -u src/usr.bin/m4/main.c:1.41 src/usr.bin/m4/main.c:1.42
--- src/usr.bin/m4/main.c:1.41	Tue Sep  6 14:16:01 2011
+++ src/usr.bin/m4/main.c	Wed Apr 25 14:23:58 2012
@@ -1,5 +1,5 @@
 /*	$OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: main.c,v 1.41 2011/09/06 18:16:01 joerg Exp $	*/
+/*	$NetBSD: main.c,v 1.42 2012/04/25 18:23:58 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include nbtool_config.h
 #endif
 #include sys/cdefs.h
-__RCSID($NetBSD: main.c,v 1.41 2011/09/06 18:16:01 joerg Exp $);
+__RCSID($NetBSD: main.c,v 1.42 2012/04/25 18:23:58 christos Exp $);
 #include assert.h
 #include signal.h
 #include err.h
@@ -494,7 +494,7 @@ macro(void)
 		default:
 			if (LOOK_AHEAD(t, scommt)) {
 char *q;
-for (q = scommt; *q; p++)
+for (q = scommt; *q; q++)
 	chrsave(*q);
 for(;;) {
 	t = gpbc();



CVS commit: src/usr.bin/m4

2011-09-06 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Sep  6 18:16:01 UTC 2011

Modified Files:
src/usr.bin/m4: extern.h gnum4.c main.c misc.c

Log Message:
Move usage and onintr to make them static. Add __dead as needed.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/m4/extern.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/m4/gnum4.c
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/m4/main.c
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/m4/misc.c

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

Modified files:

Index: src/usr.bin/m4/extern.h
diff -u src/usr.bin/m4/extern.h:1.14 src/usr.bin/m4/extern.h:1.15
--- src/usr.bin/m4/extern.h:1.14	Mon Oct 26 21:12:47 2009
+++ src/usr.bin/m4/extern.h	Tue Sep  6 18:16:01 2011
@@ -1,5 +1,5 @@
 /*	$OpenBSD: extern.h,v 1.49 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: extern.h,v 1.14 2009/10/26 21:12:47 christos Exp $	*/
+/*	$NetBSD: extern.h,v 1.15 2011/09/06 18:16:01 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -96,7 +96,6 @@
 extern ptrdiff_t indx(const char *, const char *);
 extern void 	initspaces(void);
 extern void	killdiv(void);
-extern void	onintr(int);
 extern void	pbnum(int);
 extern void	pbnumbase(int, int, int);
 extern void	pbunsigned(unsigned long);
@@ -105,7 +104,6 @@
 extern void	*xalloc(size_t, const char *fmt, ...);
 extern void	*xrealloc(void *, size_t, const char *fmt, ...);
 extern char	*xstrdup(const char *);
-extern void	usage(void);
 extern void	resizedivs(int);
 extern size_t	buffer_mark(void);
 extern void	dump_buffer(FILE *, size_t);

Index: src/usr.bin/m4/gnum4.c
diff -u src/usr.bin/m4/gnum4.c:1.7 src/usr.bin/m4/gnum4.c:1.8
--- src/usr.bin/m4/gnum4.c:1.7	Mon Oct 26 21:16:49 2009
+++ src/usr.bin/m4/gnum4.c	Tue Sep  6 18:16:01 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: gnum4.c,v 1.7 2009/10/26 21:16:49 christos Exp $ */
+/* $NetBSD: gnum4.c,v 1.8 2011/09/06 18:16:01 joerg Exp $ */
 /* $OpenBSD: gnum4.c,v 1.39 2008/08/21 21:01:04 espie Exp $ */
 
 /*
@@ -33,7 +33,7 @@
 #include nbtool_config.h
 #endif
 #include sys/cdefs.h
-__RCSID($NetBSD: gnum4.c,v 1.7 2009/10/26 21:16:49 christos Exp $);
+__RCSID($NetBSD: gnum4.c,v 1.8 2011/09/06 18:16:01 joerg Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -203,7 +203,7 @@
 static void addchar(int);
 static char *twiddle(const char *);
 static char *getstring(void);
-static void exit_regerror(int, regex_t *);
+static void exit_regerror(int, regex_t *) __dead;
 static void do_subst(const char *, regex_t *, const char *, regmatch_t *);
 static void do_regexpindex(const char *, regex_t *, regmatch_t *);
 static void do_regexp(const char *, regex_t *, const char *, regmatch_t *);

Index: src/usr.bin/m4/main.c
diff -u src/usr.bin/m4/main.c:1.40 src/usr.bin/m4/main.c:1.41
--- src/usr.bin/m4/main.c:1.40	Sun Aug 14 12:59:25 2011
+++ src/usr.bin/m4/main.c	Tue Sep  6 18:16:01 2011
@@ -1,5 +1,5 @@
 /*	$OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: main.c,v 1.40 2011/08/14 12:59:25 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.41 2011/09/06 18:16:01 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include nbtool_config.h
 #endif
 #include sys/cdefs.h
-__RCSID($NetBSD: main.c,v 1.40 2011/08/14 12:59:25 christos Exp $);
+__RCSID($NetBSD: main.c,v 1.41 2011/09/06 18:16:01 joerg Exp $);
 #include assert.h
 #include signal.h
 #include err.h
@@ -167,7 +167,22 @@
 
 static void enlarge_stack(void);
 
-int main(int, char *[]);
+__dead static void
+usage(void)
+{
+	fprintf(stderr, usage: %s [-gPs] [-Dname[=value]] [-d flags] 
+			[-I dirname] [-o filename]\n
+			\t[-t macro] [-Uname] [file ...]\n, getprogname());
+	exit(1);
+}
+
+__dead static void
+onintr(int signo)
+{
+	char intrmessage[] = m4: interrupted.\n;
+	write(STDERR_FILENO, intrmessage, sizeof(intrmessage)-1);
+	_exit(1);
+}
 
 int
 main(int argc, char *argv[])

Index: src/usr.bin/m4/misc.c
diff -u src/usr.bin/m4/misc.c:1.21 src/usr.bin/m4/misc.c:1.22
--- src/usr.bin/m4/misc.c:1.21	Sat Mar  5 16:37:50 2011
+++ src/usr.bin/m4/misc.c	Tue Sep  6 18:16:01 2011
@@ -1,5 +1,5 @@
 /*	$OpenBSD: misc.c,v 1.41 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: misc.c,v 1.21 2011/03/05 16:37:50 christos Exp $	*/
+/*	$NetBSD: misc.c,v 1.22 2011/09/06 18:16:01 joerg Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -36,7 +36,7 @@
 #include nbtool_config.h
 #endif
 #include sys/cdefs.h
-__RCSID($NetBSD: misc.c,v 1.21 2011/03/05 16:37:50 christos Exp $);
+__RCSID($NetBSD: misc.c,v 1.22 2011/09/06 18:16:01 joerg Exp $);
 #include sys/types.h
 #include errno.h
 #include unistd.h
@@ -240,19 +240,11 @@
 	outfile[n] = NULL;
 }
 
-void
-onintr(int signo)
-{
-#define intrmessage	m4: interrupted.\n
-	write(STDERR_FILENO, intrmessage, sizeof(intrmessage)-1);
-	_exit(1);
-}
-
 /*
  * killdiv - get rid of the diversion files
  */
 void
-killdiv()
+killdiv(void)
 {
 	int n;
 
@@ -340,15 +332,6 @@
 	return p;
 }
 
-void
-usage(void)
-{
-	fprintf(stderr, usage: 

CVS commit: src/usr.bin/m4

2011-08-21 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 21 23:38:43 UTC 2011

Modified Files:
src/usr.bin/m4: eval.c

Log Message:
Requires stdint.h.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/m4/eval.c

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

Modified files:

Index: src/usr.bin/m4/eval.c
diff -u src/usr.bin/m4/eval.c:1.21 src/usr.bin/m4/eval.c:1.22
--- src/usr.bin/m4/eval.c:1.21	Sat Mar  5 16:38:25 2011
+++ src/usr.bin/m4/eval.c	Sun Aug 21 23:38:43 2011
@@ -1,5 +1,5 @@
 /*	$OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $	*/
-/*	$NetBSD: eval.c,v 1.21 2011/03/05 16:38:25 christos Exp $	*/
+/*	$NetBSD: eval.c,v 1.22 2011/08/21 23:38:43 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include nbtool_config.h
 #endif
 #include sys/cdefs.h
-__RCSID($NetBSD: eval.c,v 1.21 2011/03/05 16:38:25 christos Exp $);
+__RCSID($NetBSD: eval.c,v 1.22 2011/08/21 23:38:43 dholland Exp $);
 
 #include sys/types.h
 #include err.h
@@ -52,6 +52,7 @@
 #include stdio.h
 #include stdlib.h
 #include stddef.h
+#include stdint.h
 #include string.h
 #include fcntl.h
 #include mdef.h



CVS commit: src/usr.bin/m4

2011-08-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 14 12:59:25 UTC 2011

Modified Files:
src/usr.bin/m4: Makefile main.c

Log Message:
kill gcc-4.5 warning


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/m4/Makefile
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/m4/main.c

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

Modified files:

Index: src/usr.bin/m4/Makefile
diff -u src/usr.bin/m4/Makefile:1.16 src/usr.bin/m4/Makefile:1.17
--- src/usr.bin/m4/Makefile:1.16	Wed Jun 22 01:23:53 2011
+++ src/usr.bin/m4/Makefile	Sun Aug 14 08:59:25 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.16 2011/06/22 05:23:53 mrg Exp $
+#	$NetBSD: Makefile,v 1.17 2011/08/14 12:59:25 christos Exp $
 #
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
@@ -25,8 +25,3 @@
 CLEANFILES+=parser.c parser.h tokenizer.o
 
 .include bsd.prog.mk
-
-# XXX
-.if ${HAVE_GCC} == 45
-COPTS.main.c+=	-Wno-error
-.endif

Index: src/usr.bin/m4/main.c
diff -u src/usr.bin/m4/main.c:1.39 src/usr.bin/m4/main.c:1.40
--- src/usr.bin/m4/main.c:1.39	Fri Nov  6 10:13:27 2009
+++ src/usr.bin/m4/main.c	Sun Aug 14 08:59:25 2011
@@ -1,5 +1,5 @@
 /*	$OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: main.c,v 1.39 2009/11/06 15:13:27 joerg Exp $	*/
+/*	$NetBSD: main.c,v 1.40 2011/08/14 12:59:25 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include nbtool_config.h
 #endif
 #include sys/cdefs.h
-__RCSID($NetBSD: main.c,v 1.39 2009/11/06 15:13:27 joerg Exp $);
+__RCSID($NetBSD: main.c,v 1.40 2011/08/14 12:59:25 christos Exp $);
 #include assert.h
 #include signal.h
 #include err.h
@@ -572,7 +572,7 @@
 		return NULL;
 	}
 
-	p = ohash_find(macros, ohash_qlookupi(macros, name, (const char **)tp));
+	p = ohash_find(macros, ohash_qlookupi(macros, name, (void *)tp));
 	if (p == NULL)
 		return NULL;
 	if (macro_getdef(p) == NULL)



CVS commit: src/usr.bin/m4

2011-05-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue May 24 12:32:36 UTC 2011

Modified Files:
src/usr.bin/m4: tokenizer.l

Log Message:
Doesn't need input.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/m4/tokenizer.l

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

Modified files:

Index: src/usr.bin/m4/tokenizer.l
diff -u src/usr.bin/m4/tokenizer.l:1.4 src/usr.bin/m4/tokenizer.l:1.5
--- src/usr.bin/m4/tokenizer.l:1.4	Thu Oct 29 14:49:03 2009
+++ src/usr.bin/m4/tokenizer.l	Tue May 24 12:32:36 2011
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: tokenizer.l,v 1.4 2009/10/29 14:49:03 christos Exp $ */
+/* $NetBSD: tokenizer.l,v 1.5 2011/05/24 12:32:36 joerg Exp $ */
 /* $OpenBSD: tokenizer.l,v 1.6 2008/08/21 21:00:14 espie Exp $ */
 /*
  * Copyright (c) 2004 Marc Espie es...@cvs.openbsd.org
@@ -20,7 +20,7 @@
 #include nbtool_config.h
 #endif
 #include parser.h
-__RCSID($NetBSD: tokenizer.l,v 1.4 2009/10/29 14:49:03 christos Exp $);
+__RCSID($NetBSD: tokenizer.l,v 1.5 2011/05/24 12:32:36 joerg Exp $);
 #include stdlib.h
 #include errno.h
 #include stdint.h
@@ -37,6 +37,7 @@
 %}
 
 %option nounput
+%option noinput
 
 delim 	[ \t\n]
 ws	{delim}+



CVS commit: src/usr.bin/m4

2011-03-08 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Tue Mar  8 23:55:19 UTC 2011

Modified Files:
src/usr.bin/m4: pathnames.h

Log Message:
Revert previous, to fix build on Mac OS X again.

ok christos@


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/m4/pathnames.h

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

Modified files:

Index: src/usr.bin/m4/pathnames.h
diff -u src/usr.bin/m4/pathnames.h:1.14 src/usr.bin/m4/pathnames.h:1.15
--- src/usr.bin/m4/pathnames.h:1.14	Sat Mar  5 16:38:46 2011
+++ src/usr.bin/m4/pathnames.h	Tue Mar  8 23:55:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pathnames.h,v 1.14 2011/03/05 16:38:46 christos Exp $	*/
+/*	$NetBSD: pathnames.h,v 1.15 2011/03/08 23:55:19 riz Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,21 +35,6 @@
  */
 
 /*
- * Definitions of diversion files.  If the name of the file is changed,
- * adjust UNIQUE to point to the wildcard (*) character in the filename.
+ * Definitions of diversion files.
  */
-
-#ifdef msdos
-#define _PATH_DIVNAME	\\M4*XX		/* msdos diversion files */
-#define	UNIQUE		3			/* unique char location */
-#endif
-
-#if defined(unix) || defined(__NetBSD__) || defined(__OpenBSD__)
 #define _PATH_DIVNAME	/tmp/m4.0XX	/* unix diversion files */
-#define UNIQUE		8			/* unique char location */
-#endif
-
-#ifdef vms
-#define _PATH_DIVNAME	sys$login:m4*XX	/* vms diversion files */
-#define UNIQUE		12			/* unique char location */
-#endif



CVS commit: src/usr.bin/m4

2011-03-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  5 16:37:50 UTC 2011

Modified Files:
src/usr.bin/m4: mdef.h misc.c trace.c

Log Message:
use TOKEN_LINE from MirBSD


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/m4/mdef.h
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/m4/misc.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/m4/trace.c

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

Modified files:

Index: src/usr.bin/m4/mdef.h
diff -u src/usr.bin/m4/mdef.h:1.13 src/usr.bin/m4/mdef.h:1.14
--- src/usr.bin/m4/mdef.h:1.13	Mon Oct 26 17:11:28 2009
+++ src/usr.bin/m4/mdef.h	Sat Mar  5 11:37:50 2011
@@ -1,5 +1,5 @@
 /*	$OpenBSD: mdef.h,v 1.29 2006/03/20 20:27:45 espie Exp $	*/
-/*	$NetBSD: mdef.h,v 1.13 2009/10/26 21:11:28 christos Exp $	*/
+/*	$NetBSD: mdef.h,v 1.14 2011/03/05 16:37:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -166,6 +166,8 @@
 
 #define CURRENT_NAME	(infile[ilevel].name)
 #define CURRENT_LINE	(infile[ilevel].lineno)
+#define	TOKEN_LINE(f)	(f-lineno - (f-c == '\n' ? 1 : 0))
+
 /*
  * macros for readibility and/or speed
  *

Index: src/usr.bin/m4/misc.c
diff -u src/usr.bin/m4/misc.c:1.20 src/usr.bin/m4/misc.c:1.21
--- src/usr.bin/m4/misc.c:1.20	Fri Nov  6 10:13:27 2009
+++ src/usr.bin/m4/misc.c	Sat Mar  5 11:37:50 2011
@@ -1,5 +1,5 @@
 /*	$OpenBSD: misc.c,v 1.41 2009/10/14 17:19:47 sthen Exp $	*/
-/*	$NetBSD: misc.c,v 1.20 2009/11/06 15:13:27 joerg Exp $	*/
+/*	$NetBSD: misc.c,v 1.21 2011/03/05 16:37:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -36,7 +36,7 @@
 #include nbtool_config.h
 #endif
 #include sys/cdefs.h
-__RCSID($NetBSD: misc.c,v 1.20 2009/11/06 15:13:27 joerg Exp $);
+__RCSID($NetBSD: misc.c,v 1.21 2011/03/05 16:37:50 christos Exp $);
 #include sys/types.h
 #include errno.h
 #include unistd.h
@@ -395,7 +395,7 @@
 void
 doprintlineno(struct input_file *f)
 {
-	pbunsigned(f-lineno);
+	pbunsigned(TOKEN_LINE(f));
 }
 
 void

Index: src/usr.bin/m4/trace.c
diff -u src/usr.bin/m4/trace.c:1.6 src/usr.bin/m4/trace.c:1.7
--- src/usr.bin/m4/trace.c:1.6	Mon Oct 26 17:11:28 2009
+++ src/usr.bin/m4/trace.c	Sat Mar  5 11:37:50 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: trace.c,v 1.6 2009/10/26 21:11:28 christos Exp $	*/
+/*	$NetBSD: trace.c,v 1.7 2011/03/05 16:37:50 christos Exp $	*/
 /* $OpenBSD: trace.c,v 1.15 2006/03/24 08:03:44 espie Exp $ */
 /*
  * Copyright (c) 2001 Marc Espie.
@@ -28,7 +28,7 @@
 #include nbtool_config.h
 #endif
 #include sys/cdefs.h
-__RCSID($NetBSD: trace.c,v 1.6 2009/10/26 21:11:28 christos Exp $);
+__RCSID($NetBSD: trace.c,v 1.7 2011/03/05 16:37:50 christos Exp $);
 
 #include sys/types.h
 #include err.h
@@ -143,7 +143,7 @@
 	if (trace_flags  TRACE_FILENAME)
 		fprintf(traceout, %s:, inp-name);
 	if (trace_flags  TRACE_LINENO)
-		fprintf(traceout, %lu:, inp-lineno);
+		fprintf(traceout, %lu:, TOKEN_LINE(inp));
 	fprintf(traceout,  -%d- , frame_level());
 	if (trace_flags  TRACE_ID)
 		fprintf(traceout, id %lu: , expansion_id);



CVS commit: src/usr.bin/m4

2011-03-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  5 16:38:26 UTC 2011

Modified Files:
src/usr.bin/m4: eval.c

Log Message:
add mimic_gnu for eval print.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/m4/eval.c

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

Modified files:

Index: src/usr.bin/m4/eval.c
diff -u src/usr.bin/m4/eval.c:1.20 src/usr.bin/m4/eval.c:1.21
--- src/usr.bin/m4/eval.c:1.20	Mon Oct 26 17:11:28 2009
+++ src/usr.bin/m4/eval.c	Sat Mar  5 11:38:25 2011
@@ -1,5 +1,5 @@
 /*	$OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $	*/
-/*	$NetBSD: eval.c,v 1.20 2009/10/26 21:11:28 christos Exp $	*/
+/*	$NetBSD: eval.c,v 1.21 2011/03/05 16:38:25 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include nbtool_config.h
 #endif
 #include sys/cdefs.h
-__RCSID($NetBSD: eval.c,v 1.20 2009/10/26 21:11:28 christos Exp $);
+__RCSID($NetBSD: eval.c,v 1.21 2011/03/05 16:38:25 christos Exp $);
 
 #include sys/types.h
 #include err.h
@@ -429,8 +429,11 @@
 	 */
 		if (argc  2) {
 			for (n = 2; n  argc; n++)
-fprintf(stderr, %s , argv[n]);
-			fprintf(stderr, \n);
+fprintf(stderr, %s%s,
+mimic_gnu  n == 2 ?  :  ,
+argv[n]);
+			if (!mimic_gnu)
+fprintf(stderr, \n);
 		}
 		break;
 



CVS commit: src/usr.bin/m4

2011-03-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  5 16:38:47 UTC 2011

Modified Files:
src/usr.bin/m4: pathnames.h

Log Message:
add other os support from MirBSD


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/m4/pathnames.h

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

Modified files:

Index: src/usr.bin/m4/pathnames.h
diff -u src/usr.bin/m4/pathnames.h:1.13 src/usr.bin/m4/pathnames.h:1.14
--- src/usr.bin/m4/pathnames.h:1.13	Sat Oct 31 19:25:04 2009
+++ src/usr.bin/m4/pathnames.h	Sat Mar  5 11:38:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pathnames.h,v 1.13 2009/10/31 23:25:04 joerg Exp $	*/
+/*	$NetBSD: pathnames.h,v 1.14 2011/03/05 16:38:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,6 +35,21 @@
  */
 
 /*
- * Definitions of diversion files.
+ * Definitions of diversion files.  If the name of the file is changed,
+ * adjust UNIQUE to point to the wildcard (*) character in the filename.
  */
+
+#ifdef msdos
+#define _PATH_DIVNAME	\\M4*XX		/* msdos diversion files */
+#define	UNIQUE		3			/* unique char location */
+#endif
+
+#if defined(unix) || defined(__NetBSD__) || defined(__OpenBSD__)
 #define _PATH_DIVNAME	/tmp/m4.0XX	/* unix diversion files */
+#define UNIQUE		8			/* unique char location */
+#endif
+
+#ifdef vms
+#define _PATH_DIVNAME	sys$login:m4*XX	/* vms diversion files */
+#define UNIQUE		12			/* unique char location */
+#endif



CVS commit: src/usr.bin/m4

2010-05-14 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri May 14 17:14:28 UTC 2010

Modified Files:
src/usr.bin/m4: m4.1

Log Message:
Improve/fix/deuglify markup.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/m4/m4.1

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

Modified files:

Index: src/usr.bin/m4/m4.1
diff -u src/usr.bin/m4/m4.1:1.21 src/usr.bin/m4/m4.1:1.22
--- src/usr.bin/m4/m4.1:1.21	Fri Oct 30 01:40:45 2009
+++ src/usr.bin/m4/m4.1	Fri May 14 17:14:28 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: m4.1,v 1.21 2009/10/30 01:40:45 joerg Exp $
+.\	$NetBSD: m4.1,v 1.22 2010/05/14 17:14:28 joerg Exp $
 .\	@(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
 .\
 .\ Copyright (c) 1989, 1993
@@ -75,7 +75,7 @@
 .Pp
 There cannot be any space following the macro name and the open
 parenthesis
-.Pq Sq ( .
+.Sq \( .
 If the macro name is not followed by an open
 parenthesis it is processed with no arguments.
 .Pp



CVS commit: src/usr.bin/m4

2009-10-29 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Oct 30 01:40:46 UTC 2009

Modified Files:
src/usr.bin/m4: m4.1

Log Message:
Fix markup.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/m4/m4.1

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

Modified files:

Index: src/usr.bin/m4/m4.1
diff -u src/usr.bin/m4/m4.1:1.20 src/usr.bin/m4/m4.1:1.21
--- src/usr.bin/m4/m4.1:1.20	Mon Oct 26 21:11:28 2009
+++ src/usr.bin/m4/m4.1	Fri Oct 30 01:40:45 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: m4.1,v 1.20 2009/10/26 21:11:28 christos Exp $
+.\	$NetBSD: m4.1,v 1.21 2009/10/30 01:40:45 joerg Exp $
 .\	@(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
 .\
 .\ Copyright (c) 1989, 1993
@@ -100,9 +100,7 @@
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
-.It Fl D Ns Ar name Ns Oo
-.Pf = Ns Ar value
-.Oc
+.It Fl D Ns Ar name Ns Op Pf = Ns Ar value
 Define the symbol
 .Ar name
 to have some value (or



CVS commit: src/usr.bin/m4/lib

2009-10-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 28 12:59:24 UTC 2009

Modified Files:
src/usr.bin/m4/lib: ohash_int.h

Log Message:
Handle nbtools build better.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/usr.bin/m4/lib/ohash_int.h

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

Modified files:

Index: src/usr.bin/m4/lib/ohash_int.h
diff -u src/usr.bin/m4/lib/ohash_int.h:1.1.1.1 src/usr.bin/m4/lib/ohash_int.h:1.2
--- src/usr.bin/m4/lib/ohash_int.h:1.1.1.1	Mon Oct 26 17:08:59 2009
+++ src/usr.bin/m4/lib/ohash_int.h	Wed Oct 28 08:59:24 2009
@@ -1,5 +1,9 @@
 /*	$OpenBSD: ohash_int.h,v 1.3 2006/01/16 15:52:25 espie Exp $	*/
 
+#if HAVE_NBTOOL_CONFIG_H
+#include nbtool_config.h
+#endif
+
 #include stddef.h
 #include stdint.h
 #include stdlib.h



CVS commit: src/usr.bin/m4

2009-10-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 28 21:42:47 UTC 2009

Modified Files:
src/usr.bin/m4: tokenizer.l

Log Message:
more no unput


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/m4/tokenizer.l

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

Modified files:

Index: src/usr.bin/m4/tokenizer.l
diff -u src/usr.bin/m4/tokenizer.l:1.2 src/usr.bin/m4/tokenizer.l:1.3
--- src/usr.bin/m4/tokenizer.l:1.2	Mon Oct 26 17:11:28 2009
+++ src/usr.bin/m4/tokenizer.l	Wed Oct 28 17:42:47 2009
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: tokenizer.l,v 1.2 2009/10/26 21:11:28 christos Exp $ */
+/* $NetBSD: tokenizer.l,v 1.3 2009/10/28 21:42:47 christos Exp $ */
 /* $OpenBSD: tokenizer.l,v 1.6 2008/08/21 21:00:14 espie Exp $ */
 /*
  * Copyright (c) 2004 Marc Espie es...@cvs.openbsd.org
@@ -20,7 +20,7 @@
 #include nbtool_config.h
 #endif
 #include parser.h
-__RCSID($NetBSD: tokenizer.l,v 1.2 2009/10/26 21:11:28 christos Exp $);
+__RCSID($NetBSD: tokenizer.l,v 1.3 2009/10/28 21:42:47 christos Exp $);
 #include stdlib.h
 #include errno.h
 #include stdint.h
@@ -33,6 +33,8 @@
 
 int32_t number(void);
 int32_t parse_radix(void);
+
+#define YY_NO_UNPUT
 %}
 
 delim 	[ \t\n]



CVS commit: src/usr.bin/m4/lib

2009-10-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Oct 26 21:14:18 UTC 2009

Modified Files:
src/usr.bin/m4/lib: ohash_do.c ohash_enum.c strtonum.c

Log Message:
fix compilation.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/usr.bin/m4/lib/ohash_do.c \
src/usr.bin/m4/lib/ohash_enum.c src/usr.bin/m4/lib/strtonum.c

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

Modified files:

Index: src/usr.bin/m4/lib/ohash_do.c
diff -u src/usr.bin/m4/lib/ohash_do.c:1.1.1.1 src/usr.bin/m4/lib/ohash_do.c:1.2
--- src/usr.bin/m4/lib/ohash_do.c:1.1.1.1	Mon Oct 26 17:08:59 2009
+++ src/usr.bin/m4/lib/ohash_do.c	Mon Oct 26 17:14:18 2009
@@ -68,7 +68,7 @@
 void *
 ohash_remove(struct ohash *h, unsigned int i)
 {
-	void 		*result = (void *)h-t[i].p;
+	void 		*result = __UNCONST(h-t[i].p);
 
 	if (result == NULL || result == DELETED)
 		return NULL;
@@ -89,7 +89,7 @@
 	if (h-t[i].p == DELETED)
 		return NULL;
 	else
-		return (void *)h-t[i].p;
+		return __UNCONST(h-t[i].p);
 }
 
 void *
Index: src/usr.bin/m4/lib/ohash_enum.c
diff -u src/usr.bin/m4/lib/ohash_enum.c:1.1.1.1 src/usr.bin/m4/lib/ohash_enum.c:1.2
--- src/usr.bin/m4/lib/ohash_enum.c:1.1.1.1	Mon Oct 26 17:08:59 2009
+++ src/usr.bin/m4/lib/ohash_enum.c	Mon Oct 26 17:14:18 2009
@@ -31,6 +31,6 @@
 {
 	for (; *pos  h-size; (*pos)++) 
 		if (h-t[*pos].p != DELETED  h-t[*pos].p != NULL) 
-			return (void *)h-t[(*pos)++].p;
+			return __UNCONST(h-t[(*pos)++].p);
 	return NULL;
 }
Index: src/usr.bin/m4/lib/strtonum.c
diff -u src/usr.bin/m4/lib/strtonum.c:1.1.1.1 src/usr.bin/m4/lib/strtonum.c:1.2
--- src/usr.bin/m4/lib/strtonum.c:1.1.1.1	Mon Oct 26 17:08:59 2009
+++ src/usr.bin/m4/lib/strtonum.c	Mon Oct 26 17:14:18 2009
@@ -16,7 +16,11 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
-
+#if HAVE_NBTOOL_CONFIG_H
+#include nbtool_config.h
+#endif
+#include sys/cdefs.h
+__RCSID($NetBSD: strtonum.c,v 1.2 2009/10/26 21:14:18 christos Exp $);
 #include errno.h
 #include limits.h
 #include stdlib.h
@@ -27,6 +31,9 @@
 
 long long
 strtonum(const char *numstr, long long minval, long long maxval,
+const char **errstrp);
+long long
+strtonum(const char *numstr, long long minval, long long maxval,
 const char **errstrp)
 {
 	long long ll = 0;



CVS commit: src/usr.bin/m4

2009-10-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Oct 26 21:16:50 UTC 2009

Modified Files:
src/usr.bin/m4: gnum4.c

Log Message:
fix the tools build


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/m4/gnum4.c

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

Modified files:

Index: src/usr.bin/m4/gnum4.c
diff -u src/usr.bin/m4/gnum4.c:1.6 src/usr.bin/m4/gnum4.c:1.7
--- src/usr.bin/m4/gnum4.c:1.6	Mon Oct 26 17:11:28 2009
+++ src/usr.bin/m4/gnum4.c	Mon Oct 26 17:16:49 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: gnum4.c,v 1.6 2009/10/26 21:11:28 christos Exp $ */
+/* $NetBSD: gnum4.c,v 1.7 2009/10/26 21:16:49 christos Exp $ */
 /* $OpenBSD: gnum4.c,v 1.39 2008/08/21 21:01:04 espie Exp $ */
 
 /*
@@ -33,7 +33,7 @@
 #include nbtool_config.h
 #endif
 #include sys/cdefs.h
-__RCSID($NetBSD: gnum4.c,v 1.6 2009/10/26 21:11:28 christos Exp $);
+__RCSID($NetBSD: gnum4.c,v 1.7 2009/10/26 21:16:49 christos Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -54,6 +54,9 @@
 
 
 int mimic_gnu = 0;
+#ifndef SIZE_T_MAX
+#define SIZE_T_MAX (size_t)~0ull
+#endif
 
 /*
  * Support for include path search