version 1.3, 2010/02/10 10:14:25
|
version 1.47, 2013/04/01 15:29:38
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.11 |
RPL/2 (R) version 4.1.14 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2013 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 20
|
Line 20
|
*/ |
*/ |
|
|
|
|
#include "rpl.conv.h" |
#include "rpl-conv.h" |
|
|
|
|
/* |
/* |
Line 38
|
Line 38
|
void |
void |
instruction_trnc(struct_processus *s_etat_processus) |
instruction_trnc(struct_processus *s_etat_processus) |
{ |
{ |
int parametre; |
integer8 parametre; |
|
|
logical1 i43; |
logical1 i43; |
logical1 i44; |
logical1 i44; |
logical1 i49; |
logical1 i49; |
logical1 i50; |
logical1 i50; |
logical1 i53; |
logical1 i53; |
logical1 i54; |
logical1 i54; |
logical1 i55; |
logical1 i55; |
logical1 i56; |
logical1 i56; |
|
|
struct_objet *s_objet_argument_1; |
struct_objet *s_objet_argument_1; |
struct_objet *s_objet_argument_2; |
struct_objet *s_objet_argument_2; |
struct_objet *s_objet_parametre; |
struct_objet *s_objet_parametre; |
|
|
unsigned char *instruction_courante; |
unsigned char *instruction_courante; |
unsigned char *valeur_binaire; |
unsigned char *valeur_binaire; |
|
|
unsigned long i; |
unsigned long i; |
unsigned long j; |
unsigned long j; |
|
|
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
|
|
if ((*s_etat_processus).affichage_arguments == 'Y') |
if ((*s_etat_processus).affichage_arguments == 'Y') |
{ |
{ |
printf("\n TRNC "); |
printf("\n TRNC "); |
|
|
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("(troncature)\n\n"); |
printf("(troncature)\n\n"); |
} |
} |
else |
else |
{ |
{ |
printf("(truncation)\n\n"); |
printf("(truncation)\n\n"); |
} |
} |
|
|
printf(" 1: %s, %s, %s, %s, %s, %s,\n" |
printf(" 2: %s, %s, %s, %s, %s, %s,\n" |
" %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); |
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\n", d_INT); |
printf("-> 1: %s, %s, %s, %s, %s, %s,\n" |
printf("-> 1: %s, %s, %s, %s, %s, %s,\n" |
" %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); |
d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX); |
|
|
return; |
return; |
} |
} |
else if ((*s_etat_processus).test_instruction == 'Y') |
else if ((*s_etat_processus).test_instruction == 'Y') |
{ |
{ |
(*s_etat_processus).nombre_arguments = -1; |
(*s_etat_processus).nombre_arguments = -1; |
return; |
return; |
} |
} |
|
|
if (test_cfsf(s_etat_processus, 31) == d_vrai) |
if (test_cfsf(s_etat_processus, 31) == d_vrai) |
{ |
{ |
if (empilement_pile_last(s_etat_processus, 2) == d_erreur) |
if (empilement_pile_last(s_etat_processus, 2) == d_erreur) |
{ |
{ |
return; |
return; |
} |
} |
} |
} |
|
|
if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), |
if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), |
&s_objet_argument_1) == d_erreur) |
&s_objet_argument_1) == d_erreur) |
{ |
{ |
(*s_etat_processus).erreur_execution = d_ex_manque_argument; |
(*s_etat_processus).erreur_execution = d_ex_manque_argument; |
return; |
return; |
} |
} |
|
|
if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), |
if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), |
&s_objet_argument_2) == d_erreur) |
&s_objet_argument_2) == d_erreur) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_1); |
|
|
(*s_etat_processus).erreur_execution = d_ex_manque_argument; |
(*s_etat_processus).erreur_execution = d_ex_manque_argument; |
return; |
return; |
} |
} |
|
|
if (((*s_objet_argument_1).type == INT) && |
if (((*s_objet_argument_1).type == INT) && |
(((*s_objet_argument_2).type == INT) || |
(((*s_objet_argument_2).type == INT) || |
((*s_objet_argument_2).type == REL) || |
((*s_objet_argument_2).type == REL) || |
((*s_objet_argument_2).type == CPL) || |
((*s_objet_argument_2).type == CPL) || |
((*s_objet_argument_2).type == VIN) || |
((*s_objet_argument_2).type == VIN) || |
((*s_objet_argument_2).type == VRL) || |
((*s_objet_argument_2).type == VRL) || |
((*s_objet_argument_2).type == VCX) || |
((*s_objet_argument_2).type == VCX) || |
((*s_objet_argument_2).type == MIN) || |
((*s_objet_argument_2).type == MIN) || |
((*s_objet_argument_2).type == MRL) || |
((*s_objet_argument_2).type == MRL) || |
((*s_objet_argument_2).type == MCX))) |
((*s_objet_argument_2).type == MCX))) |
{ |
{ |
parametre = (*((integer8 *) (*s_objet_argument_1).objet)); |
parametre = (*((integer8 *) (*s_objet_argument_1).objet)); |
|
|
if ((parametre >= -15) && (parametre <= 15)) |
if ((parametre >= -15) && (parametre <= 15)) |
{ |
{ |
if ((s_objet_parametre = allocation(s_etat_processus, BIN)) |
if ((s_objet_parametre = allocation(s_etat_processus, BIN)) |
== NULL) |
== NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
return; |
return; |
} |
} |
|
|
(*((integer8 *) (*s_objet_parametre).objet)) = |
(*((integer8 *) (*s_objet_parametre).objet)) = |
abs((*((integer8 *) (*s_objet_argument_1).objet))); |
abs((*((integer8 *) (*s_objet_argument_1).objet))); |
|
|
i43 = test_cfsf(s_etat_processus, 43); |
i43 = test_cfsf(s_etat_processus, 43); |
i44 = test_cfsf(s_etat_processus, 44); |
i44 = test_cfsf(s_etat_processus, 44); |
|
|
sf(s_etat_processus, 44); |
sf(s_etat_processus, 44); |
cf(s_etat_processus, 43); |
cf(s_etat_processus, 43); |
|
|
if ((valeur_binaire = formateur(s_etat_processus, 0, |
if ((valeur_binaire = formateur(s_etat_processus, 0, |
s_objet_parametre)) == NULL) |
s_objet_parametre)) == NULL) |
{ |
{ |
liberation(s_etat_processus, s_objet_parametre); |
liberation(s_etat_processus, s_objet_parametre); |
|
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
return; |
return; |
} |
} |
|
|
liberation(s_etat_processus, s_objet_parametre); |
liberation(s_etat_processus, s_objet_parametre); |
|
|
if (i43 == d_vrai) |
if (i43 == d_vrai) |
{ |
{ |
sf(s_etat_processus, 43); |
sf(s_etat_processus, 43); |
} |
} |
else |
else |
{ |
{ |
cf(s_etat_processus, 43); |
cf(s_etat_processus, 43); |
} |
} |
|
|
if (i44 == d_vrai) |
if (i44 == d_vrai) |
{ |
{ |
sf(s_etat_processus, 44); |
sf(s_etat_processus, 44); |
} |
} |
else |
else |
{ |
{ |
cf(s_etat_processus, 44); |
cf(s_etat_processus, 44); |
} |
} |
|
|
i53 = test_cfsf(s_etat_processus, 53); |
i53 = test_cfsf(s_etat_processus, 53); |
i54 = test_cfsf(s_etat_processus, 54); |
i54 = test_cfsf(s_etat_processus, 54); |
i55 = test_cfsf(s_etat_processus, 55); |
i55 = test_cfsf(s_etat_processus, 55); |
i56 = test_cfsf(s_etat_processus, 56); |
i56 = test_cfsf(s_etat_processus, 56); |
|
|
for(j = 53, i = strlen(valeur_binaire) - 2; i >= 2; i--) |
for(j = 53, i = strlen(valeur_binaire) - 2; i >= 2; i--) |
{ |
{ |
if (valeur_binaire[i] == '0') |
if (valeur_binaire[i] == '0') |
{ |
{ |
cf(s_etat_processus, j++); |
cf(s_etat_processus, (unsigned char) j++); |
} |
} |
else |
else |
{ |
{ |
sf(s_etat_processus, j++); |
sf(s_etat_processus, (unsigned char) j++); |
} |
} |
} |
} |
|
|
for(; j <= 56; cf(s_etat_processus, j++)); |
for(; j <= 56; cf(s_etat_processus, (unsigned char) j++)); |
|
|
free(valeur_binaire); |
free(valeur_binaire); |
|
|
i49 = test_cfsf(s_etat_processus, 49); |
i49 = test_cfsf(s_etat_processus, 49); |
i50 = test_cfsf(s_etat_processus, 50); |
i50 = test_cfsf(s_etat_processus, 50); |
|
|
if (parametre >= 0) |
if (parametre >= 0) |
{ |
{ |
// Troncature FIX |
// Troncature FIX |
sf(s_etat_processus, 49); |
sf(s_etat_processus, 49); |
cf(s_etat_processus, 50); |
cf(s_etat_processus, 50); |
} |
} |
else |
else |
{ |
{ |
// Troncature SCI |
// Troncature SCI |
cf(s_etat_processus, 49); |
cf(s_etat_processus, 49); |
sf(s_etat_processus, 50); |
sf(s_etat_processus, 50); |
} |
} |
|
|
instruction_courante = (*s_etat_processus).instruction_courante; |
instruction_courante = (*s_etat_processus).instruction_courante; |
|
|
if (((*s_etat_processus).instruction_courante = |
if (((*s_etat_processus).instruction_courante = |
formateur(s_etat_processus, 0, s_objet_argument_2)) == NULL) |
formateur(s_etat_processus, 0, s_objet_argument_2)) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).instruction_courante = instruction_courante; |
(*s_etat_processus).instruction_courante = instruction_courante; |
return; |
return; |
} |
} |
|
|
if (i49 == d_vrai) |
if (i49 == d_vrai) |
{ |
{ |
sf(s_etat_processus, 49); |
sf(s_etat_processus, 49); |
} |
} |
else |
else |
{ |
{ |
cf(s_etat_processus, 49); |
cf(s_etat_processus, 49); |
} |
} |
|
|
if (i50 == d_vrai) |
if (i50 == d_vrai) |
{ |
{ |
sf(s_etat_processus, 50); |
sf(s_etat_processus, 50); |
} |
} |
else |
else |
{ |
{ |
cf(s_etat_processus, 50); |
cf(s_etat_processus, 50); |
} |
} |
|
|
if (i53 == d_vrai) |
if (i53 == d_vrai) |
{ |
{ |
sf(s_etat_processus, 53); |
sf(s_etat_processus, 53); |
} |
} |
else |
else |
{ |
{ |
cf(s_etat_processus, 53); |
cf(s_etat_processus, 53); |
} |
} |
|
|
if (i54 == d_vrai) |
if (i54 == d_vrai) |
{ |
{ |
sf(s_etat_processus, 54); |
sf(s_etat_processus, 54); |
} |
} |
else |
else |
{ |
{ |
cf(s_etat_processus, 54); |
cf(s_etat_processus, 54); |
} |
} |
|
|
if (i55 == d_vrai) |
if (i55 == d_vrai) |
{ |
{ |
sf(s_etat_processus, 55); |
sf(s_etat_processus, 55); |
} |
} |
else |
else |
{ |
{ |
cf(s_etat_processus, 55); |
cf(s_etat_processus, 55); |
} |
} |
|
|
if (i56 == d_vrai) |
if (i56 == d_vrai) |
{ |
{ |
sf(s_etat_processus, 56); |
sf(s_etat_processus, 56); |
} |
} |
else |
else |
{ |
{ |
cf(s_etat_processus, 56); |
cf(s_etat_processus, 56); |
} |
} |
|
|
recherche_type(s_etat_processus); |
recherche_type(s_etat_processus); |
|
|
free((*s_etat_processus).instruction_courante); |
free((*s_etat_processus).instruction_courante); |
(*s_etat_processus).instruction_courante = instruction_courante; |
(*s_etat_processus).instruction_courante = instruction_courante; |
|
|
if ((*s_etat_processus).erreur_systeme != d_es) |
if ((*s_etat_processus).erreur_systeme != d_es) |
{ |
{ |
return; |
return; |
} |
} |
|
|
if ((*s_etat_processus).erreur_execution != d_ex) |
if ((*s_etat_processus).erreur_execution != d_ex) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_2); |
liberation(s_etat_processus, s_objet_argument_2); |
return; |
return; |
} |
} |
} |
} |
else |
else |
{ |
{ |
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_2); |
liberation(s_etat_processus, s_objet_argument_2); |
|
|
(*s_etat_processus).erreur_execution = d_ex_argument_invalide; |
(*s_etat_processus).erreur_execution = d_ex_argument_invalide; |
return; |
return; |
} |
} |
} |
} |
|
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Line 308 instruction_trnc(struct_processus *s_eta
|
Line 308 instruction_trnc(struct_processus *s_eta
|
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
*/ |
*/ |
|
|
else |
else |
{ |
{ |
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_2); |
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); |
(*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; |
liberation(s_etat_processus, s_objet_argument_2); |
return; |
|
} |
|
|
|
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
return; |
return; |
} |
} |
|
|
|
|
Line 342 instruction_table_fleche(struct_processu
|
Line 342 instruction_table_fleche(struct_processu
|
struct_objet *s_objet; |
struct_objet *s_objet; |
struct_objet *s_objet_resultat; |
struct_objet *s_objet_resultat; |
|
|
unsigned long i; |
integer8 i; |
|
|
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
|
|
Line 361 instruction_table_fleche(struct_processu
|
Line 361 instruction_table_fleche(struct_processu
|
|
|
printf(" 1: %s\n", d_TAB); |
printf(" 1: %s\n", d_TAB); |
printf("-> n: %s, %s, %s, %s, %s, %s,\n" |
printf("-> n: %s, %s, %s, %s, %s, %s,\n" |
" %s, %s, %s, %s, %s,\n" |
" %s, %s, %s, %s, %s,\n" |
" %s, %s, %s, %s, %s,\n" |
" %s, %s, %s, %s, %s,\n" |
" %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_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); |
d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SLB); |
printf(" ...\n"); |
printf(" ...\n"); |
printf(" 2: %s, %s, %s, %s, %s, %s,\n" |
printf(" 2: %s, %s, %s, %s, %s, %s,\n" |
" %s, %s, %s, %s, %s,\n" |
" %s, %s, %s, %s, %s,\n" |
" %s, %s, %s, %s, %s,\n" |
" %s, %s, %s, %s, %s,\n" |
" %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_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); |
d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SLB); |
printf(" 1: %s\n", d_INT); |
printf(" 1: %s\n", d_INT); |
Line 462 instruction_table_fleche(struct_processu
|
Line 462 instruction_table_fleche(struct_processu
|
void |
void |
instruction_trim(struct_processus *s_etat_processus) |
instruction_trim(struct_processus *s_etat_processus) |
{ |
{ |
struct_objet *s_objet_argument; |
struct_objet *s_objet_argument; |
struct_objet *s_objet_resultat; |
struct_objet *s_objet_resultat; |
|
|
unsigned char *debut; |
unsigned char *debut; |
unsigned char *fin; |
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).affichage_arguments == 'Y') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("\n TRIM "); |
printf("(suppression des espaces initiaux et finaux d'une " |
|
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf("(suppression des espaces initiaux et finaux d'une " |
|
"chaîne)\n\n"); |
"chaîne)\n\n"); |
} |
} |
else |
else |
{ |
{ |
printf("(delete initial and final spaces from string)\n\n"); |
printf("(delete initial and final spaces from string)\n\n"); |
} |
} |
|
|
printf(" 1: %s\n", d_CHN); |
printf(" 1: %s\n", d_CHN); |
printf("-> 1: %s\n", d_CHN); |
printf("-> 1: %s\n", d_CHN); |
|
|
return; |
return; |
} |
} |
else if ((*s_etat_processus).test_instruction == 'Y') |
else if ((*s_etat_processus).test_instruction == 'Y') |
{ |
{ |
(*s_etat_processus).nombre_arguments = -1; |
(*s_etat_processus).nombre_arguments = -1; |
return; |
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) |
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; |
debut = (unsigned char *) (*s_objet_argument).objet; |
|
|
while(((*debut) != d_code_fin_chaine) && ((*debut) == d_code_espace)) |
while(((*debut) != d_code_fin_chaine) && |
|
(((*debut) == d_code_espace) |
|
|| ((*debut) == d_code_retour_chariot) |
|
|| ((*debut) == d_code_tabulation))) |
{ |
{ |
debut++; |
debut++; |
} |
} |
Line 522 instruction_trim(struct_processus *s_eta
|
Line 525 instruction_trim(struct_processus *s_eta
|
fin = &(((unsigned char *) (*s_objet_argument).objet) |
fin = &(((unsigned char *) (*s_objet_argument).objet) |
[strlen((unsigned char *) (*s_objet_argument).objet) - 1]); |
[strlen((unsigned char *) (*s_objet_argument).objet) - 1]); |
|
|
while((fin > debut) && ((*fin) == d_code_espace)) |
while((fin > debut) && |
|
(((*fin) == d_code_espace) |
|
|| ((*fin) == d_code_retour_chariot) |
|
|| ((*fin) == d_code_tabulation))) |
{ |
{ |
fin--; |
fin--; |
} |
} |
Line 535 instruction_trim(struct_processus *s_eta
|
Line 541 instruction_trim(struct_processus *s_eta
|
return; |
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) |
* sizeof(unsigned char))) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
Line 543 instruction_trim(struct_processus *s_eta
|
Line 549 instruction_trim(struct_processus *s_eta
|
} |
} |
|
|
strcpy((unsigned char *) (*s_objet_resultat).objet, debut); |
strcpy((unsigned char *) (*s_objet_resultat).objet, debut); |
} |
} |
|
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Line 551 instruction_trim(struct_processus *s_eta
|
Line 557 instruction_trim(struct_processus *s_eta
|
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
*/ |
*/ |
|
|
else |
else |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
|
|
(*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; |
(*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; |
return; |
return; |
} |
} |
|
|
if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), |
if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), |
s_objet_resultat) == d_erreur) |
s_objet_resultat) == d_erreur) |
Line 565 instruction_trim(struct_processus *s_eta
|
Line 571 instruction_trim(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
|
|
return; |
return; |
} |
} |
|
|
|
|
Line 586 instruction_trim(struct_processus *s_eta
|
Line 592 instruction_trim(struct_processus *s_eta
|
void |
void |
instruction_tokenize(struct_processus *s_etat_processus) |
instruction_tokenize(struct_processus *s_etat_processus) |
{ |
{ |
struct_objet *s_objet_argument; |
struct_objet *s_objet_argument; |
struct_objet *s_objet_resultat; |
struct_objet *s_objet_resultat; |
|
|
struct_liste_chainee *l_element_courant; |
struct_liste_chainee *l_element_courant; |
|
|
|
unsigned char *ptr; |
|
unsigned char *ptr2; |
unsigned char *registre_instruction_courante; |
unsigned char *registre_instruction_courante; |
unsigned char *registre_definitions_chainees; |
unsigned char *registre_definitions_chainees; |
|
unsigned char *tampon; |
|
unsigned char *tampon2; |
|
|
|
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); |
|
|
|
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 |
|
|
|
if ((tampon2 = malloc((strlen((*s_objet_argument).objet) + 1) * |
|
sizeof(unsigned char))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
strcpy(tampon2, (*s_objet_argument).objet); |
|
ptr = tampon2; |
|
ptr2 = ptr; |
|
|
|
while((*ptr) != d_code_fin_chaine) |
|
{ |
|
(*ptr2) = (*ptr); |
|
|
|
// Début de la séquence d'échappement |
|
|
|
if ((*ptr) == '\\') |
|
{ |
|
if ((*(ptr + 1)) == '"') |
|
{ |
|
ptr++; |
|
(*ptr2) = '\"'; |
|
} |
|
else if ((*(ptr + 1)) == 'n') |
|
{ |
|
ptr++; |
|
(*ptr2) = '\n'; |
|
} |
|
else if ((*(ptr + 1)) == 't') |
|
{ |
|
ptr++; |
|
(*ptr2) = '\t'; |
|
} |
|
else if ((*(ptr + 1)) == '\\') |
|
{ |
|
ptr++; |
|
} |
|
else |
|
{ |
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf("+++Information : Séquence d'échappement " |
|
"inconnue [%d]\n", (int) getpid()); |
|
} |
|
else |
|
{ |
|
printf("+++Warning : Unknown escape code " |
|
"[%d]\n", (int) getpid()); |
|
} |
|
} |
|
} |
|
|
|
ptr++; |
|
ptr2++; |
|
} |
|
|
|
(*ptr2) = d_code_fin_chaine; |
|
|
unsigned long registre_longueur_definitions_chainees; |
// Remplacement des éventuels retours à la ligne et tabulations par |
unsigned long registre_position_courante; |
// des espaces. |
|
|
(*s_etat_processus).erreur_execution = d_ex; |
ptr = tampon2; |
|
|
if ((*s_etat_processus).affichage_arguments == 'Y') |
while((*ptr) != d_code_fin_chaine) |
{ |
{ |
printf("\n TOKENIZE "); |
if (((*ptr) == d_code_retour_chariot) || |
|
((*ptr) == d_code_tabulation)) |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
(*ptr) = d_code_espace; |
printf("(extraction d'objets en sous-chaînes)\n\n"); |
} |
} |
|
else |
ptr++; |
{ |
} |
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; |
|
} |
|
|
|
if ((*s_objet_argument).type == CHN) |
|
{ |
|
if ((s_objet_resultat = allocation(s_etat_processus, LST)) == NULL) |
if ((s_objet_resultat = allocation(s_etat_processus, LST)) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
Line 654 instruction_tokenize(struct_processus *s
|
Line 742 instruction_tokenize(struct_processus *s
|
.longueur_definitions_chainees; |
.longueur_definitions_chainees; |
registre_position_courante = (*s_etat_processus).position_courante; |
registre_position_courante = (*s_etat_processus).position_courante; |
|
|
(*s_etat_processus).definitions_chainees = (unsigned char *) |
(*s_etat_processus).definitions_chainees = tampon2; |
(*s_objet_argument).objet; |
|
(*s_etat_processus).longueur_definitions_chainees = |
(*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; |
(*s_etat_processus).position_courante = 0; |
|
|
l_element_courant = NULL; |
l_element_courant = NULL; |
Line 678 instruction_tokenize(struct_processus *s
|
Line 765 instruction_tokenize(struct_processus *s
|
(*s_etat_processus).position_courante = |
(*s_etat_processus).position_courante = |
registre_position_courante; |
registre_position_courante; |
|
|
|
free(tampon2); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
Line 723 instruction_tokenize(struct_processus *s
|
Line 812 instruction_tokenize(struct_processus *s
|
(*(*l_element_courant).donnee).objet = (*s_etat_processus) |
(*(*l_element_courant).donnee).objet = (*s_etat_processus) |
.instruction_courante; |
.instruction_courante; |
(*l_element_courant).suivant = NULL; |
(*l_element_courant).suivant = NULL; |
|
|
|
/* |
|
* Rajout du caractère d'échappement devant un guillemet |
|
*/ |
|
|
|
nombre_caracteres_echappement = 0; |
|
ptr = (unsigned char *) (*(*l_element_courant).donnee).objet; |
|
|
|
while((*ptr) != d_code_fin_chaine) |
|
{ |
|
if ((*ptr) == '\"') |
|
{ |
|
nombre_caracteres_echappement++; |
|
} |
|
|
|
ptr++; |
|
} |
|
|
|
if (nombre_caracteres_echappement != 0) |
|
{ |
|
tampon = (unsigned char *) (*(*l_element_courant) |
|
.donnee).objet; |
|
|
|
if (((*(*l_element_courant).donnee).objet = malloc( |
|
(strlen(tampon) + 1 + |
|
((size_t) nombre_caracteres_echappement)) |
|
* sizeof(unsigned char))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
ptr = tampon; |
|
ptr2 = (*(*l_element_courant).donnee).objet; |
|
|
|
while((*ptr) != d_code_fin_chaine) |
|
{ |
|
if ((*ptr) == '\"') |
|
{ |
|
(*(ptr2++)) = '\\'; |
|
|
|
} |
|
else if ((*ptr) == '\\') |
|
{ |
|
(*(ptr2++)) = '\\'; |
|
} |
|
|
|
(*(ptr2++)) = (*(ptr++)); |
|
} |
|
|
|
(*ptr2) = d_code_fin_chaine; |
|
free(tampon); |
|
} |
} |
} |
else |
else |
{ |
{ |
Line 737 instruction_tokenize(struct_processus *s
|
Line 880 instruction_tokenize(struct_processus *s
|
(*s_etat_processus).longueur_definitions_chainees = |
(*s_etat_processus).longueur_definitions_chainees = |
registre_longueur_definitions_chainees; |
registre_longueur_definitions_chainees; |
(*s_etat_processus).position_courante = registre_position_courante; |
(*s_etat_processus).position_courante = registre_position_courante; |
} |
|
|
free(tampon2); |
|
} |
|
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Line 745 instruction_tokenize(struct_processus *s
|
Line 890 instruction_tokenize(struct_processus *s
|
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
*/ |
*/ |
|
|
else |
else |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
|
|
(*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; |
(*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; |
return; |
return; |
} |
} |
|
|
if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), |
if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), |
s_objet_resultat) == d_erreur) |
s_objet_resultat) == d_erreur) |
Line 759 instruction_tokenize(struct_processus *s
|
Line 904 instruction_tokenize(struct_processus *s
|
return; |
return; |
} |
} |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
|
return; |
return; |
|
} |
} |
|
|
|
|
|
/* |
|
================================================================================ |
|
Fonction 't->l' |
|
================================================================================ |
|
Entrées : pointeur sur une structure struct_processus |
|
-------------------------------------------------------------------------------- |
|
Sorties : |
|
-------------------------------------------------------------------------------- |
|
Effets de bord : néant |
|
================================================================================ |
|
*/ |
|
|
|
void |
|
instruction_t_vers_l(struct_processus *s_etat_processus) |
|
{ |
|
logical1 last; |
|
|
|
(*s_etat_processus).erreur_execution = d_ex; |
|
|
|
if ((*s_etat_processus).affichage_arguments == 'Y') |
|
{ |
|
printf("\n T->L "); |
|
|
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf("(converison d'une table en liste)\n\n"); |
|
} |
|
else |
|
{ |
|
printf("(convert table to list)\n\n"); |
|
} |
|
|
|
printf(" 1: %s\n", d_TAB); |
|
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) |
|
{ |
|
last = d_vrai; |
|
cf(s_etat_processus, 31); |
|
|
|
if (empilement_pile_last(s_etat_processus, 1) == d_erreur) |
|
{ |
|
return; |
|
} |
|
} |
|
else |
|
{ |
|
last = d_faux; |
|
} |
|
|
|
instruction_table_fleche(s_etat_processus); |
|
|
|
if (((*s_etat_processus).erreur_systeme == d_es) && |
|
((*s_etat_processus).erreur_execution == d_ex)) |
|
{ |
|
instruction_fleche_list(s_etat_processus); |
|
} |
|
|
|
if (last == d_vrai) |
|
{ |
|
sf(s_etat_processus, 31); |
|
} |
|
|
|
return; |
|
} |
// vim: ts=4 |
// vim: ts=4 |