--- rpl/src/instructions_e2.c 2010/01/26 15:22:45 1.1.1.1 +++ rpl/src/instructions_e2.c 2020/01/10 11:15:45 1.76 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.9 - Copyright (C) 1989-2010 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.32 + Copyright (C) 1989-2020 Dr. BERTRAND Joël This file is part of RPL/2. @@ -20,7 +20,7 @@ */ -#include "rpl.conv.h" +#include "rpl-conv.h" /* @@ -623,9 +623,9 @@ instruction_errm(struct_processus *s_eta { struct_objet *s_objet_resultat; - unsigned int registre_erreur_execution; - unsigned int registre_erreur_systeme; - unsigned int registre_exception; + int registre_erreur_execution; + int registre_erreur_systeme; + int registre_exception; (*s_etat_processus).erreur_execution = d_ex; @@ -721,11 +721,10 @@ void instruction_edit(struct_processus *s_etat_processus) { # ifdef VIM_SUPPORT -# include "vim.conv.h" +# include "vim-conv.h" file *fichier; - logical1 drapeau; logical1 drapeau49; logical1 drapeau50; @@ -738,6 +737,7 @@ instruction_edit(struct_processus *s_eta unsigned char *chaine; unsigned char *commande; unsigned char *nom_fichier; + unsigned char registre; (*s_etat_processus).erreur_execution = d_ex; @@ -848,12 +848,19 @@ instruction_edit(struct_processus *s_eta return; } + registre = (*s_etat_processus).autorisation_conversion_chaine; + (*s_etat_processus).autorisation_conversion_chaine = 'N'; + if ((chaine = formateur(s_etat_processus, 0, s_objet)) == NULL) { + (*s_etat_processus).autorisation_conversion_chaine = registre; + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } + (*s_etat_processus).autorisation_conversion_chaine = registre; + if ((*s_objet).type == CHN) { if (fprintf(fichier, "\"%s\"\n", chaine) != (int) (strlen(chaine) + 3)) @@ -879,101 +886,93 @@ instruction_edit(struct_processus *s_eta return; } - do + if ((commande = malloc((strlen(ds_vim_commande) + strlen(nom_fichier) + - 1) * sizeof(unsigned char))) == NULL) { - if ((commande = malloc((strlen(ds_vim_commande) + strlen(nom_fichier) - - 1) * sizeof(unsigned char))) == NULL) - { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return; - } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } - sprintf(commande, ds_vim_commande, nom_fichier); + sprintf(commande, ds_vim_commande, nom_fichier); - if (system(commande) != 0) - { - free(commande); + if (system(commande) != 0) + { + free(commande); - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } - free(commande); + free(commande); - if ((s_objet_nom = allocation(s_etat_processus, CHN)) == NULL) - { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return; - } + if ((s_objet_nom = allocation(s_etat_processus, CHN)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } - if (((*s_objet_nom).objet = malloc((strlen(nom_fichier) + 1) - * sizeof(unsigned char))) == NULL) - { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return; - } + if (((*s_objet_nom).objet = malloc((strlen(nom_fichier) + 1) + * sizeof(unsigned char))) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } - strcpy((unsigned char *) (*s_objet_nom).objet, nom_fichier); + strcpy((unsigned char *) (*s_objet_nom).objet, nom_fichier); - if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), - s_objet_nom) == d_erreur) - { - return; - } + if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), + s_objet_nom) == d_erreur) + { + return; + } - registre_pile_last = (*s_etat_processus).l_base_pile_last; - (*s_etat_processus).l_base_pile_last = NULL; + registre_pile_last = (*s_etat_processus).l_base_pile_last; + (*s_etat_processus).l_base_pile_last = NULL; - instruction_recall(s_etat_processus); + instruction_recall(s_etat_processus); - // Destruction du fichier temporaire + if (empilement_pile_last(s_etat_processus, 0) == d_erreur) + { + return; + } - if (destruction_fichier(nom_fichier) == d_erreur) - { - (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; - return; - } + (*s_etat_processus).l_base_pile_last = registre_pile_last; - free(nom_fichier); + // Destruction du fichier temporaire - if (((*s_etat_processus).erreur_systeme != d_es) || - ((*s_etat_processus).erreur_execution != d_ex) || - ((*s_etat_processus).exception != d_ep)) - { - if (empilement_pile_last(s_etat_processus, 0) == d_erreur) - { - return; - } + if (destruction_fichier(nom_fichier) == d_erreur) + { + (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; + return; + } - (*s_etat_processus).l_base_pile_last = registre_pile_last; - liberation(s_etat_processus, s_objet); + free(nom_fichier); - return; - } + if (((*s_etat_processus).erreur_systeme != d_es) || + ((*s_etat_processus).erreur_execution != d_ex) || + ((*s_etat_processus).exception != d_ep)) + { + liberation(s_etat_processus, s_objet); - if ((*s_etat_processus).erreur_systeme != d_es) - { - return; - } + return; + } - if ((*s_etat_processus).erreur_execution == d_ex_fichier_vide) - { - if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), - s_objet) == d_erreur) - { - return; - } + if ((*s_etat_processus).erreur_systeme != d_es) + { + return; + } - (*s_etat_processus).erreur_execution = d_ex; - drapeau = d_faux; - } - else + if ((*s_etat_processus).erreur_execution == d_ex_fichier_vide) + { + if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), + s_objet) == d_erreur) { - drapeau = d_vrai; + return; } - } while((*s_etat_processus).erreur_execution != d_ex); - if (drapeau == d_vrai) + (*s_etat_processus).erreur_execution = d_ex; + } + else { liberation(s_etat_processus, s_objet); } @@ -1019,7 +1018,7 @@ instruction_externals(struct_processus * { logical1 ambiguite; - unsigned long i; + integer8 i; struct_liste_chainee *l_element_courant; @@ -1133,6 +1132,16 @@ instruction_externals(struct_processus * strcpy((unsigned char *) (*(*l_element_courant).donnee).objet, (*s_etat_processus).s_instructions_externes[i].nom); + + if ((*s_etat_processus).s_instructions_externes[i].position_fleche + >= 0) + { + memcpy((unsigned char *) (*(*l_element_courant).donnee).objet + + (*s_etat_processus).s_instructions_externes[i] + .position_fleche - (strlen((*s_etat_processus) + .s_instructions_externes[i].nom_bibliotheque) + 1), + "->", 2); + } } else { @@ -1149,6 +1158,14 @@ instruction_externals(struct_processus * "%s$%s", (*s_etat_processus).s_instructions_externes[i] .nom_bibliotheque, (*s_etat_processus) .s_instructions_externes[i].nom); + + if ((*s_etat_processus).s_instructions_externes[i].position_fleche + >= 0) + { + memcpy((unsigned char *) (*(*l_element_courant).donnee).objet + + (*s_etat_processus).s_instructions_externes[i] + .position_fleche, "->", 2); + } } } @@ -1188,7 +1205,7 @@ instruction_exit(struct_processus *s_eta unsigned char *instruction_majuscule; unsigned char *tampon; - unsigned long niveau; + integer8 niveau; void (*fonction)(); @@ -1215,6 +1232,12 @@ instruction_exit(struct_processus *s_eta printf(" (expression 2)\n"); printf(" NEXT/STEP\n\n"); + printf(" FORALL\n"); + printf(" (expression 1)\n"); + printf(" EXIT\n"); + printf(" (expression 2)\n"); + printf(" NEXT\n\n"); + printf(" DO\n"); printf(" (expression 1)\n"); printf(" EXIT\n"); @@ -1254,7 +1277,8 @@ instruction_exit(struct_processus *s_eta while((l_element_pile_systeme != NULL) && (presence_boucle == d_faux)) { if (((*l_element_pile_systeme).type_cloture == 'S') || - ((*l_element_pile_systeme).type_cloture == 'F')) + ((*l_element_pile_systeme).type_cloture == 'F') || + ((*l_element_pile_systeme).type_cloture == 'A')) { presence_boucle = d_vrai; drapeau_boucle_definie = d_vrai; @@ -1281,7 +1305,7 @@ instruction_exit(struct_processus *s_eta tampon = (*s_etat_processus).instruction_courante; niveau = 1; - instruction_majuscule = conversion_majuscule(""); + instruction_majuscule = conversion_majuscule(s_etat_processus, ""); if (drapeau_boucle_definie == d_vrai) { @@ -1298,213 +1322,114 @@ instruction_exit(struct_processus *s_eta return; } - if (recherche_variable(s_etat_processus, - (*s_etat_processus).instruction_courante) == d_vrai) + (*s_etat_processus).erreur_systeme = d_es; + instruction_majuscule = conversion_majuscule(s_etat_processus, + (*s_etat_processus).instruction_courante); + + if (instruction_majuscule == NULL) { - instruction_majuscule = conversion_majuscule(""); + return; + } - if ((*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante] - .objet == NULL) + /* + * Traitement de la pile système par les + * différentes instructions. + */ + + if ((strcmp(instruction_majuscule, "IF") == 0) || + (strcmp(instruction_majuscule, "IFERR") == 0) || + (strcmp(instruction_majuscule, "DO") == 0) || + (strcmp(instruction_majuscule, "WHILE") == 0) || + (strcmp(instruction_majuscule, "FOR") == 0) || + (strcmp(instruction_majuscule, "FORALL") == 0) || + (strcmp(instruction_majuscule, "START") == 0) || + (strcmp(instruction_majuscule, "SELECT") == 0) + || (strcmp(instruction_majuscule, "CRITICAL") == 0) + || (strcmp(instruction_majuscule, "CASE") == 0) + || (strcmp(instruction_majuscule, "<<") == 0)) + { + if (strcmp(instruction_majuscule, "<<") == 0) { - if (pthread_mutex_lock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = - d_es_processus; - return; - } - - if (recherche_variable_partagee(s_etat_processus, - (*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante] - .nom, (*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante] - .variable_partagee, - (*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante] - .origine) == d_vrai) - { - if ((*((*s_etat_processus).s_liste_variables - [(*s_etat_processus) - .position_variable_courante]).objet).type - == ADR) - { - empilement_pile_systeme(s_etat_processus); - - if ((*s_etat_processus).erreur_systeme != d_es) - { - if (pthread_mutex_unlock( - &((*(*s_etat_processus) - .s_liste_variables_partagees) - .mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = - d_es_processus; - return; - } - - return; - } - - (*(*s_etat_processus).l_base_pile_systeme) - .adresse_retour = - (*s_etat_processus).position_courante; - - (*(*s_etat_processus).l_base_pile_systeme) - .retour_definition = 'Y'; - (*(*s_etat_processus).l_base_pile_systeme) - .niveau_courant = - (*s_etat_processus).niveau_courant; - - (*s_etat_processus).position_courante = - (*((unsigned long *) - ((*((*s_etat_processus) - .s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet)) - .objet))); - - (*s_etat_processus) - .autorisation_empilement_programme - = 'N'; - } - } - else - { - (*s_etat_processus).erreur_systeme = d_es; - } - - if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = - d_es_processus; - return; - } + analyse(s_etat_processus, NULL); } else { - if ((*((*s_etat_processus).s_liste_variables - [(*s_etat_processus) - .position_variable_courante]).objet).type - == ADR) + if ((strcmp(instruction_majuscule, "FOR") == 0) || + (strcmp(instruction_majuscule, "FORALL") == 0) + || (strcmp(instruction_majuscule, "START") + == 0)) { - empilement_pile_systeme(s_etat_processus); + niveau++; + } - if ((*s_etat_processus).erreur_systeme != d_es) - { - return; - } + empilement_pile_systeme(s_etat_processus); - (*(*s_etat_processus).l_base_pile_systeme) - .adresse_retour = - (*s_etat_processus).position_courante; - - (*(*s_etat_processus).l_base_pile_systeme) - .retour_definition = 'Y'; - (*(*s_etat_processus).l_base_pile_systeme) - .niveau_courant = - (*s_etat_processus).niveau_courant; - - (*s_etat_processus).position_courante = - (*((unsigned long *) ((*((*s_etat_processus) - .s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet)) - .objet))); - - (*s_etat_processus) - .autorisation_empilement_programme - = 'N'; + if ((*s_etat_processus).erreur_systeme != d_es) + { + return; } } } - else + else if ((strcmp(instruction_majuscule, "END") == 0) || + (strcmp(instruction_majuscule, "NEXT") == 0) || + (strcmp(instruction_majuscule, "STEP") == 0) || + (strcmp(instruction_majuscule, ">>") == 0)) { - (*s_etat_processus).erreur_systeme = d_es; - instruction_majuscule = conversion_majuscule( - (*s_etat_processus).instruction_courante); - - if (instruction_majuscule == NULL) + if (strcmp(instruction_majuscule, ">>") == 0) { - return; - } + analyse(s_etat_processus, NULL); - /* - * Traitement de la pile système par les - * différentes instructions. - */ - - if ((strcmp(instruction_majuscule, "IF") == 0) || - (strcmp(instruction_majuscule, "IFERR") == 0) || - (strcmp(instruction_majuscule, "DO") == 0) || - (strcmp(instruction_majuscule, "WHILE") == 0) || - (strcmp(instruction_majuscule, "FOR") == 0) || - (strcmp(instruction_majuscule, "START") == 0) || - (strcmp(instruction_majuscule, "SELECT") == 0) - || (strcmp(instruction_majuscule, "CASE") == 0) - || (strcmp(instruction_majuscule, "<<") == 0)) - { - if (strcmp(instruction_majuscule, "<<") == 0) - { - analyse(s_etat_processus, NULL); - } - else + if ((*s_etat_processus).retour_routine_evaluation + == 'Y') { - if ((strcmp(instruction_majuscule, "FOR") == 0) || - (strcmp(instruction_majuscule, "START") - == 0)) - { - niveau++; - } - - empilement_pile_systeme(s_etat_processus); + drapeau_presence_fin_boucle = d_faux; + free((*s_etat_processus).instruction_courante); - if ((*s_etat_processus).erreur_systeme != d_es) - { - return; - } + break; } } - else if ((strcmp(instruction_majuscule, "END") == 0) || - (strcmp(instruction_majuscule, "NEXT") == 0) || - (strcmp(instruction_majuscule, "STEP") == 0) || - (strcmp(instruction_majuscule, ">>") == 0)) + else { - if (strcmp(instruction_majuscule, ">>") == 0) + if ((strcmp(instruction_majuscule, "NEXT") == 0) || + (strcmp(instruction_majuscule, "STEP") + == 0)) { - analyse(s_etat_processus, NULL); + niveau--; - if ((*s_etat_processus).retour_routine_evaluation - == 'Y') + if (niveau != 0) { - drapeau_presence_fin_boucle = d_faux; - free((*s_etat_processus).instruction_courante); - - break; + depilement_pile_systeme(s_etat_processus); } } else { - if ((strcmp(instruction_majuscule, "NEXT") == 0) || - (strcmp(instruction_majuscule, "STEP") - == 0)) + if ((*s_etat_processus).l_base_pile_systeme == NULL) { - niveau--; + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; + } - if (niveau != 0) + if ((*(*s_etat_processus).l_base_pile_systeme) + .type_cloture == 'Q') + { + if (pthread_mutex_unlock( + &mutex_sections_critiques) != 0) { - depilement_pile_systeme(s_etat_processus); + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; } - } - else - { - depilement_pile_systeme(s_etat_processus); - } - if ((*s_etat_processus).erreur_systeme != d_es) - { - return; + (*s_etat_processus).sections_critiques--; } + + depilement_pile_systeme(s_etat_processus); + } + + if ((*s_etat_processus).erreur_systeme != d_es) + { + return; } } } @@ -1526,215 +1451,114 @@ instruction_exit(struct_processus *s_eta return; } - if (recherche_variable(s_etat_processus, - (*s_etat_processus).instruction_courante) == d_vrai) + instruction_majuscule = conversion_majuscule(s_etat_processus, + (*s_etat_processus).instruction_courante); + + if (instruction_majuscule == NULL) { - instruction_majuscule = conversion_majuscule(""); + return; + } - if ((*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante] - .objet == NULL) + /* + * Traitement de la pile système par les + * différentes instructions. + */ + + if ((strcmp(instruction_majuscule, "IF") == 0) || + (strcmp(instruction_majuscule, "IFERR") == 0) || + (strcmp(instruction_majuscule, "DO") == 0) || + (strcmp(instruction_majuscule, "WHILE") == 0) || + (strcmp(instruction_majuscule, "FOR") == 0) || + (strcmp(instruction_majuscule, "FORALL") == 0) || + (strcmp(instruction_majuscule, "START") == 0) || + (strcmp(instruction_majuscule, "SELECT") == 0) + || (strcmp(instruction_majuscule, "CRITICAL") == 0) + || (strcmp(instruction_majuscule, "CASE") == 0) + || (strcmp(instruction_majuscule, "<<") == 0)) + { + if (strcmp(instruction_majuscule, "<<") == 0) { - if (pthread_mutex_lock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = - d_es_processus; - return; - } - - if (recherche_variable_partagee(s_etat_processus, - (*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante] - .nom, (*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante] - .variable_partagee, - (*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante] - .origine) == d_vrai) - { - if ((*((*s_etat_processus).s_liste_variables - [(*s_etat_processus) - .position_variable_courante]).objet).type - == ADR) - { - empilement_pile_systeme(s_etat_processus); - - if ((*s_etat_processus).erreur_systeme != d_es) - { - if (pthread_mutex_unlock( - &((*(*s_etat_processus) - .s_liste_variables_partagees) - .mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = - d_es_processus; - return; - } - - return; - } - - (*(*s_etat_processus).l_base_pile_systeme) - .adresse_retour = - (*s_etat_processus).position_courante; - - (*(*s_etat_processus).l_base_pile_systeme) - .retour_definition = 'Y'; - (*(*s_etat_processus).l_base_pile_systeme) - .niveau_courant = - (*s_etat_processus).niveau_courant; - - (*s_etat_processus).position_courante = - (*((unsigned long *) - ((*((*s_etat_processus) - .s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet)) - .objet))); - - (*s_etat_processus) - .autorisation_empilement_programme - = 'N'; - } - } - else - { - (*s_etat_processus).erreur_systeme = d_es; - } - - if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = - d_es_processus; - return; - } + analyse(s_etat_processus, NULL); } else { - if ((*((*s_etat_processus).s_liste_variables - [(*s_etat_processus) - .position_variable_courante]).objet).type - == ADR) + if ((strcmp(instruction_majuscule, "DO") == 0) || + (strcmp(instruction_majuscule, "WHILE") + == 0)) { - empilement_pile_systeme(s_etat_processus); + niveau++; + } - if ((*s_etat_processus).erreur_systeme != d_es) - { - return; - } + empilement_pile_systeme(s_etat_processus); - (*(*s_etat_processus).l_base_pile_systeme) - .adresse_retour = - (*s_etat_processus).position_courante; - - (*(*s_etat_processus).l_base_pile_systeme) - .retour_definition = 'Y'; - (*(*s_etat_processus).l_base_pile_systeme) - .niveau_courant = - (*s_etat_processus).niveau_courant; - - (*s_etat_processus).position_courante = - (*((unsigned long *) ((*((*s_etat_processus) - .s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet)) - .objet))); - - (*s_etat_processus) - .autorisation_empilement_programme - = 'N'; + if ((*s_etat_processus).erreur_systeme != d_es) + { + return; } } } - else + else if ((strcmp(instruction_majuscule, "END") == 0) || + (strcmp(instruction_majuscule, "NEXT") == 0) || + (strcmp(instruction_majuscule, "STEP") == 0) || + (strcmp(instruction_majuscule, ">>") == 0)) { - (*s_etat_processus).erreur_systeme = d_es; - instruction_majuscule = conversion_majuscule( - (*s_etat_processus).instruction_courante); - - if (instruction_majuscule == NULL) + if (strcmp(instruction_majuscule, ">>") == 0) { - return; - } + analyse(s_etat_processus, NULL); - /* - * Traitement de la pile système par les - * différentes instructions. - */ - - if ((strcmp(instruction_majuscule, "IF") == 0) || - (strcmp(instruction_majuscule, "IFERR") == 0) || - (strcmp(instruction_majuscule, "DO") == 0) || - (strcmp(instruction_majuscule, "WHILE") == 0) || - (strcmp(instruction_majuscule, "FOR") == 0) || - (strcmp(instruction_majuscule, "START") == 0) || - (strcmp(instruction_majuscule, "SELECT") == 0) - || (strcmp(instruction_majuscule, "CASE") == 0) - || (strcmp(instruction_majuscule, "<<") == 0)) - { - if (strcmp(instruction_majuscule, "<<") == 0) - { - analyse(s_etat_processus, NULL); - } - else + if ((*s_etat_processus).retour_routine_evaluation + == 'Y') { - if ((strcmp(instruction_majuscule, "DO") == 0) || - (strcmp(instruction_majuscule, "WHILE") - == 0)) - { - niveau++; - } + drapeau_presence_fin_boucle = d_faux; + free((*s_etat_processus).instruction_courante); - empilement_pile_systeme(s_etat_processus); - - if ((*s_etat_processus).erreur_systeme != d_es) - { - return; - } + break; } } - else if ((strcmp(instruction_majuscule, "END") == 0) || - (strcmp(instruction_majuscule, "NEXT") == 0) || - (strcmp(instruction_majuscule, "STEP") == 0) || - (strcmp(instruction_majuscule, ">>") == 0)) + else { - if (strcmp(instruction_majuscule, ">>") == 0) + if (strcmp(instruction_majuscule, "END") == 0) { - analyse(s_etat_processus, NULL); - - if ((*s_etat_processus).retour_routine_evaluation - == 'Y') + if (((*(*s_etat_processus).l_base_pile_systeme) + .type_cloture == 'D') || + ((*(*s_etat_processus) + .l_base_pile_systeme).type_cloture + == 'W')) { - drapeau_presence_fin_boucle = d_faux; - free((*s_etat_processus).instruction_courante); - - break; + niveau--; } + + depilement_pile_systeme(s_etat_processus); } else { - if (strcmp(instruction_majuscule, "END") == 0) + if ((*s_etat_processus).l_base_pile_systeme == NULL) + { + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; + } + + if ((*(*s_etat_processus).l_base_pile_systeme) + .type_cloture == 'Q') { - if (((*(*s_etat_processus).l_base_pile_systeme) - .type_cloture == 'D') || - ((*(*s_etat_processus) - .l_base_pile_systeme).type_cloture - == 'W')) + if (pthread_mutex_unlock( + &mutex_sections_critiques) != 0) { - niveau--; + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; } - depilement_pile_systeme(s_etat_processus); - } - else - { - depilement_pile_systeme(s_etat_processus); + (*s_etat_processus).sections_critiques--; } - if ((*s_etat_processus).erreur_systeme != d_es) - { - return; - } + depilement_pile_systeme(s_etat_processus); + } + + if ((*s_etat_processus).erreur_systeme != d_es) + { + return; } } } @@ -1789,9 +1613,11 @@ instruction_exit(struct_processus *s_eta (fonction == instruction_do) || (fonction == instruction_while) || (fonction == instruction_for) || + (fonction == instruction_forall) || (fonction == instruction_start) || (fonction == instruction_select) || (fonction == instruction_case) || + (fonction == instruction_critical) || (fonction == instruction_vers_niveau_superieur)) { if (fonction == instruction_vers_niveau_superieur) @@ -1802,6 +1628,7 @@ instruction_exit(struct_processus *s_eta else { if ((fonction == instruction_for) || + (fonction == instruction_forall) || (fonction == instruction_start)) { niveau++; @@ -1850,6 +1677,27 @@ instruction_exit(struct_processus *s_eta } else { + if ((*s_etat_processus).l_base_pile_systeme == NULL) + { + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; + } + + if ((*(*s_etat_processus).l_base_pile_systeme) + .type_cloture == 'Q') + { + if (pthread_mutex_unlock( + &mutex_sections_critiques) != 0) + { + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; + } + + (*s_etat_processus).sections_critiques--; + } + depilement_pile_systeme(s_etat_processus); } @@ -1890,8 +1738,10 @@ instruction_exit(struct_processus *s_eta (fonction == instruction_do) || (fonction == instruction_while) || (fonction == instruction_for) || + (fonction == instruction_forall) || (fonction == instruction_start) || (fonction == instruction_select) || + (fonction == instruction_critical) || (fonction == instruction_case) || (fonction == instruction_vers_niveau_superieur)) { @@ -1948,6 +1798,27 @@ instruction_exit(struct_processus *s_eta } else { + if ((*s_etat_processus).l_base_pile_systeme == NULL) + { + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; + } + + if ((*(*s_etat_processus).l_base_pile_systeme) + .type_cloture == 'Q') + { + if (pthread_mutex_unlock( + &mutex_sections_critiques) != 0) + { + (*s_etat_processus).erreur_systeme = + d_es_processus; + return; + } + + (*s_etat_processus).sections_critiques--; + } + depilement_pile_systeme(s_etat_processus); } @@ -1976,8 +1847,9 @@ instruction_exit(struct_processus *s_eta if ((drapeau_boucle_definie == d_vrai) && (drapeau_presence_fin_boucle == d_vrai)) { - presence_compteur = ((*(*s_etat_processus).l_base_pile_systeme) - .type_cloture == 'F') ? d_vrai : d_faux; + presence_compteur = (((*(*s_etat_processus).l_base_pile_systeme) + .type_cloture == 'F') || ((*(*s_etat_processus) + .l_base_pile_systeme).type_cloture == 'A')) ? d_vrai : d_faux; if (((*(*s_etat_processus).l_base_pile_systeme).type_cloture != 'S') && (presence_compteur == d_faux)) @@ -1999,7 +1871,7 @@ instruction_exit(struct_processus *s_eta (*(*s_etat_processus).l_base_pile_systeme).indice_boucle = NULL; (*s_etat_processus).niveau_courant--; - if (retrait_variable_par_niveau(s_etat_processus) == d_erreur) + if (retrait_variables_par_niveau(s_etat_processus) == d_erreur) { return; }