--- rpl/src/instructions_g2.c 2016/03/01 22:12:31 1.59 +++ rpl/src/instructions_g2.c 2020/01/10 11:15:45 1.73 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.25 - Copyright (C) 1989-2016 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. @@ -35,6 +35,14 @@ ================================================================================ */ +static int +fonction_comparaison(const void *argument_1, const void *argument_2) +{ + return(strcmp((unsigned char *) argument_1, + (unsigned char *) (**((struct_objet **) argument_2)).objet)); +} + + void instruction_get(struct_processus *s_etat_processus) { @@ -42,10 +50,12 @@ instruction_get(struct_processus *s_etat struct_liste_chainee *l_element_courant; + struct_objet **s_enregistrement; struct_objet *s_objet_1; struct_objet *s_objet_2; struct_objet *s_objet_3; struct_objet *s_objet_element; + struct_objet *s_objet_noms; struct_objet *s_objet_resultat; integer8 indice_i; @@ -85,10 +95,21 @@ instruction_get(struct_processus *s_etat " %s, %s, %s, %s, %s,\n" " %s, %s, %s, %s, %s,\n" " %s, %s, %s, %s,\n" - " %s, %s\n\n", + " %s, %s, %s\n\n", d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX, d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK, - d_SQL, d_SLB, d_PRC, d_MTX); + d_SQL, d_SLB, d_PRC, d_MTX, d_REC); + + printf(" 2: %s\n", d_REC); + printf(" 1: %s\n", d_CHN); + printf("-> 1: %s, %s, %s, %s, %s, %s,\n" + " %s, %s, %s, %s, %s,\n" + " %s, %s, %s, %s, %s,\n" + " %s, %s, %s, %s,\n" + " %s, %s, %s\n\n", + d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX, + d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK, + d_SQL, d_SLB, d_PRC, d_MTX, d_REC); printf(" 2: %s, %s\n", d_LST, d_NOM); printf(" 1: %s\n", d_INT); @@ -96,10 +117,10 @@ instruction_get(struct_processus *s_etat " %s, %s, %s, %s, %s,\n" " %s, %s, %s, %s, %s,\n" " %s, %s, %s, %s,\n" - " %s, %s\n", + " %s, %s, %s\n", d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX, d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK, - d_SQL, d_SLB, d_PRC, d_MTX); + d_SQL, d_SLB, d_PRC, d_MTX, d_REC); return; } @@ -519,6 +540,52 @@ instruction_get(struct_processus *s_etat /* -------------------------------------------------------------------------------- + Traitement des enregistrements +-------------------------------------------------------------------------------- +*/ + + else if ((*s_objet_2).type == REC) + { + if ((*s_objet_1).type != CHN) + { + liberation(s_etat_processus, s_objet_1); + liberation(s_etat_processus, s_objet_2); + + (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; + return; + } + + s_objet_noms = (*((struct_record *) (*s_objet_2).objet)).noms; + + if ((s_enregistrement = bsearch((unsigned char *) (*s_objet_1).objet, + (*((struct_tableau *) (*s_objet_noms).objet)).elements, + (size_t) (*((struct_tableau *) (*s_objet_noms).objet)) + .nombre_elements, sizeof(struct_objet *), fonction_comparaison)) + == NULL) + { + liberation(s_etat_processus, s_objet_1); + liberation(s_etat_processus, s_objet_2); + + (*s_etat_processus).erreur_execution = d_ex_element_inexistant; + return; + } + + indice_i = s_enregistrement - (*((struct_tableau *) + (*s_objet_noms).objet)).elements; + + // Récupération de l'objet dans le tableau données + + if ((s_objet_resultat = copie_objet(s_etat_processus, + (*((struct_tableau *) (*(*((struct_record *) + (*s_objet_2).objet)).donnees).objet)).elements[indice_i], 'P')) + == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + } +/* +-------------------------------------------------------------------------------- Traitement des variables -------------------------------------------------------------------------------- */ @@ -1195,6 +1262,78 @@ instruction_get(struct_processus *s_etat return; } } + else if ((*s_objet_3).type == REC) + { + if ((*s_objet_1).type != CHN) + { + if (variable_partagee == d_vrai) + { + if (pthread_mutex_unlock(&((*(*s_etat_processus) + .pointeur_variable_partagee_courante).mutex)) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + } + + liberation(s_etat_processus, s_objet_1); + liberation(s_etat_processus, s_objet_2); + + (*s_etat_processus).erreur_execution = + d_ex_erreur_type_argument; + return; + } + + s_objet_noms = (*((struct_record *) (*s_objet_3).objet)).noms; + + if ((s_enregistrement = bsearch((unsigned char *) + (*s_objet_1).objet, (*((struct_tableau *) + (*s_objet_noms).objet)).elements, + (size_t) (*((struct_tableau *) (*s_objet_noms).objet)) + .nombre_elements, sizeof(struct_objet *), + fonction_comparaison)) == NULL) + { + if (variable_partagee == d_vrai) + { + if (pthread_mutex_unlock(&((*(*s_etat_processus) + .pointeur_variable_partagee_courante).mutex)) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + } + + liberation(s_etat_processus, s_objet_1); + liberation(s_etat_processus, s_objet_2); + + (*s_etat_processus).erreur_execution = d_ex_element_inexistant; + return; + } + + indice_i = s_enregistrement - (*((struct_tableau *) + (*s_objet_noms).objet)).elements; + + // Récupération de l'objet dans le tableau données + + if ((s_objet_resultat = copie_objet(s_etat_processus, + (*((struct_tableau *) (*(*((struct_record *) + (*s_objet_3).objet)).donnees).objet)).elements[indice_i], + 'P')) == NULL) + { + if (variable_partagee == d_vrai) + { + if (pthread_mutex_unlock(&((*(*s_etat_processus) + .pointeur_variable_partagee_courante).mutex)) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + } + + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + } else { if (variable_partagee == d_vrai) @@ -1384,10 +1523,10 @@ instruction_geti(struct_processus *s_eta " %s, %s, %s, %s, %s,\n" " %s, %s, %s, %s, %s,\n" " %s, %s, %s, %s,\n" - " %s, %s\n", + " %s, %s, %s\n", d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX, d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK, - d_SQL, d_SLB, d_PRC, d_MTX); + d_SQL, d_SLB, d_PRC, d_MTX, d_REC); return; }