Index: anr/gantt.l
===================================================================
--- anr/gantt.l	(revision 278)
+++ anr/gantt.l	(revision 279)
@@ -54,5 +54,4 @@
 
 typedef struct _Tlivrable {
-    int tn,stn,dn,vn;  // task, sub-task, number
     char v;            // 0, 1, 2, ..., F 
     char* kind;
@@ -60,4 +59,7 @@
     int   bm,em;       // mois de bebut et de fin
     double hman[3];    // nombre de mh par an
+    int tn,stn,dn,vn;  // task, sub-task, number
+    int    leader;     // 1: the partner leads this livrable
+                       // 0: the partner helps for this livrable
     int    partner;    // index dans partner_table
     // these fields are filled by the program for data[tn][0][0][0]
@@ -67,7 +69,11 @@
     double nbma[3];          // durÃ©e en mois par annee
     // these fields are filled by the program for data[tn][stn][dn][0]
-    struct _Tlivrable
-            **vers; // null termiated (vers[i] = &data[tn][stn][dn][i])
-    int    nbvers;     // nombre de vers
+    struct _Tlivrable // versions of the livrable
+            **vers; // null termiated (vers[i] = data[tn][stn][dn][j])
+                    // this->leader == 1 
+                    // vers[0] = this
+                    // vers[i]->leadaer == this->leader 
+                    // vers[i]->partner == this->partner 
+    int    nbvers;  // nombre de vers
     double height;     // height of livrable
     // int del_bm,del_em;    // mois de bebut et de fin cummule
@@ -75,4 +81,11 @@
     int   nbTitleLines;
     char* titleLines[5]; // null termiated
+    struct _Tlivrable // participant to the livrable
+            **part; // null termiated (vers[i] = data[tn][stn][dn][j])
+                    // this->leader == 1 
+                    // vers[i] != this
+                    // vers[i]->leader ==  0
+                    // vers[i]->partner != this->partner 
+    int    nbpart;  // nombre de vers
 } Tlivrable;
 
@@ -215,10 +228,12 @@
  double an[3];
  char*  an_comment;
+ int    leader;
  int    partner;
 #.*\n   ;
+L=1       { leader=1; }
+L=0       { leader=0; }
 T=[0-9]+  { tn=atoi(yytext+2); }
 S=[0-9]+  { stn=atoi(yytext+2); }
 D=[0-9]+  { dn=atoi(yytext+2); }
-D=none    { dn=-2; }
 V=V[1-8F] { v=yytext[3]; }
 ML=[0-9]+ {
@@ -282,4 +297,5 @@
         p->hman[1] = an[1];
         p->hman[2] = an[2];
+        p->leader = leader;
         p->partner = partner;
         p->title = title;
@@ -297,4 +313,5 @@
         an_comment=0;
         partner=0;
+        leader=0;
     }
 [ \t\n] ;
