![]() ![]() | ![]() |
1.1 bertrand 1: /*
2: ================================================================================
1.25 ! bertrand 3: RPL/2 (R) version 4.1.0.prerelease.2
1.18 bertrand 4: Copyright (C) 1989-2011 Dr. BERTRAND Joël
1.1 bertrand 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:
1.13 bertrand 23: #include "rpl-conv.h"
1.1 bertrand 24:
25:
26: /*
27: ================================================================================
28: Fonction 'trnc'
29: ================================================================================
30: Entrées : pointeur sur une structure struct_processus
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_trnc(struct_processus *s_etat_processus)
40: {
41: int parametre;
42:
43: logical1 i43;
44: logical1 i44;
45: logical1 i49;
46: logical1 i50;
47: logical1 i53;
48: logical1 i54;
49: logical1 i55;
50: logical1 i56;
51:
52: struct_objet *s_objet_argument_1;
53: struct_objet *s_objet_argument_2;
54: struct_objet *s_objet_parametre;
55:
56: unsigned char *instruction_courante;
57: unsigned char *valeur_binaire;
58:
59: unsigned long i;
60: unsigned long j;
61:
62: (*s_etat_processus).erreur_execution = d_ex;
63:
64: if ((*s_etat_processus).affichage_arguments == 'Y')
65: {
66: printf("\n TRNC ");
67:
68: if ((*s_etat_processus).langue == 'F')
69: {
70: printf("(troncature)\n\n");
71: }
72: else
73: {
74: printf("(truncation)\n\n");
75: }
76:
1.16 bertrand 77: printf(" 2: %s, %s, %s, %s, %s, %s,\n"
1.1 bertrand 78: " %s, %s, %s\n",
79: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX);
80: printf(" 1: %s\n", d_INT);
81: printf("-> 1: %s, %s, %s, %s, %s, %s,\n"
82: " %s, %s, %s\n",
83: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX);
84:
85: return;
86: }
87: else if ((*s_etat_processus).test_instruction == 'Y')
88: {
89: (*s_etat_processus).nombre_arguments = -1;
90: return;
91: }
92:
93: if (test_cfsf(s_etat_processus, 31) == d_vrai)
94: {
95: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
96: {
97: return;
98: }
99: }
100:
101: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
102: &s_objet_argument_1) == d_erreur)
103: {
104: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
105: return;
106: }
107:
108: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
109: &s_objet_argument_2) == d_erreur)
110: {
111: liberation(s_etat_processus, s_objet_argument_1);
112:
113: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
114: return;
115: }
116:
117: if (((*s_objet_argument_1).type == INT) &&
118: (((*s_objet_argument_2).type == INT) ||
119: ((*s_objet_argument_2).type == REL) ||
120: ((*s_objet_argument_2).type == CPL) ||
121: ((*s_objet_argument_2).type == VIN) ||
122: ((*s_objet_argument_2).type == VRL) ||
123: ((*s_objet_argument_2).type == VCX) ||
124: ((*s_objet_argument_2).type == MIN) ||
125: ((*s_objet_argument_2).type == MRL) ||
126: ((*s_objet_argument_2).type == MCX)))
127: {
128: parametre = (*((integer8 *) (*s_objet_argument_1).objet));
129:
130: if ((parametre >= -15) && (parametre <= 15))
131: {
132: if ((s_objet_parametre = allocation(s_etat_processus, BIN))
133: == NULL)
134: {
135: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
136: return;
137: }
138:
139: (*((integer8 *) (*s_objet_parametre).objet)) =
140: abs((*((integer8 *) (*s_objet_argument_1).objet)));
141:
142: i43 = test_cfsf(s_etat_processus, 43);
143: i44 = test_cfsf(s_etat_processus, 44);
144:
145: sf(s_etat_processus, 44);
146: cf(s_etat_processus, 43);
147:
148: if ((valeur_binaire = formateur(s_etat_processus, 0,
149: s_objet_parametre)) == NULL)
150: {
151: liberation(s_etat_processus, s_objet_parametre);
152:
153: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
154: return;
155: }
156:
157: liberation(s_etat_processus, s_objet_parametre);
158:
159: if (i43 == d_vrai)
160: {
161: sf(s_etat_processus, 43);
162: }
163: else
164: {
165: cf(s_etat_processus, 43);
166: }
167:
168: if (i44 == d_vrai)
169: {
170: sf(s_etat_processus, 44);
171: }
172: else
173: {
174: cf(s_etat_processus, 44);
175: }
176:
177: i53 = test_cfsf(s_etat_processus, 53);
178: i54 = test_cfsf(s_etat_processus, 54);
179: i55 = test_cfsf(s_etat_processus, 55);
180: i56 = test_cfsf(s_etat_processus, 56);
181:
182: for(j = 53, i = strlen(valeur_binaire) - 2; i >= 2; i--)
183: {
184: if (valeur_binaire[i] == '0')
185: {
186: cf(s_etat_processus, j++);
187: }
188: else
189: {
190: sf(s_etat_processus, j++);
191: }
192: }
193:
194: for(; j <= 56; cf(s_etat_processus, j++));
195:
196: free(valeur_binaire);
197:
198: i49 = test_cfsf(s_etat_processus, 49);
199: i50 = test_cfsf(s_etat_processus, 50);
200:
201: if (parametre >= 0)
202: {
203: // Troncature FIX
204: sf(s_etat_processus, 49);
205: cf(s_etat_processus, 50);
206: }
207: else
208: {
209: // Troncature SCI
210: cf(s_etat_processus, 49);
211: sf(s_etat_processus, 50);
212: }
213:
214: instruction_courante = (*s_etat_processus).instruction_courante;
215:
216: if (((*s_etat_processus).instruction_courante =
217: formateur(s_etat_processus, 0, s_objet_argument_2)) == NULL)
218: {
219: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
220: (*s_etat_processus).instruction_courante = instruction_courante;
221: return;
222: }
223:
224: if (i49 == d_vrai)
225: {
226: sf(s_etat_processus, 49);
227: }
228: else
229: {
230: cf(s_etat_processus, 49);
231: }
232:
233: if (i50 == d_vrai)
234: {
235: sf(s_etat_processus, 50);
236: }
237: else
238: {
239: cf(s_etat_processus, 50);
240: }
241:
242: if (i53 == d_vrai)
243: {
244: sf(s_etat_processus, 53);
245: }
246: else
247: {
248: cf(s_etat_processus, 53);
249: }
250:
251: if (i54 == d_vrai)
252: {
253: sf(s_etat_processus, 54);
254: }
255: else
256: {
257: cf(s_etat_processus, 54);
258: }
259:
260: if (i55 == d_vrai)
261: {
262: sf(s_etat_processus, 55);
263: }
264: else
265: {
266: cf(s_etat_processus, 55);
267: }
268:
269: if (i56 == d_vrai)
270: {
271: sf(s_etat_processus, 56);
272: }
273: else
274: {
275: cf(s_etat_processus, 56);
276: }
277:
278: recherche_type(s_etat_processus);
279:
280: free((*s_etat_processus).instruction_courante);
281: (*s_etat_processus).instruction_courante = instruction_courante;
282:
283: if ((*s_etat_processus).erreur_systeme != d_es)
284: {
285: return;
286: }
287:
288: if ((*s_etat_processus).erreur_execution != d_ex)
289: {
290: liberation(s_etat_processus, s_objet_argument_1);
291: liberation(s_etat_processus, s_objet_argument_2);
292: return;
293: }
294: }
295: else
296: {
297: liberation(s_etat_processus, s_objet_argument_1);
298: liberation(s_etat_processus, s_objet_argument_2);
299:
300: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
301: return;
302: }
303: }
304:
305: /*
306: --------------------------------------------------------------------------------
307: Fonction troncature impossible à réaliser
308: --------------------------------------------------------------------------------
309: */
310:
311: else
312: {
313: liberation(s_etat_processus, s_objet_argument_1);
314: liberation(s_etat_processus, s_objet_argument_2);
315:
316: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
317: return;
318: }
319:
320: liberation(s_etat_processus, s_objet_argument_1);
321: liberation(s_etat_processus, s_objet_argument_2);
322:
323: return;
324: }
325:
326:
327: /*
328: ================================================================================
329: Fonction 'table->'
330: ================================================================================
331: Entrées : structure processus
332: --------------------------------------------------------------------------------
333: Sorties :
334: --------------------------------------------------------------------------------
335: Effets de bord : néant
336: ================================================================================
337: */
338:
339: void
340: instruction_table_fleche(struct_processus *s_etat_processus)
341: {
342: struct_objet *s_objet;
343: struct_objet *s_objet_resultat;
344:
345: unsigned long i;
346:
347: (*s_etat_processus).erreur_execution = d_ex;
348:
349: if ((*s_etat_processus).affichage_arguments == 'Y')
350: {
351: printf("\n TABLE-> ");
352:
353: if ((*s_etat_processus).langue == 'F')
354: {
355: printf("(expansion d'une table)\n\n");
356: }
357: else
358: {
359: printf("(expand table)\n\n");
360: }
361:
362: printf(" 1: %s\n", d_TAB);
363: printf("-> n: %s, %s, %s, %s, %s, %s,\n"
364: " %s, %s, %s, %s, %s,\n"
365: " %s, %s, %s, %s, %s,\n"
366: " %s, %s\n",
367: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
368: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SLB);
369: printf(" ...\n");
370: printf(" 2: %s, %s, %s, %s, %s, %s,\n"
371: " %s, %s, %s, %s, %s,\n"
372: " %s, %s, %s, %s, %s,\n"
373: " %s, %s\n",
374: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
375: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SLB);
376: printf(" 1: %s\n", d_INT);
377:
378: return;
379: }
380: else if ((*s_etat_processus).test_instruction == 'Y')
381: {
382: (*s_etat_processus).nombre_arguments = -1;
383: return;
384: }
385:
386: if (test_cfsf(s_etat_processus, 31) == d_vrai)
387: {
388: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
389: {
390: return;
391: }
392: }
393:
394: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
395: &s_objet) == d_erreur)
396: {
397: return;
398: }
399:
400: if ((*s_objet).type != TBL)
401: {
402: liberation(s_etat_processus, s_objet);
403:
404: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
405: return;
406: }
407:
408: for(i = 0; i < (*((struct_tableau *) (*s_objet).objet))
409: .nombre_elements; i++)
410: {
411: if (((*((struct_tableau *) (*s_objet).objet)).elements[i] =
412: copie_objet(s_etat_processus, (*((struct_tableau *)
413: (*s_objet).objet)).elements[i], 'P')) == NULL)
414: {
415: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
416: return;
417: }
418:
419: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
420: (*((struct_tableau *) (*s_objet).objet)).elements[i])
421: == d_erreur)
422: {
423: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
424: return;
425: }
426: }
427:
428: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
429: {
430: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
431: return;
432: }
433:
434: (*((integer8 *) ((*s_objet_resultat).objet))) = (integer8)
435: (*((struct_tableau *) (*s_objet).objet)).nombre_elements;
436:
437: liberation(s_etat_processus, s_objet);
438:
439: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
440: s_objet_resultat) == d_erreur)
441: {
442: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
443: return;
444: }
445:
446: return;
447: }
448:
449:
450: /*
451: ================================================================================
452: Fonction 'trim'
453: ================================================================================
454: Entrées : pointeur sur une structure struct_processus
455: --------------------------------------------------------------------------------
456: Sorties :
457: --------------------------------------------------------------------------------
458: Effets de bord : néant
459: ================================================================================
460: */
461:
462: void
463: instruction_trim(struct_processus *s_etat_processus)
464: {
465: struct_objet *s_objet_argument;
466: struct_objet *s_objet_resultat;
467:
468: unsigned char *debut;
469: unsigned char *fin;
470:
471: (*s_etat_processus).erreur_execution = d_ex;
472:
473: if ((*s_etat_processus).affichage_arguments == 'Y')
474: {
475: printf("\n TRIM ");
476:
477: if ((*s_etat_processus).langue == 'F')
478: {
479: printf("(suppression des espaces initiaux et finaux d'une "
480: "chaîne)\n\n");
481: }
482: else
483: {
484: printf("(delete initial and final spaces from string)\n\n");
485: }
486:
487: printf(" 1: %s\n", d_CHN);
488: printf("-> 1: %s\n", d_CHN);
489:
490: return;
491: }
492: else if ((*s_etat_processus).test_instruction == 'Y')
493: {
494: (*s_etat_processus).nombre_arguments = -1;
495: return;
496: }
497:
498: if (test_cfsf(s_etat_processus, 31) == d_vrai)
499: {
500: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
501: {
502: return;
503: }
504: }
505:
506: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
507: &s_objet_argument) == d_erreur)
508: {
509: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
510: return;
511: }
512:
513: if ((*s_objet_argument).type == CHN)
514: {
515: debut = (unsigned char *) (*s_objet_argument).objet;
516:
1.10 bertrand 517: while(((*debut) != d_code_fin_chaine) &&
518: (((*debut) == d_code_espace)
519: || ((*debut) == d_code_retour_chariot)
520: || ((*debut) == d_code_tabulation)))
1.1 bertrand 521: {
522: debut++;
523: }
524:
525: fin = &(((unsigned char *) (*s_objet_argument).objet)
526: [strlen((unsigned char *) (*s_objet_argument).objet) - 1]);
527:
1.10 bertrand 528: while((fin > debut) &&
529: (((*fin) == d_code_espace)
530: || ((*fin) == d_code_retour_chariot)
531: || ((*fin) == d_code_tabulation)))
1.1 bertrand 532: {
533: fin--;
534: }
535:
536: (*(++fin)) = d_code_fin_chaine;
537:
538: if ((s_objet_resultat = allocation(s_etat_processus, CHN)) == NULL)
539: {
540: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
541: return;
542: }
543:
544: if (((*s_objet_resultat).objet = malloc((1 + fin - debut)
545: * sizeof(unsigned char))) == NULL)
546: {
547: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
548: return;
549: }
550:
551: strcpy((unsigned char *) (*s_objet_resultat).objet, debut);
552: }
553:
554: /*
555: --------------------------------------------------------------------------------
556: Fonction TRIM impossible à réaliser
557: --------------------------------------------------------------------------------
558: */
559:
560: else
561: {
562: liberation(s_etat_processus, s_objet_argument);
563:
564: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
565: return;
566: }
567:
568: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
569: s_objet_resultat) == d_erreur)
570: {
571: return;
572: }
573:
574: liberation(s_etat_processus, s_objet_argument);
575:
576: return;
577: }
578:
579:
580: /*
581: ================================================================================
582: Fonction 'tokenize'
583: ================================================================================
584: Entrées : pointeur sur une structure struct_processus
585: --------------------------------------------------------------------------------
586: Sorties :
587: --------------------------------------------------------------------------------
588: Effets de bord : néant
589: ================================================================================
590: */
591:
592: void
593: instruction_tokenize(struct_processus *s_etat_processus)
594: {
595: struct_objet *s_objet_argument;
596: struct_objet *s_objet_resultat;
597:
598: struct_liste_chainee *l_element_courant;
599:
1.10 bertrand 600: unsigned char *ptr;
1.12 bertrand 601: unsigned char *ptr2;
1.1 bertrand 602: unsigned char *registre_instruction_courante;
603: unsigned char *registre_definitions_chainees;
1.12 bertrand 604: unsigned char *tampon;
1.1 bertrand 605:
1.12 bertrand 606: unsigned long nombre_caracteres_echappement;
1.1 bertrand 607: unsigned long registre_longueur_definitions_chainees;
608: unsigned long registre_position_courante;
609:
610: (*s_etat_processus).erreur_execution = d_ex;
611:
612: if ((*s_etat_processus).affichage_arguments == 'Y')
613: {
614: printf("\n TOKENIZE ");
615:
616: if ((*s_etat_processus).langue == 'F')
617: {
618: printf("(extraction d'objets en sous-chaînes)\n\n");
619: }
620: else
621: {
622: printf("(extract objects in substrings)\n\n");
623: }
624:
625: printf(" 1: %s\n", d_CHN);
626: printf("-> 1: %s\n", d_LST);
627:
628: return;
629: }
630: else if ((*s_etat_processus).test_instruction == 'Y')
631: {
632: (*s_etat_processus).nombre_arguments = -1;
633: return;
634: }
635:
636: if (test_cfsf(s_etat_processus, 31) == d_vrai)
637: {
638: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
639: {
640: return;
641: }
642: }
643:
644: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
645: &s_objet_argument) == d_erreur)
646: {
647: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
648: return;
649: }
650:
651: if ((*s_objet_argument).type == CHN)
652: {
1.12 bertrand 653: // Conversion des caractères d'échappement
654:
655: ptr = (unsigned char *) (*s_objet_argument).objet;
656: ptr2 = ptr;
657:
658: while((*ptr) != d_code_fin_chaine)
659: {
660: (*ptr2) = (*ptr);
661:
662: // Début de la séquence d'échappement
663:
664: if ((*ptr) == '\\')
665: {
666: if ((*(ptr + 1)) == '"')
667: {
668: ptr++;
669: (*ptr2) = '\"';
670: }
671: else if ((*(ptr + 1)) == 'n')
672: {
673: ptr++;
674: (*ptr2) = '\n';
675: }
676: else if ((*(ptr + 1)) == 't')
677: {
678: ptr++;
679: (*ptr2) = '\t';
680: }
681: else if ((*(ptr + 1)) == '\\')
682: {
683: ptr++;
684: }
685: else
686: {
687: if ((*s_etat_processus).langue == 'F')
688: {
689: printf("+++Information : Séquence d'échappement "
690: "inconnue [%d]\n", (int) getpid());
691: }
692: else
693: {
694: printf("+++Warning : Unknown escape code "
695: "[%d]\n", (int) getpid());
696: }
697: }
698: }
699:
700: ptr++;
701: ptr2++;
702: }
703:
704: (*ptr2) = d_code_fin_chaine;
705:
1.10 bertrand 706: // Remplacement des éventuels retours à la ligne et tabulations par
707: // des espaces.
708:
709: ptr = (unsigned char *) (*s_objet_argument).objet;
710:
711: while((*ptr) != d_code_fin_chaine)
712: {
713: if (((*ptr) == d_code_retour_chariot) ||
714: ((*ptr) == d_code_tabulation))
715: {
716: (*ptr) = d_code_espace;
717: }
718:
719: ptr++;
720: }
721:
1.1 bertrand 722: if ((s_objet_resultat = allocation(s_etat_processus, LST)) == NULL)
723: {
724: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
725: return;
726: }
727:
728: registre_instruction_courante = (*s_etat_processus)
729: .instruction_courante;
730: registre_definitions_chainees = (*s_etat_processus)
731: .definitions_chainees;
732: registre_longueur_definitions_chainees = (*s_etat_processus)
733: .longueur_definitions_chainees;
734: registre_position_courante = (*s_etat_processus).position_courante;
735:
736: (*s_etat_processus).definitions_chainees = (unsigned char *)
737: (*s_objet_argument).objet;
738: (*s_etat_processus).longueur_definitions_chainees =
739: strlen((*s_etat_processus).definitions_chainees);
740: (*s_etat_processus).position_courante = 0;
741:
742: l_element_courant = NULL;
743:
744: while((*s_etat_processus).position_courante
745: < (*s_etat_processus).longueur_definitions_chainees)
746: {
747: if (recherche_instruction_suivante(s_etat_processus) == d_erreur)
748: {
749: free((*s_etat_processus).instruction_courante);
750:
751: (*s_etat_processus).instruction_courante =
752: registre_instruction_courante;
753: (*s_etat_processus).definitions_chainees =
754: registre_definitions_chainees;
755: (*s_etat_processus).longueur_definitions_chainees =
756: registre_longueur_definitions_chainees;
757: (*s_etat_processus).position_courante =
758: registre_position_courante;
759:
760: liberation(s_etat_processus, s_objet_argument);
761: liberation(s_etat_processus, s_objet_resultat);
762:
763: return;
764: }
765:
766: if ((*s_etat_processus).instruction_courante[0] !=
767: d_code_fin_chaine)
768: {
769: if (l_element_courant == NULL)
770: {
771: if (((*s_objet_resultat).objet =
772: allocation_maillon(s_etat_processus)) == NULL)
773: {
774: (*s_etat_processus).erreur_systeme =
775: d_es_allocation_memoire;
776: return;
777: }
778:
779: l_element_courant = (*s_objet_resultat).objet;
780: }
781: else
782: {
783: if (((*l_element_courant).suivant =
784: allocation_maillon(s_etat_processus)) == NULL)
785: {
786: (*s_etat_processus).erreur_systeme =
787: d_es_allocation_memoire;
788: return;
789: }
790:
791: l_element_courant = (*l_element_courant).suivant;
792: }
793:
794: if (((*l_element_courant).donnee = allocation(s_etat_processus,
795: CHN)) == NULL)
796: {
797: (*s_etat_processus).erreur_systeme =
798: d_es_allocation_memoire;
799: return;
800: }
801:
802: (*(*l_element_courant).donnee).objet = (*s_etat_processus)
803: .instruction_courante;
804: (*l_element_courant).suivant = NULL;
1.12 bertrand 805:
806: /*
807: * Rajout du caractère d'échappement devant un guillemet
808: */
809:
810: nombre_caracteres_echappement = 0;
811: ptr = (unsigned char *) (*(*l_element_courant).donnee).objet;
812:
813: while((*ptr) != d_code_fin_chaine)
814: {
815: if ((*ptr) == '\"')
816: {
817: nombre_caracteres_echappement++;
818: }
819:
820: ptr++;
821: }
822:
823: if (nombre_caracteres_echappement != 0)
824: {
825: tampon = (unsigned char *) (*(*l_element_courant)
826: .donnee).objet;
827:
828: if (((*(*l_element_courant).donnee).objet = malloc(
829: (strlen(tampon) + 1 + nombre_caracteres_echappement)
830: * sizeof(unsigned char))) == NULL)
831: {
832: (*s_etat_processus).erreur_systeme =
833: d_es_allocation_memoire;
834: return;
835: }
836:
837: ptr = tampon;
838: ptr2 = (*(*l_element_courant).donnee).objet;
839:
840: while((*ptr) != d_code_fin_chaine)
841: {
842: if ((*ptr) == '\"')
843: {
844: (*(ptr2++)) = '\\';
845:
846: }
847: else if ((*ptr) == '\\')
848: {
849: (*(ptr2++)) = '\\';
850: }
851:
852: (*(ptr2++)) = (*(ptr++));
853: }
854:
855: (*ptr2) = d_code_fin_chaine;
856: free(tampon);
857: }
1.1 bertrand 858: }
859: else
860: {
861: free((*s_etat_processus).instruction_courante);
862: }
863: }
864:
865: (*s_etat_processus).instruction_courante =
866: registre_instruction_courante;
867: (*s_etat_processus).definitions_chainees =
868: registre_definitions_chainees;
869: (*s_etat_processus).longueur_definitions_chainees =
870: registre_longueur_definitions_chainees;
871: (*s_etat_processus).position_courante = registre_position_courante;
872: }
873:
874: /*
875: --------------------------------------------------------------------------------
876: Fonction TOKENIZE impossible à réaliser
877: --------------------------------------------------------------------------------
878: */
879:
880: else
881: {
882: liberation(s_etat_processus, s_objet_argument);
883:
884: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
885: return;
886: }
887:
888: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
889: s_objet_resultat) == d_erreur)
890: {
891: return;
892: }
893:
894: liberation(s_etat_processus, s_objet_argument);
895:
896: return;
897: }
898:
1.19 bertrand 899:
900: /*
901: ================================================================================
902: Fonction 't->l'
903: ================================================================================
904: Entrées : pointeur sur une structure struct_processus
905: --------------------------------------------------------------------------------
906: Sorties :
907: --------------------------------------------------------------------------------
908: Effets de bord : néant
909: ================================================================================
910: */
911:
912: void
913: instruction_t_vers_l(struct_processus *s_etat_processus)
914: {
1.20 bertrand 915: logical1 last;
1.19 bertrand 916:
917: (*s_etat_processus).erreur_execution = d_ex;
918:
919: if ((*s_etat_processus).affichage_arguments == 'Y')
920: {
921: printf("\n T->L ");
922:
923: if ((*s_etat_processus).langue == 'F')
924: {
925: printf("(converison d'une table en liste)\n\n");
926: }
927: else
928: {
929: printf("(convert table to list)\n\n");
930: }
931:
932: printf(" 1: %s\n", d_TAB);
933: printf("-> 1: %s\n", d_LST);
934: return;
935: }
936: else if ((*s_etat_processus).test_instruction == 'Y')
937: {
938: (*s_etat_processus).nombre_arguments = -1;
939: return;
940: }
941:
1.20 bertrand 942: if (test_cfsf(s_etat_processus, 31) == d_vrai)
943: {
944: last = d_vrai;
945: cf(s_etat_processus, 31);
946:
947: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
948: {
949: return;
950: }
951: }
952: else
953: {
954: last = d_faux;
955: }
956:
957: instruction_table_fleche(s_etat_processus);
958:
959: if (((*s_etat_processus).erreur_systeme == d_es) &&
960: ((*s_etat_processus).erreur_execution == d_ex))
961: {
962: instruction_fleche_list(s_etat_processus);
963: }
964:
965: if (last == d_vrai)
966: {
967: sf(s_etat_processus, 31);
968: }
969:
1.19 bertrand 970: return;
971: }
1.1 bertrand 972: // vim: ts=4