From a6b98aa498fd2f9c68ca3c70191bc2ba4ef5ad35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Sat, 27 Feb 1999 21:36:14 +0100
Subject: [PATCH] Added strtod_pcharp().

Rev: src/stuff.c:1.7
Rev: src/stuff.h:1.6
---
 src/stuff.c | 32 +++++++++++++++++++++++++++++++-
 src/stuff.h |  3 ++-
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/stuff.c b/src/stuff.c
index 68211ec8b5..fc10d0ab16 100644
--- a/src/stuff.c
+++ b/src/stuff.c
@@ -5,7 +5,7 @@
 \*/
 
 /*
- * $Id: stuff.c,v 1.6 1998/03/28 15:04:29 grubba Exp $
+ * $Id: stuff.c,v 1.7 1999/02/27 20:35:34 grubba Exp $
  */
 #include "stuff.h"
 
@@ -123,3 +123,33 @@ double my_strtod(char *nptr, char **endptr)
   }
   return tmp;
 }
+
+double strtod_pcharp(PCHARP ptr, PCHARP *endptr)
+{
+  /* NOTE: Cuts at 63 digits */
+
+  char buff[64];
+  int i;
+  double res;
+  char *end_;
+
+  endptr->shift = ptr.shift;
+
+  if (!ptr.shift) {
+    return my_strtod(ptr.ptr, &endptr->ptr);
+  }
+
+  for (i=0; i < 63; i++) {
+    unsigned int c = INDEX_PCHARP(ptr, i);
+    if (!c || (c >= 256)) {
+      break;
+    }
+    buff[i] = c;
+  }
+  buff[i] = 0;
+
+  res = my_strtod(buff, &end_);
+
+  endptr->ptr = ptr.ptr + ((end_ - buff)<<SHIFT);
+  return res;
+}
diff --git a/src/stuff.h b/src/stuff.h
index dda28f0f63..cfde9b6a1e 100644
--- a/src/stuff.h
+++ b/src/stuff.h
@@ -5,7 +5,7 @@
 \*/
 
 /*
- * $Id: stuff.h,v 1.5 1998/03/28 14:59:12 grubba Exp $
+ * $Id: stuff.h,v 1.6 1999/02/27 20:36:14 grubba Exp $
  */
 #ifndef STUFF_H
 #define STUFF_H
@@ -17,6 +17,7 @@ int my_log2(unsigned INT32 x);
 int count_bits(unsigned INT32 x);
 int is_more_than_one_bit(unsigned INT32 x);
 double my_strtod(char *nptr, char **endptr);
+double strtod_pcharp(PCHARP ptr, PCHARP *endptr);
 /* Prototypes end here */
 
 extern INT32 hashprimes[32];
-- 
GitLab