From 611703586331cc818a3d2607af90a46c1735cfc4 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Thu, 6 Nov 2014 12:48:57 +0100 Subject: [PATCH] null element handling for structure/union array --- src/factory/Compare.cpp | 16 ++++++++++++++-- src/factory/PVStructureArray.cpp | 9 +++++++-- src/factory/PVUnionArray.cpp | 9 +++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/factory/Compare.cpp b/src/factory/Compare.cpp index 6d902df..06b4e27 100644 --- a/src/factory/Compare.cpp +++ b/src/factory/Compare.cpp @@ -251,7 +251,13 @@ bool compareField(const PVStructureArray* left, const PVStructureArray* right) lit!=lend; ++lit, ++rit) { - if(**lit != **rit) + // element can be null + if (!(*lit) || !(*rit)) + { + if (*lit || *rit) + return false; + } + else if (**lit != **rit) return false; } return true; @@ -304,7 +310,13 @@ bool compareField(const PVUnionArray* left, const PVUnionArray* right) lit!=lend; ++lit, ++rit) { - if(**lit != **rit) + // element can be null + if (!(*lit) || !(*rit)) + { + if (*lit || *rit) + return false; + } + else if (**lit != **rit) return false; } return true; diff --git a/src/factory/PVStructureArray.cpp b/src/factory/PVStructureArray.cpp index 29e4663..b54ff85 100644 --- a/src/factory/PVStructureArray.cpp +++ b/src/factory/PVStructureArray.cpp @@ -232,8 +232,13 @@ std::ostream& PVStructureArray::dumpValue(std::ostream& o) const std::ostream& PVStructureArray::dumpValue(std::ostream& o, std::size_t index) const { const_svector temp(view()); - if(index