--- rpl/src/instructions_s2.c 2010/02/26 19:22:05 1.4 +++ rpl/src/instructions_s2.c 2020/01/10 11:15:48 1.73 @@ -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" /* @@ -764,7 +764,8 @@ instruction_size(struct_processus *s_eta } (*((integer8 *) (*s_objet_resultat).objet)) = - strlen((unsigned char *) (*s_objet_argument).objet); + longueur_chaine(s_etat_processus, + (unsigned char *) (*s_objet_argument).objet); } /* @@ -1034,8 +1035,8 @@ instruction_str_fleche(struct_processus unsigned char registre_interruption; unsigned char *tampon; - unsigned long nombre_caracteres_supplementaires; - unsigned long position_courante; + integer8 nombre_caracteres_supplementaires; + integer8 position_courante; (*s_etat_processus).erreur_execution = d_ex; @@ -1092,12 +1093,6 @@ instruction_str_fleche(struct_processus if ((*s_objet).type == CHN) { - position_courante = (*s_etat_processus).position_courante; - registre_definitions_chainees = (*s_etat_processus) - .definitions_chainees; - registre_instruction_courante = (*s_etat_processus) - .instruction_courante; - // Comptage des caractères à protéger. drapeau45 = test_cfsf(s_etat_processus, 45); @@ -1127,9 +1122,29 @@ instruction_str_fleche(struct_processus if (presence_chaine == d_vrai) { - if ((*ptr_l) == '\\') + switch(*ptr_l) + { + case '\\': + case '\t': + case '\b': + case '\n': + { + nombre_caracteres_supplementaires++; + break; + } + } + } + else + { + switch(*ptr_l) { - nombre_caracteres_supplementaires++; + case '\n': + case '\b': + case '\t': + { + nombre_caracteres_supplementaires--; + break; + } } } @@ -1140,9 +1155,9 @@ instruction_str_fleche(struct_processus // de caractères incluses. Le seul caractère protégé est le '\' // qui est doublé. - if ((chaine_convertie = malloc((strlen(tampon) + - nombre_caracteres_supplementaires + 1) * sizeof(unsigned char))) - == NULL) + if ((chaine_convertie = malloc((strlen(tampon) + ((size_t) + nombre_caracteres_supplementaires) + 1) * + sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -1163,9 +1178,47 @@ instruction_str_fleche(struct_processus if (presence_chaine == d_vrai) { - if ((*ptr_l) == '\\') + switch(*ptr_l) + { + case '\\': + { + (*(++ptr_e)) = '\\'; + break; + } + + case '\t': + { + (*ptr_e) = '\\'; + (*(++ptr_e)) = 't'; + break; + } + + case '\b': + { + (*ptr_e) = '\\'; + (*(++ptr_e)) = 'b'; + break; + } + + case '\n': + { + (*ptr_e) = '\\'; + (*(++ptr_e)) = 'n'; + break; + } + } + } + else + { + switch(*ptr_l) { - (*(++ptr_e)) = '\\'; + case '\n': + case '\b': + case '\t': + { + ptr_e--; + break; + } } } @@ -1175,6 +1228,12 @@ instruction_str_fleche(struct_processus (*ptr_e) = d_code_fin_chaine; + position_courante = (*s_etat_processus).position_courante; + registre_definitions_chainees = (*s_etat_processus) + .definitions_chainees; + registre_instruction_courante = (*s_etat_processus) + .instruction_courante; + (*s_etat_processus).position_courante = 0; (*s_etat_processus).definitions_chainees = chaine_convertie; free(tampon); @@ -1197,9 +1256,11 @@ instruction_str_fleche(struct_processus .definitions_chainees); (*s_etat_processus).instruction_courante = commande; + (*s_etat_processus).type_en_cours = NON; recherche_type(s_etat_processus); - if ((*s_etat_processus).erreur_execution != d_ex) + if (((*s_etat_processus).erreur_execution != d_ex) || + ((*s_etat_processus).erreur_systeme != d_es)) { liberation(s_etat_processus, s_objet);