Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 3876)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 3877)
@@ -18,4 +18,11 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/04/29: Javier Rico
+
+   * mbase/MRunIter.cc
+     - Remove AddRuns(const char*,const char*) dependence on length of 
+       first character chain
+
+	
  2004/04/28: Javier Rico
 
Index: /trunk/MagicSoft/Mars/mbase/MRunIter.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MRunIter.cc	(revision 3876)
+++ /trunk/MagicSoft/Mars/mbase/MRunIter.cc	(revision 3877)
@@ -72,37 +72,31 @@
 Int_t MRunIter::AddRuns(const char* runrange, const char* path)
 { 
-  char* last;
-  char  chcopy[100];
-  Int_t lowrun=-1;
-  Int_t upprun;
-  Int_t totdir=0;
+  TString chcopy = runrange;
+  Ssiz_t  last=0;
+  Int_t   lowrun=-1;
+  Int_t   upprun;
+  UInt_t  totdir=0;
 
-  //  cout << "Analyzing chain " << runrange << " in path " << path << endl;
 
-  sprintf(chcopy,"%s",runrange);
-  last=&chcopy[0];
-
-  // loop over the elements of the character chain (break inside the loop)
-  for(char* cp=last;cp;cp++)
+  // loop over the elements of the character chain 
+  for(Int_t i=0;i<chcopy.Length();i++)
     {
-      // look for a digit, a '-' or a ',' or end of string
-      char c=*cp;
-      if(! ((c>='0' && c<='9') || c=='-' || c==',' || c=='\0'))
+      // look for a digit, a '-' or a ',' 
+      char c=chcopy[i];
+      if(! ((c>='0' && c<='9') || c=='-' || c==','))
 	return totdir;
       
       // if '-' is found, save the previous number as initial run
-      if(c=='-' && lowrun<0)
+      else if(c=='-' && lowrun<0 && i>last)
 	{
-	  char chrun[100];
-	  strncpy(chrun,last,cp-last);
-	  lowrun=atoi(chrun);	  	  
-	  last=cp+1;
+	  TSubString chrun = chcopy(last,i-last);
+	  lowrun=atoi(chrun.Data());	  	  
+	  last=i+1;
 	}
       // if ',' or the end of the string are found, save the previous run or run range
-      if(c==',' || c=='\0')
+      else if(c==',' && i>last)
 	{
-	  char chrun[100];
-	  strncpy(chrun,last,cp-last);
-	  upprun=atoi(chrun);
+	  TSubString chrun = chcopy(last,i-last);
+	  upprun=atoi(chrun.Data());	  	  
 	  if(lowrun>=0 && lowrun<=upprun)
 	    totdir+=AddRuns(lowrun,upprun,path);
@@ -110,10 +104,20 @@
 	    totdir+=AddRun(upprun,path);	  
 	  
-	  if(c=='\0')
-	    break;
 	  lowrun=-1;
-	  last=cp+1;
+	  last=i+1;
 	}
+      // if find two contiguous separators exit
+      else if((c=='-' && i==last) || (c==',' && i==last))
+	return totdir;
     }
+
+  // save last run range
+  TSubString chrun = chcopy(last,chcopy.Length()-last);
+  upprun=atoi(chrun.Data());	  	  
+  if(lowrun>=0 && lowrun<=upprun)
+    totdir+=AddRuns(lowrun,upprun,path);
+  else if(lowrun<0)
+    totdir+=AddRun(upprun,path);	  
+
   return totdir;
 }
