/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        D E C A L A G E   E N   B O U T   D E   L I G N E   D E S   F I N S   D E   C O M M E N T A I R E S   " * / "  :           */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        Author of '$xcp/adjustK.02$K' :                                                                                            */
/*                                                                                                                                   */
/*                    Jean-Francois COLONNA (LACTAMME, 1988??????????).                                                              */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        I N T E R F A C E   ' listG '  :                                                                                           */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        :Debut_listG:                                                                                                              */
/*        :Fin_listG:                                                                                                                */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        D I R E C T I V E S   S P E C I F I Q U E S   D E   C O M P I L A T I O N  :                                               */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
@define   PRAGMA_CL_____PAS_DE_LIBRAIRIES_DYNAMIQUES
                                        /* Introduit le 20070713161955 a cause de 'v $xcg/gen$ARG$Z 20070713163308'...               */

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        F I C H I E R S   D ' I N C L U D E S  :                                                                                   */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#include  INCLUDES_MINI

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        P A R A M E T R E S  :                                                                                                     */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#define   DUPLIQUER_LES_ETOILES                                                                                                         \
                    VRAI                                                                                                                \
                                        /* Afin de savoir s'il faut laisser intact les chaines "SLASH""ETOILE""ETOILE""SLASH"...     */
#define   LONGUEUR_D_UNE_LIGNE_SOURCE_02                                                                                                \
                    LONGUEUR_D_UNE_LIGNE_SOURCE_ETOILE

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        M A C R O S   U T I L E S  :                                                                                               */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#define   SEND_CARACTERE(caractere)                                                                                                     \
                    Bblock                                                                                                              \
                    CALS(Putchar(caractere));                                                                                           \
                                        /* Emission du caractere courant.                                                            */ \
                                                                                                                                        \
                    Test(IFEQ(caractere,K_LF))                                                                                          \
                         Bblock                                                                                                         \
                         CLIR(compteur_des_caracteres_sur_la_ligne);                                                                    \
                                        /* Reinitialisation du comptage des caracteres sur la nouvelle ligne courante.               */ \
                         Eblock                                                                                                         \
                    ATes                                                                                                                \
                         Bblock                                                                                                         \
                         Eblock                                                                                                         \
                    ETes                                                                                                                \
                                                                                                                                        \
                    INCR(compteur_des_caracteres_sur_la_ligne,I);                                                                       \
                                        /* Comptage des caracteres sur la ligne courante.                                            */ \
                    Eblock

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        D E C A L A G E   E N   B O U T   D E   L I G N E   D E S   F I N S   D E   C O M M E N T A I R E S   " * / "  :           */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
BCommande(nombre_d_arguments,arguments)
/*-----------------------------------------------------------------------------------------------------------------------------------*/
     Bblock
     DEFV(Logical,INIT(dupliquer_les_etoiles,DUPLIQUER_LES_ETOILES));
                                        /* Afin de savoir s'il faut laisser intact les chaines "SLASH""ETOILE""ETOILE""SLASH"...     */
     DEFV(Int,INIT(compteur_des_caracteres_sur_la_ligne,UN));
                                        /* Ce compteur permet de savoir ou l'on en est a chaque instant sur la ligne courante...     */
     DEFV(Char,INIT(caractere_courant_00,K_NULL));
                                        /* Caractere courant (00),                                                                   */
     DEFV(Char,INIT(caractere_courant_01,K_NULL));
                                        /* Caractere precedent (01),                                                                 */
     DEFV(Char,INIT(caractere_courant_02,K_NULL));
                                        /* Caractere precedent precedent (02),                                                       */
     /*..............................................................................................................................*/
     GET_ARGUMENTS_(nombre_d_arguments
                   ,BLOC(GET_ARGUMENT_L("etoiles=",dupliquer_les_etoiles);
                         )
                    );

     Tant(GetcharT(caractere_courant_00))
          Bblock
                                        /* Le caractere courant de l'entree courante est recupere ; et on boucle                     */
                                        /* sur cette recuperation tant que l'on n'est pas au bout du fichier.                        */
          Test(IFET(IFOU(EST_VRAI(dupliquer_les_etoiles),IFNE(caractere_courant_02,K_ETOILE))
                   ,IFET(IFEQ(caractere_courant_01,K_ETOILE),IFEQ(caractere_courant_00,K_SLASH))
                    )
               )
               Bblock
               Tant(IFLT(compteur_des_caracteres_sur_la_ligne,LONGUEUR_D_UNE_LIGNE_SOURCE_02))
                    Bblock
                    SEND_CARACTERE(caractere_courant_02);
                                        /* Insertion de caracteres identiques au precedent du precedent (sauf si celui-ci est        */
                                        /* lui-meme une 'ETOILE' auquel cas on ne fait rien) a la fin des commentaires.              */
                    Eblock
               ETan

               SEND_CARACTERE(caractere_courant_01);
               SEND_CARACTERE(caractere_courant_00);
                                        /* Puis envoi de la fin des commentaires.                                                    */
               Eblock
          ATes
               Bblock
               Test(IFEQ(caractere_courant_01,K_ETOILE))
                    Bblock
                    SEND_CARACTERE(caractere_courant_01);
                                        /* Emission differee du caractere 'ETOILE' lorsqu'il n'est pas une fin de commentaires.      */
                    Eblock
               ATes
                    Bblock
                    Eblock
               ETes

               Test(IFNE(caractere_courant_00,K_ETOILE))
                    Bblock
                    SEND_CARACTERE(caractere_courant_00);
                                        /* Re-emission de tous les caracteres, sauf des caracteres 'ETOILE' que l'on differe...      */
                    Eblock
               ATes
                    Bblock
                    Eblock
               ETes
               Eblock
          ETes

          Test(IFEQ(caractere_courant_00,K_LF))
               Bblock
               EGAL(caractere_courant_02,K_NULL);
               EGAL(caractere_courant_01,K_NULL);
                                        /* En bout de ligne, on reinitialise...                                                      */
               Eblock
          ATes
               Bblock
               EGAL(caractere_courant_02,caractere_courant_01);
               EGAL(caractere_courant_01,caractere_courant_00);
                                        /* Decalage des derniers caracteres memorises lorsque l'on n'est pas en bout de ligne.       */
               Eblock
          ETes

          EGAL(caractere_courant_00,K_NULL);
          Eblock
     ETan

     RETU_Commande;
     Eblock
ECommande



Copyright © Jean-François COLONNA, 2019-2024.
Copyright © CMAP (Centre de Mathématiques APpliquées) UMR CNRS 7641 / École polytechnique, Institut Polytechnique de Paris, 2019-2024.