--- rpl/src/instructions_g2.c 2018/12/22 10:13:10 1.65 +++ rpl/src/instructions_g2.c 2020/01/10 11:15:45 1.73 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.29 - Copyright (C) 1989-2018 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. @@ -38,11 +38,7 @@ static int fonction_comparaison(const void *argument_1, const void *argument_2) { - /* - uprintf("%p->%s\n",(unsigned char *) (**((struct_objet **) argument_2)).objet, (unsigned char *) (**((struct_objet **) argument_2)).objet); - uprintf("%p->%s\n",(unsigned char *) (**((struct_objet **) argument_1)).objet, (unsigned char *) (**((struct_objet **) argument_1)).objet); - */ - return(strcmp((unsigned char *) (**((struct_objet **) argument_1)).objet, + return(strcmp((unsigned char *) argument_1, (unsigned char *) (**((struct_objet **) argument_2)).objet)); } @@ -54,6 +50,7 @@ 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; @@ -98,10 +95,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\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); @@ -109,10 +106,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\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, %s\n", d_LST, d_NOM); printf(" 1: %s\n", d_INT); @@ -120,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; } @@ -560,67 +557,32 @@ instruction_get(struct_processus *s_etat s_objet_noms = (*((struct_record *) (*s_objet_2).objet)).noms; - int i; - for(i = 0; i < (*((struct_tableau *) (*s_objet_noms).objet)).nombre_elements; uprintf("%d->%p (%s)\n", i, - (unsigned char *) (*(*((struct_tableau *) (*s_objet_noms).objet)).elements[i]).objet, - (unsigned char *) (*(*((struct_tableau *) (*s_objet_noms).objet)).elements[i]).objet), i++); - - s_objet_element = bsearch((unsigned char *) (*s_objet_1).objet, + 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); - - uprintf("%d\n", s_objet_element - (*((struct_tableau *) (*s_objet_2).objet)).elements[0]); - - /* - l_element_courant = (*s_objet_1).objet; - s_objet_element = s_objet_2; - - - while(l_element_courant != NULL) + .nombre_elements, sizeof(struct_objet *), fonction_comparaison)) + == NULL) { - if ((*(*l_element_courant).donnee).type != INT) - { - 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; - } - - if ((*s_objet_element).type != TBL) - { - liberation(s_etat_processus, s_objet_1); - liberation(s_etat_processus, s_objet_2); - - (*s_etat_processus).erreur_execution = d_ex_element_inexistant; - return; - } + liberation(s_etat_processus, s_objet_1); + liberation(s_etat_processus, s_objet_2); - indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet)); + (*s_etat_processus).erreur_execution = d_ex_element_inexistant; + return; + } - if ((indice_i < 1) || (indice_i > (*((struct_tableau *) - (*s_objet_element).objet)).nombre_elements)) - { - liberation(s_etat_processus, s_objet_1); - liberation(s_etat_processus, s_objet_2); + indice_i = s_enregistrement - (*((struct_tableau *) + (*s_objet_noms).objet)).elements; - (*s_etat_processus).erreur_execution = d_ex_element_inexistant; - return; - } + // Récupération de l'objet dans le tableau données - s_objet_element = (*((struct_tableau *) (*s_objet_element) - .objet)).elements[indice_i - 1]; - l_element_courant = (*l_element_courant).suivant; - } if ((s_objet_resultat = copie_objet(s_etat_processus, - s_objet_element, 'P')) == NULL) + (*((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; } - */ } /* -------------------------------------------------------------------------------- @@ -1300,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) @@ -1489,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; }