summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-19 05:37:45 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-09-19 05:37:45 (GMT)
commitb35bfa7633e1df47e2df699942f13ad2398ccd5e (patch)
tree688c6ed17b47b2788a39a2858f85e2d6e172ae6b /kicad
parenta526af25620a0ba684552942622086f6e1d028f3 (diff)
downloadeeshow-b35bfa7633e1df47e2df699942f13ad2398ccd5e.zip
eeshow-b35bfa7633e1df47e2df699942f13ad2398ccd5e.tar.gz
eeshow-b35bfa7633e1df47e2df699942f13ad2398ccd5e.tar.bz2
kicad/pl-render.c (expand): centralize NULL check
Diffstat (limited to 'kicad')
-rw-r--r--kicad/pl-render.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/kicad/pl-render.c b/kicad/pl-render.c
index a222d0b..da628b9 100644
--- a/kicad/pl-render.c
+++ b/kicad/pl-render.c
@@ -77,13 +77,10 @@ static char *expand(const struct pl_ctx *pl, const char *s,
case 'C': // comment #n
if (isdigit(p[2])) {
n = p[2] - '0';
- if (n >= sheet->n_comments) {
+ if (n >= sheet->n_comments)
cx = "";
- } else {
+ else
cx = sheet->comments[n];
- if (!cx)
- cx = "";
- }
} else {
warning("%%C without number");
cx = "???";
@@ -93,7 +90,7 @@ static char *expand(const struct pl_ctx *pl, const char *s,
cx = "%D";
break;
case 'F': // file name
- cx = sheet->file ? sheet->file : "";
+ cx = sheet->file;
break;
case 'K': // KiCad version
cx = "%K";
@@ -105,7 +102,7 @@ static char *expand(const struct pl_ctx *pl, const char *s,
alloc_printf(&x, "%u", n);
break;
case 'P': // sheet path
- cx = sheet->path ? sheet->path : "";
+ cx = sheet->path;
break;
case 'R': // revision
cx = "%R";
@@ -118,7 +115,7 @@ static char *expand(const struct pl_ctx *pl, const char *s,
alloc_printf(&x, "%u", n);
break;
case 'T': // title
- cx = sheet->title ? sheet->title : "";
+ cx = sheet->title;
break;
case 'Y': // company name
cx = "%Y";
@@ -131,7 +128,7 @@ static char *expand(const struct pl_ctx *pl, const char *s,
break;
}
if (!cx)
- cx = x;
+ cx = x ? x : "";
len = strlen(cx);
res = realloc_size(res, size + p - s + len);
memcpy(res + size, s, p - s);