@@ -375,5 +392,6 @@
 void prepare3(Tdata* data)
 {
-int tn,stn,dn,vn;
+int tn,stn,dn,vn,cnt;
+Tlivrable* tmp;
     for (tn=0 ; tn<T_MAX ; tn++)
     for (stn=0; stn<S_MAX; stn++)
@@ -382,12 +400,33 @@
         if (p==0) continue;
         p->nbvers=0 ;
-        for (vn=0 ; vn<V_MAX ; vn+=1) 
-            if (data->ls[tn][stn][dn][vn]!=0) p->nbvers+=1;
+        p->nbpart=0 ;
+        for (vn=0 ; vn<V_MAX ; vn+=1) {
+            tmp = data->ls[tn][stn][dn][vn];
+            if (tmp==0) continue;
+            if (tmp->leader==0)
+               p->nbpart+=1;
+            else
+                p->nbvers+=1;
+        }
         p->vers=(Tlivrable**)malloc(sizeof(*p->vers)*(p->nbvers+1));
-        for (vn=0 ; vn<p->nbvers ; vn+=1) {
-            p->vers[vn] = data->ls[tn][stn][dn][vn];
-            data->ls[tn][stn][dn][vn]->nbvers = p->nbvers;
-        }
-        p->vers[vn] = 0;
+        for (vn=0,cnt=0 ; vn<V_MAX ; vn+=1) {
+            tmp = data->ls[tn][stn][dn][vn];
+            if (tmp!=0 && tmp->leader==1) {
+                p->vers[cnt++] = tmp;
+                tmp->nbvers = p->nbvers;
+             }
+        }
+        p->vers[cnt] = 0;
+        if (p->nbpart!=0) {
+            p->part=(Tlivrable**)malloc(sizeof(*p->part)*(p->nbpart+1));
+            for (vn=0,cnt=0 ; vn<V_MAX ; vn+=1) {
+                tmp = data->ls[tn][stn][dn][vn];
+                if (tmp!=0 && tmp->leader==0) {
+                    p->part[cnt++] = tmp;
+                 }
+            }
+            p->part[cnt] = 0;
+        }
+
         p->height = 1.0*DELIVRABLE_HEIGHT;
         if (p->nbTitleLines>=1) {
@@ -429,5 +468,5 @@
     for (stn=0 ; curr->ls[tn][stn][0][0]!=0 ; stn++)
         for (dn=0 ; curr->ls[tn][stn][dn][0]!=0 ; dn++) {
-            if ( curr->ls[tn][stn][dn][0]->dn<0 ) continue;
+            if ( curr->ls[tn][stn][dn][0]->leader==0 ) continue;
             nblivrables += 1;
             height+=curr->ls[tn][stn][dn][0]->height;
@@ -635,4 +674,19 @@
 }
 
+Tlivrable* do_partner_table_getLivrable(Tlivrable** leader, Tlivrable* top, int partner)
+{
+    int i;
+    Tlivrable* ret;
+    *leader=top->vers[top->nbvers-1];
+    if (leader[0]->partner==partner) 
+        return *leader;
+    for (i=0; i<top->nbpart ; i+=1) {
+        ret= top->part[i];
+        if ( ret->partner==partner )
+                return ret;
+    }
+    return 0;
+}
+
 void do_partner_table_full(int partner)
 {
@@ -662,15 +716,16 @@
         for (stn=0; stn<S_MAX; stn++) {
             for (dn=0; dn<D_MAX; dn++) {
+                Tlivrable *lcurr,*leader;
                 Tlivrable* top=curr->ls[tn][stn][dn][v];
                 if (top==0) continue;
-                Tlivrable* last=top->vers[top->nbvers-1];
-                if (last->partner!=partner) continue;
+                if ( (lcurr=do_partner_table_getLivrable(&leader,top,partner))==0 )
+                    continue;
                 double sum1,sum2,sum3,sum=0;
-                sum1 = last->hman[0]; sum +=sum1;
-                sum2 = last->hman[1]; sum +=sum2;
-                sum3 = last->hman[2]; sum +=sum3;
+                sum1 = lcurr->hman[0]; sum +=sum1;
+                sum2 = lcurr->hman[1]; sum +=sum2;
+                sum3 = lcurr->hman[2]; sum +=sum3;
                 char label[1000],title[1000];
-                gen_label_base(label,last);
-                sprintf(title,"\\resstablestyletitle{%s}",last->title);
+                gen_label_base(label,leader);
+                sprintf(title,"\\resstablestyletitle{%s}",leader->title);
                 fprintf(curr->os,"%s & %s & %2.1f & %2.1f & %2.1f & %2.1f \\\\\\hline\n",
                    label,title,sum1,sum2,sum3,sum);
@@ -680,31 +735,31 @@
                 an  += sum  ; tsk  += sum  ;
                 newlineadded=0;
-                if ( sum1==0 && last->nbma[0]!=0) 
+                if ( sum1==0 && leader->nbma[0]!=0) 
                     fprintf(stderr,"ERROR:   %-10s:%s probleme sur l'an 1 (in table=%2.1f, in gantt=%2.1f\n",
-                        part->name,label,sum1,last->nbma[0]);
-                else if (sum1!=0 && last->nbma[0]==0 ) 
+                        part->name,label,sum1,leader->nbma[0]);
+                else if (sum1!=0 && leader->nbma[0]==0 ) 
                     fprintf(stderr,"ERROR:   %-10s:%s probleme sur l'an 1 (in table=%2.1f, in gantt=%2.1f\n",
-                        part->name,label,sum1,last->nbma[0]);
-                else if (sum1!=0 && sum1>last->nbma[0] ) 
+                        part->name,label,sum1,leader->nbma[0]);
+                else if (sum1!=0 && sum1>leader->nbma[0] ) 
                     fprintf(stderr,"WARNING: %-10s:%s probleme sur l'an 1 (in table=%2.1f, in gantt=%2.1f\n",
-                        part->name,label,sum1,last->nbma[0]);
-                if ( sum2==0 && last->nbma[1]!=0) 
+                        part->name,label,sum1,leader->nbma[0]);
+                if ( sum2==0 && leader->nbma[1]!=0) 
                     fprintf(stderr,"ERROR:   %-10s:%s probleme sur l'an 2 (in table=%2.1f, in gantt=%2.1f\n",
-                        part->name,label,sum2,last->nbma[1]);
-                else if ( sum2!=0 && last->nbma[1]==0) 
+                        part->name,label,sum2,leader->nbma[1]);
+                else if ( sum2!=0 && leader->nbma[1]==0) 
                     fprintf(stderr,"ERROR:   %-10s:%s probleme sur l'an 2 (in table=%2.1f, in gantt=%2.1f\n",
-                        part->name,label,sum2,last->nbma[1]);
-                else if (sum2!=0 && sum2>last->nbma[1]) 
+                        part->name,label,sum2,leader->nbma[1]);
+                else if (sum2!=0 && sum2>leader->nbma[1]) 
                     fprintf(stderr,"WARNING: %-10s:%s probleme sur l'an 2 (in table=%2.1f, in gantt=%2.1f\n",
-                        part->name,label,sum2,last->nbma[1]);
-                if ( sum3==0 && last->nbma[2]!=0) 
+                        part->name,label,sum2,leader->nbma[1]);
+                if ( sum3==0 && leader->nbma[2]!=0) 
                     fprintf(stderr,"ERROR:   %-10s:%s probleme sur l'an 3 (in table=%2.1f, in gantt=%2.1f\n",
-                        part->name,label,sum3,last->nbma[2]);
-                else if ( sum3!=0 && last->nbma[2]==0) 
+                        part->name,label,sum3,leader->nbma[2]);
+                else if ( sum3!=0 && leader->nbma[2]==0) 
                     fprintf(stderr,"ERROR:   %-10s:%s probleme sur l'an 3 (in table=%2.1f, in gantt=%2.1f\n",
-                        part->name,label,sum3,last->nbma[2]);
-                else if (sum3!=0 && sum3>last->nbma[2]) 
+                        part->name,label,sum3,leader->nbma[2]);
+                else if (sum3!=0 && sum3>leader->nbma[2]) 
                     fprintf(stderr,"WARNING: %-10s:%s probleme sur l'an 3 (in table=%2.1f, in gantt=%2.1f\n",
-                        part->name,label,sum3,last->nbma[2]);
+                        part->name,label,sum3,leader->nbma[2]);
             }
         }
