Project

General

Profile

Bug #3248 » 0010-sh-1-bring-back-Makefile-changes-between-2234273d6f-.patch

piecuch, 09/16/2020 11:16 AM

View differences:

bin/sh/Makefile
# @(#)Makefile 8.4 (Berkeley) 5/5/95
# $FreeBSD$
# Makefile for /bin/sh
#
PROG= sh
INSTALLFLAGS= -S
......
# MLINKS for Shell built in commands for which there are no userland
# utilities of the same name are handled with the associated manpage,
# builtin.1 in share/man/man1/.
CFLAGS+=-DSHELL -I. -I${.CURDIR} -I${.CURDIR}/../../contrib/libedit/src
# for debug:
# DEBUG_FLAGS+= -g -DDEBUG=2 -fno-inline
......
LDADD= ${LIBEDIT} ${LIBNCURSES}
.endif
.PATH: ${.CURDIR}/bltin \
${.CURDIR}/../kill \
${.CURDIR}/../test \
${.CURDIR}/../../usr.bin/printf
CLEANFILES+= mknodes mksyntax
#
# NOTE: the headers and sources in pregenerated/ must be updated upon any
# changes to the nodetypes nodes.c.pat mkbuiltins mknodes.c mksyntax.c mktokens
# files using following scripts and build programs.
#
.if 1 # not updating sh(1)
.PATH: ${.CURDIR}/pregenerated
CFLAGS+= -I${.CURDIR}/pregenerated
.else
CLEANFILES+= ${GENSRCS} ${GENHDRS}
build-tools: mknodes mksyntax
.ORDER: builtins.c builtins.h
builtins.c builtins.h: mkbuiltins builtins.def
sh ${.CURDIR}/mkbuiltins ${.CURDIR}
DEPENDOBJS+= mknodes mksyntax
mknodes mksyntax: ${BUILD_TOOLS_META}
# XXX this is just to stop the default .c rule being used, so that the
# intermediate object has a fixed name.
# XXX we have a default .c rule, but no default .o rule.
.o:
${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
.ORDER: nodes.c nodes.h
nodes.c nodes.h: mknodes nodetypes nodes.c.pat
${BTOOLSPATH:U.}/mknodes ${.CURDIR}/nodetypes ${.CURDIR}/nodes.c.pat
nodes.c nodes.h: nodetypes nodes.c.pat
${.OBJDIR}/mknodes/mknodes.nx ${.ALLSRC}
.ORDER: syntax.c syntax.h
syntax.c syntax.h: mksyntax
${BTOOLSPATH:U.}/mksyntax
syntax.c syntax.h:
${.OBJDIR}/mksyntax/mksyntax.nx
token.h: mktokens
sh ${.CURDIR}/mktokens
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
.endif
regress: sh
cd ${.CURDIR}/../../tools/regression/bin/sh && ${MAKE} SH=${.OBJDIR}/sh
.include <bsd.prog.mk>
bin/sh/mknodes/Makefile
.PATH: ${.CURDIR}/..
PROG= mknodes
build-tools: mknodes.nx
# this mknodes is used in place, it is not installed anywhere
install:
.include <bsd.hostprog.mk>
bin/sh/mksyntax/Makefile
.PATH: ${.CURDIR}/..
PROG= mksyntax
build-tools: mksyntax.nx
# this mksyntax is used in place, it is not installed anywhere
install:
.include <bsd.hostprog.mk>
bin/sh/pregenerated/builtins.c
/*
* This file was generated by the mkbuiltins program.
*/
#include <stdlib.h>
#include "shell.h"
#include "builtins.h"
int (*const builtinfunc[])(int, char **) = {
bltincmd,
aliascmd,
bgcmd,
bindcmd,
breakcmd,
cdcmd,
commandcmd,
dotcmd,
echocmd,
evalcmd,
execcmd,
exitcmd,
letcmd,
exportcmd,
falsecmd,
fgcmd,
freebsd_wordexpcmd,
getoptscmd,
hashcmd,
histcmd,
jobidcmd,
jobscmd,
killcmd,
localcmd,
printfcmd,
pwdcmd,
readcmd,
returncmd,
setcmd,
setvarcmd,
shiftcmd,
testcmd,
timescmd,
trapcmd,
truecmd,
typecmd,
ulimitcmd,
umaskcmd,
unaliascmd,
unsetcmd,
waitcmd,
wordexpcmd,
};
const unsigned char builtincmd[] = {
"\007\000builtin"
"\005\001alias"
"\002\002bg"
"\004\003bind"
"\005\204break"
"\010\204continue"
"\002\005cd"
"\005\005chdir"
"\007\006command"
"\001\207."
"\004\010echo"
"\004\211eval"
"\004\212exec"
"\004\213exit"
"\003\014let"
"\006\215export"
"\010\215readonly"
"\005\016false"
"\002\017fg"
"\017\020freebsd_wordexp"
"\007\021getopts"
"\004\022hash"
"\002\023fc"
"\005\024jobid"
"\004\025jobs"
"\004\026kill"
"\005\027local"
"\006\030printf"
"\003\031pwd"
"\004\032read"
"\006\233return"
"\003\234set"
"\006\035setvar"
"\005\236shift"
"\004\037test"
"\001\037["
"\005\240times"
"\004\241trap"
"\001\242:"
"\004\042true"
"\004\043type"
"\006\044ulimit"
"\005\045umask"
"\007\046unalias"
"\005\247unset"
"\004\050wait"
"\007\051wordexp"
};
bin/sh/pregenerated/builtins.h
/*
* This file was generated by the mkbuiltins program.
*/
#include <sys/cdefs.h>
#define BLTINCMD 0
#define ALIASCMD 1
#define BGCMD 2
#define BINDCMD 3
#define BREAKCMD 4
#define CDCMD 5
#define COMMANDCMD 6
#define DOTCMD 7
#define ECHOCMD 8
#define EVALCMD 9
#define EXECCMD 10
#define EXITCMD 11
#define LETCMD 12
#define EXPORTCMD 13
#define FALSECMD 14
#define FGCMD 15
#define FREEBSD_WORDEXPCMD 16
#define GETOPTSCMD 17
#define HASHCMD 18
#define HISTCMD 19
#define JOBIDCMD 20
#define JOBSCMD 21
#define KILLCMD 22
#define LOCALCMD 23
#define PRINTFCMD 24
#define PWDCMD 25
#define READCMD 26
#define RETURNCMD 27
#define SETCMD 28
#define SETVARCMD 29
#define SHIFTCMD 30
#define TESTCMD 31
#define TIMESCMD 32
#define TRAPCMD 33
#define TRUECMD 34
#define TYPECMD 35
#define ULIMITCMD 36
#define UMASKCMD 37
#define UNALIASCMD 38
#define UNSETCMD 39
#define WAITCMD 40
#define WORDEXPCMD 41
#define BUILTIN_SPECIAL 0x80
extern int (*const builtinfunc[])(int, char **);
extern const unsigned char builtincmd[];
int bltincmd(int, char **);
int aliascmd(int, char **);
int bgcmd(int, char **);
int bindcmd(int, char **);
int breakcmd(int, char **);
int cdcmd(int, char **);
int commandcmd(int, char **);
int dotcmd(int, char **);
int echocmd(int, char **);
int evalcmd(int, char **);
int execcmd(int, char **);
int exitcmd(int, char **);
int letcmd(int, char **);
int exportcmd(int, char **);
int falsecmd(int, char **);
int fgcmd(int, char **);
int freebsd_wordexpcmd(int, char **);
int getoptscmd(int, char **);
int hashcmd(int, char **);
int histcmd(int, char **);
int jobidcmd(int, char **);
int jobscmd(int, char **);
int killcmd(int, char **);
int localcmd(int, char **);
int printfcmd(int, char **);
int pwdcmd(int, char **);
int readcmd(int, char **);
int returncmd(int, char **);
int setcmd(int, char **);
int setvarcmd(int, char **);
int shiftcmd(int, char **);
int testcmd(int, char **);
int timescmd(int, char **);
int trapcmd(int, char **);
int truecmd(int, char **);
int typecmd(int, char **);
int ulimitcmd(int, char **);
int umaskcmd(int, char **);
int unaliascmd(int, char **);
int unsetcmd(int, char **);
int waitcmd(int, char **);
int wordexpcmd(int, char **);
static inline int
safe_builtin_always(int idx)
{
if (idx == BLTINCMD ||
idx == COMMANDCMD ||
idx == ECHOCMD ||
idx == FALSECMD ||
idx == JOBIDCMD ||
idx == JOBSCMD ||
idx == KILLCMD ||
idx == PRINTFCMD ||
idx == PWDCMD ||
idx == TESTCMD ||
idx == TIMESCMD ||
idx == TRUECMD ||
idx == TYPECMD)
return (1);
return(0);
}
bin/sh/pregenerated/nodes.c
/*
* This file was generated by the mknodes program.
*/
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Kenneth Almquist.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)nodes.c.pat 8.2 (Berkeley) 5/4/95
* $FreeBSD$
*/
#include <sys/param.h>
#include <stdlib.h>
#include <stddef.h>
/*
* Routine for dealing with parsed shell commands.
*/
#include "shell.h"
#include "nodes.h"
#include "memalloc.h"
#include "mystring.h"
struct nodesize {
int blocksize; /* size of structures in function */
int stringsize; /* size of strings in node */
};
struct nodecopystate {
pointer block; /* block to allocate function from */
char *string; /* block to allocate strings from */
};
static const short nodesize[27] = {
ALIGN(sizeof (struct nbinary)),
ALIGN(sizeof (struct ncmd)),
ALIGN(sizeof (struct npipe)),
ALIGN(sizeof (struct nredir)),
ALIGN(sizeof (struct nredir)),
ALIGN(sizeof (struct nredir)),
ALIGN(sizeof (struct nbinary)),
ALIGN(sizeof (struct nbinary)),
ALIGN(sizeof (struct nif)),
ALIGN(sizeof (struct nbinary)),
ALIGN(sizeof (struct nbinary)),
ALIGN(sizeof (struct nfor)),
ALIGN(sizeof (struct ncase)),
ALIGN(sizeof (struct nclist)),
ALIGN(sizeof (struct nclist)),
ALIGN(sizeof (struct narg)),
ALIGN(sizeof (struct narg)),
ALIGN(sizeof (struct nfile)),
ALIGN(sizeof (struct nfile)),
ALIGN(sizeof (struct nfile)),
ALIGN(sizeof (struct nfile)),
ALIGN(sizeof (struct nfile)),
ALIGN(sizeof (struct ndup)),
ALIGN(sizeof (struct ndup)),
ALIGN(sizeof (struct nhere)),
ALIGN(sizeof (struct nhere)),
ALIGN(sizeof (struct nnot)),
};
static void calcsize(union node *, struct nodesize *);
static void sizenodelist(struct nodelist *, struct nodesize *);
static union node *copynode(union node *, struct nodecopystate *);
static struct nodelist *copynodelist(struct nodelist *, struct nodecopystate *);
static char *nodesavestr(const char *, struct nodecopystate *);
struct funcdef {
unsigned int refcount;
union node n;
};
/*
* Make a copy of a parse tree.
*/
struct funcdef *
copyfunc(union node *n)
{
struct nodesize sz;
struct nodecopystate st;
struct funcdef *fn;
if (n == NULL)
return NULL;
sz.blocksize = offsetof(struct funcdef, n);
sz.stringsize = 0;
calcsize(n, &sz);
fn = ckmalloc(sz.blocksize + sz.stringsize);
fn->refcount = 1;
st.block = (char *)fn + offsetof(struct funcdef, n);
st.string = (char *)fn + sz.blocksize;
copynode(n, &st);
return fn;
}
union node *
getfuncnode(struct funcdef *fn)
{
return fn == NULL ? NULL : &fn->n;
}
static void
calcsize(union node *n, struct nodesize *result)
{
if (n == NULL)
return;
result->blocksize += nodesize[n->type];
switch (n->type) {
case NSEMI:
case NAND:
case NOR:
case NWHILE:
case NUNTIL:
calcsize(n->nbinary.ch2, result);
calcsize(n->nbinary.ch1, result);
break;
case NCMD:
calcsize(n->ncmd.redirect, result);
calcsize(n->ncmd.args, result);
break;
case NPIPE:
sizenodelist(n->npipe.cmdlist, result);
break;
case NREDIR:
case NBACKGND:
case NSUBSHELL:
calcsize(n->nredir.redirect, result);
calcsize(n->nredir.n, result);
break;
case NIF:
calcsize(n->nif.elsepart, result);
calcsize(n->nif.ifpart, result);
calcsize(n->nif.test, result);
break;
case NFOR:
result->stringsize += strlen(n->nfor.var) + 1;
calcsize(n->nfor.body, result);
calcsize(n->nfor.args, result);
break;
case NCASE:
calcsize(n->ncase.cases, result);
calcsize(n->ncase.expr, result);
break;
case NCLIST:
case NCLISTFALLTHRU:
calcsize(n->nclist.body, result);
calcsize(n->nclist.pattern, result);
calcsize(n->nclist.next, result);
break;
case NDEFUN:
case NARG:
sizenodelist(n->narg.backquote, result);
result->stringsize += strlen(n->narg.text) + 1;
calcsize(n->narg.next, result);
break;
case NTO:
case NFROM:
case NFROMTO:
case NAPPEND:
case NCLOBBER:
calcsize(n->nfile.fname, result);
calcsize(n->nfile.next, result);
break;
case NTOFD:
case NFROMFD:
calcsize(n->ndup.vname, result);
calcsize(n->ndup.next, result);
break;
case NHERE:
case NXHERE:
calcsize(n->nhere.doc, result);
calcsize(n->nhere.next, result);
break;
case NNOT:
calcsize(n->nnot.com, result);
break;
};
}
static void
sizenodelist(struct nodelist *lp, struct nodesize *result)
{
while (lp) {
result->blocksize += ALIGN(sizeof(struct nodelist));
calcsize(lp->n, result);
lp = lp->next;
}
}
static union node *
copynode(union node *n, struct nodecopystate *state)
{
union node *new;
if (n == NULL)
return NULL;
new = state->block;
state->block = (char *)state->block + nodesize[n->type];
switch (n->type) {
case NSEMI:
case NAND:
case NOR:
case NWHILE:
case NUNTIL:
new->nbinary.ch2 = copynode(n->nbinary.ch2, state);
new->nbinary.ch1 = copynode(n->nbinary.ch1, state);
break;
case NCMD:
new->ncmd.redirect = copynode(n->ncmd.redirect, state);
new->ncmd.args = copynode(n->ncmd.args, state);
break;
case NPIPE:
new->npipe.cmdlist = copynodelist(n->npipe.cmdlist, state);
new->npipe.backgnd = n->npipe.backgnd;
break;
case NREDIR:
case NBACKGND:
case NSUBSHELL:
new->nredir.redirect = copynode(n->nredir.redirect, state);
new->nredir.n = copynode(n->nredir.n, state);
break;
case NIF:
new->nif.elsepart = copynode(n->nif.elsepart, state);
new->nif.ifpart = copynode(n->nif.ifpart, state);
new->nif.test = copynode(n->nif.test, state);
break;
case NFOR:
new->nfor.var = nodesavestr(n->nfor.var, state);
new->nfor.body = copynode(n->nfor.body, state);
new->nfor.args = copynode(n->nfor.args, state);
break;
case NCASE:
new->ncase.cases = copynode(n->ncase.cases, state);
new->ncase.expr = copynode(n->ncase.expr, state);
break;
case NCLIST:
case NCLISTFALLTHRU:
new->nclist.body = copynode(n->nclist.body, state);
new->nclist.pattern = copynode(n->nclist.pattern, state);
new->nclist.next = copynode(n->nclist.next, state);
break;
case NDEFUN:
case NARG:
new->narg.backquote = copynodelist(n->narg.backquote, state);
new->narg.text = nodesavestr(n->narg.text, state);
new->narg.next = copynode(n->narg.next, state);
break;
case NTO:
case NFROM:
case NFROMTO:
case NAPPEND:
case NCLOBBER:
new->nfile.fname = copynode(n->nfile.fname, state);
new->nfile.next = copynode(n->nfile.next, state);
new->nfile.fd = n->nfile.fd;
break;
case NTOFD:
case NFROMFD:
new->ndup.vname = copynode(n->ndup.vname, state);
new->ndup.dupfd = n->ndup.dupfd;
new->ndup.next = copynode(n->ndup.next, state);
new->ndup.fd = n->ndup.fd;
break;
case NHERE:
case NXHERE:
new->nhere.doc = copynode(n->nhere.doc, state);
new->nhere.next = copynode(n->nhere.next, state);
new->nhere.fd = n->nhere.fd;
break;
case NNOT:
new->nnot.com = copynode(n->nnot.com, state);
break;
};
new->type = n->type;
return new;
}
static struct nodelist *
copynodelist(struct nodelist *lp, struct nodecopystate *state)
{
struct nodelist *start;
struct nodelist **lpp;
lpp = &start;
while (lp) {
*lpp = state->block;
state->block = (char *)state->block +
ALIGN(sizeof(struct nodelist));
(*lpp)->n = copynode(lp->n, state);
lp = lp->next;
lpp = &(*lpp)->next;
}
*lpp = NULL;
return start;
}
static char *
nodesavestr(const char *s, struct nodecopystate *state)
{
const char *p = s;
char *q = state->string;
char *rtn = state->string;
while ((*q++ = *p++) != '\0')
continue;
state->string = q;
return rtn;
}
void
reffunc(struct funcdef *fn)
{
if (fn)
fn->refcount++;
}
/*
* Decrement the reference count of a function definition, freeing it
* if it falls to 0.
*/
void
unreffunc(struct funcdef *fn)
{
if (fn) {
fn->refcount--;
if (fn->refcount > 0)
return;
ckfree(fn);
}
}
bin/sh/pregenerated/nodes.h
/*
* This file was generated by the mknodes program.
*/
#define NSEMI 0
#define NCMD 1
#define NPIPE 2
#define NREDIR 3
#define NBACKGND 4
#define NSUBSHELL 5
#define NAND 6
#define NOR 7
#define NIF 8
#define NWHILE 9
#define NUNTIL 10
#define NFOR 11
#define NCASE 12
#define NCLIST 13
#define NCLISTFALLTHRU 14
#define NDEFUN 15
#define NARG 16
#define NTO 17
#define NFROM 18
#define NFROMTO 19
#define NAPPEND 20
#define NCLOBBER 21
#define NTOFD 22
#define NFROMFD 23
#define NHERE 24
#define NXHERE 25
#define NNOT 26
struct nbinary {
int type;
union node *ch1;
union node *ch2;
};
struct ncmd {
int type;
union node *args;
union node *redirect;
};
struct npipe {
int type;
int backgnd;
struct nodelist *cmdlist;
};
struct nredir {
int type;
union node *n;
union node *redirect;
};
struct nif {
int type;
union node *test;
union node *ifpart;
union node *elsepart;
};
struct nfor {
int type;
union node *args;
union node *body;
char *var;
};
struct ncase {
int type;
union node *expr;
union node *cases;
};
struct nclist {
int type;
union node *next;
union node *pattern;
union node *body;
};
struct narg {
int type;
union node *next;
char *text;
struct nodelist *backquote;
};
struct nfile {
int type;
int fd;
union node *next;
union node *fname;
char *expfname;
};
struct ndup {
int type;
int fd;
union node *next;
int dupfd;
union node *vname;
};
struct nhere {
int type;
int fd;
union node *next;
union node *doc;
const char *expdoc;
};
struct nnot {
int type;
union node *com;
};
union node {
int type;
struct nbinary nbinary;
struct ncmd ncmd;
struct npipe npipe;
struct nredir nredir;
struct nif nif;
struct nfor nfor;
struct ncase ncase;
struct nclist nclist;
struct narg narg;
struct nfile nfile;
struct ndup ndup;
struct nhere nhere;
struct nnot nnot;
};
struct nodelist {
struct nodelist *next;
union node *n;
};
struct funcdef;
struct funcdef *copyfunc(union node *);
union node *getfuncnode(struct funcdef *);
void reffunc(struct funcdef *);
void unreffunc(struct funcdef *);
bin/sh/pregenerated/syntax.c
/*
* This file was generated by the mksyntax program.
*/
#include "parser.h"
#include "shell.h"
#include "syntax.h"
/* syntax table used when not in quotes */
const char basesyntax[SYNBASE + CHAR_MAX + 1] = {
[SYNBASE + PEOF] = CEOF,
[SYNBASE + CTLESC] = CCTL,
[SYNBASE + CTLVAR] = CCTL,
[SYNBASE + CTLENDVAR] = CCTL,
[SYNBASE + CTLBACKQ] = CCTL,
[SYNBASE + CTLBACKQ + CTLQUOTE] = CCTL,
[SYNBASE + CTLARI] = CCTL,
[SYNBASE + CTLENDARI] = CCTL,
[SYNBASE + CTLQUOTEMARK] = CCTL,
[SYNBASE + CTLQUOTEEND] = CCTL,
[SYNBASE + '\n'] = CNL,
[SYNBASE + '\\'] = CBACK,
[SYNBASE + '\''] = CSQUOTE,
[SYNBASE + '"'] = CDQUOTE,
[SYNBASE + '`'] = CBQUOTE,
[SYNBASE + '$'] = CVAR,
[SYNBASE + '}'] = CENDVAR,
[SYNBASE + '<'] = CSPCL,
[SYNBASE + '>'] = CSPCL,
[SYNBASE + '('] = CSPCL,
[SYNBASE + ')'] = CSPCL,
[SYNBASE + ';'] = CSPCL,
[SYNBASE + '&'] = CSPCL,
[SYNBASE + '|'] = CSPCL,
[SYNBASE + ' '] = CSPCL,
[SYNBASE + '\t'] = CSPCL,
};
/* syntax table used when in double quotes */
const char dqsyntax[SYNBASE + CHAR_MAX + 1] = {
[SYNBASE + PEOF] = CEOF,
[SYNBASE + CTLESC] = CCTL,
[SYNBASE + CTLVAR] = CCTL,
[SYNBASE + CTLENDVAR] = CCTL,
[SYNBASE + CTLBACKQ] = CCTL,
[SYNBASE + CTLBACKQ + CTLQUOTE] = CCTL,
[SYNBASE + CTLARI] = CCTL,
[SYNBASE + CTLENDARI] = CCTL,
[SYNBASE + CTLQUOTEMARK] = CCTL,
[SYNBASE + CTLQUOTEEND] = CCTL,
[SYNBASE + '\n'] = CQNL,
[SYNBASE + '\\'] = CBACK,
[SYNBASE + '"'] = CENDQUOTE,
[SYNBASE + '`'] = CBQUOTE,
[SYNBASE + '$'] = CVAR,
[SYNBASE + '}'] = CENDVAR,
[SYNBASE + '!'] = CCTL,
[SYNBASE + '*'] = CCTL,
[SYNBASE + '?'] = CCTL,
[SYNBASE + '['] = CCTL,
[SYNBASE + ']'] = CCTL,
[SYNBASE + '='] = CCTL,
[SYNBASE + '~'] = CCTL,
[SYNBASE + ':'] = CCTL,
[SYNBASE + '/'] = CCTL,
[SYNBASE + '-'] = CCTL,
[SYNBASE + '^'] = CCTL,
};
/* syntax table used when in single quotes */
const char sqsyntax[SYNBASE + CHAR_MAX + 1] = {
[SYNBASE + PEOF] = CEOF,
[SYNBASE + CTLESC] = CCTL,
[SYNBASE + CTLVAR] = CCTL,
[SYNBASE + CTLENDVAR] = CCTL,
[SYNBASE + CTLBACKQ] = CCTL,
[SYNBASE + CTLBACKQ + CTLQUOTE] = CCTL,
[SYNBASE + CTLARI] = CCTL,
[SYNBASE + CTLENDARI] = CCTL,
[SYNBASE + CTLQUOTEMARK] = CCTL,
[SYNBASE + CTLQUOTEEND] = CCTL,
[SYNBASE + '\n'] = CQNL,
[SYNBASE + '\\'] = CSBACK,
[SYNBASE + '\''] = CENDQUOTE,
[SYNBASE + '!'] = CCTL,
[SYNBASE + '*'] = CCTL,
[SYNBASE + '?'] = CCTL,
[SYNBASE + '['] = CCTL,
[SYNBASE + ']'] = CCTL,
[SYNBASE + '='] = CCTL,
[SYNBASE + '~'] = CCTL,
[SYNBASE + ':'] = CCTL,
[SYNBASE + '/'] = CCTL,
[SYNBASE + '-'] = CCTL,
[SYNBASE + '^'] = CCTL,
};
/* syntax table used when in arithmetic */
const char arisyntax[SYNBASE + CHAR_MAX + 1] = {
[SYNBASE + PEOF] = CEOF,
[SYNBASE + CTLESC] = CCTL,
[SYNBASE + CTLVAR] = CCTL,
[SYNBASE + CTLENDVAR] = CCTL,
[SYNBASE + CTLBACKQ] = CCTL,
[SYNBASE + CTLBACKQ + CTLQUOTE] = CCTL,
[SYNBASE + CTLARI] = CCTL,
[SYNBASE + CTLENDARI] = CCTL,
[SYNBASE + CTLQUOTEMARK] = CCTL,
[SYNBASE + CTLQUOTEEND] = CCTL,
[SYNBASE + '\n'] = CQNL,
[SYNBASE + '\\'] = CBACK,
[SYNBASE + '`'] = CBQUOTE,
[SYNBASE + '"'] = CIGN,
[SYNBASE + '$'] = CVAR,
[SYNBASE + '}'] = CENDVAR,
[SYNBASE + '('] = CLP,
[SYNBASE + ')'] = CRP,
};
/* character classification table */
const char is_type[SYNBASE + CHAR_MAX + 1] = {
[SYNBASE + '0'] = ISDIGIT,
[SYNBASE + '1'] = ISDIGIT,
[SYNBASE + '2'] = ISDIGIT,
[SYNBASE + '3'] = ISDIGIT,
[SYNBASE + '4'] = ISDIGIT,
[SYNBASE + '5'] = ISDIGIT,
[SYNBASE + '6'] = ISDIGIT,
[SYNBASE + '7'] = ISDIGIT,
[SYNBASE + '8'] = ISDIGIT,
[SYNBASE + '9'] = ISDIGIT,
[SYNBASE + 'a'] = ISLOWER,
[SYNBASE + 'b'] = ISLOWER,
[SYNBASE + 'c'] = ISLOWER,
[SYNBASE + 'd'] = ISLOWER,
[SYNBASE + 'e'] = ISLOWER,
[SYNBASE + 'f'] = ISLOWER,
[SYNBASE + 'g'] = ISLOWER,
[SYNBASE + 'h'] = ISLOWER,
[SYNBASE + 'i'] = ISLOWER,
[SYNBASE + 'j'] = ISLOWER,
[SYNBASE + 'k'] = ISLOWER,
[SYNBASE + 'l'] = ISLOWER,
[SYNBASE + 'm'] = ISLOWER,
[SYNBASE + 'n'] = ISLOWER,
[SYNBASE + 'o'] = ISLOWER,
[SYNBASE + 'p'] = ISLOWER,
[SYNBASE + 'q'] = ISLOWER,
[SYNBASE + 'r'] = ISLOWER,
[SYNBASE + 's'] = ISLOWER,
[SYNBASE + 't'] = ISLOWER,
[SYNBASE + 'u'] = ISLOWER,
[SYNBASE + 'v'] = ISLOWER,
[SYNBASE + 'w'] = ISLOWER,
[SYNBASE + 'x'] = ISLOWER,
[SYNBASE + 'y'] = ISLOWER,
[SYNBASE + 'z'] = ISLOWER,
[SYNBASE + 'A'] = ISUPPER,
[SYNBASE + 'B'] = ISUPPER,
[SYNBASE + 'C'] = ISUPPER,
[SYNBASE + 'D'] = ISUPPER,
[SYNBASE + 'E'] = ISUPPER,
[SYNBASE + 'F'] = ISUPPER,
[SYNBASE + 'G'] = ISUPPER,
[SYNBASE + 'H'] = ISUPPER,
[SYNBASE + 'I'] = ISUPPER,
[SYNBASE + 'J'] = ISUPPER,
[SYNBASE + 'K'] = ISUPPER,
[SYNBASE + 'L'] = ISUPPER,
[SYNBASE + 'M'] = ISUPPER,
[SYNBASE + 'N'] = ISUPPER,
[SYNBASE + 'O'] = ISUPPER,
[SYNBASE + 'P'] = ISUPPER,
[SYNBASE + 'Q'] = ISUPPER,
[SYNBASE + 'R'] = ISUPPER,
[SYNBASE + 'S'] = ISUPPER,
[SYNBASE + 'T'] = ISUPPER,
[SYNBASE + 'U'] = ISUPPER,
[SYNBASE + 'V'] = ISUPPER,
[SYNBASE + 'W'] = ISUPPER,
[SYNBASE + 'X'] = ISUPPER,
[SYNBASE + 'Y'] = ISUPPER,
[SYNBASE + 'Z'] = ISUPPER,
[SYNBASE + '_'] = ISUNDER,
[SYNBASE + '#'] = ISSPECL,
[SYNBASE + '?'] = ISSPECL,
[SYNBASE + '$'] = ISSPECL,
[SYNBASE + '!'] = ISSPECL,
[SYNBASE + '-'] = ISSPECL,
[SYNBASE + '*'] = ISSPECL,
[SYNBASE + '@'] = ISSPECL,
};
bin/sh/pregenerated/syntax.h
/*
* This file was generated by the mksyntax program.
*/
#include <sys/cdefs.h>
#include <limits.h>
/* Syntax classes */
#define CWORD 0 /* character is nothing special */
#define CNL 1 /* newline character */
#define CQNL 2 /* newline character in quotes */
#define CBACK 3 /* a backslash character */
#define CSBACK 4 /* a backslash character in single quotes */
#define CSQUOTE 5 /* single quote */
#define CDQUOTE 6 /* double quote */
#define CENDQUOTE 7 /* a terminating quote */
#define CBQUOTE 8 /* backwards single quote */
#define CVAR 9 /* a dollar sign */
#define CENDVAR 10 /* a '}' character */
#define CLP 11 /* a left paren in arithmetic */
#define CRP 12 /* a right paren in arithmetic */
#define CEOF 13 /* end of file */
#define CCTL 14 /* like CWORD, except it must be escaped */
#define CSPCL 15 /* these terminate a word */
#define CIGN 16 /* character should be ignored */
/* Syntax classes for is_ functions */
#define ISDIGIT 01 /* a digit */
#define ISUPPER 02 /* an upper case letter */
#define ISLOWER 04 /* a lower case letter */
#define ISUNDER 010 /* an underscore */
#define ISSPECL 020 /* the name of a special parameter */
#define SYNBASE (1 - CHAR_MIN)
#define PEOF -SYNBASE
#define BASESYNTAX (basesyntax + SYNBASE)
#define DQSYNTAX (dqsyntax + SYNBASE)
#define SQSYNTAX (sqsyntax + SYNBASE)
#define ARISYNTAX (arisyntax + SYNBASE)
#define is_digit(c) ((unsigned int)((c) - '0') <= 9)
#define is_eof(c) ((c) == PEOF)
#define is_alpha(c) ((is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER))
#define is_name(c) ((is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER|ISUNDER))
#define is_in_name(c) ((is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER|ISUNDER|ISDIGIT))
#define is_special(c) ((is_type+SYNBASE)[(int)c] & (ISSPECL|ISDIGIT))
#define digit_val(c) ((c) - '0')
extern const char basesyntax[];
extern const char dqsyntax[];
extern const char sqsyntax[];
extern const char arisyntax[];
extern const char is_type[];
bin/sh/pregenerated/token.h
#define TEOF 0
#define TNL 1
#define TSEMI 2
#define TBACKGND 3
#define TAND 4
#define TOR 5
#define TPIPE 6
#define TLP 7
#define TRP 8
#define TENDCASE 9
#define TFALLTHRU 10
#define TREDIR 11
#define TWORD 12
#define TIF 13
#define TTHEN 14
#define TELSE 15
#define TELIF 16
#define TFI 17
#define TWHILE 18
#define TUNTIL 19
#define TFOR 20
#define TDO 21
#define TDONE 22
#define TBEGIN 23
#define TEND 24
#define TCASE 25
#define TESAC 26
#define TNOT 27
/* Array indicating which tokens mark the end of a list */
static const char tokendlist[] = {
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
1,
1,
0,
1,
0,
1,
0,
};
static const char *const tokname[] = {
"end of file",
"newline",
"\";\"",
"\"&\"",
"\"&&\"",
"\"||\"",
"\"|\"",
"\"(\"",
"\")\"",
"\";;\"",
"\";&\"",
"redirection",
"word",
"\"if\"",
"\"then\"",
"\"else\"",
"\"elif\"",
"\"fi\"",
"\"while\"",
"\"until\"",
"\"for\"",
"\"do\"",
"\"done\"",
"\"{\"",
"\"}\"",
"\"case\"",
"\"esac\"",
"\"!\"",
};
#define KWDOFFSET 13
const char *const parsekwd[] = {
"if",
"then",
"else",
"elif",
"fi",
"while",
"until",
"for",
"do",
"done",
"{",
"}",
"case",
"esac",
"!",
0
};
(3-3/10)