version 1.4, 1998/12/05 00:06:27 |
version 1.5, 1999/12/06 22:24:31 |
|
|
* last two fields are stored in condInvert and condDefProc, respectively. |
* last two fields are stored in condInvert and condDefProc, respectively. |
*/ |
*/ |
static void CondPushBack __P((Token)); |
static void CondPushBack __P((Token)); |
static int CondGetArg __P((char **, char **, char *, Boolean)); |
static size_t CondGetArg __P((char **, char **, char *, Boolean)); |
static Boolean CondDoDefined __P((int, char *)); |
static Boolean CondDoDefined __P((size_t, char *)); |
static int CondStrMatch __P((ClientData, ClientData)); |
static int CondStrMatch __P((ClientData, ClientData)); |
static Boolean CondDoMake __P((int, char *)); |
static Boolean CondDoMake __P((size_t, char *)); |
static Boolean CondDoExists __P((int, char *)); |
static Boolean CondDoExists __P((size_t, char *)); |
static Boolean CondDoTarget __P((int, char *)); |
static Boolean CondDoTarget __P((size_t, char *)); |
static Boolean CondCvtArg __P((char *, double *)); |
static Boolean CondCvtArg __P((char *, double *)); |
static Token CondToken __P((Boolean)); |
static Token CondToken __P((Boolean)); |
static Token CondT __P((Boolean)); |
static Token CondT __P((Boolean)); |
|
|
char *form; /* Form of if */ |
char *form; /* Form of if */ |
int formlen; /* Length of form */ |
int formlen; /* Length of form */ |
Boolean doNot; /* TRUE if default function should be negated */ |
Boolean doNot; /* TRUE if default function should be negated */ |
Boolean (*defProc) __P((int, char *)); /* Default function to apply */ |
Boolean (*defProc) __P((size_t, char *)); /* Default function to apply */ |
} ifs[] = { |
} ifs[] = { |
{ "ifdef", 5, FALSE, CondDoDefined }, |
{ "ifdef", 5, FALSE, CondDoDefined }, |
{ "ifndef", 6, TRUE, CondDoDefined }, |
{ "ifndef", 6, TRUE, CondDoDefined }, |
|
|
|
|
static Boolean condInvert; /* Invert the default function */ |
static Boolean condInvert; /* Invert the default function */ |
static Boolean (*condDefProc) /* Default function to apply */ |
static Boolean (*condDefProc) /* Default function to apply */ |
__P((int, char *)); |
__P((size_t, char *)); |
static char *condExpr; /* The expression to parse */ |
static char *condExpr; /* The expression to parse */ |
static Token condPushBack=None; /* Single push-back token used in |
static Token condPushBack=None; /* Single push-back token used in |
* parsing */ |
* parsing */ |
|
|
* |
* |
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static int |
static size_t |
CondGetArg (linePtr, argPtr, func, parens) |
CondGetArg(linePtr, argPtr, func, parens) |
char **linePtr; |
char **linePtr; |
char **argPtr; |
char **argPtr; |
char *func; |
char *func; |
Boolean parens; /* TRUE if arg should be bounded by parens */ |
Boolean parens; /* TRUE if arg should be bounded by parens */ |
{ |
{ |
register char *cp; |
register char *cp; |
int argLen; |
size_t argLen; |
register Buffer buf; |
register Buffer buf; |
|
|
cp = *linePtr; |
cp = *linePtr; |
|
|
|
|
cp2 = Var_Parse(cp, VAR_CMD, TRUE, &len, &doFree); |
cp2 = Var_Parse(cp, VAR_CMD, TRUE, &len, &doFree); |
|
|
Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2); |
Buf_AddChars(buf, strlen(cp2), cp2); |
if (doFree) { |
if (doFree) { |
free(cp2); |
free(cp2); |
} |
} |
cp += len; |
cp += len; |
} else { |
} else { |
Buf_AddByte(buf, (Byte)*cp); |
Buf_AddChar(buf, *cp); |
cp++; |
cp++; |
} |
} |
} |
} |
|
|
Buf_AddByte(buf, (Byte)'\0'); |
Buf_AddChar(buf, '\0'); |
*argPtr = (char *)Buf_GetAll(buf, &argLen); |
*argPtr = Buf_GetAll(buf, &argLen); |
Buf_Destroy(buf, FALSE); |
Buf_Destroy(buf, FALSE); |
|
|
while (*cp == ' ' || *cp == '\t') { |
while (*cp == ' ' || *cp == '\t') { |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static Boolean |
static Boolean |
CondDoDefined (argLen, arg) |
CondDoDefined(argLen, arg) |
int argLen; |
size_t argLen; |
char *arg; |
char *arg; |
{ |
{ |
char savec = arg[argLen]; |
char savec = arg[argLen]; |
|
|
*/ |
*/ |
static Boolean |
static Boolean |
CondDoMake (argLen, arg) |
CondDoMake (argLen, arg) |
int argLen; |
size_t argLen; |
char *arg; |
char *arg; |
{ |
{ |
char savec = arg[argLen]; |
char savec = arg[argLen]; |
|
|
*/ |
*/ |
static Boolean |
static Boolean |
CondDoExists (argLen, arg) |
CondDoExists (argLen, arg) |
int argLen; |
size_t argLen; |
char *arg; |
char *arg; |
{ |
{ |
char savec = arg[argLen]; |
char savec = arg[argLen]; |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static Boolean |
static Boolean |
CondDoTarget (argLen, arg) |
CondDoTarget(argLen, arg) |
int argLen; |
size_t argLen; |
char *arg; |
char *arg; |
{ |
{ |
char savec = arg[argLen]; |
char savec = arg[argLen]; |
|
|
buf = Buf_Init(0); |
buf = Buf_Init(0); |
|
|
for (cp = lhs; *cp; cp++) |
for (cp = lhs; *cp; cp++) |
Buf_AddByte(buf, (Byte)*cp); |
Buf_AddChar(buf, *cp); |
|
|
if (doFree) |
if (doFree) |
free(lhs); |
free(lhs); |
|
|
for (;*condExpr && !isspace((unsigned char) *condExpr); |
for (;*condExpr && !isspace((unsigned char) *condExpr); |
condExpr++) |
condExpr++) |
Buf_AddByte(buf, (Byte)*condExpr); |
Buf_AddChar(buf, *condExpr); |
|
|
Buf_AddByte(buf, (Byte)'\0'); |
Buf_AddChar(buf, '\0'); |
lhs = (char *)Buf_GetAll(buf, &varSpecLen); |
lhs = Buf_GetAll(buf, &varSpecLen); |
Buf_Destroy(buf, FALSE); |
Buf_Destroy(buf, FALSE); |
|
|
doFree = TRUE; |
doFree = TRUE; |
|
|
* character, if it exists. |
* character, if it exists. |
*/ |
*/ |
cp++; |
cp++; |
Buf_AddByte(buf, (Byte)*cp); |
Buf_AddChar(buf, *cp); |
} else if (*cp == '$') { |
} else if (*cp == '$') { |
int len; |
int len; |
Boolean freeIt; |
Boolean freeIt; |
|
|
cp2 = Var_Parse(cp, VAR_CMD, doEval,&len, &freeIt); |
cp2 = Var_Parse(cp, VAR_CMD, doEval,&len, &freeIt); |
if (cp2 != var_Error) { |
if (cp2 != var_Error) { |
Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2); |
Buf_AddChars(buf, strlen(cp2), cp2); |
if (freeIt) { |
if (freeIt) { |
free(cp2); |
free(cp2); |
} |
} |
cp += len - 1; |
cp += len - 1; |
} else { |
} else { |
Buf_AddByte(buf, (Byte)*cp); |
Buf_AddChar(buf, *cp); |
} |
} |
} else { |
} else { |
Buf_AddByte(buf, (Byte)*cp); |
Buf_AddChar(buf, *cp); |
} |
} |
} |
} |
|
|
Buf_AddByte(buf, (Byte)0); |
Buf_AddChar(buf, '\0'); |
|
|
string = (char *)Buf_GetAll(buf, (int *)0); |
string = Buf_GetAll(buf, NULL); |
Buf_Destroy(buf, FALSE); |
Buf_Destroy(buf, FALSE); |
|
|
if (DEBUG(COND)) { |
if (DEBUG(COND)) { |
|
|
break; |
break; |
} |
} |
default: { |
default: { |
Boolean (*evalProc) __P((int, char *)); |
Boolean (*evalProc) __P((size_t, char *)); |
Boolean invert = FALSE; |
Boolean invert = FALSE; |
char *arg; |
char *arg; |
int arglen; |
size_t arglen; |
|
|
if (strncmp (condExpr, "defined", 7) == 0) { |
if (strncmp (condExpr, "defined", 7) == 0) { |
/* |
/* |