@@ -749,12 +804,13 @@
         for (stn=0; stn<S_MAX; stn++) {
             for (dn=0; dn<D_MAX; dn++) {
+                Tlivrable *lcurr,*leader;
                 Tlivrable* top=curr->ls[tn][stn][dn][v];
                 if (top==0) continue;
-                Tlivrable* last=top->vers[top->nbvers-1];
-                if (last->partner!=partner) continue;
+                if ( (lcurr=do_partner_table_getLivrable(&leader,top,partner))==0 )
+                    continue;
                 double sum1,sum2,sum3,sum=0;
-                sum1 = last->hman[0]; sum +=sum1;
-                sum2 = last->hman[1]; sum +=sum2;
-                sum3 = last->hman[2]; sum +=sum3;
+                sum1 = lcurr->hman[0]; sum +=sum1;
+                sum2 = lcurr->hman[1]; sum +=sum2;
+                sum3 = lcurr->hman[2]; sum +=sum3;
                 an1 += sum1 ; tsk1 += sum1 ;
                 an2 += sum2 ; tsk2 += sum2 ;
@@ -763,5 +819,5 @@
                 newlineadded=0;
                 char label[1000];
-                gen_label_base(label,last);
+                gen_label_base(label,leader);
             }
         }
@@ -829,5 +885,5 @@
             Tlivrable* l = curr->ls[tn][stn][dn][v]; 
             if ( l==0 ) break;
-            if ( l->dn<0 ) continue;
+            if ( l->leader==0 ) continue;
             char label[1000],resp[100],date[100],kind[100],desc[1000];
             gen_label_full(label,l);
