28 #define DEBUG(x) do { x ; } while (0)
52 v->
type = VALUE_TYPE_INTEGER;
65 v->
type = VALUE_TYPE_STRING;
76 if (v->
type == VALUE_TYPE_STRING)
83 static void valueDump(
const char *msg,
Value v, FILE *fp)
87 fprintf(fp,
"%s ", msg);
89 if (v->
type == VALUE_TYPE_INTEGER)
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"));
415 DEBUG(valueDump(
"doPrimary:", v, stdout));
430 DEBUG(printf(
"doMultiplyDivide()\n"));
491 DEBUG(printf(
"doAddSubtract()\n"));
559 DEBUG(printf(
"doRelational()\n"));
610 const char * s1 = v1->
data.
s;
611 const char * s2 = v2->
data.
s;
614 r = (strcmp(s1,s2) == 0);
617 r = (strcmp(s1,s2) != 0);
620 r = (strcmp(s1,s2) < 0);
623 r = (strcmp(s1,s2) <= 0);
626 r = (strcmp(s1,s2) > 0);
629 r = (strcmp(s1,s2) >= 0);
659 DEBUG(printf(
"doLogical()\n"));
713 DEBUG(printf(
"parseExprBoolean(?, '%s')\n", expr));
736 DEBUG(valueDump(
"parseExprBoolean:", v, stdout));
739 case VALUE_TYPE_INTEGER:
740 result = v->
data.
i != 0;
742 case VALUE_TYPE_STRING:
743 result = v->
data.
s[0] !=
'\0';
760 DEBUG(printf(
"parseExprString(?, '%s')\n", expr));
783 DEBUG(valueDump(
"parseExprString:", v, stdout));
786 case VALUE_TYPE_INTEGER: {
788 sprintf(buf,
"%d", v->
data.
i);
791 case VALUE_TYPE_STRING:
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.
const char const bson_bool_t v
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.
const char const bson const bson * op
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)