mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
Support the -P option from gnu m4, which prefixes builtins with the
string m4_. Feedback from jmc@, Tobias Ulmer, Matthew Dempsky - thanks! ok espie@
This commit is contained in:
parent
cf271f1992
commit
092f48df65
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: extern.h,v 1.48 2008/08/21 20:59:14 espie Exp $ */
|
||||
/* $OpenBSD: extern.h,v 1.49 2009/10/14 17:19:47 sthen Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.3 1996/01/13 23:25:24 pk Exp $ */
|
||||
|
||||
/*-
|
||||
@ -173,4 +173,5 @@ extern char scommt[MAXCCHARS+1];/* start character for comment */
|
||||
extern int synch_lines; /* line synchronisation directives */
|
||||
|
||||
extern int mimic_gnu; /* behaves like gnu-m4 */
|
||||
extern int prefix_builtins; /* prefix builtin macros with m4_ */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: look.c,v 1.19 2009/06/26 22:03:17 guenther Exp $ */
|
||||
/* $OpenBSD: look.c,v 1.20 2009/10/14 17:19:47 sthen Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -231,11 +231,19 @@ void
|
||||
setup_builtin(const char *name, unsigned int type)
|
||||
{
|
||||
ndptr n;
|
||||
char *name2;
|
||||
|
||||
n = create_entry(name);
|
||||
if(prefix_builtins) {
|
||||
name2 = xalloc(strlen(name)+3+1, NULL);
|
||||
memcpy(name2, "m4_", 3);
|
||||
memcpy(name2 + 3, name, strlen(name)+1);
|
||||
} else
|
||||
name2 = xstrdup(name);
|
||||
|
||||
n = create_entry(name2);
|
||||
n->builtin_type = type;
|
||||
n->d = xalloc(sizeof(struct macro_definition), NULL);
|
||||
n->d->defn = xstrdup(name);
|
||||
n->d->defn = name2;
|
||||
n->d->type = type;
|
||||
n->d->next = NULL;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" @(#) $OpenBSD: m4.1,v 1.55 2009/02/08 17:15:10 jmc Exp $
|
||||
.\" @(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -30,7 +30,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: February 8 2009 $
|
||||
.Dd $Mdocdate: October 14 2009 $
|
||||
.Dt M4 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -38,7 +38,7 @@
|
||||
.Nd macro language processor
|
||||
.Sh SYNOPSIS
|
||||
.Nm m4
|
||||
.Op Fl gs
|
||||
.Op Fl gPs
|
||||
.Oo
|
||||
.Sm off
|
||||
.Fl D Ar name Op No = Ar value
|
||||
@ -150,6 +150,13 @@ to the include path.
|
||||
.It Fl o Ar filename
|
||||
Send trace output to
|
||||
.Ar filename .
|
||||
.It Fl P
|
||||
Prefix all built-in macros with
|
||||
.Sq m4_ .
|
||||
For example, instead of writing
|
||||
.Ic define ,
|
||||
use
|
||||
.Ic m4_define .
|
||||
.It Fl s
|
||||
Output line synchronization directives, suitable for
|
||||
.Xr cpp 1 .
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.76 2008/08/16 12:21:46 espie Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $ */
|
||||
/* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -77,6 +77,7 @@ char rquote[MAXCCHARS+1] = {RQUOTE}; /* right quote character (') */
|
||||
char scommt[MAXCCHARS+1] = {SCOMMT}; /* start character for comment */
|
||||
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 */
|
||||
|
||||
struct keyblk {
|
||||
char *knam; /* keyword name */
|
||||
@ -175,7 +176,6 @@ main(int argc, char *argv[])
|
||||
signal(SIGINT, onintr);
|
||||
|
||||
init_macros();
|
||||
initkwds();
|
||||
initspaces();
|
||||
STACKMAX = INITSTACKMAX;
|
||||
|
||||
@ -186,7 +186,7 @@ main(int argc, char *argv[])
|
||||
outfile = NULL;
|
||||
resizedivs(MAXOUT);
|
||||
|
||||
while ((c = getopt(argc, argv, "gst:d:D:U:o:I:")) != -1)
|
||||
while ((c = getopt(argc, argv, "gst:d:D:U:o:I:P")) != -1)
|
||||
switch(c) {
|
||||
|
||||
case 'D': /* define something..*/
|
||||
@ -200,12 +200,14 @@ main(int argc, char *argv[])
|
||||
case 'I':
|
||||
addtoincludepath(optarg);
|
||||
break;
|
||||
case 'P':
|
||||
prefix_builtins = 1;
|
||||
break;
|
||||
case 'U': /* undefine... */
|
||||
macro_popdef(optarg);
|
||||
break;
|
||||
case 'g':
|
||||
mimic_gnu = 1;
|
||||
setup_builtin("format", FORMATTYPE);
|
||||
break;
|
||||
case 'd':
|
||||
set_trace_flags(optarg);
|
||||
@ -226,6 +228,10 @@ main(int argc, char *argv[])
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
initkwds();
|
||||
if (mimic_gnu)
|
||||
setup_builtin("format", FORMATTYPE);
|
||||
|
||||
active = stdout; /* default active output */
|
||||
bbase[0] = bufbase;
|
||||
if (!argc) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: misc.c,v 1.40 2008/08/21 20:59:14 espie Exp $ */
|
||||
/* $OpenBSD: misc.c,v 1.41 2009/10/14 17:19:47 sthen Exp $ */
|
||||
/* $NetBSD: misc.c,v 1.6 1995/09/28 05:37:41 tls Exp $ */
|
||||
|
||||
/*
|
||||
@ -341,7 +341,7 @@ xstrdup(const char *s)
|
||||
void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "usage: m4 [-gs] [-Dname[=value]] [-d flags] "
|
||||
fprintf(stderr, "usage: m4 [-gPs] [-Dname[=value]] [-d flags] "
|
||||
"[-I dirname] [-o filename]\n"
|
||||
"\t[-t macro] [-Uname] [file ...]\n");
|
||||
exit(1);
|
||||
|
Loading…
Reference in New Issue
Block a user