76 #define MAC_PARSE_ACTION(status, type, buf, context) \
78 VSTRING_TERMINATE(buf); \
79 status |= action((type), (buf), (context)); \
87 const char *myname =
"mac_parse";
92 static char open_paren[] =
"({";
93 static char close_paren[] =
")}";
97 #define SKIP(start, var, cond) do { \
98 for (var = start; *var && (cond); var++) \
105 for (vp = value; *vp;) {
109 }
else if (vp[1] ==
'$') {
117 if (*vp == *pp || *vp == *++pp) {
120 for (ep = vp; level > 0; ep++) {
122 msg_warn(
"truncated macro reference: \"%s\"", value);
128 if (*ep == close_paren[pp - open_paren])
142 msg_warn(
"empty macro name: \"%s\"", value);
169 static int mac_parse_print(
int type,
VSTRING *buf,
void *unused_context)
175 type_name =
"MAC_PARSE_EXPR";
178 type_name =
"MAC_PARSE_LITERAL";
181 msg_panic(
"unknown token type %d", type);
187 int main(
int unused_argc,
char **unused_argv)
#define vstring_fgets_nonl(s, p)
NORETURN msg_panic(const char *fmt,...)
int main(int argc, char **argv)
VSTRING * vstring_strncat(VSTRING *vp, const char *src, ssize_t len)
#define VSTRING_ADDCH(vp, ch)
VSTREAM * vstream_printf(const char *fmt,...)
void msg_warn(const char *fmt,...)
VSTRING * vstring_alloc(ssize_t len)
int vstream_fflush(VSTREAM *stream)
int mac_parse(const char *value, MAC_PARSE_FN action, void *context)
VSTRING * vstring_free(VSTRING *vp)
#define MAC_PARSE_ACTION(status, type, buf, context)
int(* MAC_PARSE_FN)(int, VSTRING *, void *)
#define MAC_PARSE_LITERAL
#define SKIP(start, var, cond)
void msg_info(const char *fmt,...)