File:  [local] / rpl / src / instructions_e2.c
Revision 1.67: download - view: text, annotated - select for diffs - revision graph
Wed Jun 28 09:20:33 2017 UTC (6 years, 10 months ago) by bertrand
Branches: MAIN
CVS tags: HEAD
En route pour la 4.1.27.

    1: /*
    2: ================================================================================
    3:   RPL/2 (R) version 4.1.27
    4:   Copyright (C) 1989-2017 Dr. BERTRAND Joël
    5: 
    6:   This file is part of RPL/2.
    7: 
    8:   RPL/2 is free software; you can redistribute it and/or modify it
    9:   under the terms of the CeCILL V2 License as published by the french
   10:   CEA, CNRS and INRIA.
   11:  
   12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
   13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
   15:   for more details.
   16:  
   17:   You should have received a copy of the CeCILL License
   18:   along with RPL/2. If not, write to info@cecill.info.
   19: ================================================================================
   20: */
   21: 
   22: 
   23: #include "rpl-conv.h"
   24: 
   25: 
   26: /*
   27: ================================================================================
   28:   Fonction 'egvl'
   29: ================================================================================
   30:   Entrées : pointeur sur une structure struct_processus
   31: --------------------------------------------------------------------------------
   32:   Sorties :
   33: --------------------------------------------------------------------------------
   34:   Effets de bord : néant
   35: ================================================================================
   36: */
   37: 
   38: void
   39: instruction_egvl(struct_processus *s_etat_processus)
   40: {
   41:     struct_objet                *s_objet_argument;
   42:     struct_objet                *s_objet_resultat;
   43: 
   44:     (*s_etat_processus).erreur_execution = d_ex;
   45: 
   46:     if ((*s_etat_processus).affichage_arguments == 'Y')
   47:     {
   48:         printf("\n  EGVL ");
   49:         
   50:         if ((*s_etat_processus).langue == 'F')
   51:         {
   52:             printf("(valeurs propres)\n\n");
   53:         }
   54:         else
   55:         {
   56:             printf("(eigenvalues)\n\n");
   57:         }
   58: 
   59:         printf("    1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
   60:         printf("->  1: %s\n", d_VCX);
   61: 
   62:         return;
   63:     }
   64:     else if ((*s_etat_processus).test_instruction == 'Y')
   65:     {
   66:         (*s_etat_processus).nombre_arguments = -1;
   67:         return;
   68:     }
   69: 
   70:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
   71:     {
   72:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
   73:         {
   74:             return;
   75:         }
   76:     }
   77: 
   78:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
   79:             &s_objet_argument) == d_erreur)
   80:     {
   81:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
   82:         return;
   83:     }
   84: 
   85: /*
   86: --------------------------------------------------------------------------------
   87:   L'argument est une matrice carrée
   88: --------------------------------------------------------------------------------
   89: */
   90: 
   91:     if (((*s_objet_argument).type == MIN) ||
   92:             ((*s_objet_argument).type == MRL) ||
   93:             ((*s_objet_argument).type == MCX))
   94:     {
   95:         if ((*((struct_matrice *) (*s_objet_argument).objet)).nombre_lignes !=
   96:                 (*((struct_matrice *) (*s_objet_argument).objet))
   97:                 .nombre_colonnes)
   98:         {
   99:             liberation(s_etat_processus, s_objet_argument);
  100: 
  101:             (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
  102:             return;
  103:         }
  104: 
  105:         if ((s_objet_resultat = allocation(s_etat_processus, VCX))
  106:                 == NULL)
  107:         {
  108:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  109:             return;
  110:         }
  111: 
  112:         valeurs_propres(s_etat_processus,
  113:                 (struct_matrice *) (*s_objet_argument).objet,
  114:                 (struct_vecteur *) (*s_objet_resultat).objet,
  115:                 NULL, NULL);
  116: 
  117:         if ((*s_etat_processus).erreur_systeme != d_es)
  118:         {
  119:             return;
  120:         }
  121: 
  122:         if (((*s_etat_processus).exception != d_ep) ||
  123:                 ((*s_etat_processus).erreur_execution != d_ex))
  124:         {
  125:             liberation(s_etat_processus, s_objet_argument);
  126:             liberation(s_etat_processus, s_objet_resultat);
  127:             return;
  128:         }
  129:     }
  130: 
  131: /*
  132: --------------------------------------------------------------------------------
  133:   Type incompatible
  134: --------------------------------------------------------------------------------
  135: */
  136: 
  137:     else
  138:     {
  139:         liberation(s_etat_processus, s_objet_argument);
  140: 
  141:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  142:         return;
  143:     }
  144: 
  145:     liberation(s_etat_processus, s_objet_argument);
  146: 
  147:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  148:             s_objet_resultat) == d_erreur)
  149:     {
  150:         return;
  151:     }
  152: 
  153:     return;
  154: }
  155: 
  156: 
  157: /*
  158: ================================================================================
  159:   Fonction 'egv'
  160: ================================================================================
  161:   Entrées : pointeur sur une structure struct_processus
  162: --------------------------------------------------------------------------------
  163:   Sorties :
  164: --------------------------------------------------------------------------------
  165:   Effets de bord : néant
  166: ================================================================================
  167: */
  168: 
  169: void
  170: instruction_egv(struct_processus *s_etat_processus)
  171: {
  172:     struct_objet                *s_objet_argument;
  173:     struct_objet                *s_objet_resultat_1;
  174:     struct_objet                *s_objet_resultat_2;
  175:     struct_objet                *s_objet_resultat_3;
  176: 
  177:     (*s_etat_processus).erreur_execution = d_ex;
  178: 
  179:     if ((*s_etat_processus).affichage_arguments == 'Y')
  180:     {
  181:         printf("\n  EGV ");
  182:         
  183:         if ((*s_etat_processus).langue == 'F')
  184:         {
  185:             printf("(valeurs et vecteurs propres)\n\n");
  186:         }
  187:         else
  188:         {
  189:             printf("(eigenvalues and eigenvectors)\n\n");
  190:         }
  191: 
  192:         printf("    1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
  193:         printf("->  3: %s\n", d_MCX);
  194:         printf("    2: %s\n", d_MCX);
  195:         printf("    1: %s\n", d_VCX);
  196: 
  197:         return;
  198:     }
  199:     else if ((*s_etat_processus).test_instruction == 'Y')
  200:     {
  201:         (*s_etat_processus).nombre_arguments = -1;
  202:         return;
  203:     }
  204: 
  205:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  206:     {
  207:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
  208:         {
  209:             return;
  210:         }
  211:     }
  212: 
  213:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  214:             &s_objet_argument) == d_erreur)
  215:     {
  216:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  217:         return;
  218:     }
  219: 
  220: /*
  221: --------------------------------------------------------------------------------
  222:   L'argument est une matrice carrée
  223: --------------------------------------------------------------------------------
  224: */
  225: 
  226:     if (((*s_objet_argument).type == MIN) ||
  227:             ((*s_objet_argument).type == MRL) ||
  228:             ((*s_objet_argument).type == MCX))
  229:     {
  230:         if ((*((struct_matrice *) (*s_objet_argument).objet)).nombre_lignes !=
  231:                 (*((struct_matrice *) (*s_objet_argument).objet))
  232:                 .nombre_colonnes)
  233:         {
  234:             liberation(s_etat_processus, s_objet_argument);
  235: 
  236:             (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
  237:             return;
  238:         }
  239: 
  240:         if ((s_objet_resultat_1 = allocation(s_etat_processus, VCX))
  241:                 == NULL)
  242:         {
  243:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  244:             return;
  245:         }
  246: 
  247:         if ((s_objet_resultat_2 = allocation(s_etat_processus, MCX))
  248:                 == NULL)
  249:         {
  250:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  251:             return;
  252:         }
  253: 
  254:         if ((s_objet_resultat_3 = allocation(s_etat_processus, MCX))
  255:                 == NULL)
  256:         {
  257:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  258:             return;
  259:         }
  260: 
  261:         valeurs_propres(s_etat_processus,
  262:                 (struct_matrice *) (*s_objet_argument).objet,
  263:                 (struct_vecteur *) (*s_objet_resultat_1).objet,
  264:                 (struct_matrice *) (*s_objet_resultat_3).objet,
  265:                 (struct_matrice *) (*s_objet_resultat_2).objet);
  266: 
  267:         if ((*s_etat_processus).erreur_systeme != d_es)
  268:         {
  269:             return;
  270:         }
  271: 
  272:         if (((*s_etat_processus).exception != d_ep) ||
  273:                 ((*s_etat_processus).erreur_execution != d_ex))
  274:         {
  275:             liberation(s_etat_processus, s_objet_argument);
  276:             liberation(s_etat_processus, s_objet_resultat_1);
  277:             liberation(s_etat_processus, s_objet_resultat_2);
  278:             liberation(s_etat_processus, s_objet_resultat_3);
  279:             return;
  280:         }
  281:     }
  282: 
  283: /*
  284: --------------------------------------------------------------------------------
  285:   Type incompatible
  286: --------------------------------------------------------------------------------
  287: */
  288: 
  289:     else
  290:     {
  291:         liberation(s_etat_processus, s_objet_argument);
  292: 
  293:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  294:         return;
  295:     }
  296: 
  297:     liberation(s_etat_processus, s_objet_argument);
  298: 
  299:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  300:             s_objet_resultat_3) == d_erreur)
  301:     {
  302:         return;
  303:     }
  304: 
  305:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  306:             s_objet_resultat_2) == d_erreur)
  307:     {
  308:         return;
  309:     }
  310: 
  311:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  312:             s_objet_resultat_1) == d_erreur)
  313:     {
  314:         return;
  315:     }
  316: 
  317:     return;
  318: }
  319: 
  320: 
  321: /*
  322: ================================================================================
  323:   Fonction 'erase' (detruit la queue d'impression)
  324: ================================================================================
  325:   Entrées : structure processus
  326: --------------------------------------------------------------------------------
  327:   Sorties :
  328: --------------------------------------------------------------------------------
  329:   Effets de bord : néant
  330: ================================================================================
  331: */
  332: 
  333: void
  334: instruction_erase(struct_processus *s_etat_processus)
  335: {
  336:     (*s_etat_processus).erreur_execution = d_ex;
  337: 
  338:     if ((*s_etat_processus).affichage_arguments == 'Y')
  339:     {
  340:         printf("\n  ERASE ");
  341: 
  342:         if ((*s_etat_processus).langue == 'F')
  343:         {
  344:             printf("(efface la file d'impression)\n\n");
  345:             printf("  Aucun argument\n");
  346:         }
  347:         else
  348:         {
  349:             printf("(erase the printer queue)\n\n");
  350:             printf("  No argument\n");
  351:         }
  352: 
  353:         return;
  354:     }
  355:     else if ((*s_etat_processus).test_instruction == 'Y')
  356:     {
  357:         (*s_etat_processus).nombre_arguments = -1;
  358:         return;
  359:     }
  360: 
  361:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  362:     {
  363:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  364:         {
  365:             return;
  366:         }
  367:     }
  368: 
  369:     if ((*s_etat_processus).nom_fichier_impression != NULL)
  370:     {
  371:         if (destruction_fichier((*s_etat_processus).nom_fichier_impression)
  372:                 == d_erreur)
  373:         {
  374:             (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  375:             return;
  376:         }
  377: 
  378:         free((*s_etat_processus).nom_fichier_impression);
  379:         (*s_etat_processus).nom_fichier_impression = NULL;
  380:     }
  381: 
  382:     return;
  383: }
  384: 
  385: 
  386: /*
  387: ================================================================================
  388:   Fonction 'epsilon' (renvoie la le plus petit réel e tel x + e != x)
  389: ================================================================================
  390:   Entrées : structure processus
  391: --------------------------------------------------------------------------------
  392:   Sorties :
  393: --------------------------------------------------------------------------------
  394:   Effets de bord : néant
  395: ================================================================================
  396: */
  397: 
  398: void
  399: instruction_epsilon(struct_processus *s_etat_processus)
  400: {
  401:     struct_objet            *s_copie;
  402:     struct_objet            *s_objet;
  403: 
  404:     (*s_etat_processus).erreur_execution = d_ex;
  405: 
  406:     if ((*s_etat_processus).affichage_arguments == 'Y')
  407:     {
  408:         printf("\n  EPSILON ");
  409:         
  410:         if ((*s_etat_processus).langue == 'F')
  411:         {
  412:             printf("(epsilon machine)\n\n");
  413:         }
  414:         else
  415:         {
  416:             printf("(computer epsilon)\n\n");
  417:         }
  418: 
  419:         printf("    1: %s\n", d_INT);
  420:         printf("->  1: %s\n\n", d_INT);
  421: 
  422:         printf("    1: %s\n", d_CPL);
  423:         printf("->  1: %s\n\n", d_CPL);
  424: 
  425:         printf("    1: %s\n", d_REL);
  426:         printf("->  1: %s\n", d_REL);
  427: 
  428:         return;
  429:     }
  430:     else if ((*s_etat_processus).test_instruction == 'Y')
  431:     {
  432:         (*s_etat_processus).nombre_arguments = 1;
  433:         return;
  434:     }
  435: 
  436:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  437:     {
  438:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  439:         {
  440:             return;
  441:         }
  442:     }
  443: 
  444:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  445:             &s_objet) == d_erreur)
  446:     {
  447:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  448:         return;
  449:     }
  450: 
  451:     if ((s_copie = copie_objet(s_etat_processus, s_objet, 'O')) == NULL)
  452:     {
  453:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  454:         return;
  455:     }
  456: 
  457:     liberation(s_etat_processus, s_objet);
  458:     s_objet = s_copie;
  459: 
  460:     /*
  461:      * L'argument est un entier et la routine renvoie 1.
  462:      */
  463: 
  464:     if ((*s_objet).type == INT)
  465:     {
  466:         (*((integer8 *) (*s_objet).objet)) = 1;
  467:     }
  468: 
  469:     /*
  470:      * L'argument est un réel
  471:      */
  472: 
  473:     else if ((*s_objet).type == REL)
  474:     {
  475:         if ((*((real8 *) (*s_objet).objet)) == 0)
  476:         {
  477:             (*((real8 *) (*s_objet).objet)) = nextafter((double) 0, (double) 1);
  478:         }
  479:         else
  480:         {
  481:             (*((real8 *) (*s_objet).objet)) = nextafter(-abs(*((real8 *)
  482:                     (*s_objet).objet)), 0) + abs(*((real8 *) (*s_objet).objet));
  483:         }
  484:     }
  485: 
  486:     /*
  487:      * L'argument est un complexe
  488:      */
  489: 
  490:     else if ((*s_objet).type == CPL)
  491:     {
  492:         (*((complex16 *) (*s_objet).objet)).partie_reelle =
  493:                 nextafter(-abs((*((complex16 *) (*s_objet).objet))
  494:                 .partie_reelle), 0) + abs((*((complex16 *) (*s_objet).objet))
  495:                 .partie_reelle);
  496:         (*((complex16 *) (*s_objet).objet)).partie_imaginaire =
  497:                 nextafter(-abs((*((complex16 *) (*s_objet).objet))
  498:                 .partie_imaginaire), 0) + abs((*((complex16 *)
  499:                 (*s_objet).objet)).partie_imaginaire);
  500:     }
  501:     else
  502:     {
  503:         liberation(s_etat_processus, s_objet);
  504: 
  505:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  506:         return;
  507:     }
  508: 
  509:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  510:             s_objet) == d_erreur)
  511:     {
  512:         return;
  513:     }
  514: 
  515:     return;
  516: }
  517: 
  518: 
  519: /*
  520: ================================================================================
  521:   Fonction 'errn' (detruit la queue d'impression)
  522: ================================================================================
  523:   Entrées : structure processus
  524: --------------------------------------------------------------------------------
  525:   Sorties :
  526: --------------------------------------------------------------------------------
  527:   Effets de bord : néant
  528: ================================================================================
  529: */
  530: 
  531: void
  532: instruction_errn(struct_processus *s_etat_processus)
  533: {
  534:     struct_objet            *s_objet_resultat;
  535: 
  536:     (*s_etat_processus).erreur_execution = d_ex;
  537: 
  538:     if ((*s_etat_processus).affichage_arguments == 'Y')
  539:     {
  540:         printf("\n  ERRN ");
  541:         
  542:         if ((*s_etat_processus).langue == 'F')
  543:         {
  544:             printf("(numéro de la dernière erreur)\n\n");
  545:         }
  546:         else
  547:         {
  548:             printf("(last error number)\n\n");
  549:         }
  550: 
  551:         printf("->  1: %s\n", d_INT);
  552: 
  553:         return;
  554:     }
  555:     else if ((*s_etat_processus).test_instruction == 'Y')
  556:     {
  557:         (*s_etat_processus).nombre_arguments = -1;
  558:         return;
  559:     }
  560: 
  561:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  562:     {
  563:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  564:         {
  565:             return;
  566:         }
  567:     }
  568: 
  569:     if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
  570:     {
  571:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  572:         return;
  573:     }
  574: 
  575:     if ((*s_etat_processus).derniere_exception != d_ep)
  576:     {
  577:         (*((integer8 *) (*s_objet_resultat).objet)) =
  578:                 1000 + ((*s_etat_processus).derniere_exception - d_ep);
  579:     }
  580:     else if ((*s_etat_processus).derniere_erreur_execution != d_ex)
  581:     {
  582:         (*((integer8 *) (*s_objet_resultat).objet)) =
  583:                 0 + ((*s_etat_processus).derniere_erreur_execution - d_ex);
  584:     }
  585:     else if ((*s_etat_processus).derniere_erreur_systeme != d_es)
  586:     {
  587:         /*
  588:          * On ne doit jamais passer par ici !
  589:          */
  590: 
  591:         (*((integer8 *) (*s_objet_resultat).objet)) =
  592:                 2000 + ((*s_etat_processus).derniere_erreur_systeme - d_es);
  593:     }
  594:     else
  595:     {
  596:         (*((integer8 *) (*s_objet_resultat).objet)) = 0;
  597:     }
  598:         
  599:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  600:             s_objet_resultat) == d_erreur)
  601:     {
  602:         return;
  603:     }
  604: 
  605:     return;
  606: }
  607: 
  608: 
  609: /*
  610: ================================================================================
  611:   Fonction 'errm'
  612: ================================================================================
  613:   Entrées : structure processus
  614: --------------------------------------------------------------------------------
  615:   Sorties :
  616: --------------------------------------------------------------------------------
  617:   Effets de bord : néant
  618: ================================================================================
  619: */
  620: 
  621: void
  622: instruction_errm(struct_processus *s_etat_processus)
  623: {
  624:     struct_objet            *s_objet_resultat;
  625: 
  626:     int                     registre_erreur_execution;
  627:     int                     registre_erreur_systeme;
  628:     int                     registre_exception;
  629: 
  630:     (*s_etat_processus).erreur_execution = d_ex;
  631: 
  632:     if ((*s_etat_processus).affichage_arguments == 'Y')
  633:     {
  634:         printf("\n  ERRM ");
  635:         
  636:         if ((*s_etat_processus).langue == 'F')
  637:         {
  638:             printf("(dernier message d'erreur)\n\n");
  639:         }
  640:         else
  641:         {
  642:             printf("(last error message)\n\n");
  643:         }
  644: 
  645:         printf("->  1: %s\n", d_CHN);
  646: 
  647:         return;
  648:     }
  649:     else if ((*s_etat_processus).test_instruction == 'Y')
  650:     {
  651:         (*s_etat_processus).nombre_arguments = -1;
  652:         return;
  653:     }
  654: 
  655:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  656:     {
  657:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  658:         {
  659:             return;
  660:         }
  661:     }
  662: 
  663:     if ((s_objet_resultat = allocation(s_etat_processus, CHN)) == NULL)
  664:     {
  665:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  666:         return;
  667:     }
  668: 
  669:     registre_exception = (*s_etat_processus).exception;
  670:     registre_erreur_execution = (*s_etat_processus).erreur_execution;
  671:     registre_erreur_systeme = (*s_etat_processus).erreur_systeme;
  672: 
  673:     (*s_etat_processus).exception =
  674:             (*s_etat_processus).derniere_exception;
  675:     (*s_etat_processus).erreur_execution =
  676:             (*s_etat_processus).derniere_erreur_execution;
  677:     (*s_etat_processus).erreur_systeme =
  678:             (*s_etat_processus).derniere_erreur_systeme;
  679: 
  680:     if (((*s_objet_resultat).objet =
  681:             messages(s_etat_processus)) == NULL)
  682:     {
  683:         (*s_etat_processus).exception =
  684:                 registre_exception;
  685:         (*s_etat_processus).erreur_execution =
  686:                 registre_erreur_execution;
  687:         (*s_etat_processus).erreur_systeme =
  688:                 registre_erreur_systeme;
  689: 
  690:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  691:         return;
  692:     }
  693: 
  694:     (*s_etat_processus).exception = registre_exception;
  695:     (*s_etat_processus).erreur_execution = registre_erreur_execution;
  696:     (*s_etat_processus).erreur_systeme = registre_erreur_systeme;
  697: 
  698:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  699:             s_objet_resultat) == d_erreur)
  700:     {
  701:         return;
  702:     }
  703: 
  704:     return;
  705: }
  706: 
  707: 
  708: /*
  709: ================================================================================
  710:   Fonction 'edit'
  711: ================================================================================
  712:   Entrées : structure processus
  713: --------------------------------------------------------------------------------
  714:   Sorties :
  715: --------------------------------------------------------------------------------
  716:   Effets de bord : néant
  717: ================================================================================
  718: */
  719: 
  720: void
  721: instruction_edit(struct_processus *s_etat_processus)
  722: {
  723: #   ifdef VIM_SUPPORT
  724: #   include "vim-conv.h"
  725: 
  726:     file                    *fichier;
  727: 
  728:     logical1                drapeau49;
  729:     logical1                drapeau50;
  730: 
  731:     struct_liste_chainee    *registre_pile_last;
  732: 
  733:     struct_objet            *s_copie;
  734:     struct_objet            *s_objet;
  735:     struct_objet            *s_objet_nom;
  736: 
  737:     unsigned char           *chaine;
  738:     unsigned char           *commande;
  739:     unsigned char           *nom_fichier;
  740:     unsigned char           registre;
  741: 
  742:     (*s_etat_processus).erreur_execution = d_ex;
  743: 
  744:     if ((*s_etat_processus).affichage_arguments == 'Y')
  745:     {
  746:         printf("\n  EDIT ");
  747: 
  748:         if ((*s_etat_processus).langue == 'F')
  749:         {
  750:             printf("(édition d'un objet)\n\n");
  751:         }
  752:         else
  753:         {
  754:             printf("(edit object)\n\n");
  755:         }
  756: 
  757:         printf("    1: %s, %s, %s, %s, %s, %s,\n"
  758:                 "       %s, %s, %s, %s, %s,\n"
  759:                 "       %s, %s, %s, %s, %s\n",
  760:                 d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
  761:                 d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN);
  762:         printf("->  n: %s, %s, %s, %s, %s, %s,\n"
  763:                 "       %s, %s, %s, %s, %s,\n"
  764:                 "       %s, %s, %s, %s, %s\n",
  765:                 d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
  766:                 d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN);
  767:         printf("    ...\n");
  768:         printf("    1: %s, %s, %s, %s, %s, %s,\n"
  769:                 "       %s, %s, %s, %s, %s,\n"
  770:                 "       %s, %s, %s, %s, %s\n",
  771:                 d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
  772:                 d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN);
  773:         return;
  774:     }
  775:     else if ((*s_etat_processus).test_instruction == 'Y')
  776:     {
  777:         (*s_etat_processus).nombre_arguments = -1;
  778:         return;
  779:     }
  780: 
  781:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  782:     {
  783:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
  784:         {
  785:             return;
  786:         }
  787:     }
  788: 
  789:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  790:             &s_objet) == d_erreur)
  791:     {
  792:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  793:         return;
  794:     }
  795: 
  796:     if (((*s_objet).type != INT) &&
  797:             ((*s_objet).type != REL) &&
  798:             ((*s_objet).type != CPL) &&
  799:             ((*s_objet).type != VIN) &&
  800:             ((*s_objet).type != VRL) &&
  801:             ((*s_objet).type != VCX) &&
  802:             ((*s_objet).type != MIN) &&
  803:             ((*s_objet).type != MRL) &&
  804:             ((*s_objet).type != MCX) &&
  805:             ((*s_objet).type != TBL) &&
  806:             ((*s_objet).type != BIN) &&
  807:             ((*s_objet).type != NOM) &&
  808:             ((*s_objet).type != CHN) &&
  809:             ((*s_objet).type != LST) &&
  810:             ((*s_objet).type != ALG) &&
  811:             ((*s_objet).type != RPN))
  812:     {
  813:         liberation(s_etat_processus, s_objet);
  814: 
  815:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  816:         return;
  817:     }
  818: 
  819:     if ((s_copie = copie_objet(s_etat_processus, s_objet, 'O')) == NULL)
  820:     {
  821:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  822:         return;
  823:     }
  824: 
  825:     liberation(s_etat_processus, s_objet);
  826:     s_objet = s_copie;
  827: 
  828:     // Création d'un fichier temporaire à éditer
  829: 
  830:     if ((nom_fichier = creation_nom_fichier(s_etat_processus,
  831:             (*s_etat_processus).chemin_fichiers_temporaires)) == NULL)
  832:     {
  833:         (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  834:         return;
  835:     }
  836: 
  837:     drapeau49 = test_cfsf(s_etat_processus, 49);
  838:     drapeau50 = test_cfsf(s_etat_processus, 50);
  839: 
  840:     cf(s_etat_processus, 49);
  841:     cf(s_etat_processus, 50);
  842: 
  843:     // Ecriture de l'objet dans le fichier en mode STD et multiligne
  844: 
  845:     if ((fichier = fopen(nom_fichier, "w+")) == NULL)
  846:     {
  847:         (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  848:         return;
  849:     }
  850: 
  851:     registre = (*s_etat_processus).autorisation_conversion_chaine;
  852:     (*s_etat_processus).autorisation_conversion_chaine = 'N';
  853: 
  854:     if ((chaine = formateur(s_etat_processus, 0, s_objet)) == NULL)
  855:     {
  856:         (*s_etat_processus).autorisation_conversion_chaine = registre;
  857: 
  858:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  859:         return;
  860:     }
  861: 
  862:     (*s_etat_processus).autorisation_conversion_chaine = registre;
  863: 
  864:     if ((*s_objet).type == CHN)
  865:     {
  866:         if (fprintf(fichier, "\"%s\"\n", chaine) != (int) (strlen(chaine) + 3))
  867:         {
  868:             (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  869:             return;
  870:         }
  871:     }
  872:     else
  873:     {
  874:         if (fprintf(fichier, "%s\n", chaine) != (int) (strlen(chaine) + 1))
  875:         {
  876:             (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  877:             return;
  878:         }
  879:     }
  880: 
  881:     free(chaine);
  882: 
  883:     if (fclose(fichier) != 0)
  884:     {
  885:         (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  886:         return;
  887:     }
  888: 
  889:     if ((commande = malloc((strlen(ds_vim_commande) + strlen(nom_fichier)
  890:             - 1) * sizeof(unsigned char))) == NULL)
  891:     {
  892:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  893:         return;
  894:     }
  895: 
  896:     sprintf(commande, ds_vim_commande, nom_fichier);
  897: 
  898:     if (system(commande) != 0)
  899:     {
  900:         free(commande);
  901: 
  902:         (*s_etat_processus).erreur_systeme = d_es_processus;
  903:         return;
  904:     }
  905: 
  906:     free(commande);
  907: 
  908:     if ((s_objet_nom = allocation(s_etat_processus, CHN)) == NULL)
  909:     {
  910:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  911:         return;
  912:     }
  913: 
  914:     if (((*s_objet_nom).objet = malloc((strlen(nom_fichier) + 1)
  915:             * sizeof(unsigned char))) == NULL)
  916:     {
  917:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  918:         return;
  919:     }
  920: 
  921:     strcpy((unsigned char *) (*s_objet_nom).objet, nom_fichier);
  922: 
  923:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  924:             s_objet_nom) == d_erreur)
  925:     {
  926:         return;
  927:     }
  928: 
  929:     registre_pile_last = (*s_etat_processus).l_base_pile_last;
  930:     (*s_etat_processus).l_base_pile_last = NULL;
  931: 
  932:     instruction_recall(s_etat_processus);
  933: 
  934:     if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  935:     {
  936:         return;
  937:     }
  938: 
  939:     (*s_etat_processus).l_base_pile_last = registre_pile_last;
  940: 
  941:     // Destruction du fichier temporaire
  942: 
  943:     if (destruction_fichier(nom_fichier) == d_erreur)
  944:     {
  945:         (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  946:         return;
  947:     }
  948: 
  949:     free(nom_fichier);
  950: 
  951:     if (((*s_etat_processus).erreur_systeme != d_es) ||
  952:             ((*s_etat_processus).erreur_execution != d_ex) ||
  953:             ((*s_etat_processus).exception != d_ep))
  954:     {
  955:         liberation(s_etat_processus, s_objet);
  956: 
  957:         return;
  958:     }
  959: 
  960:     if ((*s_etat_processus).erreur_systeme != d_es)
  961:     {
  962:         return;
  963:     }
  964: 
  965:     if ((*s_etat_processus).erreur_execution == d_ex_fichier_vide)
  966:     {
  967:         if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  968:                 s_objet) == d_erreur)
  969:         {
  970:             return;
  971:         }
  972: 
  973:         (*s_etat_processus).erreur_execution = d_ex;
  974:     }
  975:     else
  976:     {
  977:         liberation(s_etat_processus, s_objet);
  978:     }
  979: 
  980:     if (drapeau49 == d_vrai)
  981:     {
  982:         sf(s_etat_processus, 49);
  983:     }
  984:     else
  985:     {
  986:         cf(s_etat_processus, 49);
  987:     }
  988: 
  989:     if (drapeau50 == d_vrai)
  990:     {
  991:         sf(s_etat_processus, 50);
  992:     }
  993:     else
  994:     {
  995:         cf(s_etat_processus, 50);
  996:     }
  997: 
  998: #   endif
  999: 
 1000:     return;
 1001: }
 1002: 
 1003: 
 1004: /*
 1005: ================================================================================
 1006:   Fonction 'externals'
 1007: ================================================================================
 1008:   Entrées : structure processus
 1009: --------------------------------------------------------------------------------
 1010:   Sorties :
 1011: --------------------------------------------------------------------------------
 1012:   Effets de bord : néant
 1013: ================================================================================
 1014: */
 1015: 
 1016: void
 1017: instruction_externals(struct_processus *s_etat_processus)
 1018: {
 1019:     logical1                ambiguite;
 1020: 
 1021:     integer8                i;
 1022: 
 1023:     struct_liste_chainee    *l_element_courant;
 1024: 
 1025:     struct_objet            *s_objet;
 1026: 
 1027:     (*s_etat_processus).erreur_execution = d_ex;
 1028: 
 1029:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1030:     {
 1031:         printf("\n  EXTERNALS ");
 1032: 
 1033:         if ((*s_etat_processus).langue == 'F')
 1034:         {
 1035:             printf("(liste des définitions externes)\n\n");
 1036:         }
 1037:         else
 1038:         {
 1039:             printf("(list of external definitions)\n\n");
 1040:         }
 1041: 
 1042:         printf("->  1: %s\n", d_LST);
 1043:         return;
 1044:     }
 1045:     else if ((*s_etat_processus).test_instruction == 'Y')
 1046:     {
 1047:         (*s_etat_processus).nombre_arguments = -1;
 1048:         return;
 1049:     }
 1050: 
 1051:     if ((s_objet = allocation(s_etat_processus, LST)) == NULL)
 1052:     {
 1053:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 1054:         return;
 1055:     }
 1056: 
 1057:     (*s_objet).objet = NULL;
 1058: 
 1059:     /*
 1060:      * { "fonction" } si la fonction n'est pas ambiguë
 1061:      * { "bibliotheque$fonction" } sinon.
 1062:      */
 1063: 
 1064:     l_element_courant = NULL;
 1065: 
 1066:     for(i = 0; i < (*s_etat_processus).nombre_instructions_externes; i++)
 1067:     {
 1068:         if (l_element_courant == NULL)
 1069:         {
 1070:             if (((*s_objet).objet = allocation_maillon(s_etat_processus))
 1071:                     == NULL)
 1072:             {
 1073:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 1074:                 return;
 1075:             }
 1076: 
 1077:             l_element_courant = (*s_objet).objet;
 1078:         }
 1079:         else
 1080:         {
 1081:             if (((*l_element_courant).suivant =
 1082:                     allocation_maillon(s_etat_processus)) == NULL)
 1083:             {
 1084:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 1085:                 return;
 1086:             }
 1087: 
 1088:             l_element_courant = (*l_element_courant).suivant;
 1089:         }
 1090: 
 1091:         (*l_element_courant).suivant = NULL;
 1092: 
 1093:         if (((*l_element_courant).donnee = allocation(s_etat_processus, CHN))
 1094:                 == NULL)
 1095:         {
 1096:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 1097:             return;
 1098:         }
 1099: 
 1100:         ambiguite = d_faux;
 1101: 
 1102:         if (i > 0)
 1103:         {
 1104:             if (strcmp((*s_etat_processus).s_instructions_externes[i].nom,
 1105:                     (*s_etat_processus).s_instructions_externes[i - 1].nom)
 1106:                     == 0)
 1107:             {
 1108:                 ambiguite = d_vrai;
 1109:             }
 1110:         }
 1111: 
 1112:         if (((i + 1) < (*s_etat_processus).nombre_instructions_externes) &&
 1113:                 (ambiguite == d_faux))
 1114:         {
 1115:             if (strcmp((*s_etat_processus).s_instructions_externes[i].nom,
 1116:                     (*s_etat_processus).s_instructions_externes[i + 1].nom)
 1117:                     == 0)
 1118:             {
 1119:                 ambiguite = d_vrai;
 1120:             }
 1121:         }
 1122: 
 1123:         if (ambiguite == d_faux)
 1124:         {
 1125:             if (((*(*l_element_courant).donnee).objet = malloc((strlen(
 1126:                     (*s_etat_processus).s_instructions_externes[i].nom) + 1)
 1127:                     * sizeof(unsigned char))) == NULL)
 1128:             {
 1129:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 1130:                 return;
 1131:             }
 1132: 
 1133:             strcpy((unsigned char *) (*(*l_element_courant).donnee).objet,
 1134:                     (*s_etat_processus).s_instructions_externes[i].nom);
 1135:         }
 1136:         else
 1137:         {
 1138:             if (((*(*l_element_courant).donnee).objet = malloc((strlen(
 1139:                     (*s_etat_processus).s_instructions_externes[i].nom) +
 1140:                     strlen((*s_etat_processus).s_instructions_externes[i]
 1141:                     .nom_bibliotheque) + 2) * sizeof(unsigned char))) == NULL)
 1142:             {
 1143:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 1144:                 return;
 1145:             }
 1146: 
 1147:             sprintf((unsigned char *) (*(*l_element_courant).donnee).objet,
 1148:                     "%s$%s", (*s_etat_processus).s_instructions_externes[i]
 1149:                     .nom_bibliotheque, (*s_etat_processus)
 1150:                     .s_instructions_externes[i].nom);
 1151:         }
 1152:     }
 1153: 
 1154:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1155:             s_objet) == d_erreur)
 1156:     {
 1157:         return;
 1158:     }
 1159: 
 1160:     return;
 1161: }
 1162: 
 1163: 
 1164: /*
 1165: ================================================================================
 1166:   Fonction 'exit'
 1167: ================================================================================
 1168:   Entrées : structure processus
 1169: --------------------------------------------------------------------------------
 1170:   Sorties :
 1171: --------------------------------------------------------------------------------
 1172:   Effets de bord : néant
 1173: ================================================================================
 1174: */
 1175: 
 1176: void
 1177: instruction_exit(struct_processus *s_etat_processus)
 1178: {
 1179:     logical1                        drapeau_boucle_definie;
 1180:     logical1                        drapeau_presence_fin_boucle;
 1181:     logical1                        erreur;
 1182:     logical1                        presence_boucle;
 1183:     logical1                        presence_compteur;
 1184: 
 1185:     struct_liste_pile_systeme       *l_element_pile_systeme;
 1186: 
 1187:     unsigned char                   *instruction_majuscule;
 1188:     unsigned char                   *tampon;
 1189: 
 1190:     integer8                        niveau;
 1191: 
 1192:     void                            (*fonction)();
 1193: 
 1194:     (*s_etat_processus).erreur_execution = d_ex;
 1195: 
 1196:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1197:     {
 1198:         printf("\n  EXIT ");
 1199: 
 1200:         if ((*s_etat_processus).langue == 'F')
 1201:         {
 1202:             printf("(structure de contrôle)\n\n");
 1203:             printf("  Utilisation :\n\n");
 1204:         }
 1205:         else
 1206:         {
 1207:             printf("(control statement)\n\n");
 1208:             printf("  Usage:\n\n");
 1209:         }
 1210: 
 1211:         printf("    START/FOR\n");
 1212:         printf("        (expression 1)\n");
 1213:         printf("        EXIT\n");
 1214:         printf("        (expression 2)\n");
 1215:         printf("    NEXT/STEP\n\n");
 1216: 
 1217:         printf("    FORALL\n");
 1218:         printf("        (expression 1)\n");
 1219:         printf("        EXIT\n");
 1220:         printf("        (expression 2)\n");
 1221:         printf("    NEXT\n\n");
 1222: 
 1223:         printf("    DO\n");
 1224:         printf("        (expression 1)\n");
 1225:         printf("        EXIT\n");
 1226:         printf("        (expression 2)\n");
 1227:         printf("    UNTIL\n");
 1228:         printf("        (expression test 1)\n");
 1229:         printf("        [EXIT\n");
 1230:         printf("        (expression test 2)]\n");
 1231:         printf("    END\n\n");
 1232: 
 1233:         printf("    WHILE\n");
 1234:         printf("        (expression test 1)\n");
 1235:         printf("        [EXIT\n");
 1236:         printf("        (expression test 2)]\n");
 1237:         printf("    REPEAT\n");
 1238:         printf("        (expression 1)\n");
 1239:         printf("        EXIT\n");
 1240:         printf("        (expression 2)\n");
 1241:         printf("    END\n");
 1242: 
 1243:         return;
 1244:     }
 1245:     else if ((*s_etat_processus).test_instruction == 'Y')
 1246:     {
 1247:         (*s_etat_processus).nombre_arguments = -1;
 1248:         return;
 1249:     }
 1250: 
 1251:     /*
 1252:      * Test de la présence de l'instruction EXIT dans une boucle
 1253:      */
 1254: 
 1255:     l_element_pile_systeme = (*s_etat_processus).l_base_pile_systeme;
 1256:     presence_boucle = d_faux;
 1257:     drapeau_boucle_definie = d_faux;
 1258: 
 1259:     while((l_element_pile_systeme != NULL) && (presence_boucle == d_faux))
 1260:     {
 1261:         if (((*l_element_pile_systeme).type_cloture == 'S') ||
 1262:                 ((*l_element_pile_systeme).type_cloture == 'F') ||
 1263:                 ((*l_element_pile_systeme).type_cloture == 'A'))
 1264:         {
 1265:             presence_boucle = d_vrai;
 1266:             drapeau_boucle_definie = d_vrai;
 1267:         }
 1268:         else if (((*l_element_pile_systeme).type_cloture ==  'D') ||
 1269:                 ((*l_element_pile_systeme).type_cloture == 'W'))
 1270:         {
 1271:             presence_boucle = d_vrai;
 1272:             drapeau_boucle_definie = d_faux;
 1273:         }
 1274: 
 1275:         l_element_pile_systeme = (*l_element_pile_systeme).suivant;
 1276:     }
 1277: 
 1278:     if (presence_boucle == d_faux)
 1279:     {
 1280:         (*s_etat_processus).erreur_execution = d_ex_exit_hors_boucle;
 1281:         return;
 1282:     }
 1283: 
 1284:     if ((*s_etat_processus).mode_execution_programme == 'Y')
 1285:     {
 1286:         drapeau_presence_fin_boucle = d_vrai;
 1287:         tampon = (*s_etat_processus).instruction_courante;
 1288:         niveau = 1;
 1289: 
 1290:         instruction_majuscule = conversion_majuscule(s_etat_processus, "");
 1291: 
 1292:         if (drapeau_boucle_definie == d_vrai)
 1293:         {
 1294:             while(!(((strcmp(instruction_majuscule, "NEXT") == 0) ||
 1295:                     (strcmp(instruction_majuscule, "STEP") == 0)) &&
 1296:                     (niveau == 0)))
 1297:             {
 1298:                 free(instruction_majuscule);
 1299: 
 1300:                 erreur = recherche_instruction_suivante(s_etat_processus);
 1301: 
 1302:                 if (erreur == d_erreur)
 1303:                 {
 1304:                     return;
 1305:                 }
 1306: 
 1307:                 (*s_etat_processus).erreur_systeme = d_es;
 1308:                 instruction_majuscule = conversion_majuscule(s_etat_processus,
 1309:                         (*s_etat_processus).instruction_courante);
 1310: 
 1311:                 if (instruction_majuscule == NULL)
 1312:                 {
 1313:                     return;
 1314:                 }
 1315: 
 1316:                 /*
 1317:                  * Traitement de la pile système par les
 1318:                  * différentes instructions.
 1319:                  */
 1320: 
 1321:                 if ((strcmp(instruction_majuscule, "IF") == 0) ||
 1322:                         (strcmp(instruction_majuscule, "IFERR") == 0) ||
 1323:                         (strcmp(instruction_majuscule, "DO") == 0) ||
 1324:                         (strcmp(instruction_majuscule, "WHILE") == 0) ||
 1325:                         (strcmp(instruction_majuscule, "FOR") == 0) ||
 1326:                         (strcmp(instruction_majuscule, "FORALL") == 0) ||
 1327:                         (strcmp(instruction_majuscule, "START") == 0) ||
 1328:                         (strcmp(instruction_majuscule, "SELECT") == 0)
 1329:                         || (strcmp(instruction_majuscule, "CRITICAL") == 0)
 1330:                         || (strcmp(instruction_majuscule, "CASE") == 0)
 1331:                         || (strcmp(instruction_majuscule, "<<") == 0))
 1332:                 {
 1333:                     if (strcmp(instruction_majuscule, "<<") == 0)
 1334:                     {
 1335:                         analyse(s_etat_processus, NULL);
 1336:                     }
 1337:                     else
 1338:                     {
 1339:                         if ((strcmp(instruction_majuscule, "FOR") == 0) ||
 1340:                                 (strcmp(instruction_majuscule, "FORALL") == 0)
 1341:                                 || (strcmp(instruction_majuscule, "START")
 1342:                                 == 0))
 1343:                         {
 1344:                             niveau++;
 1345:                         }
 1346: 
 1347:                         empilement_pile_systeme(s_etat_processus);
 1348: 
 1349:                         if ((*s_etat_processus).erreur_systeme != d_es)
 1350:                         {
 1351:                             return;
 1352:                         }
 1353:                     }
 1354:                 }
 1355:                 else if ((strcmp(instruction_majuscule, "END") == 0) ||
 1356:                         (strcmp(instruction_majuscule, "NEXT") == 0) ||
 1357:                         (strcmp(instruction_majuscule, "STEP") == 0) ||
 1358:                         (strcmp(instruction_majuscule, ">>") == 0))
 1359:                 {
 1360:                     if (strcmp(instruction_majuscule, ">>") == 0)
 1361:                     {
 1362:                         analyse(s_etat_processus, NULL);
 1363: 
 1364:                         if ((*s_etat_processus).retour_routine_evaluation
 1365:                                 == 'Y')
 1366:                         {
 1367:                             drapeau_presence_fin_boucle = d_faux;
 1368:                             free((*s_etat_processus).instruction_courante);
 1369: 
 1370:                             break;
 1371:                         }
 1372:                     }
 1373:                     else
 1374:                     {
 1375:                         if ((strcmp(instruction_majuscule, "NEXT") == 0) ||
 1376:                                 (strcmp(instruction_majuscule, "STEP")
 1377:                                 == 0))
 1378:                         {
 1379:                             niveau--;
 1380: 
 1381:                             if (niveau != 0)
 1382:                             {
 1383:                                 depilement_pile_systeme(s_etat_processus);
 1384:                             }
 1385:                         }
 1386:                         else
 1387:                         {
 1388:                             if ((*s_etat_processus).l_base_pile_systeme == NULL)
 1389:                             {
 1390:                                 (*s_etat_processus).erreur_systeme =
 1391:                                         d_es_processus;
 1392:                                 return;
 1393:                             }
 1394: 
 1395:                             if ((*(*s_etat_processus).l_base_pile_systeme)
 1396:                                     .type_cloture == 'Q')
 1397:                             {
 1398:                                 if (pthread_mutex_unlock(
 1399:                                         &mutex_sections_critiques) != 0)
 1400:                                 {
 1401:                                     (*s_etat_processus).erreur_systeme =
 1402:                                             d_es_processus;
 1403:                                     return;
 1404:                                 }
 1405: 
 1406:                                 (*s_etat_processus).sections_critiques--;
 1407:                             }
 1408: 
 1409:                             depilement_pile_systeme(s_etat_processus);
 1410:                         }
 1411: 
 1412:                         if ((*s_etat_processus).erreur_systeme != d_es)
 1413:                         {
 1414:                             return;
 1415:                         }
 1416:                     }
 1417:                 }
 1418: 
 1419:                 free((*s_etat_processus).instruction_courante);
 1420:             }
 1421:         }
 1422:         else
 1423:         {
 1424:             while(!((strcmp(instruction_majuscule, "END") == 0) &&
 1425:                     (niveau == 0)))
 1426:             {
 1427:                 free(instruction_majuscule);
 1428: 
 1429:                 erreur = recherche_instruction_suivante(s_etat_processus);
 1430: 
 1431:                 if (erreur == d_erreur)
 1432:                 {
 1433:                     return;
 1434:                 }
 1435: 
 1436:                 instruction_majuscule = conversion_majuscule(s_etat_processus,
 1437:                         (*s_etat_processus).instruction_courante);
 1438: 
 1439:                 if (instruction_majuscule == NULL)
 1440:                 {
 1441:                     return;
 1442:                 }
 1443: 
 1444:                 /*
 1445:                  * Traitement de la pile système par les
 1446:                  * différentes instructions.
 1447:                  */
 1448: 
 1449:                 if ((strcmp(instruction_majuscule, "IF") == 0) ||
 1450:                         (strcmp(instruction_majuscule, "IFERR") == 0) ||
 1451:                         (strcmp(instruction_majuscule, "DO") == 0) ||
 1452:                         (strcmp(instruction_majuscule, "WHILE") == 0) ||
 1453:                         (strcmp(instruction_majuscule, "FOR") == 0) ||
 1454:                         (strcmp(instruction_majuscule, "FORALL") == 0) ||
 1455:                         (strcmp(instruction_majuscule, "START") == 0) ||
 1456:                         (strcmp(instruction_majuscule, "SELECT") == 0)
 1457:                         || (strcmp(instruction_majuscule, "CRITICAL") == 0)
 1458:                         || (strcmp(instruction_majuscule, "CASE") == 0)
 1459:                         || (strcmp(instruction_majuscule, "<<") == 0))
 1460:                 {
 1461:                     if (strcmp(instruction_majuscule, "<<") == 0)
 1462:                     {
 1463:                         analyse(s_etat_processus, NULL);
 1464:                     }
 1465:                     else
 1466:                     {
 1467:                         if ((strcmp(instruction_majuscule, "DO") == 0) ||
 1468:                                 (strcmp(instruction_majuscule, "WHILE")
 1469:                                 == 0))
 1470:                         {
 1471:                             niveau++;
 1472:                         }
 1473: 
 1474:                         empilement_pile_systeme(s_etat_processus);
 1475: 
 1476:                         if ((*s_etat_processus).erreur_systeme != d_es)
 1477:                         {
 1478:                             return;
 1479:                         }
 1480:                     }
 1481:                 }
 1482:                 else if ((strcmp(instruction_majuscule, "END") == 0) ||
 1483:                         (strcmp(instruction_majuscule, "NEXT") == 0) ||
 1484:                         (strcmp(instruction_majuscule, "STEP") == 0) ||
 1485:                         (strcmp(instruction_majuscule, ">>") == 0))
 1486:                 {
 1487:                     if (strcmp(instruction_majuscule, ">>") == 0)
 1488:                     {
 1489:                         analyse(s_etat_processus, NULL);
 1490: 
 1491:                         if ((*s_etat_processus).retour_routine_evaluation
 1492:                                 == 'Y')
 1493:                         {
 1494:                             drapeau_presence_fin_boucle = d_faux;
 1495:                             free((*s_etat_processus).instruction_courante);
 1496: 
 1497:                             break;
 1498:                         }
 1499:                     }
 1500:                     else
 1501:                     {
 1502:                         if (strcmp(instruction_majuscule, "END") == 0)
 1503:                         {
 1504:                             if (((*(*s_etat_processus).l_base_pile_systeme)
 1505:                                     .type_cloture == 'D') ||
 1506:                                     ((*(*s_etat_processus)
 1507:                                     .l_base_pile_systeme).type_cloture
 1508:                                     == 'W'))
 1509:                             {
 1510:                                 niveau--;
 1511:                             }
 1512: 
 1513:                             depilement_pile_systeme(s_etat_processus);
 1514:                         }
 1515:                         else
 1516:                         {
 1517:                             if ((*s_etat_processus).l_base_pile_systeme == NULL)
 1518:                             {
 1519:                                 (*s_etat_processus).erreur_systeme =
 1520:                                         d_es_processus;
 1521:                                 return;
 1522:                             }
 1523: 
 1524:                             if ((*(*s_etat_processus).l_base_pile_systeme)
 1525:                                     .type_cloture == 'Q')
 1526:                             {
 1527:                                 if (pthread_mutex_unlock(
 1528:                                         &mutex_sections_critiques) != 0)
 1529:                                 {
 1530:                                     (*s_etat_processus).erreur_systeme =
 1531:                                             d_es_processus;
 1532:                                     return;
 1533:                                 }
 1534: 
 1535:                                 (*s_etat_processus).sections_critiques--;
 1536:                             }
 1537: 
 1538:                             depilement_pile_systeme(s_etat_processus);
 1539:                         }
 1540: 
 1541:                         if ((*s_etat_processus).erreur_systeme != d_es)
 1542:                         {
 1543:                             return;
 1544:                         }
 1545:                     }
 1546:                 }
 1547: 
 1548:                 free((*s_etat_processus).instruction_courante);
 1549:             }
 1550:         }
 1551: 
 1552:         if (drapeau_presence_fin_boucle == d_faux)
 1553:         {
 1554:             (*s_etat_processus).traitement_cycle_exit = 'E';
 1555:         }
 1556:         else
 1557:         {
 1558:             (*s_etat_processus).traitement_cycle_exit = 'N';
 1559:         }
 1560: 
 1561:         free(instruction_majuscule);
 1562:         (*s_etat_processus).instruction_courante = tampon;
 1563:     }
 1564:     else
 1565:     {
 1566:         /* EXIT apparaissant dans l'évaluation d'une expression */
 1567: 
 1568:         drapeau_presence_fin_boucle = d_faux;
 1569:         instruction_majuscule = NULL;
 1570:         niveau = 1;
 1571: 
 1572:         if (drapeau_boucle_definie == d_vrai)
 1573:         {
 1574:             while((*s_etat_processus).expression_courante != NULL)
 1575:             {
 1576:                 while((*(*(*s_etat_processus).expression_courante)
 1577:                         .donnee).type != FCT)
 1578:                 {
 1579:                     if ((*s_etat_processus).expression_courante == NULL)
 1580:                     {
 1581:                         (*s_etat_processus).erreur_execution =
 1582:                                 d_ex_erreur_traitement_boucle;
 1583:                         return;
 1584:                     }
 1585: 
 1586:                     (*s_etat_processus).expression_courante =
 1587:                             (*(*s_etat_processus).expression_courante).suivant;
 1588:                 }
 1589: 
 1590:                 fonction = (*((struct_fonction *) (*(*(*s_etat_processus)
 1591:                         .expression_courante).donnee).objet)).fonction;
 1592: 
 1593:                 if ((fonction == instruction_if) ||
 1594:                         (fonction == instruction_iferr) ||
 1595:                         (fonction == instruction_do) ||
 1596:                         (fonction == instruction_while) ||
 1597:                         (fonction == instruction_for) ||
 1598:                         (fonction == instruction_forall) ||
 1599:                         (fonction == instruction_start) ||
 1600:                         (fonction == instruction_select) ||
 1601:                         (fonction == instruction_case) ||
 1602:                         (fonction == instruction_critical) ||
 1603:                         (fonction == instruction_vers_niveau_superieur))
 1604:                 {
 1605:                     if (fonction == instruction_vers_niveau_superieur)
 1606:                     {
 1607:                         analyse(s_etat_processus,
 1608:                                 instruction_vers_niveau_superieur);
 1609:                     }
 1610:                     else
 1611:                     {
 1612:                         if ((fonction == instruction_for) ||
 1613:                                 (fonction == instruction_forall) ||
 1614:                                 (fonction == instruction_start))
 1615:                         {
 1616:                             niveau++;
 1617:                         }
 1618: 
 1619:                         empilement_pile_systeme(s_etat_processus);
 1620: 
 1621:                         if ((*s_etat_processus).erreur_systeme != d_es)
 1622:                         {
 1623:                             return;
 1624:                         }
 1625:                     }
 1626:                 }
 1627:                 else if ((fonction == instruction_end) ||
 1628:                         (fonction == instruction_next) ||
 1629:                         (fonction == instruction_step) ||
 1630:                         (fonction == instruction_vers_niveau_inferieur))
 1631:                 {
 1632:                     if (fonction == instruction_vers_niveau_inferieur)
 1633:                     {
 1634:                         tampon = (*s_etat_processus).instruction_courante;
 1635:                         (*s_etat_processus).instruction_courante =
 1636:                                 instruction_majuscule;
 1637: 
 1638:                         analyse(s_etat_processus,
 1639:                                 instruction_vers_niveau_inferieur);
 1640: 
 1641:                         (*s_etat_processus).instruction_courante = tampon;
 1642:                     }
 1643:                     else
 1644:                     {
 1645:                         if ((fonction == instruction_next) ||
 1646:                                 (fonction == instruction_step))
 1647:                         {
 1648:                             niveau--;
 1649: 
 1650:                             if (niveau != 0)
 1651:                             {
 1652:                                 depilement_pile_systeme(s_etat_processus);
 1653:                             }
 1654:                             else
 1655:                             {
 1656:                                 drapeau_presence_fin_boucle = d_vrai;
 1657:                                 break;
 1658:                             }
 1659:                         }
 1660:                         else
 1661:                         {
 1662:                             if ((*s_etat_processus).l_base_pile_systeme == NULL)
 1663:                             {
 1664:                                 (*s_etat_processus).erreur_systeme =
 1665:                                         d_es_processus;
 1666:                                 return;
 1667:                             }
 1668: 
 1669:                             if ((*(*s_etat_processus).l_base_pile_systeme)
 1670:                                     .type_cloture == 'Q')
 1671:                             {
 1672:                                 if (pthread_mutex_unlock(
 1673:                                         &mutex_sections_critiques) != 0)
 1674:                                 {
 1675:                                     (*s_etat_processus).erreur_systeme =
 1676:                                             d_es_processus;
 1677:                                     return;
 1678:                                 }
 1679: 
 1680:                                 (*s_etat_processus).sections_critiques--;
 1681:                             }
 1682: 
 1683:                             depilement_pile_systeme(s_etat_processus);
 1684:                         }
 1685: 
 1686:                         if ((*s_etat_processus).erreur_systeme != d_es)
 1687:                         {
 1688:                             return;
 1689:                         }
 1690:                     }
 1691:                 }
 1692: 
 1693:                 (*s_etat_processus).expression_courante = (*(*s_etat_processus)
 1694:                         .expression_courante).suivant;
 1695:             }
 1696:         }
 1697:         else
 1698:         {
 1699:             while((*s_etat_processus).expression_courante != NULL)
 1700:             {
 1701:                 while((*(*(*s_etat_processus).expression_courante)
 1702:                         .donnee).type != FCT)
 1703:                 {
 1704:                     if ((*s_etat_processus).expression_courante == NULL)
 1705:                     {
 1706:                         (*s_etat_processus).erreur_execution =
 1707:                                 d_ex_erreur_traitement_boucle;
 1708:                         return;
 1709:                     }
 1710: 
 1711:                     (*s_etat_processus).expression_courante =
 1712:                             (*(*s_etat_processus).expression_courante).suivant;
 1713:                 }
 1714: 
 1715:                 fonction = (*((struct_fonction *) (*(*(*s_etat_processus)
 1716:                         .expression_courante).donnee).objet)).fonction;
 1717: 
 1718:                 if ((fonction == instruction_if) ||
 1719:                         (fonction == instruction_iferr) ||
 1720:                         (fonction == instruction_do) ||
 1721:                         (fonction == instruction_while) ||
 1722:                         (fonction == instruction_for) ||
 1723:                         (fonction == instruction_forall) ||
 1724:                         (fonction == instruction_start) ||
 1725:                         (fonction == instruction_select) ||
 1726:                         (fonction == instruction_critical) ||
 1727:                         (fonction == instruction_case) ||
 1728:                         (fonction == instruction_vers_niveau_superieur))
 1729:                 {
 1730:                     if (fonction == instruction_vers_niveau_superieur)
 1731:                     {
 1732:                         analyse(s_etat_processus,
 1733:                                 instruction_vers_niveau_superieur);
 1734:                     }
 1735:                     else
 1736:                     {
 1737:                         if ((fonction == instruction_do) ||
 1738:                                 (fonction == instruction_while))
 1739:                         {
 1740:                             niveau++;
 1741:                         }
 1742: 
 1743:                         empilement_pile_systeme(s_etat_processus);
 1744: 
 1745:                         if ((*s_etat_processus).erreur_systeme != d_es)
 1746:                         {
 1747:                             return;
 1748:                         }
 1749:                     }
 1750:                 }
 1751:                 else if ((fonction == instruction_end) ||
 1752:                         (fonction == instruction_next) ||
 1753:                         (fonction == instruction_step) ||
 1754:                         (fonction == instruction_vers_niveau_inferieur))
 1755:                 {
 1756:                     if (fonction == instruction_vers_niveau_inferieur)
 1757:                     {
 1758:                         analyse(s_etat_processus,
 1759:                                 instruction_vers_niveau_inferieur);
 1760:                     }
 1761:                     else
 1762:                     {
 1763:                         if (fonction == instruction_end)
 1764:                         {
 1765:                             if (((*(*s_etat_processus).l_base_pile_systeme)
 1766:                                     .type_cloture == 'D') ||
 1767:                                     ((*(*s_etat_processus).l_base_pile_systeme)
 1768:                                     .type_cloture == 'W'))
 1769:                             {
 1770:                                 niveau--;
 1771:                             }
 1772: 
 1773:                             depilement_pile_systeme(s_etat_processus);
 1774: 
 1775:                             if (niveau == 0)
 1776:                             {
 1777:                                 drapeau_presence_fin_boucle = d_vrai;
 1778:                                 break;
 1779:                             }
 1780:                         }
 1781:                         else
 1782:                         {
 1783:                             if ((*s_etat_processus).l_base_pile_systeme == NULL)
 1784:                             {
 1785:                                 (*s_etat_processus).erreur_systeme =
 1786:                                         d_es_processus;
 1787:                                 return;
 1788:                             }
 1789: 
 1790:                             if ((*(*s_etat_processus).l_base_pile_systeme)
 1791:                                     .type_cloture == 'Q')
 1792:                             {
 1793:                                 if (pthread_mutex_unlock(
 1794:                                         &mutex_sections_critiques) != 0)
 1795:                                 {
 1796:                                     (*s_etat_processus).erreur_systeme =
 1797:                                             d_es_processus;
 1798:                                     return;
 1799:                                 }
 1800: 
 1801:                                 (*s_etat_processus).sections_critiques--;
 1802:                             }
 1803: 
 1804:                             depilement_pile_systeme(s_etat_processus);
 1805:                         }
 1806: 
 1807:                         if ((*s_etat_processus).erreur_systeme != d_es)
 1808:                         {
 1809:                             return;
 1810:                         }
 1811:                     }
 1812:                 }
 1813: 
 1814:                 (*s_etat_processus).expression_courante = (*(*s_etat_processus)
 1815:                         .expression_courante).suivant;
 1816:             }
 1817:         }
 1818: 
 1819:         if (drapeau_presence_fin_boucle == d_faux)
 1820:         {
 1821:             (*s_etat_processus).traitement_cycle_exit = 'E';
 1822:         }
 1823:         else
 1824:         {
 1825:             (*s_etat_processus).traitement_cycle_exit = 'N';
 1826:         }
 1827:     }
 1828: 
 1829:     if ((drapeau_boucle_definie == d_vrai) &&
 1830:             (drapeau_presence_fin_boucle == d_vrai))
 1831:     {
 1832:         presence_compteur = (((*(*s_etat_processus).l_base_pile_systeme)
 1833:                 .type_cloture == 'F') || ((*(*s_etat_processus)
 1834:                 .l_base_pile_systeme).type_cloture == 'A')) ? d_vrai : d_faux;
 1835: 
 1836:         if (((*(*s_etat_processus).l_base_pile_systeme).type_cloture != 'S')
 1837:                 && (presence_compteur == d_faux))
 1838:         {
 1839:             (*s_etat_processus).erreur_execution =
 1840:                     d_ex_erreur_traitement_boucle;
 1841:             return;
 1842:         }
 1843: 
 1844:         depilement_pile_systeme(s_etat_processus);
 1845: 
 1846:         if ((*s_etat_processus).erreur_systeme != d_es)
 1847:         {
 1848:             return;
 1849:         }
 1850: 
 1851:         if (presence_compteur == d_vrai)
 1852:         {
 1853:             (*(*s_etat_processus).l_base_pile_systeme).indice_boucle = NULL;
 1854:             (*s_etat_processus).niveau_courant--;
 1855: 
 1856:             if (retrait_variables_par_niveau(s_etat_processus) == d_erreur)
 1857:             {
 1858:                 return;
 1859:             }
 1860:         }
 1861:     }
 1862: 
 1863:     return;
 1864: }
 1865: 
 1866: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>