Project

General

Profile

Bug #497 » m4.patch

pavalos, 12/28/2006 07:09 AM

View differences:

usr.bin/m4/m4.1 28 Dec 2006 00:10:12 -0000
.Nm
.Op Fl d Ar flags
.Op Fl t Ar name
.Op Fl gs
.Op Fl Pgs
.Op Fl D Ar name Ns Op = Ns Ar value
.Op Fl U Ar name
.Op Fl I Ar dirname
......
.It Fl U Ar name
Undefine the symbol
.Ar name .
.It Fl P
Prefixes all
.Nm
builtin macros with the string
.Li m4_ .
This changes the macro names
.Li dnl
to
.Li m4_dnl ,
.Li index
to
.Li m4_index ,
and so forth.
.It Fl I Ar dirname
Add directory
.Ar dirname
usr.bin/m4/main.c 28 Dec 2006 00:24:20 -0000
int oindex = 0; /* diversion index.. */
char null[] = ""; /* as it says.. just a null.. */
const char *m4wraps = ""; /* m4wrap string default.. */
int m4prefix = 0; /* prefix keywords with m4_ */
char lquote[MAXCCHARS+1] = {LQUOTE}; /* left quote character (`) */
char rquote[MAXCCHARS+1] = {RQUOTE}; /* right quote character (') */
char scommt[MAXCCHARS+1] = {SCOMMT}; /* start character for comment */
......
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
signal(SIGINT, onintr);
/*
* We need to know if -P is there before checking -D and -U.
*/
while ((c = getopt(argc, argv, "Pgst:d:D:U:o:I:")) != -1)
if (c == 'P')
m4prefix = 1;
optind = 1;
initkwds();
initspaces();
STACKMAX = INITSTACKMAX;
......
outfile = NULL;
resizedivs(MAXOUT);
while ((c = getopt(argc, argv, "gst:d:D:U:o:I:")) != -1)
while ((c = getopt(argc, argv, "Pgst:d:D:U:o:I:")) != -1)
switch(c) {
case 'D': /* define something..*/
for (p = optarg; *p; p++)
......
case 'I':
addtoincludepath(optarg);
break;
case 'P':
break;
case 'U': /* undefine... */
remhash(optarg, TOP);
break;
......
size_t i;
unsigned int h;
ndptr p;
char *k;
for (i = 0; i < MAXKEYS; i++) {
h = hash(keywrds[i].knam);
k = (char *)keywrds[i].knam;
if (m4prefix) {
if (asprintf(&k, "m4_%s", k) == -1)
err(1, "asprintf");
keywrds[i].knam = k;
}
h = hash(k);
p = (ndptr) xalloc(sizeof(struct ndblock));
p->nxtptr = hashtab[h % HASHSIZE];
hashtab[h % HASHSIZE] = p;
(1-1/2)