--- rpl/src/instructions_r7.c 2018/12/21 13:53:18 1.41 +++ rpl/src/instructions_r7.c 2018/12/21 14:38:06 1.42 @@ -716,6 +716,15 @@ instruction_rgdr(struct_processus *s_eta ================================================================================ */ +static int +fonction_comparaison(const void *argument_1, const void *argument_2) +{ + return(strcmp((unsigned char *) (**((struct_objet **) argument_1)) + .objet, (unsigned char *) (**((struct_objet **) argument_2)) + .objet)); +} + + void instruction_record(struct_processus *s_etat_processus) { @@ -770,6 +779,14 @@ instruction_record(struct_processus *s_e { // Vérification des noms + if ((*((struct_tableau *) (*s_objet_argument_1).objet)).nombre_elements + == 0) + { + (*s_etat_processus).erreur_execution = d_ex_nombre_arguments; + liberation(s_etat_processus, s_objet_argument_1); + return; + } + for(i = 0; i < (*((struct_tableau *) (*s_objet_argument_1).objet)) .nombre_elements; i++) { @@ -784,7 +801,33 @@ instruction_record(struct_processus *s_e } } - // Allocation de la table des données. + // Tri de la table des noms + + qsort((*((struct_tableau *) (*s_objet_argument_1).objet)).elements, + (size_t) (*((struct_tableau *) (*s_objet_argument_1).objet)) + .nombre_elements, sizeof(struct_objet *), + fonction_comparaison); + + // Vérification de l'unicité des noms + + for(i = 0; i < (*((struct_tableau *) (*s_objet_argument_1).objet)) + .nombre_elements - 1; i++) + { + if (strcmp((unsigned char *) (*(*((struct_tableau *) + (*s_objet_argument_1).objet)).elements[i]).objet, + (unsigned char *) (*(*((struct_tableau *) + (*s_objet_argument_1).objet)).elements[i + 1]).objet) + == 0) + { + (*s_etat_processus).erreur_execution = + d_ex_argument_invalide; + + liberation(s_etat_processus, s_objet_argument_1); + return; + } + } + + // Allocation de la table des données if ((s_objet_argument_2 = allocation(s_etat_processus, TBL)) == NULL) {