summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-30 17:23:34 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-30 17:26:22 -0300
commita08e3a8ca8f7da2d934f021ef9e88fca44443e4c (patch)
treea2b9abb2e9f7c634fdc4f12b08ddc95ae2ef87cd /kicad
parent8cca3541498950b79633001555f2f221f9cb1594 (diff)
downloadeeshow-a08e3a8ca8f7da2d934f021ef9e88fca44443e4c.tar.gz
eeshow-a08e3a8ca8f7da2d934f021ef9e88fca44443e4c.tar.bz2
eeshow-a08e3a8ca8f7da2d934f021ef9e88fca44443e4c.zip
kicad/pl-parse.c (get_float, get_int): add error checking
Diffstat (limited to 'kicad')
-rw-r--r--kicad/pl-parse.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/kicad/pl-parse.c b/kicad/pl-parse.c
index e0f0c5f..dec6fd0 100644
--- a/kicad/pl-parse.c
+++ b/kicad/pl-parse.c
@@ -116,10 +116,15 @@ static bool get_size(const struct expr *e, float *x, float *y)
static bool get_float(const struct expr *e, float *f)
{
+ char *end;
+
for (; e; e = e->next)
if (e->s) {
- *f = atof(e->s); // @@@ error checking
- return 1;
+ *f = strtod(e->s, &end);
+ if (!*end)
+ return 1;
+ error("invalid number \"%s\"", e->s);
+ return 0;
}
error("no number found");
return 0;
@@ -129,10 +134,18 @@ static bool get_float(const struct expr *e, float *f)
static bool get_int(const struct expr *e, int *n)
{
+ long tmp;
+ char *end;
+
for (; e; e = e->next)
if (e->s) {
- *n = atoi(e->s); // @@@ error checking
- return 1;
+ tmp = strtol(e->s, &end, 0);
+ if (!*end && (int) tmp == tmp) {
+ *n = (int) tmp;
+ return 1;
+ }
+ error("invalid number \"%s\"", e->s);
+ return 0;
}
error("no number foundn");
return 0;