Changeset 3877 for trunk/MagicSoft/Mars
- Timestamp:
- 04/29/04 11:02:37 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r3876 r3877 18 18 19 19 -*-*- END OF LINE -*-*- 20 2004/04/29: Javier Rico 21 22 * mbase/MRunIter.cc 23 - Remove AddRuns(const char*,const char*) dependence on length of 24 first character chain 25 26 20 27 2004/04/28: Javier Rico 21 28 -
trunk/MagicSoft/Mars/mbase/MRunIter.cc
r3874 r3877 72 72 Int_t MRunIter::AddRuns(const char* runrange, const char* path) 73 73 { 74 char* last;75 char chcopy[100];76 Int_t lowrun=-1;77 Int_t upprun;78 Int_ttotdir=0;74 TString chcopy = runrange; 75 Ssiz_t last=0; 76 Int_t lowrun=-1; 77 Int_t upprun; 78 UInt_t totdir=0; 79 79 80 // cout << "Analyzing chain " << runrange << " in path " << path << endl;81 80 82 sprintf(chcopy,"%s",runrange); 83 last=&chcopy[0]; 84 85 // loop over the elements of the character chain (break inside the loop) 86 for(char* cp=last;cp;cp++) 81 // loop over the elements of the character chain 82 for(Int_t i=0;i<chcopy.Length();i++) 87 83 { 88 // look for a digit, a '-' or a ',' or end of string89 char c= *cp;90 if(! ((c>='0' && c<='9') || c=='-' || c==',' || c=='\0'))84 // look for a digit, a '-' or a ',' 85 char c=chcopy[i]; 86 if(! ((c>='0' && c<='9') || c=='-' || c==',')) 91 87 return totdir; 92 88 93 89 // if '-' is found, save the previous number as initial run 94 if(c=='-' && lowrun<0)90 else if(c=='-' && lowrun<0 && i>last) 95 91 { 96 char chrun[100]; 97 strncpy(chrun,last,cp-last); 98 lowrun=atoi(chrun); 99 last=cp+1; 92 TSubString chrun = chcopy(last,i-last); 93 lowrun=atoi(chrun.Data()); 94 last=i+1; 100 95 } 101 96 // if ',' or the end of the string are found, save the previous run or run range 102 if(c==',' || c=='\0')97 else if(c==',' && i>last) 103 98 { 104 char chrun[100]; 105 strncpy(chrun,last,cp-last); 106 upprun=atoi(chrun); 99 TSubString chrun = chcopy(last,i-last); 100 upprun=atoi(chrun.Data()); 107 101 if(lowrun>=0 && lowrun<=upprun) 108 102 totdir+=AddRuns(lowrun,upprun,path); … … 110 104 totdir+=AddRun(upprun,path); 111 105 112 if(c=='\0')113 break;114 106 lowrun=-1; 115 last= cp+1;107 last=i+1; 116 108 } 109 // if find two contiguous separators exit 110 else if((c=='-' && i==last) || (c==',' && i==last)) 111 return totdir; 117 112 } 113 114 // save last run range 115 TSubString chrun = chcopy(last,chcopy.Length()-last); 116 upprun=atoi(chrun.Data()); 117 if(lowrun>=0 && lowrun<=upprun) 118 totdir+=AddRuns(lowrun,upprun,path); 119 else if(lowrun<0) 120 totdir+=AddRun(upprun,path); 121 118 122 return totdir; 119 123 }
Note:
See TracChangeset
for help on using the changeset viewer.