aboutsummaryrefslogtreecommitdiffstats
path: root/mpfr.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2016-07-08 15:26:00 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2016-07-08 15:26:00 -0400
commitc86137f472fdf876c2c223c8d99f673f477b7554 (patch)
tree7ed0e172eaa8d4f831a2d59287547f63f1e71dee /mpfr.c
parent4a0f74139fb702a14c2e6782fb1965245e4f9d2f (diff)
downloadegawk-c86137f472fdf876c2c223c8d99f673f477b7554.tar.gz
egawk-c86137f472fdf876c2c223c8d99f673f477b7554.tar.bz2
egawk-c86137f472fdf876c2c223c8d99f673f477b7554.zip
Optimization: support unterminated field strings inside gawk, but make terminated copies for the API.
Diffstat (limited to 'mpfr.c')
-rw-r--r--mpfr.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/mpfr.c b/mpfr.c
index b239e4b6..cd929d4c 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -275,6 +275,7 @@ static int
force_mpnum(NODE *n, int do_nondec, int use_locale)
{
char *cp, *cpend, *ptr, *cp1;
+ char save;
int tval, base = 10;
if (n->stlen == 0) {
@@ -291,6 +292,9 @@ force_mpnum(NODE *n, int do_nondec, int use_locale)
return false;
}
+ save = *cpend;
+ *cpend = '\0';
+
if (*cp == '+' || *cp == '-')
cp1 = cp + 1;
else
@@ -325,6 +329,7 @@ done:
/* trailing space is OK for NUMBER */
while (ptr < cpend && isspace((unsigned char) *ptr))
ptr++;
+ *cpend = save;
if (errno == 0 && ptr == cpend)
return true;
errno = 0;