From 548a1045a4df8ef3d3df86538f5a83f134c8b79b Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 28 Feb 2015 19:22:01 +0100 Subject: [PATCH] parser/inpeval.c, simplify mil/meg/milli processing --- src/spicelib/parser/inpeval.c | 44 ++++++++++------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/src/spicelib/parser/inpeval.c b/src/spicelib/parser/inpeval.c index 8b0b48ddc..436ab3e59 100644 --- a/src/spicelib/parser/inpeval.c +++ b/src/spicelib/parser/inpeval.c @@ -184,39 +184,19 @@ INPevaluate(char **line, int *error, int gobble) break; case 'm': case 'M': - { - /* special case for m - may be m or mil or meg */ - if (here[1] != '\0' && here[2] != '\0') { - /* at least 2 characters, so check them. */ - if ((here[1] == 'E') || (here[1] == 'e')) { - if ((here[2] == 'G') || (here[2] == 'g')) { - expo1 = expo1 + 6; - if (gobble) { - FREE(token); - } else { - *line = here; - } - return (sign * mantis * - pow(10.0, (double) (expo1 + expsgn * expo2))); - } - } else if ((here[1] == 'I') || (here[1] == 'i')) { - if ((here[2] == 'L') || (here[2] == 'l')) { - expo1 = expo1 - 6; - mantis = mantis * 25.4; - if (gobble) { - FREE(token); - } else { - *line = here; - } - return (sign * mantis * - pow(10.0, (double) (expo1 + expsgn * expo2))); - } - } + if (((here[1] == 'E') || (here[1] == 'e')) && + ((here[2] == 'G') || (here[2] == 'g'))) + { + expo1 = expo1 + 6; /* Meg */ + } else if (((here[1] == 'I') || (here[1] == 'i')) && + ((here[2] == 'L') || (here[2] == 'l'))) + { + expo1 = expo1 - 6; + mantis *= 25.4; /* Mil */ + } else { + expo1 = expo1 - 3; /* m, milli */ } - /* not either special case, so just m => 1e-3 */ - expo1 = expo1 - 3; - } - break; + break; default: break; }