Stable AP read/write generation.

* Change: In the AP parser (mbk/alc_pars_p.c), elements are inserted in
    head of list and in the AP driver they are saved in the list order.
    The result is that each time we perform a full read/write cycle, all
    lines in the AP file are reversed. This is annoying to spot differences
    betweeen mofificated files and for git managment as side effect.
      So now reverse all the PHFIG elements list (PHINS, PHCON, PHVIA,
    PHSEG, PHREF) after loading.
      Add functions in mph.h to perform fast chained list reversal.
This commit is contained in:
Jean-Paul Chaput 2019-11-13 17:47:22 +01:00
parent 565c0db1a4
commit 93cd988d07
3 changed files with 117 additions and 21 deletions

View File

@ -1341,4 +1341,10 @@ char buffer[BUFSIZ];
if (fclose(parser.file) != 0)
alc_printerror(ECLOSE);
revphins(ptfig);
revphcon(ptfig);
revphseg(ptfig);
revphvia(ptfig);
revphref(ptfig);
}

View File

@ -251,6 +251,23 @@ char *insname;
return ptins;
}
/*******************************************************************************
* fonction revphins *
*******************************************************************************/
phins_list* revphins ( phfig_list* ptfig )
{
phins_list* ptprev1 = NULL;
phins_list* ptprev2 = NULL;
phins_list* ptins = ptfig->PHINS;
while ( ptins != NULL ) {
ptprev2 = ptprev1;
ptprev1 = ptins;
ptins = ptins->NEXT;
ptprev1->NEXT = ptprev2;
}
ptfig->PHINS = ptprev1;
}
/*******************************************************************************
* fonction addphvia *
*******************************************************************************/
@ -291,6 +308,23 @@ char *name;
return ptvia;
}
/*******************************************************************************
* fonction revphvia *
*******************************************************************************/
phvia_list* revphvia ( phfig_list* ptfig )
{
phvia_list* ptprev1 = NULL;
phvia_list* ptprev2 = NULL;
phvia_list* ptvia = ptfig->PHVIA;
while ( ptvia != NULL ) {
ptprev2 = ptprev1;
ptprev1 = ptvia;
ptvia = ptvia->NEXT;
ptprev1->NEXT = ptprev2;
}
ptfig->PHVIA = ptprev1;
}
/*******************************************************************************
* fonction addphref *
*******************************************************************************/
@ -320,6 +354,23 @@ char *name;
return ptref;
}
/*******************************************************************************
* fonction revphref *
*******************************************************************************/
phref_list* revphref ( phfig_list* ptfig )
{
phref_list* ptprev1 = NULL;
phref_list* ptprev2 = NULL;
phref_list* ptref = ptfig->PHREF;
while ( ptref != NULL ) {
ptprev2 = ptprev1;
ptprev1 = ptref;
ptref = ptref->NEXT;
ptprev1->NEXT = ptprev2;
}
ptfig->PHREF = ptprev1;
}
/*******************************************************************************
* fonction addphseg *
*******************************************************************************/
@ -398,6 +449,23 @@ char *nodename = namealloc(sname);
return ptseg;
}
/*******************************************************************************
* fonction revphseg *
*******************************************************************************/
phseg_list* revphseg ( phfig_list* ptfig )
{
phseg_list* ptprev1 = NULL;
phseg_list* ptprev2 = NULL;
phseg_list* ptseg = ptfig->PHSEG;
while ( ptseg != NULL ) {
ptprev2 = ptprev1;
ptprev1 = ptseg;
ptseg = ptseg->NEXT;
ptprev1->NEXT = ptprev2;
}
ptfig->PHSEG = ptprev1;
}
/*******************************************************************************
* fonction addsorted *
*******************************************************************************/
@ -530,6 +598,23 @@ char *conname;
return ptcon;
}
/*******************************************************************************
* fonction revphcon *
*******************************************************************************/
phcon_list* revphcon ( phfig_list* ptfig )
{
phcon_list* ptprev1 = NULL;
phcon_list* ptprev2 = NULL;
phcon_list* ptcon = ptfig->PHCON;
while ( ptcon != NULL ) {
ptprev2 = ptprev1;
ptprev1 = ptcon;
ptcon = ptcon->NEXT;
ptprev1->NEXT = ptprev2;
}
ptfig->PHCON = ptprev1;
}
/*******************************************************************************
* fonction defab *
*******************************************************************************/

View File

@ -252,6 +252,11 @@ extern phfig_list *HEAD_PHFIG; /* physical figure list head */
extern void xyflat __P((long *xout, long *yout, long x, long y, long xins, long yins, long x1, long y1, long x2, long y2, char trsf));
extern void invxyflat __P((long *x, long *y, long xout, long yout, long xins, long yins, long x1, long y1, long x2, long y2, char trsf));
extern void viewph __P(());
extern phins_list* revphins __P((phfig_list *ptfig));
extern phvia_list* revphvia __P((phfig_list *ptfig));
extern phref_list* revphref __P((phfig_list *ptfig));
extern phseg_list* revphseg __P((phfig_list *ptfig));
extern phcon_list* revphcon __P((phfig_list *ptfig));
#ifdef __cplusplus
}