Blob Blame History Raw
Subject: getdoublearr.stripwhite
From: Michel Normand <normand@fr.ibm.com>

GetDoubleArr must only handle the comma delimited list at string head
and ignore anything after the first blank character.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
---
 ATLAS/include/atlas_genparse.h |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Index: atlas/ATLAS/include/atlas_genparse.h
===================================================================
--- atlas.orig/ATLAS/include/atlas_genparse.h
+++ atlas/ATLAS/include/atlas_genparse.h
@@ -149,13 +149,24 @@ static int asmNames2bitfield(char *str)
 }
 
 /* procedure 7 */
-static int GetDoubleArr(char *str, int N, double *d)
+static int GetDoubleArr(char *callerstr, int N, double *d)
 /*
  * Reads in a list with form "%le,%le...,%le"; N-length d recieves doubles.
  * RETURNS: the number of doubles found, or N, whichever is less
  */
 {
-   int i=1;
+   int i;
+   char *dupstr = DupString(callerstr);
+   char *str = dupstr;
+   /* strip the string to end on first white space */
+   for (i=0; dupstr[i]; i++)
+   {
+	if (isspace(dupstr[i])) {
+		dupstr[i] = '\0';
+		break;
+	}
+   }
+   i = 1;
    assert(sscanf(str, "%le", d) == 1);
    while (i < N)
    {
@@ -166,6 +177,7 @@ static int GetDoubleArr(char *str, int N
	break;
       i++;
    }
+   free(dupstr);
    return(i);
 }