1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.3
4: Copyright (C) 1989-2011 Dr. BERTRAND Joël
5:
6: This file is part of RPL/2.
7:
8: RPL/2 is free software; you can redistribute it and/or modify it
9: under the terms of the CeCILL V2 License as published by the french
10: CEA, CNRS and INRIA.
11:
12: RPL/2 is distributed in the hope that it will be useful, but WITHOUT
13: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14: FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License
15: for more details.
16:
17: You should have received a copy of the CeCILL License
18: along with RPL/2. If not, write to info@cecill.info.
19: ================================================================================
20: */
21:
22:
23: #include "rpl-conv.h"
24:
25:
26: /*
27: ================================================================================
28: Fonction 'srev'
29: ================================================================================
30: Entrées :
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_srev(struct_processus *s_etat_processus)
40: {
41: struct_objet *s_objet_argument;
42: struct_objet *s_objet_resultat;
43:
44: unsigned char *ptr_e;
45: unsigned char *ptr_l;
46:
47: if ((*s_etat_processus).affichage_arguments == 'Y')
48: {
49: printf("\n SREV ");
50:
51: if ((*s_etat_processus).langue == 'F')
52: {
53: printf("(inversion d'une chaîne)\n\n");
54: }
55: else
56: {
57: printf("(string inversion)\n\n");
58: }
59:
60: printf(" 1: %s\n", d_CHN);
61: printf("-> 1: %s\n", d_CHN);
62:
63: return;
64: }
65: else if ((*s_etat_processus).test_instruction == 'Y')
66: {
67: (*s_etat_processus).nombre_arguments = 0;
68: return;
69: }
70:
71: if (test_cfsf(s_etat_processus, 31) == d_vrai)
72: {
73: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
74: {
75: return;
76: }
77: }
78:
79: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
80: &s_objet_argument) == d_erreur)
81: {
82: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
83: return;
84: }
85:
86: if ((s_objet_resultat = allocation(s_etat_processus, CHN)) == NULL)
87: {
88: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
89: return;
90: }
91:
92: if (((*s_objet_resultat).objet = malloc((strlen((unsigned char *)
93: (*s_objet_argument).objet) + 1) * sizeof(unsigned char))) == NULL)
94: {
95: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
96: }
97:
98: ptr_l = (unsigned char *) (*s_objet_argument).objet;
99: ptr_e = ((unsigned char *) (*s_objet_resultat).objet) +
100: strlen((unsigned char *) (*s_objet_argument).objet);
101: (*(ptr_e + 1)) = d_code_fin_chaine;
102:
103: while((*ptr_l) != d_code_fin_chaine)
104: {
105: (*ptr_e) = (*ptr_l);
106: ptr_l++;
107: ptr_e--;
108: }
109:
110: liberation(s_etat_processus, s_objet_argument);
111:
112: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
113: s_objet_resultat) == d_erreur)
114: {
115: return;
116: }
117:
118: return;
119: }
120:
121: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>