From: <dhu...@us...> - 2006-11-30 16:51:39
|
Revision: 39 http://svn.sourceforge.net/qcell/?rev=39&view=rev Author: dhubleizh Date: 2006-11-30 08:51:37 -0800 (Thu, 30 Nov 2006) Log Message: ----------- - better header parsing - some more sanity checks - resolved todo with double adding possibility Modified Paths: -------------- trunk/qcell/parsers/FQT/FQTParserPlugin.cpp Modified: trunk/qcell/parsers/FQT/FQTParserPlugin.cpp =================================================================== --- trunk/qcell/parsers/FQT/FQTParserPlugin.cpp 2006-11-30 16:33:24 UTC (rev 38) +++ trunk/qcell/parsers/FQT/FQTParserPlugin.cpp 2006-11-30 16:51:37 UTC (rev 39) @@ -90,10 +90,12 @@ format = QRegExp("^([0-9a-Z] ){2}[0-9a-Z]$"); if(format.exactMatch(lines[0])) { - arguments_nr = lines[0][0].toAscii() - '0'; - values_nr = lines[0][2].toAscii() - '0'; - return_values_nr = lines[0][4].toAscii() - '0'; + QString tmp_split = lines[0].split(' '); + arguments_nr = tmp_split[0].toLong(); + values_nr = tmp_split[1].toLong(); + return_values_nr = tmp_split[2].toLong(); + max_sum = arguments_nr * (values_nr - 1); if((arguments_nr == 0) || (values_nr == 0) || (return_values_nr == 0)) @@ -106,6 +108,18 @@ return QString(); } + int max_value = 'Z' - '0'; + if((arguments_nr > max_value) || (values_nr > max_value) || (return_values_nr) > max_value) + { + qDebug(tr("None of the numbers in line %1 cannot exceed the maximum possible value of %2") + .arg(line_nr) + .arg(max_value) + .toAscii() + ); + + return QString(); + } + lines.removeFirst(); line_nr++; } @@ -217,8 +231,18 @@ value_index++; } + if(results.contains(tmp_sum)) + { + qDebug(tr("The sum %1 in line %2 already added.") + .arg(tmp_sum) + .arg(line_nr) + .toAscii() + ); + + return QString(); + } + results[tmp_sum] == new QVector<int>(tmp_values); - // @todo A way of checking double sums occurence line_nr++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |