summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-10-28 20:34:29 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-10-28 20:34:29 (GMT)
commit2a5d0205ffc2b2b6943b2b59f04e8ab5b708ca91 (patch)
tree4786499e41fdd9d0c938b17a91190f2d6f36b248
parentf43bc96386659f51990be24183386578735e0eb8 (diff)
downloadeeshow-2a5d0205ffc2b2b6943b2b59f04e8ab5b708ca91.zip
eeshow-2a5d0205ffc2b2b6943b2b59f04e8ab5b708ca91.tar.gz
eeshow-2a5d0205ffc2b2b6943b2b59f04e8ab5b708ca91.tar.bz2
kicad/pl-render.c (format_date): fix handling of %} in argument
-rw-r--r--kicad/pl-render.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/kicad/pl-render.c b/kicad/pl-render.c
index f89ae57..fdddcf2 100644
--- a/kicad/pl-render.c
+++ b/kicad/pl-render.c
@@ -97,20 +97,20 @@ static char *format_date(const char *fmt, const char *sheet_date,
continue;
}
if (*++p == '{') {
- const char *start = ++p;
+ char *to;
- while (*p && *p != '}') {
+ /* allocate worst-case length */
+ arg = to = alloc_size(strlen(p) + 1);
+
+ for (p++; *p && *p != '}'; *to++ = *p++)
if (p[0] == '%' && p[1] == '}')
p++;
- p++;
- }
if (!*p) {
error("incomplete argument in \"%s\"", fmt);
+ free(arg);
return s;
}
- arg = alloc_size(p - start + 1);
- memcpy(arg, start, p - start);
- arg[p - start] = 0;
+ *to = 0;
p++;
}
if (*p == '!') {