/* ================================================================================ RPL/2 (R) version 4.1.32 Copyright (C) 1989-2020 Dr. BERTRAND Joël This file is part of RPL/2. RPL/2 is free software; you can redistribute it and/or modify it under the terms of the CeCILL V2 License as published by the french CEA, CNRS and INRIA. RPL/2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License for more details. You should have received a copy of the CeCILL License along with RPL/2. If not, write to info@cecill.info. ================================================================================ */ #include "rpl-conv.h" /* ================================================================================ Fonction 'r->d' ================================================================================ Entrées : pointeur sur une structure struct_processus -------------------------------------------------------------------------------- Sorties : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ void instruction_r_vers_d(struct_processus *s_etat_processus) { struct_liste_chainee *l_element_courant; struct_liste_chainee *l_element_precedent; struct_objet *s_copie_argument; struct_objet *s_objet_argument; struct_objet *s_objet_resultat; if ((*s_etat_processus).affichage_arguments == 'Y') { printf("\n R->D "); if ((*s_etat_processus).langue == 'F') { printf("(radians vers degrés)\n\n"); } else { printf("(radians to degrees)\n\n"); } printf(" 1: %s, %s\n", d_INT, d_REL); printf("-> 1: %s\n\n", d_REL); printf(" 1: %s, %s\n", d_NOM, d_ALG); printf("-> 1: %s\n\n", d_ALG); printf(" 1: %s\n", d_RPN); printf("-> 1: %s\n", d_RPN); return; } else if ((*s_etat_processus).test_instruction == 'Y') { (*s_etat_processus).nombre_arguments = -1; return; } if (test_cfsf(s_etat_processus, 31) == d_vrai) { if (empilement_pile_last(s_etat_processus, 1) == d_erreur) { return; } } if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), &s_objet_argument) == d_erreur) { (*s_etat_processus).erreur_execution = d_ex_manque_argument; return; } /* -------------------------------------------------------------------------------- Conversion d'un entier ou d'un réel -------------------------------------------------------------------------------- */ if (((*s_objet_argument).type == INT) || ((*s_objet_argument).type == REL)) { if ((s_objet_resultat = allocation(s_etat_processus, REL)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } if ((*s_objet_argument).type == INT) { (*((real8 *) (*s_objet_resultat).objet)) = (real8) (*((integer8 *) (*s_objet_argument).objet)); } else { (*((real8 *) (*s_objet_resultat).objet)) = (*((real8 *) (*s_objet_argument).objet)); } conversion_radians_vers_degres((real8 *) (*s_objet_resultat).objet); } /* -------------------------------------------------------------------------------- Conversion d'un nom -------------------------------------------------------------------------------- */ else if ((*s_objet_argument).type == NOM) { if ((s_objet_resultat = allocation(s_etat_processus, ALG)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } if (((*s_objet_resultat).objet = allocation_maillon(s_etat_processus)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } l_element_courant = (*s_objet_resultat).objet; if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .nombre_arguments = 0; (*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .fonction = instruction_vers_niveau_superieur; if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .nom_fonction, "<<"); if (((*l_element_courant).suivant = allocation_maillon(s_etat_processus)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } l_element_courant = (*l_element_courant).suivant; (*l_element_courant).donnee = s_objet_argument; if (((*l_element_courant).suivant = allocation_maillon(s_etat_processus)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } l_element_courant = (*l_element_courant).suivant; if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .nombre_arguments = 1; (*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .fonction = instruction_r_vers_d; if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .nom_fonction = malloc(5 * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .nom_fonction, "R->D"); if (((*l_element_courant).suivant = allocation_maillon(s_etat_processus)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } l_element_courant = (*l_element_courant).suivant; if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .nombre_arguments = 0; (*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .fonction = instruction_vers_niveau_inferieur; if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet)) .nom_fonction, ">>"); (*l_element_courant).suivant = NULL; s_objet_argument = NULL; } /* -------------------------------------------------------------------------------- Conversion d'une expression -------------------------------------------------------------------------------- */ else if (((*s_objet_argument).type == ALG) || ((*s_objet_argument).type == RPN)) { if ((s_copie_argument = copie_objet(s_etat_processus, s_objet_argument, 'N')) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } l_element_courant = (struct_liste_chainee *) (*s_copie_argument).objet; l_element_precedent = l_element_courant; while((*l_element_courant).suivant != NULL) { l_element_precedent = l_element_courant; l_element_courant = (*l_element_courant).suivant; } if (((*l_element_precedent).suivant = allocation_maillon(s_etat_processus)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } if (((*(*l_element_precedent).suivant).donnee = allocation(s_etat_processus, FCT)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } (*((struct_fonction *) (*(*(*l_element_precedent).suivant) .donnee).objet)).nombre_arguments = 1; (*((struct_fonction *) (*(*(*l_element_precedent).suivant) .donnee).objet)).fonction = instruction_r_vers_d; if (((*((struct_fonction *) (*(*(*l_element_precedent) .suivant).donnee).objet)).nom_fonction = malloc(5 * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } strcpy((*((struct_fonction *) (*(*(*l_element_precedent) .suivant).donnee).objet)).nom_fonction, "R->D"); (*(*l_element_precedent).suivant).suivant = l_element_courant; s_objet_resultat = s_copie_argument; } /* -------------------------------------------------------------------------------- Réalisation impossible de la fonction R->D -------------------------------------------------------------------------------- */ else { liberation(s_etat_processus, s_objet_argument); (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; return; } liberation(s_etat_processus, s_objet_argument); if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), s_objet_resultat) == d_erreur) { return; } return; } /* ================================================================================ Fonction 'return' ================================================================================ Entrées : pointeur sur une structure struct_processus -------------------------------------------------------------------------------- Sorties : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ void instruction_return(struct_processus *s_etat_processus) { logical1 erreur; logical1 fin_boucle; logical1 fin_scrutation; logical1 presence_compteur; unsigned char *instruction_majuscule; unsigned char *tampon; integer8 registre_position_courante; struct_liste_chainee *tampon_expression; void (*fonction)(); (*s_etat_processus).erreur_execution = d_ex; if ((*s_etat_processus).affichage_arguments == 'Y') { printf("\n RETURN "); if ((*s_etat_processus).langue == 'F') { printf("(retour d'une routine)\n\n"); printf(" Aucun argument\n"); } else { printf("(return from a routine)\n\n"); printf(" No argument\n"); } return; } else if ((*s_etat_processus).test_instruction == 'Y') { (*s_etat_processus).nombre_arguments = -1; return; } if ((*s_etat_processus).niveau_courant == ((*s_etat_processus) .niveau_initial + 1)) { /* * On ne peut rien dépiler ! */ if ((*s_etat_processus).mode_execution_programme == 'Y') { (*s_etat_processus).requete_arret = 'Y'; } return; } tampon = (*s_etat_processus).instruction_courante; tampon_expression = (*s_etat_processus).expression_courante; fin_boucle = d_faux; if ((*s_etat_processus).mode_execution_programme == 'Y') { while(fin_boucle == d_faux) { erreur = recherche_instruction_suivante(s_etat_processus); if (erreur == d_erreur) { return; } if (recherche_variable(s_etat_processus, (*s_etat_processus).instruction_courante) == d_faux) { (*s_etat_processus).erreur_systeme = d_es; instruction_majuscule = conversion_majuscule(s_etat_processus, (*s_etat_processus).instruction_courante); if (instruction_majuscule == NULL) { return; } /* * 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) { analyse(s_etat_processus, NULL); } else if ((strcmp(instruction_majuscule, "FOR") == 0) || (strcmp(instruction_majuscule, "FORALL") == 0) || (strcmp(instruction_majuscule, "START") == 0)) { empilement_pile_systeme(s_etat_processus); if ((*s_etat_processus).erreur_systeme != d_es) { return; } (*(*s_etat_processus).l_base_pile_systeme) .type_cloture = 'L'; } else { /* * Si on passe sur un début de boucle FOR ou START, * les champs de la pile système sont initialisés à * NULL, ce qui permet de les libérer de façon correcte * lors du dépilement. */ empilement_pile_systeme(s_etat_processus); if ((*s_etat_processus).erreur_systeme != d_es) { return; } } } else if ((strcmp(instruction_majuscule, "END") == 0) || (strcmp(instruction_majuscule, "NEXT") == 0) || (strcmp(instruction_majuscule, "STEP") == 0) || (strcmp(instruction_majuscule, ">>") == 0)) { if (strcmp(instruction_majuscule, ">>") == 0) { registre_position_courante = (*s_etat_processus) .position_courante; analyse(s_etat_processus, NULL); fin_boucle = ((registre_position_courante != (*s_etat_processus).position_courante) || ((*s_etat_processus).retour_routine_evaluation == 'Y')) ? d_vrai : d_faux; if (fin_boucle == d_faux) { if ((*s_etat_processus).niveau_courant == (*s_etat_processus).niveau_initial) { fin_boucle = d_vrai; } } } else if (((strcmp(instruction_majuscule, "NEXT") == 0) || (strcmp(instruction_majuscule, "STEP") == 0)) && ((*(*s_etat_processus).l_base_pile_systeme) .type_cloture != 'L')) { /* * Libération des compteurs de boucle. */ 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)) { (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle; return; } if (presence_compteur == d_vrai) { if (recherche_variable(s_etat_processus, (*(*s_etat_processus).l_base_pile_systeme) .nom_variable) == d_faux) { (*s_etat_processus).erreur_systeme = d_es; (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle; return; } if ((*(*s_etat_processus) .pointeur_variable_courante).objet == NULL) { (*s_etat_processus).erreur_systeme = d_es; (*s_etat_processus).erreur_execution = d_ex_variable_partagee; return; } (*s_etat_processus).niveau_courant--; if (retrait_variables_par_niveau( s_etat_processus) == d_erreur) { return; } } depilement_pile_systeme(s_etat_processus); if ((*s_etat_processus).erreur_systeme != d_es) { return; } } 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); if ((*s_etat_processus).erreur_systeme != d_es) { return; } } } free(instruction_majuscule); } free((*s_etat_processus).instruction_courante); } } else { while(fin_boucle == d_faux) { if ((*s_etat_processus).expression_courante == NULL) { (*s_etat_processus).expression_courante = tampon_expression; (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle; return; } (*s_etat_processus).expression_courante = (*(*s_etat_processus).expression_courante).suivant; if ((*s_etat_processus).expression_courante == NULL) { (*s_etat_processus).expression_courante = tampon_expression; (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle; return; } fin_scrutation = d_faux; do { while((*(*(*s_etat_processus).expression_courante) .donnee).type != FCT) { (*s_etat_processus).expression_courante = (*(*s_etat_processus).expression_courante).suivant; if ((*s_etat_processus).expression_courante == NULL) { (*s_etat_processus).expression_courante = tampon_expression; (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle; return; } } if ((*((struct_fonction *) (*(*(*s_etat_processus) .expression_courante).donnee).objet)) .nombre_arguments != 0) { (*s_etat_processus).expression_courante = (*(*s_etat_processus).expression_courante).suivant; if ((*s_etat_processus).expression_courante == NULL) { (*s_etat_processus).expression_courante = tampon_expression; (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle; return; } } else { fin_scrutation = d_vrai; tampon_expression = (*s_etat_processus).expression_courante; } } while(fin_scrutation == d_faux); fonction = (*((struct_fonction *) (*(*(*s_etat_processus) .expression_courante).donnee).objet)).fonction; /* * Traitement de la pile système par les différentes * instructions. */ if ((fonction == instruction_if) || (fonction == instruction_iferr) || (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)) { if (fonction == instruction_vers_niveau_superieur) { analyse(s_etat_processus, instruction_vers_niveau_superieur); } else if ((fonction == instruction_for) || (fonction == instruction_forall) || (fonction == instruction_start)) { empilement_pile_systeme(s_etat_processus); if ((*s_etat_processus).erreur_systeme != d_es) { return; } (*(*s_etat_processus).l_base_pile_systeme) .type_cloture = 'L'; } else { /* * Si on passe sur un début de boucle FOR ou START, * les champs de la pile système sont initialisés à * NULL, ce qui permet de les libérer de façon correcte * lors du dépilement. */ empilement_pile_systeme(s_etat_processus); if ((*s_etat_processus).erreur_systeme != d_es) { return; } } } else if ((fonction == instruction_end) || (fonction == instruction_next) || (fonction == instruction_step) || (fonction == instruction_vers_niveau_inferieur)) { if (fonction == instruction_vers_niveau_inferieur) { analyse(s_etat_processus, instruction_vers_niveau_inferieur); fin_boucle = ((*(*s_etat_processus) .expression_courante).suivant == NULL) ? d_vrai : d_faux; if (fin_boucle == d_faux) { if ((*s_etat_processus).niveau_courant == (*s_etat_processus).niveau_initial) { fin_boucle = d_vrai; } } } else if (((fonction == instruction_next) || (fonction == instruction_step)) && ((*(*s_etat_processus).l_base_pile_systeme) .type_cloture != 'L')) { /* * Libération des compteurs de boucle. */ 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)) { (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle; return; } if (presence_compteur == d_vrai) { if (recherche_variable(s_etat_processus, (*(*s_etat_processus).l_base_pile_systeme) .nom_variable) == d_faux) { (*s_etat_processus).erreur_systeme = d_es; (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle; return; } if ((*(*s_etat_processus).pointeur_variable_courante) .objet == NULL) { (*s_etat_processus).erreur_systeme = d_es; (*s_etat_processus).erreur_execution = d_ex_variable_partagee; return; } (*s_etat_processus).niveau_courant--; if (retrait_variables_par_niveau(s_etat_processus) == d_erreur) { return; } } depilement_pile_systeme(s_etat_processus); } 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); if ((*s_etat_processus).erreur_systeme != d_es) { return; } } } } } if ((*s_etat_processus).mode_execution_programme != 'Y') { if ((*s_etat_processus).expression_courante == NULL) { (*s_etat_processus).expression_courante = tampon_expression; (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle; return; } (*s_etat_processus).expression_courante = (*(*s_etat_processus).expression_courante).suivant; } (*s_etat_processus).instruction_courante = tampon; (*s_etat_processus).expression_courante = tampon_expression; return; } /* ================================================================================ Fonction 'rdm' ================================================================================ Entrées : pointeur sur une structure struct_processus -------------------------------------------------------------------------------- Sorties : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ void instruction_rdm(struct_processus *s_etat_processus) { struct_liste_chainee *l_element_courant; struct_objet *s_objet_dimensions; struct_objet *s_objet_initial; struct_objet *s_objet_redimensionne; logical1 argument_nom; logical1 drapeau_fin_objet_originel; logical1 variable_partagee; integer8 i; integer8 j; integer8 k; integer8 l; integer8 nombre_colonnes; integer8 nombre_dimensions; integer8 nombre_lignes; (*s_etat_processus).erreur_execution = d_ex; if ((*s_etat_processus).affichage_arguments == 'Y') { printf("\n RDM "); if ((*s_etat_processus).langue == 'F') { printf("(redimensionnement)\n\n"); } else { printf("(resizing)\n\n"); } printf(" 2: %s, %s, %s, %s, %s, %s, %s\n", d_NOM, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX); printf(" 1: %s\n", d_LST); printf("-> 1: %s, %s, %s, %s, %s, %s\n", d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX); return; } else if ((*s_etat_processus).test_instruction == 'Y') { (*s_etat_processus).nombre_arguments = -1; return; } if (test_cfsf(s_etat_processus, 31) == d_vrai) { if (empilement_pile_last(s_etat_processus, 2) == d_erreur) { return; } } if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), &s_objet_dimensions) == d_erreur) { (*s_etat_processus).erreur_execution = d_ex_manque_argument; return; } if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), &s_objet_initial) == d_erreur) { liberation(s_etat_processus, s_objet_dimensions); (*s_etat_processus).erreur_execution = d_ex_manque_argument; return; } variable_partagee = d_faux; if ((*s_objet_initial).type == NOM) { argument_nom = d_vrai; if (recherche_variable(s_etat_processus, (*((struct_nom *) (*s_objet_initial).objet)).nom) == d_faux) { (*s_etat_processus).erreur_systeme = d_es; (*s_etat_processus).erreur_execution = d_ex_variable_non_definie; liberation(s_etat_processus, s_objet_initial); liberation(s_etat_processus, s_objet_dimensions); return; } liberation(s_etat_processus, s_objet_initial); if ((*(*s_etat_processus).pointeur_variable_courante) .variable_verrouillee == d_vrai) { (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee; liberation(s_etat_processus, s_objet_dimensions); return; } s_objet_initial = (*(*s_etat_processus).pointeur_variable_courante) .objet; if (s_objet_initial == NULL) { if (recherche_variable_partagee(s_etat_processus, (*(*s_etat_processus).pointeur_variable_courante).nom, (*(*s_etat_processus).pointeur_variable_courante) .variable_partagee, (*(*s_etat_processus) .pointeur_variable_courante).origine) == NULL) { (*s_etat_processus).erreur_systeme = d_es; (*s_etat_processus).erreur_execution = d_ex_variable_non_definie; liberation(s_etat_processus, s_objet_dimensions); return; } variable_partagee = d_vrai; } } else { argument_nom = d_faux; } if ((*s_objet_dimensions).type != LST) { 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_dimensions); if (argument_nom == d_faux) { liberation(s_etat_processus, s_objet_initial); } (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; return; } l_element_courant = (*s_objet_dimensions).objet; nombre_dimensions = 0; while(l_element_courant != NULL) { nombre_dimensions++; l_element_courant = (*l_element_courant).suivant; } if ((nombre_dimensions != 1) && (nombre_dimensions != 2)) { 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_dimensions); if (argument_nom == d_faux) { liberation(s_etat_processus, s_objet_initial); } (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides; return; } nombre_colonnes = 0; nombre_lignes = 0; l_element_courant = (*s_objet_dimensions).objet; while(l_element_courant != NULL) { if ((*(*l_element_courant).donnee).type != INT) { 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_dimensions); if (argument_nom == d_faux) { liberation(s_etat_processus, s_objet_initial); } (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; return; } if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0) { 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_dimensions); if (argument_nom == d_faux) { liberation(s_etat_processus, s_objet_initial); } (*s_etat_processus).erreur_execution = d_ex_argument_invalide; return; } if (nombre_lignes == 0) { nombre_lignes = (*((integer8 *) (*(*l_element_courant).donnee).objet)); } else { nombre_colonnes = (*((integer8 *) (*(*l_element_courant).donnee).objet)); } l_element_courant = (*l_element_courant).suivant; } if ((s_objet_redimensionne = allocation(s_etat_processus, NON)) == 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; } /* -------------------------------------------------------------------------------- Redimensionnement aboutissant à un vecteur -------------------------------------------------------------------------------- */ if (nombre_dimensions == 1) { if ((*s_objet_initial).type == VIN) { (*s_objet_redimensionne).type = VIN; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_vecteur))) == 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; } (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'I'; (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille = nombre_lignes; if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(integer8))) == 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; } for(i = 0; i < nombre_lignes; i++) { if (i < (*((struct_vecteur *) (*s_objet_initial).objet)).taille) { ((integer8 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] = ((integer8 *) (*((struct_vecteur *) (*s_objet_initial).objet)).tableau)[i]; } else { ((integer8 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] = 0; } } } else if ((*s_objet_initial).type == VRL) { (*s_objet_redimensionne).type = VRL; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_vecteur))) == 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; } (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'R'; (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille = nombre_lignes; if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(real8))) == 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; } for(i = 0; i < nombre_lignes; i++) { if (i < (*((struct_vecteur *) (*s_objet_initial).objet)).taille) { ((real8 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] = ((real8 *) (*((struct_vecteur *) (*s_objet_initial).objet)).tableau)[i]; } else { ((real8 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] = (real8) 0; } } } else if ((*s_objet_initial).type == VCX) { (*s_objet_redimensionne).type = VCX; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_vecteur))) == 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; } (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'C'; (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille = nombre_lignes; if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(struct_complexe16))) == 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; } for(i = 0; i < nombre_lignes; i++) { if (i < (*((struct_vecteur *) (*s_objet_initial).objet)).taille) { ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] .partie_reelle = ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_initial).objet)) .tableau)[i].partie_reelle; ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] .partie_imaginaire = ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_initial).objet)) .tableau)[i].partie_imaginaire; } else { ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] .partie_reelle = (real8) 0; ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] .partie_imaginaire = (real8) 0; } } } else if ((*s_objet_initial).type == MIN) { (*s_objet_redimensionne).type = VIN; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_vecteur))) == 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; } (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'I'; (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille = nombre_lignes; if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(integer8))) == 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; } drapeau_fin_objet_originel = d_faux; for(i = 0, j = 0, k = 0; i < nombre_lignes; i++) { if (drapeau_fin_objet_originel == d_faux) { ((integer8 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] = ((integer8 **) (*((struct_matrice *) (*s_objet_initial).objet)).tableau)[j][k]; if ((++k) >= (*((struct_matrice *) (*s_objet_initial) .objet)).nombre_colonnes) { k = 0; if ((++j) >= (*((struct_matrice *) (*s_objet_initial) .objet)).nombre_lignes) { drapeau_fin_objet_originel = d_vrai; } } } else { ((integer8 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] = 0; } } } else if ((*s_objet_initial).type == MRL) { (*s_objet_redimensionne).type = VRL; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_vecteur))) == 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; } (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'R'; (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille = nombre_lignes; if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(real8))) == 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; } drapeau_fin_objet_originel = d_faux; for(i = 0, j = 0, k = 0; i < nombre_lignes; i++) { if (drapeau_fin_objet_originel == d_faux) { ((real8 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] = ((real8 **) (*((struct_matrice *) (*s_objet_initial).objet)).tableau)[j][k]; if ((++k) >= (*((struct_matrice *) (*s_objet_initial) .objet)).nombre_colonnes) { k = 0; if ((++j) >= (*((struct_matrice *) (*s_objet_initial) .objet)).nombre_lignes) { drapeau_fin_objet_originel = d_vrai; } } } else { ((real8 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] = (real8) 0; } } } else if ((*s_objet_initial).type == MCX) { (*s_objet_redimensionne).type = VCX; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_vecteur))) == 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; } (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'C'; (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille = nombre_lignes; if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(struct_complexe16))) == 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; } drapeau_fin_objet_originel = d_faux; for(i = 0, j = 0, k = 0; i < nombre_lignes; i++) { if (drapeau_fin_objet_originel == d_faux) { ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] .partie_reelle = ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_initial).objet)) .tableau)[j][k].partie_reelle; ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] .partie_imaginaire = ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_initial).objet)) .tableau)[j][k].partie_imaginaire; if ((++k) >= (*((struct_matrice *) (*s_objet_initial) .objet)).nombre_colonnes) { k = 0; if ((++j) >= (*((struct_matrice *) (*s_objet_initial) .objet)).nombre_lignes) { drapeau_fin_objet_originel = d_vrai; } } } else { ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] .partie_reelle = 0; ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau)[i] .partie_imaginaire = 0; } } } else { 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; } } if (argument_nom == d_faux) { liberation(s_etat_processus, s_objet_initial); } liberation(s_etat_processus, s_objet_dimensions); free(s_objet_redimensionne); (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; return; } } /* -------------------------------------------------------------------------------- Redimensionnement aboutissant à une matrice -------------------------------------------------------------------------------- */ else { if ((*s_objet_initial).type == VIN) { (*s_objet_redimensionne).type = MIN; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_matrice))) == 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; } (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'I'; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_lignes = nombre_lignes; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_colonnes = nombre_colonnes; if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(integer8 *))) == 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; } for(i = 0, k = 0; i < nombre_lignes; i++) { if ((((integer8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau)[i] = malloc(((size_t) nombre_colonnes) * sizeof(integer8))) == 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; } for(j = 0; j < nombre_colonnes; j++) { if (k < (*((struct_vecteur *) (*s_objet_initial) .objet)).taille) { ((integer8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j] = ((integer8 *) (*((struct_vecteur *) (*s_objet_initial).objet)).tableau)[k++]; } else { ((integer8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j] = 0; } } } } else if ((*s_objet_initial).type == VRL) { (*s_objet_redimensionne).type = MRL; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_matrice))) == 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; } (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'R'; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_lignes = nombre_lignes; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_colonnes = nombre_colonnes; if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(real8 *))) == 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; } for(i = 0, k = 0; i < nombre_lignes; i++) { if ((((real8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau)[i] = malloc(((size_t) nombre_colonnes) * sizeof(real8))) == 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; } for(j = 0; j < nombre_colonnes; j++) { if (k < (*((struct_vecteur *) (*s_objet_initial) .objet)).taille) { ((real8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j] = ((real8 *) (*((struct_vecteur *) (*s_objet_initial).objet)).tableau)[k++]; } else { ((real8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j] = (real8) 0; } } } } else if ((*s_objet_initial).type == VCX) { (*s_objet_redimensionne).type = MCX; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_matrice))) == 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; } (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'C'; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_lignes = nombre_lignes; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_colonnes = nombre_colonnes; if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(struct_complexe16 *))) == 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; } for(i = 0, k = 0; i < nombre_lignes; i++) { if ((((struct_complexe16 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau)[i] = malloc(((size_t) nombre_colonnes) * sizeof(struct_complexe16))) == 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; } for(j = 0; j < nombre_colonnes; j++) { if (k < (*((struct_vecteur *) (*s_objet_initial) .objet)).taille) { ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j].partie_reelle = ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_initial).objet)).tableau)[k] .partie_reelle; ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j].partie_imaginaire = ((struct_complexe16 *) (*((struct_vecteur *) (*s_objet_initial).objet)).tableau)[k++] .partie_imaginaire; } else { ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j].partie_reelle = (real8) 0; ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j].partie_imaginaire = (real8) 0; } } } } else if ((*s_objet_initial).type == MIN) { (*s_objet_redimensionne).type = MIN; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_matrice))) == 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; } (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'I'; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_lignes = nombre_lignes; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_colonnes = nombre_colonnes; if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(integer8 *))) == 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; } drapeau_fin_objet_originel = d_faux; for(i = 0, k = 0, l = 0; i < nombre_lignes; i++) { if ((((integer8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau)[i] = malloc(((size_t) nombre_colonnes) * sizeof(integer8))) == 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; } for(j = 0; j < nombre_colonnes; j++) { if (drapeau_fin_objet_originel == d_faux) { ((integer8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j] = ((integer8 **) (*((struct_matrice *) (*s_objet_initial).objet)).tableau)[k][l]; if ((++l) >= (*((struct_matrice *) (*s_objet_initial) .objet)).nombre_colonnes) { l = 0; if ((++k) >= (*((struct_matrice *) (*s_objet_initial).objet)).nombre_lignes) { drapeau_fin_objet_originel = d_vrai; } } } else { ((integer8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j] = 0; } } } } else if ((*s_objet_initial).type == MRL) { (*s_objet_redimensionne).type = MRL; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_matrice))) == 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; } (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'R'; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_lignes = nombre_lignes; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_colonnes = nombre_colonnes; if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(real8 *))) == 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; } drapeau_fin_objet_originel = d_faux; for(i = 0, k = 0, l = 0; i < nombre_lignes; i++) { if ((((real8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau)[i] = malloc(((size_t) nombre_colonnes) * sizeof(real8))) == 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; } for(j = 0; j < nombre_colonnes; j++) { if (drapeau_fin_objet_originel == d_faux) { ((real8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j] = ((real8 **) (*((struct_matrice *) (*s_objet_initial).objet)).tableau)[k][l]; if ((++l) >= (*((struct_matrice *) (*s_objet_initial) .objet)).nombre_colonnes) { l = 0; if ((++k) >= (*((struct_matrice *) (*s_objet_initial).objet)).nombre_lignes) { drapeau_fin_objet_originel = d_vrai; } } } else { ((real8 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j] = (real8) 0; } } } } else if ((*s_objet_initial).type == MCX) { (*s_objet_redimensionne).type = MCX; if (((*s_objet_redimensionne).objet = malloc(sizeof(struct_matrice))) == 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; } (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'C'; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_lignes = nombre_lignes; (*((struct_matrice *) (*s_objet_redimensionne).objet)) .nombre_colonnes = nombre_colonnes; if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau = malloc(((size_t) nombre_lignes) * sizeof(struct_complexe16 *))) == 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; } drapeau_fin_objet_originel = d_faux; for(i = 0, k = 0, l = 0; i < nombre_lignes; i++) { if ((((struct_complexe16 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau)[i] = malloc(((size_t) nombre_colonnes) * sizeof(struct_complexe16))) == 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; } for(j = 0; j < nombre_colonnes; j++) { if (drapeau_fin_objet_originel == d_faux) { ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j].partie_reelle = ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_initial).objet)) .tableau)[k][l].partie_reelle; ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j].partie_imaginaire = ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_initial).objet)).tableau)[k][l] .partie_imaginaire; if ((++l) >= (*((struct_matrice *) (*s_objet_initial) .objet)).nombre_colonnes) { l = 0; if ((++k) >= (*((struct_matrice *) (*s_objet_initial).objet)).nombre_lignes) { drapeau_fin_objet_originel = d_vrai; } } } else { ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j].partie_reelle = (real8) 0; ((struct_complexe16 **) (*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau) [i][j].partie_imaginaire = (real8) 0; } } } } else { 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; } } if (argument_nom == d_faux) { liberation(s_etat_processus, s_objet_initial); } liberation(s_etat_processus, s_objet_dimensions); free(s_objet_redimensionne); (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; return; } } liberation(s_etat_processus, s_objet_dimensions); liberation(s_etat_processus, s_objet_initial); if (argument_nom == d_faux) { if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), s_objet_redimensionne) == d_erreur) { return; } } else { if (variable_partagee == d_vrai) { (*(*s_etat_processus).pointeur_variable_partagee_courante).objet = s_objet_redimensionne; if (pthread_mutex_unlock(&((*(*s_etat_processus) .pointeur_variable_partagee_courante).mutex)) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; } } else { (*(*s_etat_processus).pointeur_variable_courante).objet = s_objet_redimensionne; } } return; } // vim: ts=4