Author: Roland Kaminski <kaminski@cs.uni-potsdam.de>
Description: check correctness of field names used in optimisation criterion
Debian-Bug: #780899

Index: libcudf/cudf/parser.h
===================================================================
--- aspcud.orig/libcudf/cudf/parser.h	(revision 9508)
+++ /aspcud/libcudf/cudf/parser.h	(working copy)
@@ -130,8 +130,35 @@
             else { throw std::runtime_error("required attribute missing"); }
         }
     }
+    
+    void _checkCrit(uint32_t uid, std::string const &name, bool includeString) {
+        TypeMap::iterator it = typeMap_.find(uid);
+        if (it != typeMap_.end()) {
+            if ((!includeString || !it->second.stringType()) && !it->second.intType() ) {
+                throw std::runtime_error(std::string("only integer") + (includeString ? " and string" : "") + " properties are supported in criteria: " + name);
+            }
+        } 
+        else {
+            throw std::runtime_error("unknown property in criteria: " + name);
+        }
+    }
+
     void addPreamble() {
         propMap_.clear();
+        BOOST_FOREACH (Criterion &crit, dep_.criteria.criteria) {
+            switch (crit.measurement) {
+                case Criterion::SUM: {
+                    _checkCrit(crit.attrUid1, crit.attr1, false);
+                    break;
+                }
+                case Criterion::ALIGNED: {
+                    _checkCrit(crit.attrUid1, crit.attr1, true);
+                    _checkCrit(crit.attrUid2, crit.attr2, true);
+                    break;
+                }
+                default: { break; }
+            }
+        }
     }
     void addPackage(uint32_t name) {
         setProperty(packageStr_, (const uint32_t)name);
Index: libcudf/src/parser_impl.y
===================================================================
--- aspcud.orig/libcudf/src/parser_impl.y	(revision 9508)
+++ aspcud/libcudf/src/parser_impl.y	(working copy)
@@ -53,11 +53,11 @@
 nl ::= nnl.
 
 // overall structure
-cudf ::= nl universe request.
 cudf ::= nl preamble universe request.
 
 // document parts
 preamble ::= PREAMBLE parse_string COLONSP STRING nnl stanza. { pParser->addPreamble(); }
+preamble ::= .                                                { pParser->addPreamble(); }
 universe ::= .
 universe ::= universe package.
 package  ::= PACKAGE COLONSP pkgname(name) nnl stanza.       { pParser->addPackage(name.index); }
