Index: trunk/src_plugins/export_bom2/bom2.c =================================================================== --- trunk/src_plugins/export_bom2/bom2.c (revision 38006) +++ trunk/src_plugins/export_bom2/bom2.c (revision 38007) @@ -105,27 +105,17 @@ return bom2_options; } -static const char *subst_attr(subst_ctx_t *ctx, const char *aname) -{ - return pcb_attribute_get(&ctx->subc->Attributes, aname); -} - static const char *subst_user(subst_ctx_t *ctx, const char *key) { - static char tmp[256]; - - if (strcmp(key, "UTC") == 0) return ctx->utcTime; if (strcmp(key, "author") == 0) return pcb_author(); if (strcmp(key, "title") == 0) return RND_UNKNOWN(PCB->hidlib.name); - if (strcmp(key, "names") == 0) return ctx->name; - if (strcmp(key, "count") == 0) { sprintf(tmp, "%ld", ctx->count); return tmp; } - if (strncmp(key, "subc.", 5) == 0) { key += 5; - if (strncmp(key, "a.", 2) == 0) return subst_attr(ctx, key+2); + if (strncmp(key, "a.", 2) == 0) return pcb_attribute_get(&ctx->subc->Attributes, key+2); else if (strcmp(key, "name") == 0) return ctx->name; if (strcmp(key, "prefix") == 0) { + static char tmp[256]; /* this is safe: caller will make a copy right after we return */ char *o = tmp; const char *t; int n = 0; Index: trunk/src_plugins/export_bom2/lib_bom.c =================================================================== --- trunk/src_plugins/export_bom2/lib_bom.c (revision 38006) +++ trunk/src_plugins/export_bom2/lib_bom.c (revision 38007) @@ -104,6 +104,7 @@ subst_ctx_t *ctx = ctx_; int escape = 0, ternary = 0; char aname[1024], unk_buf[1024], *nope = NULL; + char tmp[32]; const char *str, *end; const char *unk = ""; /* what to print on empty/NULL string if there's no ? or | in the template */ long len; @@ -165,8 +166,14 @@ else /* plain '%' */ *input = end+1; - /* get the actual string */ - str = subst_user(ctx, aname); + /* get the actual string; first a few generic ones then the app-specific callback */ + if (strcmp(aname, "count") == 0) { + sprintf(tmp, "%ld", ctx->count); + str = tmp; + } + else if (strcmp(aname, "UTC") == 0) str = ctx->utcTime; + else if (strcmp(aname, "names") == 0) str = ctx->name; + else str = subst_user(ctx, aname); /* render output */ if (ternary) {