version 1.5, 2010/03/09 10:18:49
|
version 1.27, 2011/06/24 20:31:41
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.13 |
RPL/2 (R) version 4.1.0.prerelease.4 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2011 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 74 instruction_trnc(struct_processus *s_eta
|
Line 74 instruction_trnc(struct_processus *s_eta
|
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); |
Line 514 instruction_trim(struct_processus *s_eta
|
Line 514 instruction_trim(struct_processus *s_eta
|
{ |
{ |
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 591 instruction_tokenize(struct_processus *s
|
Line 597 instruction_tokenize(struct_processus *s
|
|
|
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 long nombre_caracteres_echappement; |
unsigned long registre_longueur_definitions_chainees; |
unsigned long registre_longueur_definitions_chainees; |
unsigned long registre_position_courante; |
unsigned long registre_position_courante; |
|
|
Line 640 instruction_tokenize(struct_processus *s
|
Line 650 instruction_tokenize(struct_processus *s
|
|
|
if ((*s_objet_argument).type == CHN) |
if ((*s_objet_argument).type == CHN) |
{ |
{ |
|
// Conversion des caractères d'échappement |
|
|
|
ptr = (unsigned char *) (*s_objet_argument).objet; |
|
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; |
|
|
|
// Remplacement des éventuels retours à la ligne et tabulations par |
|
// des espaces. |
|
|
|
ptr = (unsigned char *) (*s_objet_argument).objet; |
|
|
|
while((*ptr) != d_code_fin_chaine) |
|
{ |
|
if (((*ptr) == d_code_retour_chariot) || |
|
((*ptr) == d_code_tabulation)) |
|
{ |
|
(*ptr) = d_code_espace; |
|
} |
|
|
|
ptr++; |
|
} |
|
|
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 723 instruction_tokenize(struct_processus *s
|
Line 802 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 + 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 764 instruction_tokenize(struct_processus *s
|
Line 896 instruction_tokenize(struct_processus *s
|
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 |