On Mon, 2014-05-12 at 17:29 +0200, Patrick Ohly wrote:
> I think the code which deals with group tags must use the same logic
> that I introduced for "sharedfield": a property which has a group field
> array, but no group tag, must set an unassigned value in the group field
> array,

That was already done:
  if (aPropP->groupFieldID!=FID_NOT_SUPPORTED) {
    TItemField *g_fldP =  
aItem.getArrayFieldAdjusted(aPropP->groupFieldID+baseoffset,repoffset,false);
    if (g_fldP)
      g_fldP->setAsString(aGroupName,aGroupNameLen); // store the group name 
(aGroupName might be NULL, that's ok)
  }

>  and a property which has a group tag must not reuse any of these
> unassigned group tag values.

Actually, a "property which has a group *field*" - it doesn't matter
whether the current property has a group tag value. This check was
missing. Attached a patch adding it, in a brute-force manner. Does that
look right?

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.


>From f03962222958e9311db0bcf44a1810ee89afc99b Mon Sep 17 00:00:00 2001
From: Patrick Ohly <[email protected]>
Date: Mon, 12 May 2014 09:03:56 -0700
Subject: [PATCH] mimedir parser: avoid reusing group tag

When two properties (TEL and X-ABLabel in this example) share the same group
field, then storing the property where a group tag was used for the first time
must not reuse unassigned group field entries.

There was some logic for that already (see "someGroups"), but it failed to
handle this case. This approach here uses brute-force instead of trying to me
smart: the reuse check in the n<maxrep for loop will fail repeatedly at the
beginning until reaching the end of the group field array.
---
 src/sysync/mimedirprofile.cpp |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/sysync/mimedirprofile.cpp b/src/sysync/mimedirprofile.cpp
index 418c5d0..e618f80 100644
--- a/src/sysync/mimedirprofile.cpp
+++ b/src/sysync/mimedirprofile.cpp
@@ -4168,8 +4168,11 @@ bool TMimeDirProfileHandler::parseProperty(
                   TItemField *e_fldP = NULL;
                   if (e_basefldP)
                     e_fldP=e_basefldP->getArrayField(e_rep,true); // get leaf field, if it exists
-                  if (!e_basefldP || (e_fldP && e_fldP->isAssigned())) {
-                    // base field of one of the main fields does not exist or leaf field is already assigned
+                  if (!e_basefldP || (e_fldP && e_fldP->isAssigned()) ||
+                      (aPropP->groupFieldID!=FID_NOT_SUPPORTED && !valuelist &&
+                       aItem.getArrayFieldAdjusted(aPropP->groupFieldID+baseoffset,e_rep,true))) {
+                    // base field of one of the main fields does not exist or leaf field is already assigned,
+                    // or the group field entry is already in use (doesn't matter whether it is empty)
                     // -> skip that repetition
                     dostore = false;
                     break;
-- 
1.7.10.4

_______________________________________________
os-libsynthesis mailing list
[email protected]
http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis

Reply via email to