--- rpl/src/instructions_m3.c 2010/02/10 10:14:23 1.3 +++ rpl/src/instructions_m3.c 2020/01/10 11:15:46 1.67 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.11 - 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" /* @@ -38,15 +38,11 @@ void instruction_mean(struct_processus *s_etat_processus) { - logical1 presence_variable; - - long i; - struct_objet *s_objet_statistique; struct_objet *s_objet_resultat; struct_objet *s_objet_temporaire; - unsigned long nombre_colonnes; + integer8 nombre_colonnes; (*s_etat_processus).erreur_execution = d_ex; @@ -85,74 +81,38 @@ instruction_mean(struct_processus *s_eta * Recherche d'une variable globale référencée par SIGMA */ - if (recherche_variable(s_etat_processus, ds_sdat) == d_faux) + if (recherche_variable_globale(s_etat_processus, ds_sdat) == d_faux) { /* * Aucune variable SIGMA */ (*s_etat_processus).erreur_systeme = d_es; - (*s_etat_processus).erreur_execution = d_ex_absence_observations; - return; - } - else - { - /* - * Il existe une variable locale SIGMA. Reste à vérifier l'existence - * d'une variable SIGMA globale... - */ - i = (*s_etat_processus).position_variable_courante; - presence_variable = d_faux; - - while(i >= 0) + if ((*s_etat_processus).erreur_execution == d_ex) { - if ((strcmp((*s_etat_processus).s_liste_variables[i].nom, - ds_sdat) == 0) && ((*s_etat_processus) - .s_liste_variables[i].niveau == 1)) - { - presence_variable = d_vrai; - break; - } - - i--; + (*s_etat_processus).erreur_execution = d_ex_absence_observations; } - if (presence_variable == d_faux) + return; + } + else + { + if (((*(*(*s_etat_processus).pointeur_variable_courante).objet) + .type != MIN) && ((*(*(*s_etat_processus) + .pointeur_variable_courante).objet).type != MRL)) { - (*s_etat_processus).erreur_execution = d_ex_absence_observations; + (*s_etat_processus).erreur_execution = + d_ex_matrice_statistique_invalide; return; } - else - { - (*s_etat_processus).position_variable_courante = i; - - if ((*s_etat_processus).s_liste_variables[i].objet == NULL) - { - (*s_etat_processus).erreur_execution = d_ex_variable_partagee; - return; - } - if (((*((*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante].objet)) - .type != MIN) && ((*((*s_etat_processus) - .s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet)).type != MRL)) - { - (*s_etat_processus).erreur_execution = - d_ex_matrice_statistique_invalide; - return; - } - - nombre_colonnes = (*((struct_matrice *) (*((*s_etat_processus) - .s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet)).objet)) - .nombre_colonnes; - } + nombre_colonnes = (*((struct_matrice *) (*(*(*s_etat_processus) + .pointeur_variable_courante).objet).objet)).nombre_colonnes; } - s_objet_statistique = ((*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante]).objet; + s_objet_statistique = (*(*s_etat_processus).pointeur_variable_courante) + .objet; if (((*s_objet_statistique).type == MIN) || ((*s_objet_statistique).type == MRL)) @@ -163,8 +123,8 @@ instruction_mean(struct_processus *s_eta return; } - if (((*s_objet_resultat).objet = moyenne_statistique((struct_matrice *) - (*s_objet_statistique).objet)) == NULL) + if (((*s_objet_resultat).objet = moyenne_statistique(s_etat_processus, + (struct_matrice *) (*s_objet_statistique).objet)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -255,15 +215,13 @@ instruction_mean(struct_processus *s_eta void instruction_mins(struct_processus *s_etat_processus) { - logical1 presence_variable; - long i; long j; struct_objet *s_objet_statistique; struct_objet *s_objet_resultat; - unsigned long nombre_colonnes; + integer8 nombre_colonnes; (*s_etat_processus).erreur_execution = d_ex; @@ -302,74 +260,38 @@ instruction_mins(struct_processus *s_eta * Recherche d'une variable globale référencée par SIGMA */ - if (recherche_variable(s_etat_processus, ds_sdat) == d_faux) + if (recherche_variable_globale(s_etat_processus, ds_sdat) == d_faux) { /* * Aucune variable SIGMA */ (*s_etat_processus).erreur_systeme = d_es; - (*s_etat_processus).erreur_execution = d_ex_absence_observations; - return; - } - else - { - /* - * Il existe une variable locale SIGMA. Reste à vérifier l'existence - * d'une variable SIGMA globale... - */ - - i = (*s_etat_processus).position_variable_courante; - presence_variable = d_faux; - while(i >= 0) + if ((*s_etat_processus).erreur_execution == d_ex) { - if ((strcmp((*s_etat_processus).s_liste_variables[i].nom, - ds_sdat) == 0) && ((*s_etat_processus) - .s_liste_variables[i].niveau == 1)) - { - presence_variable = d_vrai; - break; - } - - i--; + (*s_etat_processus).erreur_execution = d_ex_absence_observations; } - if (presence_variable == d_faux) + return; + } + else + { + if (((*(*(*s_etat_processus).pointeur_variable_courante).objet) + .type != MIN) && ((*(*(*s_etat_processus) + .pointeur_variable_courante).objet).type != MRL)) { - (*s_etat_processus).erreur_execution = d_ex_absence_observations; + (*s_etat_processus).erreur_execution = + d_ex_matrice_statistique_invalide; return; } - else - { - (*s_etat_processus).position_variable_courante = i; - - if ((*s_etat_processus).s_liste_variables[i].objet == NULL) - { - (*s_etat_processus).erreur_execution = d_ex_variable_partagee; - return; - } - - if (((*((*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante].objet)) - .type != MIN) && ((*((*s_etat_processus) - .s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet)).type != MRL)) - { - (*s_etat_processus).erreur_execution = - d_ex_matrice_statistique_invalide; - return; - } - nombre_colonnes = (*((struct_matrice *) (*((*s_etat_processus) - .s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet)).objet)) - .nombre_colonnes; - } + nombre_colonnes = (*((struct_matrice *) (*(*(*s_etat_processus) + .pointeur_variable_courante).objet).objet)).nombre_colonnes; } - s_objet_statistique = ((*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante]).objet; + s_objet_statistique = (*(*s_etat_processus).pointeur_variable_courante) + .objet; if (nombre_colonnes == 1) { @@ -386,7 +308,7 @@ instruction_mins(struct_processus *s_eta (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau)[0][0]; - for(i = 1; i < (long) (*((struct_matrice *) (*s_objet_statistique) + for(i = 1; i < (*((struct_matrice *) (*s_objet_statistique) .objet)).nombre_lignes; i++) { if ((*((real8 *) (*s_objet_resultat).objet)) > ((real8 **) @@ -412,7 +334,7 @@ instruction_mins(struct_processus *s_eta (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau)[0][0]; - for(i = 1; i < (long) (*((struct_matrice *) (*s_objet_statistique) + for(i = 1; i < (*((struct_matrice *) (*s_objet_statistique) .objet)).nombre_lignes; i++) { if ((*((integer8 *) (*s_objet_resultat).objet)) > ((integer8 **) @@ -441,19 +363,19 @@ instruction_mins(struct_processus *s_eta nombre_colonnes; if (((*((struct_vecteur *) (*s_objet_resultat).objet)).tableau = - malloc(nombre_colonnes * sizeof(real8))) == NULL) + malloc(((size_t) nombre_colonnes) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } - for(j = 0; j < (long) nombre_colonnes; j++) + for(j = 0; j < nombre_colonnes; j++) { ((real8 *) (*((struct_vecteur *) (*s_objet_resultat).objet)) .tableau)[j] = ((real8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau)[0][j]; - for(i = 1; i < (long) (*((struct_matrice *) + for(i = 1; i < (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes; i++) { if (((real8 *) (*((struct_vecteur *) (*s_objet_resultat) @@ -482,19 +404,20 @@ instruction_mins(struct_processus *s_eta nombre_colonnes; if (((*((struct_vecteur *) (*s_objet_resultat).objet)).tableau = - malloc(nombre_colonnes * sizeof(integer8))) == NULL) + malloc(((size_t) nombre_colonnes) * sizeof(integer8))) + == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } - for(j = 0; j < (long) nombre_colonnes; j++) + for(j = 0; j < nombre_colonnes; j++) { ((integer8 *) (*((struct_vecteur *) (*s_objet_resultat).objet)) .tableau)[j] = ((integer8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau)[0][j]; - for(i = 1; i < (long) (*((struct_matrice *) + for(i = 1; i < (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes; i++) { if (((integer8 *) (*((struct_vecteur *) (*s_objet_resultat) @@ -537,15 +460,13 @@ instruction_mins(struct_processus *s_eta void instruction_maxs(struct_processus *s_etat_processus) { - logical1 presence_variable; - long i; long j; struct_objet *s_objet_statistique; struct_objet *s_objet_resultat; - unsigned long nombre_colonnes; + integer8 nombre_colonnes; (*s_etat_processus).erreur_execution = d_ex; @@ -584,74 +505,38 @@ instruction_maxs(struct_processus *s_eta * Recherche d'une variable globale référencée par SIGMA */ - if (recherche_variable(s_etat_processus, ds_sdat) == d_faux) + if (recherche_variable_globale(s_etat_processus, ds_sdat) == d_faux) { /* * Aucune variable SIGMA */ (*s_etat_processus).erreur_systeme = d_es; - (*s_etat_processus).erreur_execution = d_ex_absence_observations; - return; - } - else - { - /* - * Il existe une variable locale SIGMA. Reste à vérifier l'existence - * d'une variable SIGMA globale... - */ - i = (*s_etat_processus).position_variable_courante; - presence_variable = d_faux; - - while(i >= 0) + if ((*s_etat_processus).erreur_execution == d_ex) { - if ((strcmp((*s_etat_processus).s_liste_variables[i].nom, - ds_sdat) == 0) && ((*s_etat_processus) - .s_liste_variables[i].niveau == 1)) - { - presence_variable = d_vrai; - break; - } - - i--; + (*s_etat_processus).erreur_execution = d_ex_absence_observations; } - if (presence_variable == d_faux) + return; + } + else + { + if (((*(*(*s_etat_processus).pointeur_variable_courante).objet) + .type != MIN) && ((*(*(*s_etat_processus) + .pointeur_variable_courante).objet).type != MRL)) { - (*s_etat_processus).erreur_execution = d_ex_absence_observations; + (*s_etat_processus).erreur_execution = + d_ex_matrice_statistique_invalide; return; } - else - { - (*s_etat_processus).position_variable_courante = i; - - if ((*s_etat_processus).s_liste_variables[i].objet == NULL) - { - (*s_etat_processus).erreur_execution = d_ex_variable_partagee; - return; - } - if (((*((*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante].objet)) - .type != MIN) && ((*((*s_etat_processus) - .s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet)).type != MRL)) - { - (*s_etat_processus).erreur_execution = - d_ex_matrice_statistique_invalide; - return; - } - - nombre_colonnes = (*((struct_matrice *) (*((*s_etat_processus) - .s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet)).objet)) - .nombre_colonnes; - } + nombre_colonnes = (*((struct_matrice *) (*(*(*s_etat_processus) + .pointeur_variable_courante).objet).objet)).nombre_colonnes; } - s_objet_statistique = ((*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante]).objet; + s_objet_statistique = (*(*s_etat_processus).pointeur_variable_courante) + .objet; if (nombre_colonnes == 1) { @@ -668,7 +553,7 @@ instruction_maxs(struct_processus *s_eta (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau)[0][0]; - for(i = 1; i < (long) (*((struct_matrice *) (*s_objet_statistique) + for(i = 1; i < (*((struct_matrice *) (*s_objet_statistique) .objet)).nombre_lignes; i++) { if ((*((real8 *) (*s_objet_resultat).objet)) < ((real8 **) @@ -694,7 +579,7 @@ instruction_maxs(struct_processus *s_eta (*((struct_matrice *) (*s_objet_statistique).objet)) .tableau)[0][0]; - for(i = 1; i < (long) (*((struct_matrice *) (*s_objet_statistique) + for(i = 1; i < (*((struct_matrice *) (*s_objet_statistique) .objet)).nombre_lignes; i++) { if ((*((integer8 *) (*s_objet_resultat).objet)) < ((integer8 **) @@ -723,19 +608,19 @@ instruction_maxs(struct_processus *s_eta nombre_colonnes; if (((*((struct_vecteur *) (*s_objet_resultat).objet)).tableau = - malloc(nombre_colonnes * sizeof(real8))) == NULL) + malloc(((size_t) nombre_colonnes) * sizeof(real8))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } - for(j = 0; j < (long) nombre_colonnes; j++) + for(j = 0; j < nombre_colonnes; j++) { ((real8 *) (*((struct_vecteur *) (*s_objet_resultat).objet)) .tableau)[j] = ((real8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau)[0][j]; - for(i = 1; i < (long) (*((struct_matrice *) + for(i = 1; i < (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes; i++) { if (((real8 *) (*((struct_vecteur *) (*s_objet_resultat) @@ -764,19 +649,20 @@ instruction_maxs(struct_processus *s_eta nombre_colonnes; if (((*((struct_vecteur *) (*s_objet_resultat).objet)).tableau = - malloc(nombre_colonnes * sizeof(integer8))) == NULL) + malloc(((size_t) nombre_colonnes) * sizeof(integer8))) + == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } - for(j = 0; j < (long) nombre_colonnes; j++) + for(j = 0; j < nombre_colonnes; j++) { ((integer8 *) (*((struct_vecteur *) (*s_objet_resultat).objet)) .tableau)[j] = ((integer8 **) (*((struct_matrice *) (*s_objet_statistique).objet)).tableau)[0][j]; - for(i = 1; i < (long) (*((struct_matrice *) + for(i = 1; i < (*((struct_matrice *) (*s_objet_statistique).objet)).nombre_lignes; i++) { if (((integer8 *) (*((struct_vecteur *) (*s_objet_resultat)