--- rpl/src/instructions_t3.c 2013/02/27 17:11:44 1.44 +++ rpl/src/instructions_t3.c 2013/03/21 11:30:30 1.45 @@ -38,269 +38,269 @@ void instruction_trnc(struct_processus *s_etat_processus) { - int parametre; + integer8 parametre; - logical1 i43; - logical1 i44; - logical1 i49; - logical1 i50; - logical1 i53; - logical1 i54; - logical1 i55; - logical1 i56; - - struct_objet *s_objet_argument_1; - struct_objet *s_objet_argument_2; - struct_objet *s_objet_parametre; - - unsigned char *instruction_courante; - unsigned char *valeur_binaire; - - unsigned long i; - unsigned long j; - - (*s_etat_processus).erreur_execution = d_ex; - - if ((*s_etat_processus).affichage_arguments == 'Y') - { - printf("\n TRNC "); - - if ((*s_etat_processus).langue == 'F') - { - printf("(troncature)\n\n"); - } - else - { - printf("(truncation)\n\n"); - } - - printf(" 2: %s, %s, %s, %s, %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); - printf(" 1: %s\n", d_INT); - printf("-> 1: %s, %s, %s, %s, %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); - - 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_argument_1) == 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_argument_2) == d_erreur) - { - liberation(s_etat_processus, s_objet_argument_1); - - (*s_etat_processus).erreur_execution = d_ex_manque_argument; - return; - } - - if (((*s_objet_argument_1).type == INT) && - (((*s_objet_argument_2).type == INT) || - ((*s_objet_argument_2).type == REL) || - ((*s_objet_argument_2).type == CPL) || - ((*s_objet_argument_2).type == VIN) || - ((*s_objet_argument_2).type == VRL) || - ((*s_objet_argument_2).type == VCX) || - ((*s_objet_argument_2).type == MIN) || - ((*s_objet_argument_2).type == MRL) || - ((*s_objet_argument_2).type == MCX))) - { - parametre = (*((integer8 *) (*s_objet_argument_1).objet)); - - if ((parametre >= -15) && (parametre <= 15)) - { - if ((s_objet_parametre = allocation(s_etat_processus, BIN)) + logical1 i43; + logical1 i44; + logical1 i49; + logical1 i50; + logical1 i53; + logical1 i54; + logical1 i55; + logical1 i56; + + struct_objet *s_objet_argument_1; + struct_objet *s_objet_argument_2; + struct_objet *s_objet_parametre; + + unsigned char *instruction_courante; + unsigned char *valeur_binaire; + + unsigned long i; + unsigned long j; + + (*s_etat_processus).erreur_execution = d_ex; + + if ((*s_etat_processus).affichage_arguments == 'Y') + { + printf("\n TRNC "); + + if ((*s_etat_processus).langue == 'F') + { + printf("(troncature)\n\n"); + } + else + { + printf("(truncation)\n\n"); + } + + printf(" 2: %s, %s, %s, %s, %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); + printf(" 1: %s\n", d_INT); + printf("-> 1: %s, %s, %s, %s, %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); + + 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_argument_1) == 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_argument_2) == d_erreur) + { + liberation(s_etat_processus, s_objet_argument_1); + + (*s_etat_processus).erreur_execution = d_ex_manque_argument; + return; + } + + if (((*s_objet_argument_1).type == INT) && + (((*s_objet_argument_2).type == INT) || + ((*s_objet_argument_2).type == REL) || + ((*s_objet_argument_2).type == CPL) || + ((*s_objet_argument_2).type == VIN) || + ((*s_objet_argument_2).type == VRL) || + ((*s_objet_argument_2).type == VCX) || + ((*s_objet_argument_2).type == MIN) || + ((*s_objet_argument_2).type == MRL) || + ((*s_objet_argument_2).type == MCX))) + { + parametre = (*((integer8 *) (*s_objet_argument_1).objet)); + + if ((parametre >= -15) && (parametre <= 15)) + { + if ((s_objet_parametre = allocation(s_etat_processus, BIN)) == NULL) - { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return; - } - - (*((integer8 *) (*s_objet_parametre).objet)) = - abs((*((integer8 *) (*s_objet_argument_1).objet))); - - i43 = test_cfsf(s_etat_processus, 43); - i44 = test_cfsf(s_etat_processus, 44); - - sf(s_etat_processus, 44); - cf(s_etat_processus, 43); - - if ((valeur_binaire = formateur(s_etat_processus, 0, - s_objet_parametre)) == NULL) - { - liberation(s_etat_processus, s_objet_parametre); - - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return; - } - - liberation(s_etat_processus, s_objet_parametre); - - if (i43 == d_vrai) - { - sf(s_etat_processus, 43); - } - else - { - cf(s_etat_processus, 43); - } - - if (i44 == d_vrai) - { - sf(s_etat_processus, 44); - } - else - { - cf(s_etat_processus, 44); - } - - i53 = test_cfsf(s_etat_processus, 53); - i54 = test_cfsf(s_etat_processus, 54); - i55 = test_cfsf(s_etat_processus, 55); - i56 = test_cfsf(s_etat_processus, 56); - - for(j = 53, i = strlen(valeur_binaire) - 2; i >= 2; i--) - { - if (valeur_binaire[i] == '0') - { - cf(s_etat_processus, j++); - } - else - { - sf(s_etat_processus, j++); - } - } - - for(; j <= 56; cf(s_etat_processus, j++)); - - free(valeur_binaire); - - i49 = test_cfsf(s_etat_processus, 49); - i50 = test_cfsf(s_etat_processus, 50); - - if (parametre >= 0) - { - // Troncature FIX - sf(s_etat_processus, 49); - cf(s_etat_processus, 50); - } - else - { - // Troncature SCI - cf(s_etat_processus, 49); - sf(s_etat_processus, 50); - } - - instruction_courante = (*s_etat_processus).instruction_courante; - - if (((*s_etat_processus).instruction_courante = - formateur(s_etat_processus, 0, s_objet_argument_2)) == NULL) - { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - (*s_etat_processus).instruction_courante = instruction_courante; - return; - } - - if (i49 == d_vrai) - { - sf(s_etat_processus, 49); - } - else - { - cf(s_etat_processus, 49); - } - - if (i50 == d_vrai) - { - sf(s_etat_processus, 50); - } - else - { - cf(s_etat_processus, 50); - } - - if (i53 == d_vrai) - { - sf(s_etat_processus, 53); - } - else - { - cf(s_etat_processus, 53); - } - - if (i54 == d_vrai) - { - sf(s_etat_processus, 54); - } - else - { - cf(s_etat_processus, 54); - } - - if (i55 == d_vrai) - { - sf(s_etat_processus, 55); - } - else - { - cf(s_etat_processus, 55); - } - - if (i56 == d_vrai) - { - sf(s_etat_processus, 56); - } - else - { - cf(s_etat_processus, 56); - } - - recherche_type(s_etat_processus); - - free((*s_etat_processus).instruction_courante); - (*s_etat_processus).instruction_courante = instruction_courante; - - if ((*s_etat_processus).erreur_systeme != d_es) - { - return; - } - - if ((*s_etat_processus).erreur_execution != d_ex) - { - liberation(s_etat_processus, s_objet_argument_1); - liberation(s_etat_processus, s_objet_argument_2); - return; - } - } - else - { - liberation(s_etat_processus, s_objet_argument_1); - liberation(s_etat_processus, s_objet_argument_2); - - (*s_etat_processus).erreur_execution = d_ex_argument_invalide; - return; - } - } + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + (*((integer8 *) (*s_objet_parametre).objet)) = + abs((*((integer8 *) (*s_objet_argument_1).objet))); + + i43 = test_cfsf(s_etat_processus, 43); + i44 = test_cfsf(s_etat_processus, 44); + + sf(s_etat_processus, 44); + cf(s_etat_processus, 43); + + if ((valeur_binaire = formateur(s_etat_processus, 0, + s_objet_parametre)) == NULL) + { + liberation(s_etat_processus, s_objet_parametre); + + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + liberation(s_etat_processus, s_objet_parametre); + + if (i43 == d_vrai) + { + sf(s_etat_processus, 43); + } + else + { + cf(s_etat_processus, 43); + } + + if (i44 == d_vrai) + { + sf(s_etat_processus, 44); + } + else + { + cf(s_etat_processus, 44); + } + + i53 = test_cfsf(s_etat_processus, 53); + i54 = test_cfsf(s_etat_processus, 54); + i55 = test_cfsf(s_etat_processus, 55); + i56 = test_cfsf(s_etat_processus, 56); + + for(j = 53, i = strlen(valeur_binaire) - 2; i >= 2; i--) + { + if (valeur_binaire[i] == '0') + { + cf(s_etat_processus, (unsigned char) j++); + } + else + { + sf(s_etat_processus, (unsigned char) j++); + } + } + + for(; j <= 56; cf(s_etat_processus, (unsigned char) j++)); + + free(valeur_binaire); + + i49 = test_cfsf(s_etat_processus, 49); + i50 = test_cfsf(s_etat_processus, 50); + + if (parametre >= 0) + { + // Troncature FIX + sf(s_etat_processus, 49); + cf(s_etat_processus, 50); + } + else + { + // Troncature SCI + cf(s_etat_processus, 49); + sf(s_etat_processus, 50); + } + + instruction_courante = (*s_etat_processus).instruction_courante; + + if (((*s_etat_processus).instruction_courante = + formateur(s_etat_processus, 0, s_objet_argument_2)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + (*s_etat_processus).instruction_courante = instruction_courante; + return; + } + + if (i49 == d_vrai) + { + sf(s_etat_processus, 49); + } + else + { + cf(s_etat_processus, 49); + } + + if (i50 == d_vrai) + { + sf(s_etat_processus, 50); + } + else + { + cf(s_etat_processus, 50); + } + + if (i53 == d_vrai) + { + sf(s_etat_processus, 53); + } + else + { + cf(s_etat_processus, 53); + } + + if (i54 == d_vrai) + { + sf(s_etat_processus, 54); + } + else + { + cf(s_etat_processus, 54); + } + + if (i55 == d_vrai) + { + sf(s_etat_processus, 55); + } + else + { + cf(s_etat_processus, 55); + } + + if (i56 == d_vrai) + { + sf(s_etat_processus, 56); + } + else + { + cf(s_etat_processus, 56); + } + + recherche_type(s_etat_processus); + + free((*s_etat_processus).instruction_courante); + (*s_etat_processus).instruction_courante = instruction_courante; + + if ((*s_etat_processus).erreur_systeme != d_es) + { + return; + } + + if ((*s_etat_processus).erreur_execution != d_ex) + { + liberation(s_etat_processus, s_objet_argument_1); + liberation(s_etat_processus, s_objet_argument_2); + return; + } + } + else + { + liberation(s_etat_processus, s_objet_argument_1); + liberation(s_etat_processus, s_objet_argument_2); + + (*s_etat_processus).erreur_execution = d_ex_argument_invalide; + return; + } + } /* -------------------------------------------------------------------------------- @@ -308,19 +308,19 @@ instruction_trnc(struct_processus *s_eta -------------------------------------------------------------------------------- */ - else - { - liberation(s_etat_processus, s_objet_argument_1); - liberation(s_etat_processus, s_objet_argument_2); - - (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; - return; - } + else + { + liberation(s_etat_processus, s_objet_argument_1); + liberation(s_etat_processus, s_objet_argument_2); - liberation(s_etat_processus, s_objet_argument_1); - liberation(s_etat_processus, s_objet_argument_2); + (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; + return; + } + + liberation(s_etat_processus, s_objet_argument_1); + liberation(s_etat_processus, s_objet_argument_2); - return; + return; } @@ -342,7 +342,7 @@ instruction_table_fleche(struct_processu struct_objet *s_objet; struct_objet *s_objet_resultat; - unsigned long i; + integer8 i; (*s_etat_processus).erreur_execution = d_ex; @@ -361,16 +361,16 @@ instruction_table_fleche(struct_processu printf(" 1: %s\n", d_TAB); printf("-> n: %s, %s, %s, %s, %s, %s,\n" - " %s, %s, %s, %s, %s,\n" - " %s, %s, %s, %s, %s,\n" - " %s, %s\n", + " %s, %s, %s, %s, %s,\n" + " %s, %s, %s, %s, %s,\n" + " %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_SLB); printf(" ...\n"); printf(" 2: %s, %s, %s, %s, %s, %s,\n" - " %s, %s, %s, %s, %s,\n" - " %s, %s, %s, %s, %s,\n" - " %s, %s\n", + " %s, %s, %s, %s, %s,\n" + " %s, %s, %s, %s, %s,\n" + " %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_SLB); printf(" 1: %s\n", d_INT); @@ -462,56 +462,56 @@ instruction_table_fleche(struct_processu void instruction_trim(struct_processus *s_etat_processus) { - struct_objet *s_objet_argument; - struct_objet *s_objet_resultat; + struct_objet *s_objet_argument; + struct_objet *s_objet_resultat; unsigned char *debut; unsigned char *fin; - (*s_etat_processus).erreur_execution = d_ex; + (*s_etat_processus).erreur_execution = d_ex; - if ((*s_etat_processus).affichage_arguments == 'Y') - { - printf("\n TRIM "); - - if ((*s_etat_processus).langue == 'F') - { - printf("(suppression des espaces initiaux et finaux d'une " + if ((*s_etat_processus).affichage_arguments == 'Y') + { + printf("\n TRIM "); + + if ((*s_etat_processus).langue == 'F') + { + printf("(suppression des espaces initiaux et finaux d'une " "chaîne)\n\n"); - } - else - { - printf("(delete initial and final spaces from string)\n\n"); - } - - printf(" 1: %s\n", d_CHN); - printf("-> 1: %s\n", d_CHN); - - 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; - } + } + else + { + printf("(delete initial and final spaces from string)\n\n"); + } - if ((*s_objet_argument).type == CHN) - { + printf(" 1: %s\n", d_CHN); + printf("-> 1: %s\n", d_CHN); + + 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; + } + + if ((*s_objet_argument).type == CHN) + { debut = (unsigned char *) (*s_objet_argument).objet; while(((*debut) != d_code_fin_chaine) && @@ -541,7 +541,7 @@ instruction_trim(struct_processus *s_eta return; } - if (((*s_objet_resultat).objet = malloc((1 + fin - debut) + if (((*s_objet_resultat).objet = malloc(((size_t) (1 + fin - debut)) * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -549,7 +549,7 @@ instruction_trim(struct_processus *s_eta } strcpy((unsigned char *) (*s_objet_resultat).objet, debut); - } + } /* -------------------------------------------------------------------------------- @@ -557,13 +557,13 @@ instruction_trim(struct_processus *s_eta -------------------------------------------------------------------------------- */ - else - { - liberation(s_etat_processus, s_objet_argument); - - (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; - return; - } + else + { + liberation(s_etat_processus, s_objet_argument); + + (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; + return; + } if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), s_objet_resultat) == d_erreur) @@ -571,9 +571,9 @@ instruction_trim(struct_processus *s_eta return; } - liberation(s_etat_processus, s_objet_argument); + liberation(s_etat_processus, s_objet_argument); - return; + return; } @@ -592,8 +592,8 @@ instruction_trim(struct_processus *s_eta void instruction_tokenize(struct_processus *s_etat_processus) { - struct_objet *s_objet_argument; - struct_objet *s_objet_resultat; + struct_objet *s_objet_argument; + struct_objet *s_objet_resultat; struct_liste_chainee *l_element_courant; @@ -603,53 +603,53 @@ instruction_tokenize(struct_processus *s unsigned char *registre_definitions_chainees; unsigned char *tampon; - unsigned long nombre_caracteres_echappement; - unsigned long registre_longueur_definitions_chainees; - unsigned long registre_position_courante; - - (*s_etat_processus).erreur_execution = d_ex; - - if ((*s_etat_processus).affichage_arguments == 'Y') - { - printf("\n TOKENIZE "); - - if ((*s_etat_processus).langue == 'F') - { - printf("(extraction d'objets en sous-chaînes)\n\n"); - } - else - { - printf("(extract objects in substrings)\n\n"); - } - - printf(" 1: %s\n", d_CHN); - printf("-> 1: %s\n", d_LST); - - 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; - } + integer8 nombre_caracteres_echappement; + integer8 registre_longueur_definitions_chainees; + integer8 registre_position_courante; + + (*s_etat_processus).erreur_execution = d_ex; + + if ((*s_etat_processus).affichage_arguments == 'Y') + { + printf("\n TOKENIZE "); + + if ((*s_etat_processus).langue == 'F') + { + printf("(extraction d'objets en sous-chaînes)\n\n"); + } + else + { + printf("(extract objects in substrings)\n\n"); + } + + printf(" 1: %s\n", d_CHN); + printf("-> 1: %s\n", d_LST); - if ((*s_objet_argument).type == CHN) - { + 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; + } + + if ((*s_objet_argument).type == CHN) + { // Conversion des caractères d'échappement ptr = (unsigned char *) (*s_objet_argument).objet; @@ -736,7 +736,7 @@ instruction_tokenize(struct_processus *s (*s_etat_processus).definitions_chainees = (unsigned char *) (*s_objet_argument).objet; (*s_etat_processus).longueur_definitions_chainees = - strlen((*s_etat_processus).definitions_chainees); + (integer8) strlen((*s_etat_processus).definitions_chainees); (*s_etat_processus).position_courante = 0; l_element_courant = NULL; @@ -826,7 +826,8 @@ instruction_tokenize(struct_processus *s .donnee).objet; if (((*(*l_element_courant).donnee).objet = malloc( - (strlen(tampon) + 1 + nombre_caracteres_echappement) + (strlen(tampon) + 1 + + ((size_t) nombre_caracteres_echappement)) * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = @@ -869,7 +870,7 @@ instruction_tokenize(struct_processus *s (*s_etat_processus).longueur_definitions_chainees = registre_longueur_definitions_chainees; (*s_etat_processus).position_courante = registre_position_courante; - } + } /* -------------------------------------------------------------------------------- @@ -877,13 +878,13 @@ instruction_tokenize(struct_processus *s -------------------------------------------------------------------------------- */ - else - { - liberation(s_etat_processus, s_objet_argument); - - (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; - return; - } + else + { + liberation(s_etat_processus, s_objet_argument); + + (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; + return; + } if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), s_objet_resultat) == d_erreur) @@ -891,9 +892,9 @@ instruction_tokenize(struct_processus *s return; } - liberation(s_etat_processus, s_objet_argument); + liberation(s_etat_processus, s_objet_argument); - return; + return; }