summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gfx/pdftoc.c7
-rw-r--r--gfx/pdftoc.h3
2 files changed, 7 insertions, 3 deletions
diff --git a/gfx/pdftoc.c b/gfx/pdftoc.c
index e24edd1..efcd4b9 100644
--- a/gfx/pdftoc.c
+++ b/gfx/pdftoc.c
@@ -238,12 +238,15 @@ bool pdftoc_write(struct pdftoc *ctx, const void *data, unsigned length)
}
-void pdftoc_title(struct pdftoc *ctx, const char *title)
+void pdftoc_title(struct pdftoc *ctx, const char *fmt, ...)
{
+ va_list ap;
struct title *t;
t = alloc_type(struct title);
- t->s = stralloc(title);
+ va_start(ap, fmt);
+ alloc_vprintf(&t->s, fmt, ap);
+ va_end(ap);
*ctx->next_title = t;
t->next = NULL;
ctx->next_title = &t->next;
diff --git a/gfx/pdftoc.h b/gfx/pdftoc.h
index aabc8ef..3dd8a71 100644
--- a/gfx/pdftoc.h
+++ b/gfx/pdftoc.h
@@ -22,7 +22,8 @@ struct pdftoc;
struct pdftoc *pdftoc_begin(void);
bool pdftoc_set_file(struct pdftoc *ctx, const char *file);
bool pdftoc_write(struct pdftoc *ctx, const void *data, unsigned length);
-void pdftoc_title(struct pdftoc *ctx, const char *title);
+void pdftoc_title(struct pdftoc *ctx, const char *fmt, ...)
+ __attribute__((format(printf, 2, 3)));
void pdftoc_end(struct pdftoc *ctx);
#endif /* !GFX_PDFTOC_H */