[Cmpl] Patch containing two minor fixes
Christopher Gross
christopher.gross at unikat.uni-augsburg.de
Mon Jan 25 07:06:02 EST 2016
Hi,
please find attached a small patch for CMPL. It fixes two issues:
- When a data element which uses undefined sets as array indices at a
position higher than 1, an error message is not necessarily generated.
Assume you define set A, set B, then X[A, B, C] and then set C. The
current array parsing algorithm will parse X with only A and B as array
indices (i.e. a dimension of 2) and will not generate an error message.
Instead, a different error message ("count of elements doesn't match the
rank of tupelset") will be output if the count of the elements happens
to not also be divisible by the incorrectly calculated dimension of X.
The attached patch fixes this problems and generates an error message
whenever any index set of the array is not found.
- When the data files uses CRLF line endings, header options are not
parsed correctly. E.g. the line "%display con nonZeros\r\n" will lead to
an error message because the \r is not removed when comparing the
string. The attached patch solves this by trimming all header lines both
left and right.
Best regards,
Christopher
--
Christopher Gross, M.Sc.
Lehrstuhl für Health Care Operations/Health Information Management
Universitäres Zentrum für Gesundheitswissenschaften am Klinikum Augsburg
(UNIKA-T), Neusässer Straße 47, 86156 Augsburg;
Wirtschaftswissenschaftliche Fakultät, Universität Augsburg,
Universitätsstraße 16, 86159 Augsburg
Tel.: +49 821 598-6454
E-Mail: christopher.gross at unikat.uni-augsburg.de
Web: http://www.wiwi.uni-augsburg.de/bwl/brunner/
-------------- next part --------------
Index: src/cmpl/CmplData.cc
===================================================================
--- src/cmpl/CmplData.cc (revision 145)
+++ src/cmpl/CmplData.cc (working copy)
@@ -776,6 +776,7 @@
stringstream setS(str);
while ( getline(setS, tmpSet, ',' )) {
+ bool symFound = false;
for (int i=0; i <_dataElements.size(); i++ ) {
str2=CmplTools::lrTrim(tmpSet);
if ( _dataElements[i].name==str2 && _dataElements[i].isSet) {
@@ -784,10 +785,11 @@
dim++;
else
dim+=_dataElements[i].setRank;
+ symFound = true;
break;
}
}
- if (dim==0) {
+ if (!symFound) {
dim = -99;
_errorMsg="Set: " + tmpSet + " is not defined for the array: ";
break;
Index: src/cmplUtil/CmplArgs.cc
===================================================================
--- src/cmplUtil/CmplArgs.cc (revision 145)
+++ src/cmplUtil/CmplArgs.cc (working copy)
@@ -240,7 +240,7 @@
for (int i=0; i< _headerOptList.size(); i++) {
- line = CmplTools::lTrim(_headerOptList[i]);
+ line = CmplTools::lrTrim(_headerOptList[i]);
lineNr++;
if (CmplTools::stringStartsWith(line,"/*")) {
More information about the Cmpl
mailing list