Index: branches/cleanup/ippTools/src/pxtools.h
===================================================================
--- branches/cleanup/ippTools/src/pxtools.h	(revision 18076)
+++ branches/cleanup/ippTools/src/pxtools.h	(revision 18357)
@@ -36,5 +36,4 @@
 #include "pxfake.h"
 #include "pxwarp.h"
-#include "pxio.h"
 #include "pxregister.h"
 #include "pxtag.h"
@@ -108,16 +107,17 @@
 type var; \
 { \
-    bool status; \
- \
-    var = psMetadataLookup##suffix(&status, md, key); \
-    if (!status) { \
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for %s", key); \
-        return ret; \
-    } \
- \
-    if (required && (var == max)) { \
-        psError(PS_ERR_UNKNOWN, true, "%s is required", key); \
-        return ret; \
-    } \
+    psMetadataItem *item = psMetadataLookup(md, key); \
+    if (!item) { \
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for %s", key); \
+        return ret; \
+    } \
+    psAssert(item->comment, "metadata item comment should be defined"); \
+    if (required && (!psStrcasestr(item->comment, "(found)"))) { \
+        psError(PS_ERR_UNKNOWN, true, "%s is required", key); \
+        return ret; \
+    } \
+ \
+    var = item->data.suffix; \
+ \
 }
 
@@ -171,16 +171,19 @@
 // XXX the PXOPT_COPY_* macros free 'to' on error
 
-#define PXOPT_COPY_PRIMITIVE(from, to, type, suffix, oldname, newname, comment) \
-{ \
-    bool status = false; \
-    type var = psMetadataLookup##suffix(&status, from, oldname); \
-    if (!status) { \
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for " oldname); \
+#define PXOPT_COPY_PRIMITIVE(from, to, type, suffix, oldname, newname, newcomment) \
+{ \
+    psMetadataItem *item = psMetadataLookup(from, oldname); \
+    if (!item) { \
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for %s", oldname); \
         return false; \
     } \
-    if (!psMetadataAdd##suffix(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, comment, var)) { \
-        psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \
-        psFree(to); \
-        return false; \
+    psAssert(item->comment, "metadata item comment should be defined"); \
+\
+    if (psStrcasestr(item->comment, "(found)")) { \
+        if (!psMetadataAdd##suffix(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, newcomment, item->data.suffix)) { \
+            psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \
+            psFree(to); \
+            return false; \
+        } \
     } \
 }
