Index: /trunk/Ohana/src/opihi/lib.shell/isolate_elements.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/isolate_elements.c	(revision 16890)
+++ /trunk/Ohana/src/opihi/lib.shell/isolate_elements.c	(revision 16891)
@@ -2,15 +2,15 @@
 
 /* local private functions */
-void InsertValue (char c);
-void EndOfString (void);
+char **InsertValue (char **myOutput, int *Nout, int *Nchar, int *NCHAR, char c);
+char **EndOfString (char **myOutput, int *Nout, int *Nchar, int *NOUT, int *NCHAR);
 int IsAnOp (char *c);
 int IsTwoOp (char *c);
 
-/* local private static variables */
-int NCHAR, Nchar, Nout, NOUT;
-char **myOutput;
-
 char **isolate_elements (int Nin, char **in, int *nout) {
   
+  /* local private static variables */
+  int NCHAR, Nchar, Nout, NOUT;
+  char **myOutput;
+
   int i, j, minus, negate, plus, posate, OpStat, SciNotation;
 
@@ -91,22 +91,24 @@
       if (negate || minus || posate || plus || (IsAnOp (&in[i][j]) && !SciNotation)) {
 	if (posate) continue;
-	EndOfString ();
+	myOutput = EndOfString (myOutput, &Nout, &Nchar, &NOUT, &NCHAR);
 	/* copy operator to myOutput[Nout] */
-	InsertValue (in[i][j]);
-	if (negate) InsertValue ('-');
+	myOutput = InsertValue (myOutput, &Nout, &Nchar, &NCHAR, in[i][j]);
+	if (negate) {
+	  myOutput = InsertValue (myOutput, &Nout, &Nchar, &NCHAR, '-');
+	}
 
 	if (IsTwoOp (&in[i][j])) {
-	  InsertValue (in[i][j+1]);
+	  myOutput = InsertValue (myOutput, &Nout, &Nchar, &NCHAR, in[i][j+1]);
 	  j++;
 	} 
-	EndOfString ();
+	myOutput = EndOfString (myOutput, &Nout, &Nchar, &NOUT, &NCHAR);
 	continue;
       }
       /* quoted string */
       if (in[i][j] == '"') {
-	InsertValue (in[i][j]);
+	myOutput = InsertValue (myOutput, &Nout, &Nchar, &NCHAR, in[i][j]);
 	j++;
 	while ((j < strlen(in[i])) && (in[i][j] != '"')) {
-	  InsertValue (in[i][j]);
+	  myOutput = InsertValue (myOutput, &Nout, &Nchar, &NCHAR, in[i][j]);
 	  j++;
 	}
@@ -117,16 +119,16 @@
 	}
 	*/
-	InsertValue (in[i][j]);
-	EndOfString ();
+	myOutput = InsertValue (myOutput, &Nout, &Nchar, &NCHAR, in[i][j]);
+	myOutput = EndOfString (myOutput, &Nout, &Nchar, &NOUT, &NCHAR);
 	continue;
       }
       /* not an operator, not a quoted string */
       if (!OHANA_WHITESPACE (in[i][j])) {
-	InsertValue (in[i][j]);
+	myOutput = InsertValue (myOutput, &Nout, &Nchar, &NCHAR, in[i][j]);
       } else {
-	EndOfString ();
+	myOutput = EndOfString (myOutput, &Nout, &Nchar, &NOUT, &NCHAR);
       }
     }
-    EndOfString ();
+	myOutput = EndOfString (myOutput, &Nout, &Nchar, &NOUT, &NCHAR);
   }
 
@@ -138,27 +140,29 @@
 }
 
-void InsertValue (char c) {
-  myOutput[Nout][Nchar] = c;
-  Nchar ++;
-  if (Nchar >= NCHAR - 2) {
-    NCHAR += 256;
-    REALLOCATE (myOutput[Nout], char, NCHAR);
+char **InsertValue (char **myOutput, int *Nout, int *Nchar, int *NCHAR, char c) {
+  myOutput[*Nout][*Nchar] = c;
+  (*Nchar) ++;
+  if ((*Nchar) >= (*NCHAR) - 2) {
+    (*NCHAR) += 256;
+    REALLOCATE (myOutput[*Nout], char, *NCHAR);
   }
-  myOutput[Nout][Nchar] = 0;
-}
-
-void EndOfString () {
-  if (Nchar > 0) {
-    myOutput[Nout][Nchar] = 0;
-    Nout ++;
-    Nchar = 0;
+  myOutput[*Nout][*Nchar] = 0;
+  return (myOutput);
+}
+
+char **EndOfString (char **myOutput, int *Nout, int *Nchar, int *NOUT, int *NCHAR) {
+  if ((*Nchar) > 0) {
+    myOutput[*Nout][*Nchar] = 0;
+    (*Nout) ++;
+    (*Nchar) = 0;
     
-    if (Nout >= NOUT - 1) {
-      NOUT += 10; 
-      REALLOCATE (myOutput, char *, NOUT); 
+    if ((*Nout) >= (*NOUT) - 1) {
+      (*NOUT) += 10; 
+      REALLOCATE (myOutput, char *, (*NOUT)); 
     } 
-    NCHAR = 256;
-    ALLOCATE (myOutput[Nout], char, NCHAR); 
+    (*NCHAR) = 256;
+    ALLOCATE (myOutput[*Nout], char, (*NCHAR)); 
   }
+  return (myOutput);
 }
 
