X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=src%2Ffcformat.c;h=898ee324151371476cfd8fba1e9d8efe42d7c99d;hb=9c83a8376f7db19421fb42d311fba81b398c67b0;hp=334eee6a71bc09ab27cde3a62d9d9eb5649e4f9e;hpb=d04a750764d89a7048f49d655fb7e4aabbcd10b3;p=fontconfig.git diff --git a/src/fcformat.c b/src/fcformat.c index 334eee6..898ee32 100644 --- a/src/fcformat.c +++ b/src/fcformat.c @@ -39,9 +39,8 @@ */ -/* fc-match needs '', etc handling, as well as printing - * printing first value only. */ -#define FCMATCH_FORMAT "%{file|basename}: \"%{family}\" \"%{style}\"" +/* fc-match needs '', etc handling. */ +#define FCMATCH_FORMAT "%{file|basename}: \"%{family[0]}\" \"%{style[0]}\"" #define FCLIST_FORMAT "%{?file{%{file}: }}%{=unparse}" @@ -543,6 +542,7 @@ interpret_simple (FcFormatContext *c, FcPatternElt *e; FcBool add_colon = FcFalse; FcBool add_elt_name = FcFalse; + int idx; if (consume_char (c, ':')) add_colon = FcTrue; @@ -550,6 +550,19 @@ interpret_simple (FcFormatContext *c, if (!read_word (c)) return FcFalse; + idx = -1; + if (consume_char (c, '[')) + { + idx = strtol ((const char *) c->format, (char **) &c->format, 10); + if (idx < 0) + { + message ("expected non-negative number at %d", + c->format-1 - c->format_orig + 1); + return FcFalse; + } + expect_char (c, ']'); + } + if (consume_char (c, '=')) add_elt_name = FcTrue; @@ -568,7 +581,29 @@ interpret_simple (FcFormatContext *c, } l = FcPatternEltValues(e); - FcNameUnparseValueList (buf, l, '\0'); + + if (idx != -1) + { + while (l && idx > 0) + { + l = FcValueListNext(l); + idx--; + } + if (l && idx == 0) + { + if (!FcNameUnparseValue (buf, &l->value, '\0')) + return FcFalse; + } + else goto notfound; + } + else + { + FcNameUnparseValueList (buf, l, '\0'); + } + } + else +notfound: + { } return FcTrue;