From 4aa903b8799722e706747cf6b9eeb6011cf4b968 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Wed, 27 Apr 2022 16:45:33 +0200 Subject: [PATCH] replace the run-list handling through the already existing handler class PStringNumberList. --- src/any2many.cpp | 57 ++++++++++++++++++++++----------------------- src/include/PMusr.h | 2 +- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/any2many.cpp b/src/any2many.cpp index 39ad19da..020d9ac5 100644 --- a/src/any2many.cpp +++ b/src/any2many.cpp @@ -66,9 +66,12 @@ void any2many_syntax() std::cout << std::endl << " e.g. 2010/lem10_his_0111.root 2010/lem10_his_0112.root"; std::cout << std::endl << " -o : this option only makes sense, if "; std::cout << std::endl << " is a single input file name!"; - std::cout << std::endl << " -r : where is a list of run numbers"; - std::cout << std::endl << " separated by spaces ' ' of the form: "; - std::cout << std::endl << " etc., or a sequence of runs -, e.g. 111-222"; + std::cout << std::endl << " -r : can be:"; + std::cout << std::endl << " (i) , , , ... : run numbers, e.g. 123 124"; + std::cout << std::endl << " (ii) - : a range, e.g. 123-125 -> 123 124 125"; + std::cout << std::endl << " (iii) :: : a sequence, e.g. 123:127:2 -> 123 125 127"; + std::cout << std::endl << " will give the step width and has to be a positive number!"; + std::cout << std::endl << " a can also combine (i)-(iii), e.g. 123 128-130 133, etc."; std::cout << std::endl << " -t : "; std::cout << std::endl << " : template file name. Needed for run-lists in"; std::cout << std::endl << " order to generate the proper file names. The following template"; @@ -280,34 +283,30 @@ int main(int argc, char *argv[]) } } else if (!strcmp(argv[i], "-r")) { if (i+1 < argc) { - // first check for run list sequence of the form - - int startNo, endNo; - status = sscanf(argv[i+1], "%d-%d", &startNo, &endNo); - if (status == 2) { // this is run list sequence - if (endNo < startNo) { - ival = startNo; - startNo = endNo; - endNo = ival; - } - for (int j=startNo; j<=endNo; j++) - info.runList.push_back(j); - i++; - } else { // check for run list of the form ... - bool done = false; - int j = i+1; - do { - status = sscanf(argv[j], "%d", &ival); - if (status == 1) { - info.runList.push_back(ival); - j++; - } else { - done = true; - } - } while (!done && (j= argc) // make sure that counter is still in range + int pos{i+1}; + std::string runStr{""}; + // collect run list string from input + for (int j=i+1; j> any2many **ERROR** found input option '-r' without any arguments" << std::endl; show_syntax = true; diff --git a/src/include/PMusr.h b/src/include/PMusr.h index e41816c5..a663289b 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -828,7 +828,7 @@ typedef struct { TString inTemplate; ///< holds the input file template TString outTemplate; ///< holds the output file template TString year; ///< holds the information about the year to be used - PIntVector runList; ///< holds the run number list to be converted + PUIntVector runList; ///< holds the run number list to be converted PIntVector groupHistoList; ///< holds the histo group list offset (used to define for MusrRoot files, what to be exported) PStringVector inFileName; ///< holds the file name of the input data file TString outFileName; ///< holds the output file name