28 #define DEBUG(x) do { x ; } while (0) 83 static void valueDump(
const char *msg,
Value v, FILE *fp)
87 fprintf(fp,
"%s ", msg);
90 fprintf(fp,
"INTEGER %d\n", v->
data.
i);
92 fprintf(fp,
"STRING '%s'\n", v->
data.
s);
94 fprintf(fp,
"NULL\n");
98 #define valueIsInteger(v) ((v)->type == VALUE_TYPE_INTEGER) 99 #define valueIsString(v) ((v)->type == VALUE_TYPE_STRING) 100 #define valueSameType(v1,v2) ((v1)->type == (v2)->type) 123 #define TOK_INTEGER 2 125 #define TOK_IDENTIFIER 4 128 #define TOK_MULTIPLY 7 131 #define TOK_CLOSE_P 10 139 #define TOK_LOGICAL_AND 18 140 #define TOK_LOGICAL_OR 19 143 #define EXPRBUFSIZ BUFSIZ 145 #if defined(DEBUG_PARSER) 146 typedef struct exprTokTableEntry {
151 ETTE_t exprTokTable[] = {
174 static const char *prToken(
int val)
179 for (et = exprTokTable; et->name != NULL; et++) {
291 while (*p && (
xisalnum(*p) || *p ==
'_'))
299 }
else if (*p ==
'\"') {
304 while (*p && *p !=
'\"')
321 DEBUG(printf(
"rdToken: \"%s\" (%d)\n", prToken(token), token));
344 DEBUG(printf(
"doPrimary()\n"));
411 DEBUG(valueDump(
"doPrimary:", v, stdout));
426 DEBUG(printf(
"doMultiplyDivide()\n"));
480 DEBUG(printf(
"doAddSubtract()\n"));
542 DEBUG(printf(
"doRelational()\n"));
592 const char * s1 = v1->
data.
s;
593 const char * s2 = v2->
data.
s;
597 r = (strcmp(s1,s2) == 0);
600 r = (strcmp(s1,s2) != 0);
603 r = (strcmp(s1,s2) < 0);
606 r = (strcmp(s1,s2) <= 0);
609 r = (strcmp(s1,s2) > 0);
612 r = (strcmp(s1,s2) >= 0);
636 DEBUG(printf(
"doLogical()\n"));
685 DEBUG(printf(
"parseExprBoolean(?, '%s')\n", expr));
708 DEBUG(valueDump(
"parseExprBoolean:", v, stdout));
712 result = v->
data.
i != 0;
715 result = v->
data.
s[0] !=
'\0';
732 DEBUG(printf(
"parseExprString(?, '%s')\n", expr));
755 DEBUG(valueDump(
"parseExprString:", v, stdout));
760 sprintf(buf,
"%d", v->
data.
i);
static Value doMultiplyDivide(ParseState state)
static int xisalnum(int c)
char * xstrdup(const char *str)
static Value doRelational(ParseState state)
static Value valueMakeString(const char *s)
static int xisalpha(int c)
static void rpmlog(int code, const char *fmt,...)
Yet Another syslog(3) API clone.
static int rdToken(ParseState state)
static Value doLogical(ParseState state)
static int xisspace(int c)
static Value valueMakeInteger(int i)
struct _value * Value
Encapsulation of a "value".
The structure used to store values parsed from a spec file.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
int parseExpressionBoolean(Spec spec, const char *expr)
Evaluate boolean expression.
static Value doAddSubtract(ParseState state)
Encapsulation of a "value".
char * parseExpressionString(Spec spec, const char *expr)
Evaluate string expression.
static int xisdigit(int c)
This is the only module users of librpmbuild should need to include.
#define valueSameType(v1, v2)
char * stpcpy(char *dest, const char *src)
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
#define valueIsInteger(v)
static Value doPrimary(ParseState state)
struct _parseState * ParseState
Parser state.
static void valueFree(Value v)