1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

Last needed m4 changes to bootstrap autoconf without gnu-m4.

This commit is contained in:
espie 2000-03-18 01:06:55 +00:00
parent 4bba202a0a
commit 87c5c065f7
4 changed files with 73 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: eval.c,v 1.25 2000/03/11 15:54:43 espie Exp $ */
/* $OpenBSD: eval.c,v 1.26 2000/03/18 01:06:55 espie Exp $ */
/* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */
/*
@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.2 (Berkeley) 4/27/95";
#else
static char rcsid[] = "$OpenBSD: eval.c,v 1.25 2000/03/11 15:54:43 espie Exp $";
static char rcsid[] = "$OpenBSD: eval.c,v 1.26 2000/03/18 01:06:55 espie Exp $";
#endif
#endif /* not lint */
@ -77,6 +77,7 @@ static void dodiv __P((int));
static void doundiv __P((const char *[], int));
static void dosub __P((const char *[], int));
static void map __P((char *, const char *, const char *, const char *));
static const char *handledash __P((char *, char *, const char *));
/*
* eval - evaluate built-in macros.
* argc - number of elements in argv.
@ -677,6 +678,15 @@ dochq(argv, argc)
const char *argv[];
int argc;
{
/* In gnu-m4 mode, having two empty arguments means no quotes at
* all. */
if (mimic_gnu) {
if (argc > 3 && !*argv[2] && !*argv[3]) {
lquote[0] = EOS;
rquote[0] = EOS;
return;
}
}
if (argc > 2) {
if (*argv[2])
strlcpy(lquote, argv[2], sizeof(lquote));
@ -833,6 +843,8 @@ map(dest, src, from, to)
{
const char *tmp;
unsigned char sch, dch;
static char frombis[257];
static char tobis[257];
static unsigned char mapvec[256] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
@ -855,6 +867,13 @@ map(dest, src, from, to)
};
if (*src) {
if (mimic_gnu) {
/*
* expand character ranges on the fly
*/
from = handledash(frombis, frombis + 256, from);
to = handledash(tobis, tobis + 256, to);
}
tmp = from;
/*
* create a mapping between "from" and
@ -884,3 +903,40 @@ map(dest, src, from, to)
}
*dest = '\0';
}
/*
* handledash:
* use buffer to copy the src string, expanding character ranges
* on the way.
*/
static const char *
handledash(buffer, end, src)
char *buffer;
char *end;
const char *src;
{
char *p;
p = buffer;
while(*src) {
if (src[1] == '-' && src[2]) {
unsigned char i;
for (i = (unsigned char)src[0];
i <= (unsigned char)src[2]; i++) {
*p++ = i;
if (p == end) {
*p = '\0';
return buffer;
}
}
src += 3;
} else
*p++ = *src++;
if (p == end)
break;
}
*p = '\0';
return buffer;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: extern.h,v 1.17 2000/03/11 15:54:44 espie Exp $ */
/* $OpenBSD: extern.h,v 1.18 2000/03/18 01:06:55 espie Exp $ */
/* $NetBSD: extern.h,v 1.3 1996/01/13 23:25:24 pk Exp $ */
/*-
@ -111,3 +111,4 @@ extern char *null; /* as it says.. just a null. */
extern char rquote[MAXCCHARS+1];/* right quote character (') */
extern char scommt[MAXCCHARS+1];/* start character for comment */
extern int mimic_gnu; /* behaves like gnu-m4 */

View File

@ -1,4 +1,4 @@
.\" @(#) $OpenBSD: m4.1,v 1.11 2000/03/11 15:54:44 espie Exp $
.\" @(#) $OpenBSD: m4.1,v 1.12 2000/03/18 01:06:55 espie Exp $
.\"
.\"
.Dd January 26, 1993
@ -9,6 +9,7 @@
.Nd macro language processor
.Sh SYNOPSIS
.Nm m4
.Op Fl g
.Oo
.Fl D Ns Ar name Ns Op Ar =value
.Oc
@ -46,7 +47,7 @@ You can change the quote characters with the
.Ic changequote
built-in macro.
.Pp
Some built-ins don't make any sense without arguments, and hence are not
Most built-ins don't make any sense without arguments, and hence are not
recognized as special when not followed by an open parenthesis.
.Pp
The options are as follows:
@ -65,6 +66,10 @@ Undefine the symbol
Add directory
.Ar dirname
to the include path.
.It Fl g
Activate GNU-m4 compatibility mode. In this mode, changequote with
two empty parameters deactivates quotes, translit handles simple character
ranges (e.g., a-z) and regular expressions mimic emacs behavior.
.Sh SYNTAX
.Nm m4
provides the following built-in macros.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.31 2000/03/11 15:54:44 espie Exp $ */
/* $OpenBSD: main.c,v 1.32 2000/03/18 01:06:56 espie Exp $ */
/* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */
/*-
@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$OpenBSD: main.c,v 1.31 2000/03/11 15:54:44 espie Exp $";
static char rcsid[] = "$OpenBSD: main.c,v 1.32 2000/03/18 01:06:56 espie Exp $";
#endif
#endif /* not lint */
@ -178,7 +178,7 @@ main(argc,argv)
initkwds();
initspaces();
while ((c = getopt(argc, argv, "tD:U:o:I:")) != -1)
while ((c = getopt(argc, argv, "gtD:U:o:I:")) != -1)
switch(c) {
case 'D': /* define something..*/
@ -195,6 +195,9 @@ main(argc,argv)
case 'U': /* undefine... */
remhash(optarg, TOP);
break;
case 'g':
mimic_gnu = 1;
break;
case 'o': /* specific output */
case '?':
usage();