summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-02-10 06:22:55 -0500
committerBehdad Esfahbod <behdad@behdad.org>2009-02-15 13:40:29 -0800
commitd4f7a4c6af5420afbbcf2217f9fe396623671294 (patch)
treef6a3b8e05c63dcda1ea9c8d57b791b65f458a893 /src
parentc8f5933d13efa6705854d8f89b22d40cf720e68d (diff)
[fcformat] Start adding builtins
Diffstat (limited to 'src')
-rw-r--r--src/fcformat.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/fcformat.c b/src/fcformat.c
index 971ee083..1d67a9dd 100644
--- a/src/fcformat.c
+++ b/src/fcformat.c
@@ -33,7 +33,7 @@
*
* - allow indexing subexprs using '%{[idx]elt1,elt2{subexpr}}'
* - allow indexing simple tags using '%{elt[idx]}'
- * - conditional/filtering/deletion on binding (using '(w)'/'(s)' notation)
+ * - conditional/filtering/deletion on binding (using '(w)'/'(s)'/'(=)' notation)
*/
static void
@@ -204,6 +204,30 @@ read_chars (FcFormatContext *c,
}
static FcBool
+interpret_builtin (FcFormatContext *c,
+ FcPattern *pat,
+ FcStrBuf *buf)
+{
+ if (!expect_char (c, '='))
+ return FcFalse;
+
+ if (!read_word (c))
+ return FcFalse;
+#define BUILTIN(name, func) \
+ else if (0 == strcmp ((const char *) c->word, name))\
+ return func (c, pat, buf)
+ BUILTIN ("unparse", FcNameUnparse);
+ BUILTIN ("verbose", FcPatternPrint);
+ BUILTIN2 ("fcmatch", FcStrDirname);
+ BUILTIN2 ("fclist", FcStrDirname);
+ BUILTIN2 ("pkgkit", FcStrDirname);
+
+ message ("unknown builtin \"%s\"",
+ c->word);
+ return FcFalse;
+}
+
+static FcBool
interpret_expr (FcFormatContext *c,
FcPattern *pat,
FcStrBuf *buf,
@@ -805,6 +829,7 @@ interpret_percent (FcFormatContext *c,
start = buf->len;
switch (*c->format) {
+ case '=': ret = interpret_builtin (c, pat, buf); break;
case '{': ret = interpret_subexpr (c, pat, buf); break;
case '+': ret = interpret_filter (c, pat, buf); break;
case '-': ret = interpret_delete (c, pat, buf); break;