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)
89 if (v->
type == VALUE_TYPE_INTEGER)
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;
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: {
791 case VALUE_TYPE_STRING:
rpmlog(RPMLOG_ERR,"%s\n", buf)
char * parseExpressionString(Spec spec, const char *expr)
Evaluate string expression.
static Value doMultiplyDivide(ParseState state)
static int xisalnum(int c)
char * xstrdup(const char *str)
int parseExpressionBoolean(Spec spec, const char *expr)
Evaluate boolean expression.
static Value doRelational(ParseState state)
static Value valueMakeString(const char *s)
static int xisalpha(int c)
sprintf(t," (%u)",(unsigned) dig->nbytes)
Yet Another syslog(3) API clone.
static int rdToken(ParseState state)
fprintf(stderr,"--> %s(%p,%p,%p) sig %p sigp %p\n", __FUNCTION__, dig, t, rsactx, sig, sigp)
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).
static Value doAddSubtract(ParseState state)
Encapsulation of a "value".
return strcmp(ame->name, bme->name)
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)
#define valueIsInteger(v)
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
char * buf
Parse (and execute) macro undefinition.
static Value doPrimary(ParseState state)
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
struct _parseState * ParseState
Parser state.
static void valueFree(Value v)