Annotation of rpl/src/instructions_s1.c, revision 1.64
1.1 bertrand 1: /*
2: ================================================================================
1.63 bertrand 3: RPL/2 (R) version 4.1.13
1.62 bertrand 4: Copyright (C) 1989-2013 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.16 bertrand 23: #include "rpl-conv.h"
1.1 bertrand 24:
25:
26: /*
27: ================================================================================
28: Fonction 'swap'
29: ================================================================================
30: Entrées : structure processus
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_swap(struct_processus *s_etat_processus)
40: {
41: struct_liste_chainee *l_liste;
42:
43: (*s_etat_processus).erreur_execution = d_ex;
44:
45: if ((*s_etat_processus).affichage_arguments == 'Y')
46: {
47: printf("\n SWAP ");
48:
49: if ((*s_etat_processus).langue == 'F')
50: {
51: printf("(inversion de deux objets)\n\n");
52: }
53: else
54: {
55: printf("(swap two objects)\n\n");
56: }
57:
58: printf(" 2: %s, %s, %s, %s, %s, %s,\n"
59: " %s, %s, %s, %s, %s,\n"
60: " %s, %s, %s, %s, %s,\n"
61: " %s, %s, %s, %s, %s,\n"
62: " %s\n",
63: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
64: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
65: d_SLB, d_PRC, d_MTX, d_SQL);
66: printf(" 1: %s, %s, %s, %s, %s, %s,\n"
67: " %s, %s, %s, %s, %s,\n"
68: " %s, %s, %s, %s, %s,\n"
69: " %s, %s, %s, %s, %s,\n"
70: " %s\n",
71: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
72: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
73: d_SLB, d_PRC, d_MTX, d_SQL);
74: printf("-> 2: %s, %s, %s, %s, %s, %s,\n"
75: " %s, %s, %s, %s, %s,\n"
76: " %s, %s, %s, %s, %s,\n"
77: " %s, %s, %s, %s, %s,\n"
78: " %s\n",
79: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
80: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
81: d_SLB, d_PRC, d_MTX, d_SQL);
82: printf(" 1: %s, %s, %s, %s, %s, %s,\n"
83: " %s, %s, %s, %s, %s,\n"
84: " %s, %s, %s, %s, %s,\n"
85: " %s, %s, %s, %s, %s,\n"
86: " %s\n",
87: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
88: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
89: d_SLB, d_PRC, d_MTX, d_SQL);
90:
91: return;
92: }
93: else if ((*s_etat_processus).test_instruction == 'Y')
94: {
95: (*s_etat_processus).nombre_arguments = -1;
96: return;
97: }
98:
99: if (test_cfsf(s_etat_processus, 31) == d_vrai)
100: {
101: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
102: {
103: return;
104: }
105: }
106:
107: if ((*s_etat_processus).hauteur_pile_operationnelle < 2)
108: {
109: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
110: return;
111: }
112:
113: l_liste = (*s_etat_processus).l_base_pile;
114: (*s_etat_processus).l_base_pile = (*l_liste).suivant;
115: (*l_liste).suivant = (*(*s_etat_processus).l_base_pile).suivant;
116: (*(*s_etat_processus).l_base_pile).suivant = l_liste;
117:
118: return;
119: }
120:
121:
122: /*
123: ================================================================================
124: Fonction 'sq'
125: ================================================================================
126: Entrées : pointeur sur une struct_processus
127: --------------------------------------------------------------------------------
128: Sorties :
129: --------------------------------------------------------------------------------
130: Effets de bord : néant
131: ================================================================================
132: */
133:
134: void
135: instruction_sq(struct_processus *s_etat_processus)
136: {
137: integer8 a;
138: integer8 r;
139:
140: logical1 depassement;
141: logical1 erreur_memoire;
142:
143: struct_liste_chainee *l_element_courant;
144: struct_liste_chainee *l_element_precedent;
145:
146: struct_objet *s_copie_argument;
147: struct_objet *s_objet_argument;
148: struct_objet *s_objet_resultat;
149:
150: unsigned long i;
151: unsigned long j;
152: unsigned long k;
153:
154: void *accumulateur;
155:
156: (*s_etat_processus).erreur_execution = d_ex;
157:
158: if ((*s_etat_processus).affichage_arguments == 'Y')
159: {
160: printf("\n SQ ");
161:
162: if ((*s_etat_processus).langue == 'F')
163: {
164: printf("(élevation au carré)\n\n");
165: }
166: else
167: {
168: printf("(square)\n\n");
169: }
170:
171: printf(" 1: %s, %s, %s\n", d_INT, d_REL, d_CPL);
172: printf("-> 1: %s, %s, %s\n\n", d_INT, d_REL, d_CPL);
173:
174: printf(" 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
175: printf("-> 1: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX);
176:
177: printf(" 1: %s, %s\n", d_NOM, d_ALG);
178: printf("-> 1: %s\n\n", d_ALG);
179:
180: printf(" 1: %s\n", d_RPN);
181: printf("-> 1: %s\n", d_RPN);
182:
183: return;
184: }
185: else if ((*s_etat_processus).test_instruction == 'Y')
186: {
187: (*s_etat_processus).nombre_arguments = 1;
188: return;
189: }
190:
191: if (test_cfsf(s_etat_processus, 31) == d_vrai)
192: {
193: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
194: {
195: return;
196: }
197: }
198:
199: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
200: &s_objet_argument) == d_erreur)
201: {
202: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
203: return;
204: }
205:
206: /*
207: --------------------------------------------------------------------------------
208: Carré d'un entier
209: --------------------------------------------------------------------------------
210: */
211:
212: if ((*s_objet_argument).type == INT)
213: {
214: a = (*((integer8 *) (*s_objet_argument).objet));
215:
216: if (depassement_multiplication(&a, &a, &r) == d_absence_erreur)
217: {
218: if ((s_objet_resultat = allocation(s_etat_processus, INT))
219: == NULL)
220: {
221: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
222: return;
223: }
224:
225: (*((integer8 *) (*s_objet_resultat).objet)) = r;
226: }
227: else
228: {
229: if ((s_objet_resultat = allocation(s_etat_processus, REL))
230: == NULL)
231: {
232: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
233: return;
234: }
235:
236: (*((real8 *) (*s_objet_resultat).objet)) =
237: ((double) (*((integer8 *) (*s_objet_argument).objet))) *
238: ((double) (*((integer8 *) (*s_objet_argument).objet)));
239: }
240: }
241:
242: /*
243: --------------------------------------------------------------------------------
244: Carré d'un réel
245: --------------------------------------------------------------------------------
246: */
247:
248: else if ((*s_objet_argument).type == REL)
249: {
250: if ((s_objet_resultat = allocation(s_etat_processus, REL)) == NULL)
251: {
252: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
253: return;
254: }
255:
256: (*((real8 *) (*s_objet_resultat).objet)) =
257: (*((real8 *) (*s_objet_argument).objet)) *
258: (*((real8 *) (*s_objet_argument).objet));
259: }
260:
261: /*
262: --------------------------------------------------------------------------------
263: Carré d'un complexe
264: --------------------------------------------------------------------------------
265: */
266:
267: else if ((*s_objet_argument).type == CPL)
268: {
269: if ((s_objet_resultat = allocation(s_etat_processus, CPL)) == NULL)
270: {
271: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
272: return;
273: }
274:
275: f77multiplicationcc_(&((*((struct_complexe16 *)
276: (*s_objet_argument).objet))), &((*((struct_complexe16 *)
277: (*s_objet_argument).objet))), &((*((struct_complexe16 *)
278: (*s_objet_resultat).objet))));
279: }
280:
281: /*
282: --------------------------------------------------------------------------------
283: Carré d'une matrice entière
284: --------------------------------------------------------------------------------
285: */
286:
287: else if ((*s_objet_argument).type == MIN)
288: {
289: if ((*((struct_matrice *) (*s_objet_argument).objet)).nombre_lignes !=
290: (*((struct_matrice *) (*s_objet_argument).objet))
291: .nombre_colonnes)
292: {
293: liberation(s_etat_processus, s_objet_argument);
294:
295: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
296: return;
297: }
298:
299: if ((s_objet_resultat = allocation(s_etat_processus, MIN)) == NULL)
300: {
301: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
302: return;
303: }
304:
305: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_lignes =
306: (*(((struct_matrice *) (*s_objet_argument)
307: .objet))).nombre_lignes;
308: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_colonnes =
309: (*(((struct_matrice *) (*s_objet_argument)
310: .objet))).nombre_colonnes;
311:
312: if (((*((struct_matrice *) (*s_objet_resultat).objet)).tableau =
313: malloc((*(((struct_matrice *) (*s_objet_resultat)
314: .objet))).nombre_lignes * sizeof(integer8 *))) == NULL)
315: {
316: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
317: return;
318: }
319:
320: depassement = d_faux;
321:
322: for(i = 0; i < (*(((struct_matrice *) (*s_objet_resultat)
323: .objet))).nombre_lignes; i++)
324: {
325: if (((*((struct_matrice *) (*s_objet_resultat).objet)).tableau[i] =
326: malloc((*(((struct_matrice *) (*s_objet_resultat)
327: .objet))).nombre_colonnes * sizeof(integer8))) == NULL)
328: {
329: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
330: return;
331: }
332:
333: for(j = 0; j < (*(((struct_matrice *) (*s_objet_resultat)
334: .objet))).nombre_colonnes; j++)
335: {
336: ((integer8 **) (*((struct_matrice *)
337: (*s_objet_resultat).objet)).tableau)[i][j] = 0;
338:
339: for(k = 0; k < (*(((struct_matrice *) (*s_objet_argument)
340: .objet))).nombre_colonnes; k++)
341: {
342: if (depassement_multiplication(&(((integer8 **)
343: (*((struct_matrice *) (*s_objet_argument).objet))
344: .tableau)[i][k]), &(((integer8 **)
345: (*((struct_matrice *) (*s_objet_argument).objet))
346: .tableau)[k][j]), &a) == d_erreur)
347: {
348: depassement = d_vrai;
349: }
350:
351: if (depassement_addition(&(((integer8 **)
352: (*((struct_matrice *) (*s_objet_resultat).objet))
353: .tableau)[i][j]), &a, &r) == d_erreur)
354: {
355: depassement = d_vrai;
356: }
357:
358: ((integer8 **) (*((struct_matrice *) (*s_objet_resultat)
359: .objet)).tableau)[i][j] = r;
360: }
361: }
362: }
363:
364: if (depassement == d_vrai)
365: {
366: (*s_objet_resultat).type = MRL;
367: (*((struct_matrice *) (*s_objet_resultat).objet)).type = 'R';
368:
369: if ((accumulateur = malloc((*(((struct_matrice *)
370: (*s_objet_argument).objet))).nombre_colonnes *
371: sizeof(real8))) == NULL)
372: {
373: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
374: return;
375: }
376:
377: for(i = 0; i < (*(((struct_matrice *) (*s_objet_resultat)
378: .objet))).nombre_lignes; i++)
379: {
380: free(((integer8 **) (*((struct_matrice *)
381: (*s_objet_resultat).objet)).tableau)[i]);
382:
383: if (((*((struct_matrice *) (*s_objet_resultat).objet))
384: .tableau[i] = malloc((*(((struct_matrice *)
385: (*s_objet_resultat).objet))).nombre_colonnes *
386: sizeof(real8))) == NULL)
387: {
388: (*s_etat_processus).erreur_systeme =
389: d_es_allocation_memoire;
390: return;
391: }
392:
393: for(j = 0; j < (*(((struct_matrice *) (*s_objet_resultat)
394: .objet))).nombre_colonnes; j++)
395: {
396: ((real8 **) (*((struct_matrice *)
397: (*s_objet_resultat).objet)).tableau)[i][j] = 0;
398:
399: for(k = 0; k < (*(((struct_matrice *) (*s_objet_argument)
400: .objet))).nombre_colonnes; k++)
401: {
402: ((real8 *) accumulateur)[k] = ((real8)
403: (((integer8 **) (*((struct_matrice *)
404: (*s_objet_argument).objet)).tableau)[i][k]) *
405: ((real8) ((integer8 **) (*((struct_matrice *)
406: (*s_objet_argument).objet)).tableau)[k][j]));
407: }
408:
409: ((real8 **) (*((struct_matrice *)
410: (*s_objet_resultat).objet)).tableau)[i][j] =
411: sommation_vecteur_reel(accumulateur,
412: &((*(((struct_matrice *) (*s_objet_argument)
413: .objet))).nombre_colonnes), &erreur_memoire);
414:
415: if (erreur_memoire == d_vrai)
416: {
417: (*s_etat_processus).erreur_systeme =
418: d_es_allocation_memoire;
419: return;
420: }
421: }
422: }
423:
424: free(accumulateur);
425: }
426: }
427:
428: /*
429: --------------------------------------------------------------------------------
430: Carré d'une matrice réelle
431: --------------------------------------------------------------------------------
432: */
433:
434: else if ((*s_objet_argument).type == MRL)
435: {
436: if ((*((struct_matrice *) (*s_objet_argument).objet)).nombre_lignes !=
437: (*((struct_matrice *) (*s_objet_argument).objet))
438: .nombre_colonnes)
439: {
440: liberation(s_etat_processus, s_objet_argument);
441:
442: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
443: return;
444: }
445:
446: if ((s_objet_resultat = allocation(s_etat_processus, MRL)) == NULL)
447: {
448: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
449: return;
450: }
451:
452: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_lignes =
453: (*(((struct_matrice *) (*s_objet_argument)
454: .objet))).nombre_lignes;
455: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_colonnes =
456: (*(((struct_matrice *) (*s_objet_argument)
457: .objet))).nombre_colonnes;
458:
459: if (((*((struct_matrice *) (*s_objet_resultat).objet)).tableau =
460: malloc((*(((struct_matrice *) (*s_objet_resultat)
461: .objet))).nombre_lignes * sizeof(real8 *))) == NULL)
462: {
463: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
464: return;
465: }
466:
467: if ((accumulateur = malloc((*(((struct_matrice *)
468: (*s_objet_argument).objet))).nombre_colonnes * sizeof(real8)))
469: == NULL)
470: {
471: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
472: return;
473: }
474:
475: for(i = 0; i < (*(((struct_matrice *) (*s_objet_resultat)
476: .objet))).nombre_lignes; i++)
477: {
478: if (((*((struct_matrice *) (*s_objet_resultat).objet)).tableau[i] =
479: malloc((*(((struct_matrice *) (*s_objet_resultat)
480: .objet))).nombre_colonnes * sizeof(real8))) == NULL)
481: {
482: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
483: return;
484: }
485:
486: for(j = 0; j < (*(((struct_matrice *) (*s_objet_resultat)
487: .objet))).nombre_colonnes; j++)
488: {
489: ((real8 **) (*((struct_matrice *)
490: (*s_objet_resultat).objet)).tableau)[i][j] = 0;
491:
492: for(k = 0; k < (*(((struct_matrice *) (*s_objet_argument)
493: .objet))).nombre_colonnes; k++)
494: {
495: ((real8 *) accumulateur)[k] =
496: (((real8 **) (*((struct_matrice *)
497: (*s_objet_argument).objet)).tableau)[i][k] *
498: ((real8 **) (*((struct_matrice *)
499: (*s_objet_argument).objet)).tableau)[k][j]);
500: }
501:
502: ((real8 **) (*((struct_matrice *) (*s_objet_resultat).objet))
503: .tableau)[i][j] = sommation_vecteur_reel(
504: accumulateur, &((*(((struct_matrice *)
505: (*s_objet_argument).objet))).nombre_colonnes),
506: &erreur_memoire);
507:
508: if (erreur_memoire == d_vrai)
509: {
510: (*s_etat_processus).erreur_systeme =
511: d_es_allocation_memoire;
512: return;
513: }
514: }
515: }
516:
517: free(accumulateur);
518: }
519:
520: /*
521: --------------------------------------------------------------------------------
522: Carré d'une matrice complexe
523: --------------------------------------------------------------------------------
524: */
525:
526: else if ((*s_objet_argument).type == MCX)
527: {
528: if ((*((struct_matrice *) (*s_objet_argument).objet)).nombre_lignes !=
529: (*((struct_matrice *) (*s_objet_argument).objet))
530: .nombre_colonnes)
531: {
532: liberation(s_etat_processus, s_objet_argument);
533:
534: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
535: return;
536: }
537:
538: if ((s_objet_resultat = allocation(s_etat_processus, MCX)) == NULL)
539: {
540: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
541: return;
542: }
543:
544: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_lignes =
545: (*(((struct_matrice *) (*s_objet_argument)
546: .objet))).nombre_lignes;
547: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_colonnes =
548: (*(((struct_matrice *) (*s_objet_argument)
549: .objet))).nombre_colonnes;
550:
551: if (((*((struct_matrice *) (*s_objet_resultat).objet)).tableau =
552: malloc((*(((struct_matrice *) (*s_objet_resultat)
553: .objet))).nombre_lignes * sizeof(struct_complexe16 *))) == NULL)
554: {
555: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
556: return;
557: }
558:
559: if ((accumulateur = malloc((*(((struct_matrice *)
560: (*s_objet_argument).objet))).nombre_colonnes *
561: sizeof(complex16))) == NULL)
562: {
563: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
564: return;
565: }
566:
567: for(i = 0; i < (*(((struct_matrice *) (*s_objet_resultat)
568: .objet))).nombre_lignes; i++)
569: {
570: if (((*((struct_matrice *) (*s_objet_resultat).objet)).tableau[i] =
571: malloc((*(((struct_matrice *) (*s_objet_resultat)
572: .objet))).nombre_colonnes * sizeof(struct_complexe16)))
573: == NULL)
574: {
575: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
576: return;
577: }
578:
579: for(j = 0; j < (*(((struct_matrice *) (*s_objet_resultat)
580: .objet))).nombre_colonnes; j++)
581: {
582: ((struct_complexe16 **) (*((struct_matrice *)
583: (*s_objet_resultat).objet)).tableau)[i][j]
584: .partie_reelle = 0;
585: ((struct_complexe16 **) (*((struct_matrice *)
586: (*s_objet_resultat).objet)).tableau)[i][j]
587: .partie_imaginaire = 0;
588:
589: for(k = 0; k < (*(((struct_matrice *) (*s_objet_argument)
590: .objet))).nombre_colonnes; k++)
591: {
592: f77multiplicationcc_(&(((struct_complexe16 **)
593: (*((struct_matrice *) (*s_objet_argument).objet))
594: .tableau)[i][k]), &(((struct_complexe16 **)
595: (*((struct_matrice *) (*s_objet_argument).objet))
596: .tableau)[k][j]), &(((complex16 *)
597: accumulateur)[k]));
598: }
599:
600: ((complex16 **) (*((struct_matrice *)
601: (*s_objet_resultat).objet)).tableau)[i][j] =
602: sommation_vecteur_complexe(accumulateur,
603: &((*(((struct_matrice *)
604: (*s_objet_argument).objet))).nombre_colonnes),
605: &erreur_memoire);
606:
607: if (erreur_memoire == d_vrai)
608: {
609: (*s_etat_processus).erreur_systeme =
610: d_es_allocation_memoire;
611: return;
612: }
613: }
614: }
615:
616: free(accumulateur);
617: }
618:
619: /*
620: --------------------------------------------------------------------------------
621: Carré d'un nom
622: --------------------------------------------------------------------------------
623: */
624: else if ((*s_objet_argument).type == NOM)
625: {
626: if ((s_objet_resultat = allocation(s_etat_processus, ALG)) == NULL)
627: {
628: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
629: return;
630: }
631:
632: if (((*s_objet_resultat).objet =
633: allocation_maillon(s_etat_processus)) == NULL)
634: {
635: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
636: return;
637: }
638:
639: l_element_courant = (*s_objet_resultat).objet;
640:
641: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
642: == NULL)
643: {
644: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
645: return;
646: }
647:
648: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
649: .nombre_arguments = 0;
650: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
651: .fonction = instruction_vers_niveau_superieur;
652:
653: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
654: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
655: {
656: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
657: return;
658: }
659:
660: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
661: .nom_fonction, "<<");
662:
663: if (((*l_element_courant).suivant =
664: allocation_maillon(s_etat_processus)) == NULL)
665: {
666: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
667: return;
668: }
669:
670: l_element_courant = (*l_element_courant).suivant;
671: (*l_element_courant).donnee = s_objet_argument;
672:
673: if (((*l_element_courant).suivant =
674: allocation_maillon(s_etat_processus)) == NULL)
675: {
676: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
677: return;
678: }
679:
680: l_element_courant = (*l_element_courant).suivant;
681:
682: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
683: == NULL)
684: {
685: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
686: return;
687: }
688:
689: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
690: .nombre_arguments = 1;
691: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
692: .fonction = instruction_sq;
693:
694: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
695: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
696: {
697: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
698: return;
699: }
700:
701: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
702: .nom_fonction, "SQ");
703:
704: if (((*l_element_courant).suivant =
705: allocation_maillon(s_etat_processus)) == NULL)
706: {
707: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
708: return;
709: }
710:
711: l_element_courant = (*l_element_courant).suivant;
712:
713: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
714: == NULL)
715: {
716: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
717: return;
718: }
719:
720: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
721: .nombre_arguments = 0;
722: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
723: .fonction = instruction_vers_niveau_inferieur;
724:
725: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
726: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
727: {
728: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
729: return;
730: }
731:
732: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
733: .nom_fonction, ">>");
734:
735: (*l_element_courant).suivant = NULL;
736: s_objet_argument = NULL;
737: }
738:
739: /*
740: --------------------------------------------------------------------------------
741: Carré d'une expression
742: --------------------------------------------------------------------------------
743: */
744:
745: else if (((*s_objet_argument).type == ALG) ||
746: ((*s_objet_argument).type == RPN))
747: {
748: if ((s_copie_argument = copie_objet(s_etat_processus, s_objet_argument,
749: 'N')) == NULL)
750: {
751: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
752: return;
753: }
754:
755: l_element_courant = (struct_liste_chainee *)
756: (*s_copie_argument).objet;
757: l_element_precedent = l_element_courant;
758:
759: while((*l_element_courant).suivant != NULL)
760: {
761: l_element_precedent = l_element_courant;
762: l_element_courant = (*l_element_courant).suivant;
763: }
764:
765: if (((*l_element_precedent).suivant =
766: allocation_maillon(s_etat_processus)) == NULL)
767: {
768: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
769: return;
770: }
771:
772: if (((*(*l_element_precedent).suivant).donnee =
773: allocation(s_etat_processus, FCT)) == NULL)
774: {
775: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
776: return;
777: }
778:
779: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
780: .donnee).objet)).nombre_arguments = 1;
781: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
782: .donnee).objet)).fonction = instruction_sq;
783:
784: if (((*((struct_fonction *) (*(*(*l_element_precedent)
785: .suivant).donnee).objet)).nom_fonction =
786: malloc(3 * sizeof(unsigned char))) == NULL)
787: {
788: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
789: return;
790: }
791:
792: strcpy((*((struct_fonction *) (*(*(*l_element_precedent)
793: .suivant).donnee).objet)).nom_fonction, "SQ");
794:
795: (*(*l_element_precedent).suivant).suivant = l_element_courant;
796:
797: s_objet_resultat = s_copie_argument;
798: }
799:
800: /*
801: --------------------------------------------------------------------------------
802: Carré impossible
803: --------------------------------------------------------------------------------
804: */
805:
806: else
807: {
808: liberation(s_etat_processus, s_objet_argument);
809:
810: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
811: return;
812: }
813:
814: liberation(s_etat_processus, s_objet_argument);
815:
816: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
817: s_objet_resultat) == d_erreur)
818: {
819: return;
820: }
821:
822: return;
823: }
824:
825:
826: /*
827: ================================================================================
828: Fonction 'sqrt'
829: ================================================================================
830: Entrées : pointeur sur une struct_processus
831: --------------------------------------------------------------------------------
832: Sorties :
833: --------------------------------------------------------------------------------
834: Effets de bord : néant
835: ================================================================================
836: */
837:
838: void
839: instruction_sqrt(struct_processus *s_etat_processus)
840: {
841: struct_liste_chainee *l_element_courant;
842: struct_liste_chainee *l_element_precedent;
843:
844: struct_objet *s_copie_argument;
845: struct_objet *s_objet_argument;
846: struct_objet *s_objet_resultat;
847:
848: (*s_etat_processus).erreur_execution = d_ex;
849:
850: if ((*s_etat_processus).affichage_arguments == 'Y')
851: {
852: printf("\n SQRT ");
853:
854: if ((*s_etat_processus).langue == 'F')
855: {
856: printf("(racine carrée)\n\n");
857: }
858: else
859: {
860: printf("(square root)\n\n");
861: }
862:
863: printf(" 1: %s, %s, %s\n", d_INT, d_REL, d_CPL);
864: printf("-> 1: %s, %s\n\n", d_REL, d_CPL);
865:
866: printf(" 1: %s, %s\n", d_NOM, d_ALG);
867: printf("-> 1: %s\n\n", d_ALG);
868:
869: printf(" 1: %s\n", d_RPN);
870: printf("-> 1: %s\n", d_RPN);
871:
872: return;
873: }
874: else if ((*s_etat_processus).test_instruction == 'Y')
875: {
876: (*s_etat_processus).nombre_arguments = 1;
877: return;
878: }
879:
880: if (test_cfsf(s_etat_processus, 31) == d_vrai)
881: {
882: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
883: {
884: return;
885: }
886: }
887:
888: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
889: &s_objet_argument) == d_erreur)
890: {
891: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
892: return;
893: }
894:
895: /*
896: --------------------------------------------------------------------------------
897: Racine carrée d'un entier
898: --------------------------------------------------------------------------------
899: */
900:
901: if ((*s_objet_argument).type == INT)
902: {
903: if ((*((integer8 *) (*s_objet_argument).objet)) >= 0)
904: {
905: if ((s_objet_resultat = allocation(s_etat_processus, REL))
906: == NULL)
907: {
908: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
909: return;
910: }
911:
912: f77racinecarreeip_(&((*((integer8 *) (*s_objet_argument).objet))),
913: &((*((real8 *) (*s_objet_resultat).objet))));
914: }
915: else
916: {
917: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
918: == NULL)
919: {
920: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
921: return;
922: }
923:
924: f77racinecarreein_(&((*((integer8 *) (*s_objet_argument).objet))),
925: &((*((struct_complexe16 *) (*s_objet_resultat).objet))));
926: }
927: }
928:
929: /*
930: --------------------------------------------------------------------------------
931: Racine carré d'un réel
932: --------------------------------------------------------------------------------
933: */
934:
935: else if ((*s_objet_argument).type == REL)
936: {
937: if ((*((real8 *) (*s_objet_argument).objet)) >= 0)
938: {
939: if ((s_objet_resultat = allocation(s_etat_processus, REL))
940: == NULL)
941: {
942: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
943: return;
944: }
945:
946: f77racinecarreerp_(&((*((real8 *) (*s_objet_argument).objet))),
947: &((*((real8 *) (*s_objet_resultat).objet))));
948: }
949: else
950: {
951: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
952: == NULL)
953: {
954: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
955: return;
956: }
957:
958: f77racinecarreern_(&((*((real8 *) (*s_objet_argument).objet))),
959: &((*((struct_complexe16 *) (*s_objet_resultat).objet))));
960: }
961: }
962:
963: /*
964: --------------------------------------------------------------------------------
965: Racine carrée d'un complexe
966: --------------------------------------------------------------------------------
967: */
968:
969: else if ((*s_objet_argument).type == CPL)
970: {
971: if ((s_objet_resultat = allocation(s_etat_processus, CPL)) == NULL)
972: {
973: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
974: return;
975: }
976:
977: f77racinecarreec_(&((*((struct_complexe16 *) (*s_objet_argument)
978: .objet))), &((*((struct_complexe16 *) (*s_objet_resultat)
979: .objet))));
980: }
981:
982: /*
983: --------------------------------------------------------------------------------
984: Racine carrée d'un nom
985: --------------------------------------------------------------------------------
986: */
987:
988: else if ((*s_objet_argument).type == NOM)
989: {
990: if ((s_objet_resultat = allocation(s_etat_processus, ALG)) == NULL)
991: {
992: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
993: return;
994: }
995:
996: if (((*s_objet_resultat).objet =
997: allocation_maillon(s_etat_processus)) == NULL)
998: {
999: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1000: return;
1001: }
1002:
1003: l_element_courant = (*s_objet_resultat).objet;
1004:
1005: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
1006: == NULL)
1007: {
1008: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1009: return;
1010: }
1011:
1012: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1013: .nombre_arguments = 0;
1014: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1015: .fonction = instruction_vers_niveau_superieur;
1016:
1017: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1018: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
1019: {
1020: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1021: return;
1022: }
1023:
1024: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1025: .nom_fonction, "<<");
1026:
1027: if (((*l_element_courant).suivant =
1028: allocation_maillon(s_etat_processus)) == NULL)
1029: {
1030: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1031: return;
1032: }
1033:
1034: l_element_courant = (*l_element_courant).suivant;
1035: (*l_element_courant).donnee = s_objet_argument;
1036:
1037: if (((*l_element_courant).suivant =
1038: allocation_maillon(s_etat_processus)) == NULL)
1039: {
1040: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1041: return;
1042: }
1043:
1044: l_element_courant = (*l_element_courant).suivant;
1045:
1046: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
1047: == NULL)
1048: {
1049: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1050: return;
1051: }
1052:
1053: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1054: .nombre_arguments = 1;
1055: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1056: .fonction = instruction_sqrt;
1057:
1058: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1059: .nom_fonction = malloc(5 * sizeof(unsigned char))) == NULL)
1060: {
1061: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1062: return;
1063: }
1064:
1065: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1066: .nom_fonction, "SQRT");
1067:
1068: if (((*l_element_courant).suivant =
1069: allocation_maillon(s_etat_processus)) == NULL)
1070: {
1071: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1072: return;
1073: }
1074:
1075: l_element_courant = (*l_element_courant).suivant;
1076:
1077: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
1078: == NULL)
1079: {
1080: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1081: return;
1082: }
1083:
1084: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1085: .nombre_arguments = 0;
1086: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1087: .fonction = instruction_vers_niveau_inferieur;
1088:
1089: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1090: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
1091: {
1092: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1093: return;
1094: }
1095:
1096: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
1097: .nom_fonction, ">>");
1098:
1099: (*l_element_courant).suivant = NULL;
1100: s_objet_argument = NULL;
1101: }
1102:
1103: /*
1104: --------------------------------------------------------------------------------
1105: Racine carrée d'une expression
1106: --------------------------------------------------------------------------------
1107: */
1108:
1109: else if (((*s_objet_argument).type == ALG) ||
1110: ((*s_objet_argument).type == RPN))
1111: {
1112: if ((s_copie_argument = copie_objet(s_etat_processus, s_objet_argument,
1113: 'N')) == NULL)
1114: {
1115: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1116: return;
1117: }
1118:
1119: l_element_courant = (struct_liste_chainee *)
1120: (*s_copie_argument).objet;
1121: l_element_precedent = l_element_courant;
1122:
1123: while((*l_element_courant).suivant != NULL)
1124: {
1125: l_element_precedent = l_element_courant;
1126: l_element_courant = (*l_element_courant).suivant;
1127: }
1128:
1129: if (((*l_element_precedent).suivant =
1130: allocation_maillon(s_etat_processus)) == NULL)
1131: {
1132: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1133: return;
1134: }
1135:
1136: if (((*(*l_element_precedent).suivant).donnee =
1137: allocation(s_etat_processus, FCT)) == NULL)
1138: {
1139: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1140: return;
1141: }
1142:
1143: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
1144: .donnee).objet)).nombre_arguments = 1;
1145: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
1146: .donnee).objet)).fonction = instruction_sqrt;
1147:
1148: if (((*((struct_fonction *) (*(*(*l_element_precedent)
1149: .suivant).donnee).objet)).nom_fonction =
1150: malloc(5 * sizeof(unsigned char))) == NULL)
1151: {
1152: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1153: return;
1154: }
1155:
1156: strcpy((*((struct_fonction *) (*(*(*l_element_precedent)
1157: .suivant).donnee).objet)).nom_fonction, "SQRT");
1158:
1159: (*(*l_element_precedent).suivant).suivant = l_element_courant;
1160:
1161: s_objet_resultat = s_copie_argument;
1162: }
1163:
1164: /*
1165: --------------------------------------------------------------------------------
1166: Racine carrée impossible
1167: --------------------------------------------------------------------------------
1168: */
1169:
1170: else
1171: {
1172: liberation(s_etat_processus, s_objet_argument);
1173:
1174: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1175: return;
1176: }
1177:
1178: liberation(s_etat_processus, s_objet_argument);
1179:
1180: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1181: s_objet_resultat) == d_erreur)
1182: {
1183: return;
1184: }
1185:
1186: return;
1187: }
1188:
1189:
1190: /*
1191: ================================================================================
1192: Fonction 'same'
1193: ================================================================================
1194: Entrées : pointeur sur une structure struct_processus
1195: --------------------------------------------------------------------------------
1196: Sorties :
1197: --------------------------------------------------------------------------------
1198: Effets de bord : néant
1199: ================================================================================
1200: */
1201:
1202: void
1203: instruction_same(struct_processus *s_etat_processus)
1204: {
1205: struct_liste_chainee *l_element_courant;
1206: struct_liste_chainee *l_element_courant_1;
1207: struct_liste_chainee *l_element_courant_2;
1208: struct_liste_chainee *l_element_precedent;
1209:
1210: struct_objet *s_copie_argument_1;
1211: struct_objet *s_copie_argument_2;
1212: struct_objet *s_objet_argument_1;
1213: struct_objet *s_objet_argument_2;
1214: struct_objet *s_objet_resultat;
1215: struct_objet *s_objet_resultat_intermediaire;
1216:
1217: logical1 difference;
1218:
1219: unsigned long i;
1220: unsigned long j;
1221: unsigned long nombre_elements;
1222:
1223: (*s_etat_processus).erreur_execution = d_ex;
1224:
1225: if ((*s_etat_processus).affichage_arguments == 'Y')
1226: {
1227: printf("\n SAME ");
1228:
1229: if ((*s_etat_processus).langue == 'F')
1230: {
1231: printf("(opérateur égalité)\n\n");
1232: }
1233: else
1234: {
1235: printf("(equality operator)\n\n");
1236: }
1237:
1238: printf(" 2: %s, %s, %s\n", d_INT, d_REL, d_CPL);
1239: printf(" 1: %s, %s, %s\n", d_INT, d_REL, d_CPL);
1240: printf("-> 1: %s\n\n", d_INT);
1241:
1242: printf(" 2: %s\n", d_BIN);
1243: printf(" 1: %s\n", d_BIN);
1244: printf("-> 1: %s\n\n", d_INT);
1245:
1246: printf(" 2: %s\n", d_LST);
1247: printf(" 1: %s\n", d_LST);
1248: printf("-> 1: %s\n\n", d_INT);
1249:
1250: printf(" 2: %s, %s, %s\n", d_VIN, d_VRL, d_VCX);
1251: printf(" 1: %s, %s, %s\n", d_VIN, d_VRL, d_VCX);
1252: printf("-> 1: %s\n\n", d_INT);
1253:
1254: printf(" 2: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
1255: printf(" 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
1256: printf("-> 1: %s\n\n", d_INT);
1257:
1258: printf(" 2: %s\n", d_TAB);
1259: printf(" 1: %s\n", d_TAB);
1260: printf("-> 1: %s\n\n", d_INT);
1261:
1262: printf(" 2: %s\n", d_NOM);
1263: printf(" 1: %s, %s, %s, %s\n", d_NOM, d_ALG, d_INT, d_REL);
1264: printf("-> 1: %s\n\n", d_ALG);
1265:
1266: printf(" 2: %s, %s, %s, %s\n", d_NOM, d_ALG, d_INT, d_REL);
1267: printf(" 1: %s\n", d_NOM);
1268: printf("-> 1: %s\n\n", d_ALG);
1269:
1270: printf(" 2: %s\n", d_ALG);
1271: printf(" 1: %s\n", d_ALG);
1272: printf("-> 1: %s\n\n", d_ALG);
1273:
1274: printf(" 2: %s\n", d_RPN);
1275: printf(" 1: %s\n", d_RPN);
1276: printf("-> 1: %s\n", d_RPN);
1277:
1.10 bertrand 1278: printf(" 2: %s\n", d_PRC);
1279: printf(" 1: %s\n", d_PRC);
1280: printf("-> 1: %s\n", d_INT);
1281:
1.1 bertrand 1282: return;
1283: }
1284: else if ((*s_etat_processus).test_instruction == 'Y')
1285: {
1286: (*s_etat_processus).nombre_arguments = -1;
1287: return;
1288: }
1289:
1290: if (test_cfsf(s_etat_processus, 31) == d_vrai)
1291: {
1292: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
1293: {
1294: return;
1295: }
1296: }
1297:
1298: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1299: &s_objet_argument_1) == d_erreur)
1300: {
1301: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1302: return;
1303: }
1304:
1305: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1306: &s_objet_argument_2) == d_erreur)
1307: {
1308: liberation(s_etat_processus, s_objet_argument_1);
1309:
1310: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1311: return;
1312: }
1313:
1314: /*
1315: --------------------------------------------------------------------------------
1316: SAME sur des valeurs numériques
1317: --------------------------------------------------------------------------------
1318: */
1319:
1320: if ((((*s_objet_argument_1).type == INT) ||
1321: ((*s_objet_argument_1).type == REL)) &&
1322: (((*s_objet_argument_2).type == INT) ||
1323: ((*s_objet_argument_2).type == REL)))
1324: {
1325: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1326: {
1327: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1328: return;
1329: }
1330:
1331: if ((*s_objet_argument_1).type == INT)
1332: {
1333: if ((*s_objet_argument_2).type == INT)
1334: {
1335: (*((integer8 *) (*s_objet_resultat).objet)) =
1336: ((*((integer8 *) (*s_objet_argument_1).objet)) ==
1337: (*((integer8 *) (*s_objet_argument_2).objet)))
1338: ? -1 : 0;
1339: }
1340: else
1341: {
1342: (*((integer8 *) (*s_objet_resultat).objet)) =
1343: ((*((integer8 *) (*s_objet_argument_1).objet)) ==
1344: (*((real8 *) (*s_objet_argument_2).objet)))
1345: ? -1 : 0;
1346: }
1347: }
1348: else
1349: {
1350: if ((*s_objet_argument_2).type == INT)
1351: {
1352: (*((integer8 *) (*s_objet_resultat).objet)) =
1353: ((*((real8 *) (*s_objet_argument_1).objet)) ==
1354: (*((integer8 *) (*s_objet_argument_2).objet)))
1355: ? -1 : 0;
1356: }
1357: else
1358: {
1359: (*((integer8 *) (*s_objet_resultat).objet)) =
1360: ((*((real8 *) (*s_objet_argument_1).objet)) ==
1361: (*((real8 *) (*s_objet_argument_2).objet)))
1362: ? -1 : 0;
1363: }
1364: }
1365: }
1366:
1367: /*
1368: --------------------------------------------------------------------------------
1369: SAME Processus
1370: --------------------------------------------------------------------------------
1371: */
1372:
1373: else if (((*s_objet_argument_1).type == PRC) &&
1374: ((*s_objet_argument_2).type == PRC))
1375: {
1376: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1377: {
1378: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1379: return;
1380: }
1381:
1382: if ((*(*((struct_processus_fils *) (*s_objet_argument_1).objet)).thread)
1383: .processus_detache != (*(*((struct_processus_fils *)
1384: (*s_objet_argument_2).objet)).thread).processus_detache)
1385: {
1386: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
1387: }
1388: else
1389: {
1390: if ((*(*((struct_processus_fils *) (*s_objet_argument_1).objet))
1391: .thread).processus_detache == d_vrai)
1392: {
1393: (*((integer8 *) (*s_objet_resultat).objet)) =
1394: ((*(*((struct_processus_fils *) (*s_objet_argument_1)
1395: .objet)).thread).pid ==
1396: (*(*((struct_processus_fils *) (*s_objet_argument_2)
1397: .objet)).thread).pid) ? -1 : 0;
1398: }
1399: else
1400: {
1401: (*((integer8 *) (*s_objet_resultat).objet)) =
1402: ((pthread_equal((*(*((struct_processus_fils *)
1403: (*s_objet_argument_1).objet)).thread).tid,
1404: (*(*((struct_processus_fils *) (*s_objet_argument_2)
1405: .objet)).thread).tid) != 0) &&
1406: ((*(*((struct_processus_fils *)
1407: (*s_objet_argument_1).objet)).thread).pid ==
1408: (*(*((struct_processus_fils *) (*s_objet_argument_2)
1409: .objet)).thread).pid)) ? -1 : 0;
1410: }
1411: }
1412: }
1413:
1414: /*
1415: --------------------------------------------------------------------------------
1416: SAME complexe
1417: --------------------------------------------------------------------------------
1418: */
1419:
1420: else if (((*s_objet_argument_1).type == CPL) &&
1421: ((*s_objet_argument_2).type == CPL))
1422: {
1423: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1424: {
1425: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1426: return;
1427: }
1428:
1429: (*((integer8 *) (*s_objet_resultat).objet)) =
1430: (((*((struct_complexe16 *) (*s_objet_argument_1).objet))
1431: .partie_reelle == (*((struct_complexe16 *) (*s_objet_argument_2)
1432: .objet)).partie_reelle) && ((*((struct_complexe16 *)
1433: (*s_objet_argument_1).objet)).partie_imaginaire ==
1434: ((*((struct_complexe16 *) (*s_objet_argument_1).objet))
1435: .partie_imaginaire))) ? -1 : 0;
1436: }
1437:
1438: /*
1439: --------------------------------------------------------------------------------
1440: SAME binaire
1441: --------------------------------------------------------------------------------
1442: */
1443:
1444: else if (((*s_objet_argument_1).type == BIN) &&
1445: ((*s_objet_argument_2).type == BIN))
1446: {
1447: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1448: {
1449: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1450: return;
1451: }
1452:
1453: (*((integer8 *) (*s_objet_resultat).objet)) =
1454: ((*((logical8 *) (*s_objet_argument_1).objet)) ==
1455: (*((logical8 *) (*s_objet_argument_2).objet)))
1456: ? -1 : 0;
1457: }
1458:
1459: /*
1460: --------------------------------------------------------------------------------
1461: SAME portant sur des chaînes de caractères
1462: --------------------------------------------------------------------------------
1463: */
1464:
1465: else if (((*s_objet_argument_1).type == CHN) &&
1466: ((*s_objet_argument_2).type == CHN))
1467: {
1468: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1469: {
1470: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1471: return;
1472: }
1473:
1474: (*((integer8 *) (*s_objet_resultat).objet)) =
1475: (strcmp((unsigned char *) (*s_objet_argument_1).objet,
1476: (unsigned char *) (*s_objet_argument_2).objet) == 0) ? -1 : 0;
1477: }
1478:
1479: /*
1480: --------------------------------------------------------------------------------
1481: SAME portant sur des listes ou (instruction "SAME") des expressions
1482: --------------------------------------------------------------------------------
1483: */
1484:
1485: else if (((*s_objet_argument_1).type == FCT) &&
1486: ((*s_objet_argument_2).type == FCT))
1487: {
1488: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1489: {
1490: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1491: return;
1492: }
1493:
1494: if ((strcmp((*((struct_fonction *) (*s_objet_argument_1).objet))
1495: .nom_fonction, (*((struct_fonction *) (*s_objet_argument_2)
1496: .objet)).nom_fonction) == 0) &&
1497: ((*((struct_fonction *) (*s_objet_argument_1).objet))
1498: .nombre_arguments == (*((struct_fonction *)
1499: (*s_objet_argument_2).objet)).nombre_arguments))
1500: {
1501: (*((integer8 *) (*s_objet_resultat).objet)) = -1;
1502: }
1503: else
1504: {
1505: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
1506: }
1507: }
1508:
1509: /*
1510: * Il y a de la récursivité dans l'air...
1511: */
1512:
1513: else if ((((*s_objet_argument_1).type == LST) &&
1514: ((*s_objet_argument_2).type == LST)) ||
1515: (((((*s_objet_argument_1).type == ALG) &&
1516: ((*s_objet_argument_2).type == ALG)) ||
1517: (((*s_objet_argument_1).type == RPN) &&
1518: ((*s_objet_argument_2).type == RPN))) &&
1519: (strcmp((*s_etat_processus).instruction_courante, "==") != 0)))
1520: {
1521: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1522: {
1523: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1524: return;
1525: }
1526:
1527: l_element_courant_1 = (struct_liste_chainee *)
1528: (*s_objet_argument_1).objet;
1529: l_element_courant_2 = (struct_liste_chainee *)
1530: (*s_objet_argument_2).objet;
1531:
1532: difference = d_faux;
1533:
1534: while((l_element_courant_1 != NULL) && (l_element_courant_2 != NULL)
1535: && (difference == d_faux))
1536: {
1537: if ((s_copie_argument_1 = copie_objet(s_etat_processus,
1538: (*l_element_courant_1).donnee, 'P')) == NULL)
1539: {
1540: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1541: return;
1542: }
1543:
1544: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1545: s_copie_argument_1) == d_erreur)
1546: {
1547: return;
1548: }
1549:
1550: if ((s_copie_argument_2 = copie_objet(s_etat_processus,
1551: (*l_element_courant_2).donnee, 'P')) == NULL)
1552: {
1553: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1554: return;
1555: }
1556:
1557: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1558: s_copie_argument_2) == d_erreur)
1559: {
1560: return;
1561: }
1562:
1563: instruction_same(s_etat_processus);
1564:
1565: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1566: &s_objet_resultat_intermediaire) == d_erreur)
1567: {
1568: liberation(s_etat_processus, s_objet_argument_1);
1569: liberation(s_etat_processus, s_objet_argument_2);
1570: liberation(s_etat_processus, s_objet_resultat);
1571:
1572: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1573: return;
1574: }
1575:
1576: if ((*s_objet_resultat_intermediaire).type != INT)
1577: {
1578: liberation(s_etat_processus, s_objet_argument_1);
1579: liberation(s_etat_processus, s_objet_argument_2);
1580: liberation(s_etat_processus, s_objet_resultat);
1581:
1582: (*s_etat_processus).erreur_execution =
1583: d_ex_erreur_type_argument;
1584:
1585: return;
1586: }
1587:
1588: difference = (*(((integer8 *) (*s_objet_resultat_intermediaire)
1589: .objet)) == 0) ? d_vrai : d_faux;
1590:
1591: liberation(s_etat_processus, s_objet_resultat_intermediaire);
1592:
1593: l_element_courant_1 = (*l_element_courant_1).suivant;
1594: l_element_courant_2 = (*l_element_courant_2).suivant;
1595: }
1596:
1597: if ((difference == d_vrai) || ((l_element_courant_1 != NULL) &&
1598: (l_element_courant_2 == NULL)) ||
1599: ((l_element_courant_1 == NULL) &&
1600: (l_element_courant_2 != NULL)))
1601: {
1602: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
1603: }
1604: else
1605: {
1606: (*((integer8 *) (*s_objet_resultat).objet)) = -1;
1607: }
1608: }
1609:
1610: /*
1611: --------------------------------------------------------------------------------
1612: SAME portant sur des tables des expressions
1613: --------------------------------------------------------------------------------
1614: */
1615: /*
1616: * Il y a de la récursivité dans l'air...
1617: */
1618:
1619: else if (((*s_objet_argument_1).type == TBL) &&
1620: ((*s_objet_argument_2).type == TBL) &&
1621: (strcmp((*s_etat_processus).instruction_courante, "==") != 0))
1622: {
1623: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1624: {
1625: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1626: return;
1627: }
1628:
1629: if ((*((struct_tableau *) (*s_objet_argument_1).objet)).nombre_elements
1630: != (*((struct_tableau *) (*s_objet_argument_2).objet))
1631: .nombre_elements)
1632: {
1633: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
1634: }
1635: else
1636: {
1637: difference = d_faux;
1638:
1639: for(i = 0; i < (*((struct_tableau *) (*s_objet_argument_1).objet))
1640: .nombre_elements; i++)
1641: {
1642: if ((s_copie_argument_1 = copie_objet(s_etat_processus,
1643: (*((struct_tableau *)
1644: (*s_objet_argument_1).objet)).elements[i],
1645: 'P')) == NULL)
1646: {
1647: (*s_etat_processus).erreur_systeme =
1648: d_es_allocation_memoire;
1649: return;
1650: }
1651:
1652: if (empilement(s_etat_processus, &((*s_etat_processus)
1653: .l_base_pile), s_copie_argument_1) == d_erreur)
1654: {
1655: return;
1656: }
1657:
1658: if ((s_copie_argument_2 = copie_objet(s_etat_processus,
1659: (*((struct_tableau *)
1660: (*s_objet_argument_2).objet)).elements[i],
1661: 'P')) == NULL)
1662: {
1663: (*s_etat_processus).erreur_systeme =
1664: d_es_allocation_memoire;
1665: return;
1666: }
1667:
1668: if (empilement(s_etat_processus, &((*s_etat_processus)
1669: .l_base_pile), s_copie_argument_2) == d_erreur)
1670: {
1671: return;
1672: }
1673:
1674: instruction_same(s_etat_processus);
1675:
1676: if (depilement(s_etat_processus, &((*s_etat_processus)
1677: .l_base_pile), &s_objet_resultat_intermediaire)
1678: == d_erreur)
1679: {
1680: liberation(s_etat_processus, s_objet_argument_1);
1681: liberation(s_etat_processus, s_objet_argument_2);
1682: liberation(s_etat_processus, s_objet_resultat);
1683:
1684: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1685: return;
1686: }
1687:
1688: if ((*s_objet_resultat_intermediaire).type != INT)
1689: {
1690: liberation(s_etat_processus, s_objet_argument_1);
1691: liberation(s_etat_processus, s_objet_argument_2);
1692: liberation(s_etat_processus, s_objet_resultat);
1693:
1694: (*s_etat_processus).erreur_execution =
1695: d_ex_erreur_type_argument;
1696: return;
1697: }
1698:
1699: difference = (*(((integer8 *) (*s_objet_resultat_intermediaire)
1700: .objet)) == 0) ? d_vrai : d_faux;
1701:
1702: liberation(s_etat_processus, s_objet_resultat_intermediaire);
1703: }
1704:
1705: if (difference == d_vrai)
1706: {
1707: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
1708: }
1709: else
1710: {
1711: (*((integer8 *) (*s_objet_resultat).objet)) = -1;
1712: }
1713: }
1714: }
1715:
1716:
1717: /*
1718: --------------------------------------------------------------------------------
1719: SAME portant sur des vecteurs
1720: --------------------------------------------------------------------------------
1721: */
1722: /*
1723: * Vecteurs d'entiers
1724: */
1725:
1726: else if (((*s_objet_argument_1).type == VIN) &&
1727: ((*s_objet_argument_2).type == VIN))
1728: {
1729: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1730: {
1731: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1732: return;
1733: }
1734:
1735: if ((*((struct_vecteur *) (*s_objet_argument_1).objet)).taille !=
1736: (*((struct_vecteur *) (*s_objet_argument_2).objet)).taille)
1737: {
1738: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
1739: }
1740: else
1741: {
1742: difference = d_faux;
1743:
1744: for(i = 0; (i < (*((struct_vecteur *) (*s_objet_argument_1).objet))
1745: .taille) && (difference == d_faux); i++)
1746: {
1747: difference = (((integer8 *) (*((struct_vecteur *)
1748: (*s_objet_argument_1).objet)).tableau)[i] ==
1749: ((integer8 *) (*((struct_vecteur *)
1750: (*s_objet_argument_2).objet)).tableau)[i])
1751: ? d_faux : d_vrai;
1752: }
1753:
1754: (*((integer8 *) (*s_objet_resultat).objet)) = (difference ==
1755: d_faux) ? -1 : 0;
1756: }
1757: }
1758:
1759: /*
1760: * Vecteurs de réels
1761: */
1762:
1763: else if (((*s_objet_argument_1).type == VRL) &&
1764: ((*s_objet_argument_2).type == VRL))
1765: {
1766: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1767: {
1768: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1769: return;
1770: }
1771:
1772: if ((*((struct_vecteur *) (*s_objet_argument_1).objet)).taille !=
1773: (*((struct_vecteur *) (*s_objet_argument_2).objet)).taille)
1774: {
1775: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
1776: }
1777: else
1778: {
1779: difference = d_faux;
1780:
1781: for(i = 0; (i < (*((struct_vecteur *) (*s_objet_argument_1).objet))
1782: .taille) && (difference == d_faux); i++)
1783: {
1784: difference = (((real8 *) (*((struct_vecteur *)
1785: (*s_objet_argument_1).objet)).tableau)[i] ==
1786: ((real8 *) (*((struct_vecteur *)
1787: (*s_objet_argument_2).objet)).tableau)[i])
1788: ? d_faux : d_vrai;
1789: }
1790:
1791: (*((integer8 *) (*s_objet_resultat).objet)) = (difference ==
1792: d_faux) ? -1 : 0;
1793: }
1794: }
1795:
1796: /*
1797: * Vecteurs de complexes
1798: */
1799:
1800: else if (((*s_objet_argument_1).type == VCX) &&
1801: ((*s_objet_argument_2).type == VCX))
1802: {
1803: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1804: {
1805: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1806: return;
1807: }
1808:
1809: if ((*((struct_vecteur *) (*s_objet_argument_1).objet)).taille !=
1810: (*((struct_vecteur *) (*s_objet_argument_2).objet)).taille)
1811: {
1812: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
1813: }
1814: else
1815: {
1816: difference = d_faux;
1817:
1818: for(i = 0; (i < (*((struct_vecteur *) (*s_objet_argument_1).objet))
1819: .taille) && (difference == d_faux); i++)
1820: {
1821: difference = ((((struct_complexe16 *) (*((struct_vecteur *)
1822: (*s_objet_argument_1).objet)).tableau)[i].partie_reelle
1823: == ((struct_complexe16 *) (*((struct_vecteur *)
1824: (*s_objet_argument_2).objet)).tableau)[i].partie_reelle)
1825: && (((struct_complexe16 *) (*((struct_vecteur *)
1826: (*s_objet_argument_1).objet)).tableau)[i]
1827: .partie_imaginaire == ((struct_complexe16 *)
1828: (*((struct_vecteur *) (*s_objet_argument_2).objet))
1829: .tableau)[i].partie_imaginaire)) ? d_faux : d_vrai;
1830: }
1831:
1832: (*((integer8 *) (*s_objet_resultat).objet)) = (difference ==
1833: d_faux) ? -1 : 0;
1834: }
1835: }
1836:
1837: /*
1838: --------------------------------------------------------------------------------
1839: SAME portant sur des matrices
1840: --------------------------------------------------------------------------------
1841: */
1842: /*
1843: * Matrice d'entiers
1844: */
1845:
1846: else if (((*s_objet_argument_1).type == MIN) &&
1847: ((*s_objet_argument_2).type == MIN))
1848: {
1849: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1850: {
1851: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1852: return;
1853: }
1854:
1855: if (((*((struct_matrice *) (*s_objet_argument_1).objet)).nombre_lignes
1856: != (*((struct_matrice *) (*s_objet_argument_2).objet))
1857: .nombre_lignes) || ((*((struct_matrice *) (*s_objet_argument_1)
1858: .objet)).nombre_colonnes != (*((struct_matrice *)
1859: (*s_objet_argument_2).objet)).nombre_colonnes))
1860: {
1861: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
1862: }
1863: else
1864: {
1865: difference = d_faux;
1866:
1867: for(i = 0; (i < (*((struct_matrice *) (*s_objet_argument_1).objet))
1868: .nombre_lignes) && (difference == d_faux); i++)
1869: {
1870: for(j = 0; (j < (*((struct_matrice *) (*s_objet_argument_1)
1871: .objet)).nombre_colonnes) && (difference == d_faux);
1872: j++)
1873: {
1874: difference = (((integer8 **) (*((struct_matrice *)
1875: (*s_objet_argument_1).objet)).tableau)[i][j] ==
1876: ((integer8 **) (*((struct_matrice *)
1877: (*s_objet_argument_2).objet)).tableau)[i][j])
1878: ? d_faux : d_vrai;
1879: }
1880: }
1881:
1882: (*((integer8 *) (*s_objet_resultat).objet)) = (difference ==
1883: d_faux) ? -1 : 0;
1884: }
1885: }
1886:
1887: /*
1888: * Matrice de réels
1889: */
1890:
1891: else if (((*s_objet_argument_1).type == MRL) &&
1892: ((*s_objet_argument_2).type == MRL))
1893: {
1894: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1895: {
1896: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1897: return;
1898: }
1899:
1900: if (((*((struct_matrice *) (*s_objet_argument_1).objet)).nombre_lignes
1901: != (*((struct_matrice *) (*s_objet_argument_2).objet))
1902: .nombre_lignes) || ((*((struct_matrice *) (*s_objet_argument_1)
1903: .objet)).nombre_colonnes != (*((struct_matrice *)
1904: (*s_objet_argument_2).objet)).nombre_colonnes))
1905: {
1906: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
1907: }
1908: else
1909: {
1910: difference = d_faux;
1911:
1912: for(i = 0; (i < (*((struct_matrice *) (*s_objet_argument_1).objet))
1913: .nombre_lignes) && (difference == d_faux); i++)
1914: {
1915: for(j = 0; (j < (*((struct_matrice *) (*s_objet_argument_1)
1916: .objet)).nombre_colonnes) && (difference == d_faux);
1917: j++)
1918: {
1919: difference = (((real8 **) (*((struct_matrice *)
1920: (*s_objet_argument_1).objet)).tableau)[i][j] ==
1921: ((real8 **) (*((struct_matrice *)
1922: (*s_objet_argument_2).objet)).tableau)[i][j])
1923: ? d_faux : d_vrai;
1924: }
1925: }
1926:
1927: (*((integer8 *) (*s_objet_resultat).objet)) = (difference ==
1928: d_faux) ? -1 : 0;
1929: }
1930: }
1931:
1932: /*
1933: * Matrice de complexes
1934: */
1935:
1936: else if (((*s_objet_argument_1).type == MCX) &&
1937: ((*s_objet_argument_2).type == MCX))
1938: {
1939: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1940: {
1941: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1942: return;
1943: }
1944:
1945: if (((*((struct_matrice *) (*s_objet_argument_1).objet)).nombre_lignes
1946: != (*((struct_matrice *) (*s_objet_argument_2).objet))
1947: .nombre_lignes) || ((*((struct_matrice *) (*s_objet_argument_1)
1948: .objet)).nombre_colonnes != (*((struct_matrice *)
1949: (*s_objet_argument_2).objet)).nombre_colonnes))
1950: {
1951: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
1952: }
1953: else
1954: {
1955: difference = d_faux;
1956:
1957: for(i = 0; (i < (*((struct_matrice *) (*s_objet_argument_1).objet))
1958: .nombre_lignes) && (difference == d_faux); i++)
1959: {
1960: for(j = 0; (j < (*((struct_matrice *) (*s_objet_argument_1)
1961: .objet)).nombre_colonnes) && (difference == d_faux);
1962: j++)
1963: {
1964: difference = ((((struct_complexe16 **) (*((struct_matrice *)
1965: (*s_objet_argument_1).objet)).tableau)[i][j]
1966: .partie_reelle == ((struct_complexe16 **)
1967: (*((struct_matrice *) (*s_objet_argument_2).objet))
1968: .tableau)[i][j].partie_reelle) &&
1969: (((struct_complexe16 **) (*((struct_matrice *)
1970: (*s_objet_argument_1).objet)).tableau)[i][j]
1971: .partie_imaginaire == ((struct_complexe16 **)
1972: (*((struct_matrice *) (*s_objet_argument_2).objet))
1973: .tableau)[i][j].partie_imaginaire))
1974: ? d_faux : d_vrai;
1975: }
1976: }
1977:
1978: (*((integer8 *) (*s_objet_resultat).objet)) = (difference ==
1979: d_faux) ? -1 : 0;
1980: }
1981: }
1982:
1983: /*
1984: --------------------------------------------------------------------------------
1985: SAME portant sur des noms (instruction "SAME")
1986: --------------------------------------------------------------------------------
1987: */
1988:
1989: else if (((*s_objet_argument_1).type == NOM) &&
1990: ((*s_objet_argument_2).type == NOM) &&
1991: (strcmp((*s_etat_processus).instruction_courante, "==") != 0))
1992: {
1993: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
1994: {
1995: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1996: return;
1997: }
1998:
1999: (*((integer8 *) (*s_objet_resultat).objet)) =
2000: (strcmp((*((struct_nom *) (*s_objet_argument_1).objet)).nom,
2001: (*((struct_nom *) (*s_objet_argument_2).objet)).nom) == 0)
2002: ? -1 : 0;
2003: }
2004:
2005: /*
2006: --------------------------------------------------------------------------------
2007: SAME entre des arguments complexes (instruction '==')
2008: --------------------------------------------------------------------------------
2009: */
2010:
2011: /*
2012: * Nom ou valeur numérique / Nom ou valeur numérique
2013: */
2014:
2015: else if (((((*s_objet_argument_1).type == NOM) &&
2016: (((*s_objet_argument_2).type == NOM) ||
2017: ((*s_objet_argument_2).type == INT) ||
2018: ((*s_objet_argument_2).type == REL))) ||
2019: (((*s_objet_argument_2).type == NOM) &&
2020: (((*s_objet_argument_1).type == INT) ||
2021: ((*s_objet_argument_1).type == REL)))) &&
2022: (strcmp((*s_etat_processus).instruction_courante, "==") == 0))
2023: {
2024: if ((s_objet_resultat = allocation(s_etat_processus, ALG)) == NULL)
2025: {
2026: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2027: return;
2028: }
2029:
2030: if (((*s_objet_resultat).objet =
2031: allocation_maillon(s_etat_processus)) == NULL)
2032: {
2033: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2034: return;
2035: }
2036:
2037: l_element_courant = (*s_objet_resultat).objet;
2038:
2039: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
2040: == NULL)
2041: {
2042: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2043: return;
2044: }
2045:
2046: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2047: .nombre_arguments = 0;
2048: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2049: .fonction = instruction_vers_niveau_superieur;
2050:
2051: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2052: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
2053: {
2054: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2055: return;
2056: }
2057:
2058: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2059: .nom_fonction, "<<");
2060:
2061: if (((*l_element_courant).suivant =
2062: allocation_maillon(s_etat_processus)) == NULL)
2063: {
2064: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2065: return;
2066: }
2067:
2068: l_element_courant = (*l_element_courant).suivant;
2069: (*l_element_courant).donnee = s_objet_argument_2;
2070:
2071: if (((*l_element_courant).suivant =
2072: allocation_maillon(s_etat_processus)) == NULL)
2073: {
2074: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2075: return;
2076: }
2077:
2078: l_element_courant = (*l_element_courant).suivant;
2079: (*l_element_courant).donnee = s_objet_argument_1;
2080:
2081: if (((*l_element_courant).suivant =
2082: allocation_maillon(s_etat_processus)) == NULL)
2083: {
2084: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2085: return;
2086: }
2087:
2088: l_element_courant = (*l_element_courant).suivant;
2089:
2090: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
2091: == NULL)
2092: {
2093: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2094: return;
2095: }
2096:
2097: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2098: .nombre_arguments = 0;
2099: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2100: .fonction = instruction_same;
2101:
2102: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2103: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
2104: {
2105: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2106: return;
2107: }
2108:
2109: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2110: .nom_fonction, "==");
2111:
2112: if (((*l_element_courant).suivant =
2113: allocation_maillon(s_etat_processus)) == NULL)
2114: {
2115: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2116: return;
2117: }
2118:
2119: l_element_courant = (*l_element_courant).suivant;
2120:
2121: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
2122: == NULL)
2123: {
2124: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2125: return;
2126: }
2127:
2128: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2129: .nombre_arguments = 0;
2130: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2131: .fonction = instruction_vers_niveau_inferieur;
2132:
2133: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2134: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
2135: {
2136: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2137: return;
2138: }
2139:
2140: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2141: .nom_fonction, ">>");
2142:
2143: (*l_element_courant).suivant = NULL;
2144:
2145: s_objet_argument_1 = NULL;
2146: s_objet_argument_2 = NULL;
2147: }
2148:
2149: /*
2150: * Nom ou valeur numérique / Expression
2151: */
2152:
2153: else if (((((*s_objet_argument_1).type == ALG) ||
2154: ((*s_objet_argument_1).type == RPN)) &&
2155: (strcmp((*s_etat_processus).instruction_courante, "==") == 0)) &&
2156: (((*s_objet_argument_2).type == NOM) ||
2157: ((*s_objet_argument_2).type == INT) ||
2158: ((*s_objet_argument_2).type == REL)))
2159: {
2160: nombre_elements = 0;
2161: l_element_courant = (struct_liste_chainee *)
2162: (*s_objet_argument_1).objet;
2163:
2164: while(l_element_courant != NULL)
2165: {
2166: nombre_elements++;
2167: l_element_courant = (*l_element_courant).suivant;
2168: }
2169:
2170: if (nombre_elements == 2)
2171: {
2172: liberation(s_etat_processus, s_objet_argument_1);
2173: liberation(s_etat_processus, s_objet_argument_2);
2174:
2175: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
2176: return;
2177: }
2178:
2179: if ((s_objet_resultat = copie_objet(s_etat_processus,
2180: s_objet_argument_1, 'N')) == NULL)
2181: {
2182: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2183: return;
2184: }
2185:
2186: l_element_courant = (struct_liste_chainee *)
2187: (*s_objet_resultat).objet;
2188: l_element_precedent = l_element_courant;
2189: l_element_courant = (*l_element_courant).suivant;
2190:
2191: if (((*l_element_precedent).suivant =
2192: allocation_maillon(s_etat_processus)) == NULL)
2193: {
2194: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2195: return;
2196: }
2197:
2198: (*(*l_element_precedent).suivant).donnee = s_objet_argument_2;
2199: (*(*l_element_precedent).suivant).suivant = l_element_courant;
2200:
2201: while((*l_element_courant).suivant != NULL)
2202: {
2203: l_element_precedent = l_element_courant;
2204: l_element_courant = (*l_element_courant).suivant;
2205: }
2206:
2207: if (((*l_element_precedent).suivant =
2208: allocation_maillon(s_etat_processus)) == NULL)
2209: {
2210: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2211: return;
2212: }
2213:
2214: if (((*(*l_element_precedent).suivant).donnee =
2215: allocation(s_etat_processus, FCT)) == NULL)
2216: {
2217: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2218: return;
2219: }
2220:
2221: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
2222: .donnee).objet)).nombre_arguments = 0;
2223: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
2224: .donnee).objet)).fonction = instruction_same;
2225:
2226: if (((*((struct_fonction *) (*(*(*l_element_precedent)
2227: .suivant).donnee).objet)).nom_fonction =
2228: malloc((strlen((*s_etat_processus).instruction_courante) + 1) *
2229: sizeof(unsigned char))) == NULL)
2230: {
2231: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2232: return;
2233: }
2234:
2235: strcpy((*((struct_fonction *) (*(*(*l_element_precedent)
2236: .suivant).donnee).objet)).nom_fonction,
2237: (*s_etat_processus).instruction_courante);
2238:
2239: (*(*l_element_precedent).suivant).suivant = l_element_courant;
2240:
2241: s_objet_argument_2 = NULL;
2242: }
2243:
2244: /*
2245: * Expression / Nom ou valeur numérique
2246: */
2247:
2248: else if ((((*s_objet_argument_1).type == NOM) ||
2249: ((*s_objet_argument_1).type == INT) ||
2250: ((*s_objet_argument_1).type == REL)) &&
2251: ((((*s_objet_argument_2).type == ALG) ||
2252: ((*s_objet_argument_2).type == RPN)) &&
2253: (strcmp((*s_etat_processus).instruction_courante, "==") == 0)))
2254: {
2255: nombre_elements = 0;
2256: l_element_courant = (struct_liste_chainee *)
2257: (*s_objet_argument_2).objet;
2258:
2259: while(l_element_courant != NULL)
2260: {
2261: nombre_elements++;
2262: l_element_courant = (*l_element_courant).suivant;
2263: }
2264:
2265: if (nombre_elements == 2)
2266: {
2267: liberation(s_etat_processus, s_objet_argument_1);
2268: liberation(s_etat_processus, s_objet_argument_2);
2269:
2270: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
2271: return;
2272: }
2273:
2274: if ((s_objet_resultat = copie_objet(s_etat_processus,
2275: s_objet_argument_2, 'N')) == NULL)
2276: {
2277: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2278: return;
2279: }
2280:
2281: l_element_courant = (struct_liste_chainee *)
2282: (*s_objet_resultat).objet;
2283: l_element_precedent = l_element_courant;
2284:
2285: while((*l_element_courant).suivant != NULL)
2286: {
2287: l_element_precedent = l_element_courant;
2288: l_element_courant = (*l_element_courant).suivant;
2289: }
2290:
2291: if (((*l_element_precedent).suivant =
2292: allocation_maillon(s_etat_processus)) == NULL)
2293: {
2294: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2295: return;
2296: }
2297:
2298: (*(*l_element_precedent).suivant).donnee = s_objet_argument_1;
2299: l_element_precedent = (*l_element_precedent).suivant;
2300:
2301: if (((*l_element_precedent).suivant =
2302: allocation_maillon(s_etat_processus)) == NULL)
2303: {
2304: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2305: return;
2306: }
2307:
2308: if (((*(*l_element_precedent).suivant).donnee =
2309: allocation(s_etat_processus, FCT)) == NULL)
2310: {
2311: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2312: return;
2313: }
2314:
2315: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
2316: .donnee).objet)).nombre_arguments = 0;
2317: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
2318: .donnee).objet)).fonction = instruction_same;
2319:
2320: if (((*((struct_fonction *) (*(*(*l_element_precedent)
2321: .suivant).donnee).objet)).nom_fonction =
2322: malloc((strlen((*s_etat_processus).instruction_courante) + 1) *
2323: sizeof(unsigned char))) == NULL)
2324: {
2325: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2326: return;
2327: }
2328:
2329: strcpy((*((struct_fonction *) (*(*(*l_element_precedent)
2330: .suivant).donnee).objet)).nom_fonction,
2331: (*s_etat_processus).instruction_courante);
2332:
2333: (*(*l_element_precedent).suivant).suivant = l_element_courant;
2334:
2335: s_objet_argument_1 = NULL;
2336: }
2337:
2338: /*
2339: * Expression / Expression
2340: */
2341:
2342: else if ((((*s_objet_argument_1).type == ALG) &&
2343: ((*s_objet_argument_2).type == ALG) &&
2344: (strcmp((*s_etat_processus).instruction_courante, "==") == 0)) ||
2345: (((*s_objet_argument_1).type == RPN) &&
2346: ((*s_objet_argument_2).type == RPN)))
2347: {
2348: nombre_elements = 0;
2349: l_element_courant = (struct_liste_chainee *)
2350: (*s_objet_argument_1).objet;
2351:
2352: while(l_element_courant != NULL)
2353: {
2354: nombre_elements++;
2355: l_element_courant = (*l_element_courant).suivant;
2356: }
2357:
2358: if (nombre_elements == 2)
2359: {
2360: liberation(s_etat_processus, s_objet_argument_1);
2361: liberation(s_etat_processus, s_objet_argument_2);
2362:
2363: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
2364: return;
2365: }
2366:
2367: nombre_elements = 0;
2368: l_element_courant = (struct_liste_chainee *)
2369: (*s_objet_argument_2).objet;
2370:
2371: while(l_element_courant != NULL)
2372: {
2373: nombre_elements++;
2374: l_element_courant = (*l_element_courant).suivant;
2375: }
2376:
2377: if (nombre_elements == 2)
2378: {
2379: liberation(s_etat_processus, s_objet_argument_1);
2380: liberation(s_etat_processus, s_objet_argument_2);
2381:
2382: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
2383: return;
2384: }
2385:
2386: if ((s_copie_argument_1 = copie_objet(s_etat_processus,
2387: s_objet_argument_1, 'N')) == NULL)
2388: {
2389: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2390: return;
2391: }
2392:
2393: if ((s_copie_argument_2 = copie_objet(s_etat_processus,
2394: s_objet_argument_2, 'N')) == NULL)
2395: {
2396: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2397: return;
2398: }
2399:
2400: l_element_courant = (struct_liste_chainee *)
2401: (*s_copie_argument_1).objet;
2402: (*s_copie_argument_1).objet = (void *) (*((struct_liste_chainee *)
2403: (*s_copie_argument_1).objet)).suivant;
2404:
2405: liberation(s_etat_processus, (*l_element_courant).donnee);
2406: free(l_element_courant);
2407:
2408: l_element_courant = (struct_liste_chainee *)
2409: (*s_copie_argument_2).objet;
2410: l_element_precedent = l_element_courant;
2411: s_objet_resultat = s_copie_argument_2;
2412:
2413: while((*l_element_courant).suivant != NULL)
2414: {
2415: l_element_precedent = l_element_courant;
2416: l_element_courant = (*l_element_courant).suivant;
2417: }
2418:
2419: liberation(s_etat_processus, (*l_element_courant).donnee);
2420: free(l_element_courant);
2421:
2422: (*l_element_precedent).suivant = (struct_liste_chainee *)
2423: (*s_copie_argument_1).objet;
2424: free(s_copie_argument_1);
2425:
2426: l_element_courant = (*l_element_precedent).suivant;
2427: while((*l_element_courant).suivant != NULL)
2428: {
2429: l_element_precedent = l_element_courant;
2430: l_element_courant = (*l_element_courant).suivant;
2431: }
2432:
2433: if (((*l_element_precedent).suivant =
2434: allocation_maillon(s_etat_processus)) == NULL)
2435: {
2436: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2437: return;
2438: }
2439:
2440: (*(*l_element_precedent).suivant).suivant = l_element_courant;
2441: l_element_courant = (*l_element_precedent).suivant;
2442:
2443: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
2444: == NULL)
2445: {
2446: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2447: return;
2448: }
2449:
2450: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2451: .nombre_arguments = 0;
2452: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2453: .fonction = instruction_same;
2454:
2455: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2456: .nom_fonction = malloc((strlen(
2457: (*s_etat_processus).instruction_courante) + 1) *
2458: sizeof(unsigned char))) == NULL)
2459: {
2460: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2461: return;
2462: }
2463:
2464: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
2465: .nom_fonction, (*s_etat_processus).instruction_courante);
2466: }
2467:
2468: /*
2469: --------------------------------------------------------------------------------
2470: SAME nul
2471: --------------------------------------------------------------------------------
2472: */
2473:
2474: else
2475: {
2476: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
2477: {
2478: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2479: return;
2480: }
2481:
2482: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
2483: }
2484:
2485: liberation(s_etat_processus, s_objet_argument_1);
2486: liberation(s_etat_processus, s_objet_argument_2);
2487:
2488: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2489: s_objet_resultat) == d_erreur)
2490: {
2491: return;
2492: }
2493:
2494: return;
2495: }
2496:
2497:
2498: /*
2499: ================================================================================
2500: Fonction 'start'
2501: ================================================================================
2502: Entrées : structure processus
2503: --------------------------------------------------------------------------------
2504: Sorties :
2505: --------------------------------------------------------------------------------
2506: Effets de bord : néant
2507: ================================================================================
2508: */
2509:
2510: void
2511: instruction_start(struct_processus *s_etat_processus)
2512: {
2513: struct_objet *s_objet_1;
2514: struct_objet *s_objet_2;
2515:
2516: (*s_etat_processus).erreur_execution = d_ex;
2517:
2518: if ((*s_etat_processus).affichage_arguments == 'Y')
2519: {
2520: printf("\n START ");
2521:
2522: if ((*s_etat_processus).langue == 'F')
2523: {
2524: printf("(boucle définie sans compteur)\n\n");
2525: }
2526: else
2527: {
2528: printf("(define a loop without counter)\n\n");
2529: }
2530:
2531: if ((*s_etat_processus).langue == 'F')
2532: {
2533: printf(" Utilisation :\n\n");
2534: }
2535: else
2536: {
2537: printf(" Usage:\n\n");
2538: }
2539:
2540: printf(" %s/%s %s/%s START\n", d_INT, d_REL,
2541: d_INT, d_REL);
2542: printf(" (expression)\n");
2543: printf(" [EXIT]/[CYCLE]\n");
2544: printf(" ...\n");
2545: printf(" NEXT\n\n");
2546:
2547: printf(" %s/%s %s/%s START\n", d_INT, d_REL,
2548: d_INT, d_REL);
2549: printf(" (expression)\n");
2550: printf(" [EXIT]/[CYCLE]\n");
2551: printf(" ...\n");
2552: printf(" %s/%s STEP\n", d_INT, d_REL);
2553:
2554: return;
2555: }
2556: else if ((*s_etat_processus).test_instruction == 'Y')
2557: {
2558: (*s_etat_processus).nombre_arguments = -1;
2559: return;
2560: }
2561:
2562: if ((*s_etat_processus).erreur_systeme != d_es)
2563: {
2564: return;
2565: }
2566:
2567: if (test_cfsf(s_etat_processus, 31) == d_vrai)
2568: {
2569: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
2570: {
2571: return;
2572: }
2573: }
2574:
2575: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2576: &s_objet_1) == d_erreur)
2577: {
2578: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
2579: return;
2580: }
2581:
1.12 bertrand 2582: if (((*s_objet_1).type != INT) && ((*s_objet_1).type != REL))
1.1 bertrand 2583: {
2584: liberation(s_etat_processus, s_objet_1);
2585:
2586: (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle;
2587: return;
2588: }
2589:
2590: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2591: &s_objet_2) == d_erreur)
2592: {
2593: liberation(s_etat_processus, s_objet_1);
2594:
2595: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
2596: return;
2597: }
2598:
1.12 bertrand 2599: if (((*s_objet_2).type != INT) && ((*s_objet_2).type != REL))
1.1 bertrand 2600: {
2601: liberation(s_etat_processus, s_objet_1);
2602: liberation(s_etat_processus, s_objet_2);
2603:
2604: (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle;
2605: return;
2606: }
2607:
1.54 bertrand 2608: empilement_pile_systeme(s_etat_processus);
2609:
2610: if ((*s_etat_processus).erreur_systeme != d_es)
2611: {
2612: return;
2613: }
2614:
2615: (*(*s_etat_processus).l_base_pile_systeme).type_cloture = 'S';
2616:
1.1 bertrand 2617: (*(*s_etat_processus).l_base_pile_systeme).indice_boucle = s_objet_2;
2618: (*(*s_etat_processus).l_base_pile_systeme).limite_indice_boucle = s_objet_1;
2619:
2620: if ((*s_etat_processus).mode_execution_programme == 'Y')
2621: {
2622: (*(*s_etat_processus).l_base_pile_systeme).adresse_retour =
2623: (*s_etat_processus).position_courante;
2624: (*(*s_etat_processus).l_base_pile_systeme)
2625: .origine_routine_evaluation = 'N';
2626: }
2627: else
2628: {
2629: (*(*s_etat_processus).l_base_pile_systeme).pointeur_objet_retour =
2630: (*s_etat_processus).expression_courante;
2631: (*(*s_etat_processus).l_base_pile_systeme)
2632: .origine_routine_evaluation = 'Y';
2633: }
2634:
2635: return;
2636: }
2637:
2638:
2639: /*
2640: ================================================================================
2641: Fonction 'step'
2642: ================================================================================
2643: Entrées : structure processus
2644: --------------------------------------------------------------------------------
2645: Sorties :
2646: --------------------------------------------------------------------------------
2647: Effets de bord : néant
2648: ================================================================================
2649: */
2650:
2651: void
2652: instruction_step(struct_processus *s_etat_processus)
2653: {
2654: struct_objet *s_objet;
2655: struct_objet *s_copie_objet;
2656:
2657: logical1 incrementation;
2658: logical1 presence_compteur;
2659:
2660: (*s_etat_processus).erreur_execution = d_ex;
2661:
2662: if ((*s_etat_processus).affichage_arguments == 'Y')
2663: {
2664: printf("\n STEP ");
2665:
2666: if ((*s_etat_processus).langue == 'F')
2667: {
2668: printf("(fin d'une boucle définie)\n\n");
2669: }
2670: else
2671: {
2672: printf("(end of defined loop)\n\n");
2673: }
2674:
2675: if ((*s_etat_processus).langue == 'F')
2676: {
2677: printf(" Utilisation :\n\n");
2678: }
2679: else
2680: {
2681: printf(" Usage:\n\n");
2682: }
2683:
2684: printf(" %s/%s %s/%s START\n", d_INT, d_REL,
2685: d_INT, d_REL);
2686: printf(" (expression)\n");
2687: printf(" [EXIT]/[CYCLE]\n");
2688: printf(" ...\n");
2689: printf(" (value) STEP\n\n");
2690:
2691: printf(" %s/%s %s/%s FOR (variable)\n", d_INT, d_REL,
2692: d_INT, d_REL);
2693: printf(" (expression)\n");
2694: printf(" [EXIT]/[CYCLE]\n");
2695: printf(" ...\n");
2696: printf(" (value) STEP\n");
2697:
2698: return;
2699: }
2700: else if ((*s_etat_processus).test_instruction == 'Y')
2701: {
2702: (*s_etat_processus).nombre_arguments = -1;
2703: return;
2704: }
2705:
2706: if (test_cfsf(s_etat_processus, 31) == d_vrai)
2707: {
2708: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
2709: {
2710: return;
2711: }
2712: }
2713:
2714: presence_compteur = ((*(*s_etat_processus).l_base_pile_systeme)
2715: .type_cloture == 'F') ? d_vrai : d_faux;
2716:
2717: if (((*(*s_etat_processus).l_base_pile_systeme).type_cloture != 'S')
2718: && (presence_compteur == d_faux))
2719: {
2720: (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle;
2721: return;
2722: }
2723:
2724: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2725: &s_objet) == d_erreur)
2726: {
2727: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
2728: return;
2729: }
2730:
2731: if (((*s_objet).type != INT) &&
2732: ((*s_objet).type != REL))
2733: {
2734: liberation(s_etat_processus, s_objet);
2735:
2736: (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle;
2737: return;
2738: }
2739:
2740: if ((*s_objet).type == INT)
2741: {
2742: incrementation = ((*((integer8 *) (*s_objet).objet)) >= 0)
2743: ? d_vrai : d_faux;
2744: }
2745: else
2746: {
2747: incrementation = ((*((real8 *) (*s_objet).objet)) >= 0)
2748: ? d_vrai : d_faux;
2749: }
2750:
2751: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2752: s_objet) == d_erreur)
2753: {
2754: return;
2755: }
2756:
2757: /*
2758: * Pour une boucle avec indice, on fait pointer
2759: * (*(*s_etat_processus).l_base_pile_systeme).indice_boucle sur
2760: * la variable correspondante. Remarque, le contenu de la variable
2761: * est détruit au courant de l'opération.
2762: */
2763:
2764: if (presence_compteur == d_vrai)
2765: {
2766: if (recherche_variable(s_etat_processus, (*(*s_etat_processus)
2767: .l_base_pile_systeme).nom_variable) == d_faux)
2768: {
2769: liberation(s_etat_processus, s_objet);
2770:
2771: (*s_etat_processus).erreur_systeme = d_es;
2772: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
2773: return;
2774: }
2775:
1.27 bertrand 2776: if ((*(*s_etat_processus).pointeur_variable_courante)
2777: .variable_verrouillee == d_vrai)
1.1 bertrand 2778: {
2779: liberation(s_etat_processus, s_objet);
2780:
2781: (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee;
2782: return;
2783: }
2784:
1.27 bertrand 2785: if ((*(*s_etat_processus).pointeur_variable_courante).objet == NULL)
1.1 bertrand 2786: {
2787: liberation(s_etat_processus, s_objet);
2788:
2789: (*s_etat_processus).erreur_execution = d_ex_variable_partagee;
2790: return;
2791: }
2792:
2793: (*(*s_etat_processus).l_base_pile_systeme).indice_boucle =
1.27 bertrand 2794: (*(*s_etat_processus).pointeur_variable_courante).objet;
1.1 bertrand 2795: }
2796:
2797: /*
2798: * Empilement pour calculer le nouvel indice. Au passage, la
2799: * variable (*(*s_etat_processus).l_base_pile_systeme).indice_boucle
2800: * est libérée.
2801: */
2802:
2803: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2804: (*(*s_etat_processus).l_base_pile_systeme).indice_boucle)
2805: == d_erreur)
2806: {
2807: return;
2808: }
2809:
2810: instruction_plus(s_etat_processus);
2811:
2812: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2813: &s_objet) == d_erreur)
2814: {
2815: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
2816: return;
2817: }
2818:
2819: if (((*s_objet).type != INT) &&
2820: ((*s_objet).type != REL))
2821: {
2822: liberation(s_etat_processus, s_objet);
2823:
2824: (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle;
2825: return;
2826: }
2827:
2828: if (presence_compteur == d_vrai)
2829: {
2830: /*
2831: * L'addition crée si besoin une copie de l'objet
2832: */
2833:
2834: (*(*s_etat_processus).l_base_pile_systeme).indice_boucle = NULL;
1.27 bertrand 2835: (*(*s_etat_processus).pointeur_variable_courante).objet = s_objet;
1.1 bertrand 2836: }
2837: else
2838: {
2839: (*(*s_etat_processus).l_base_pile_systeme).indice_boucle = s_objet;
2840: }
2841:
2842: if ((s_copie_objet = copie_objet(s_etat_processus, s_objet, 'P')) == NULL)
2843: {
2844: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2845: return;
2846: }
2847:
2848: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2849: s_copie_objet) == d_erreur)
2850: {
2851: return;
2852: }
2853:
2854: if ((s_copie_objet = copie_objet(s_etat_processus,
2855: (*(*s_etat_processus).l_base_pile_systeme)
2856: .limite_indice_boucle, 'P')) == NULL)
2857: {
2858: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2859: return;
2860: }
2861:
2862: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2863: s_copie_objet) == d_erreur)
2864: {
2865: return;
2866: }
2867:
2868: if (incrementation == d_vrai)
2869: {
2870: instruction_le(s_etat_processus);
2871: }
2872: else
2873: {
2874: instruction_ge(s_etat_processus);
2875: }
2876:
2877: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2878: &s_objet) == d_erreur)
2879: {
2880: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
2881: return;
2882: }
2883:
2884: if ((*s_objet).type != INT)
2885: {
2886: liberation(s_etat_processus, s_objet);
2887:
2888: (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle;
2889: return;
2890: }
2891:
2892: if ((*((integer8 *) (*s_objet).objet)) != 0)
2893: {
2894: if ((*(*s_etat_processus).l_base_pile_systeme)
2895: .origine_routine_evaluation == 'N')
2896: {
2897: (*s_etat_processus).position_courante = (*(*s_etat_processus)
2898: .l_base_pile_systeme).adresse_retour;
2899: }
2900: else
2901: {
2902: (*s_etat_processus).expression_courante = (*(*s_etat_processus)
2903: .l_base_pile_systeme).pointeur_objet_retour;
2904: }
2905: }
2906: else
2907: {
2908: depilement_pile_systeme(s_etat_processus);
2909:
2910: if ((*s_etat_processus).erreur_systeme != d_es)
2911: {
2912: return;
2913: }
2914:
2915: if (presence_compteur == d_vrai)
2916: {
2917: (*s_etat_processus).niveau_courant--;
2918:
1.56 bertrand 2919: if (retrait_variables_par_niveau(s_etat_processus) == d_erreur)
1.1 bertrand 2920: {
2921: return;
2922: }
2923: }
2924: }
2925:
2926: liberation(s_etat_processus, s_objet);
2927:
2928: return;
2929: }
2930:
2931:
2932: /*
2933: ================================================================================
2934: Fonction 'sf'
2935: ================================================================================
2936: Entrées : structure processus
2937: --------------------------------------------------------------------------------
2938: Sorties :
2939: --------------------------------------------------------------------------------
2940: Effets de bord : néant
2941: ================================================================================
2942: */
2943:
2944: void
2945: instruction_sf(struct_processus *s_etat_processus)
2946: {
2947: struct_objet *s_objet;
2948:
2949: (*s_etat_processus).erreur_execution = d_ex;
2950:
2951: if ((*s_etat_processus).affichage_arguments == 'Y')
2952: {
2953: printf("\n SF ");
2954:
2955: if ((*s_etat_processus).langue == 'F')
2956: {
2957: printf("(positionne un indicateur binaire)\n\n");
2958: }
2959: else
2960: {
2961: printf("(set flag)\n\n");
2962: }
2963:
2964: printf(" 1: 1 <= %s <= 64\n", d_INT);
2965:
2966: return;
2967: }
2968: else if ((*s_etat_processus).test_instruction == 'Y')
2969: {
2970: (*s_etat_processus).nombre_arguments = -1;
2971: return;
2972: }
2973:
2974: if (test_cfsf(s_etat_processus, 31) == d_vrai)
2975: {
2976: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
2977: {
2978: return;
2979: }
2980: }
2981:
2982: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2983: &s_objet) == d_erreur)
2984: {
2985: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
2986: return;
2987: }
2988:
2989: if ((*s_objet).type == INT)
2990: {
2991: if (((*((integer8 *) (*s_objet).objet)) < 1) || ((*((integer8 *)
2992: (*s_objet).objet)) > 64))
2993: {
2994: liberation(s_etat_processus, s_objet);
2995:
2996: (*s_etat_processus).erreur_execution = d_ex_drapeau_inexistant;
2997: return;
2998: }
2999:
3000: sf(s_etat_processus, (unsigned char) (*((integer8 *)
3001: (*s_objet).objet)));
3002: }
3003: else
3004: {
3005: liberation(s_etat_processus, s_objet);
3006:
3007: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
3008: return;
3009: }
3010:
3011: liberation(s_etat_processus, s_objet);
3012:
3013: return;
3014: }
3015:
3016:
3017: /*
3018: ================================================================================
3019: Fonction 'stof'
3020: ================================================================================
3021: Entrées : structure processus
3022: --------------------------------------------------------------------------------
3023: Sorties :
3024: --------------------------------------------------------------------------------
3025: Effets de bord : néant
3026: ================================================================================
3027: */
3028:
3029: void
3030: instruction_stof(struct_processus *s_etat_processus)
3031: {
3032: struct_objet *s_objet;
3033:
3034: t_8_bits masque;
3035:
3036: unsigned char indice_bit;
3037: unsigned char indice_bloc;
3038: unsigned char indice_drapeau;
3039: unsigned char taille_bloc;
3040:
3041: unsigned long i;
3042:
3043: (*s_etat_processus).erreur_execution = d_ex;
3044:
3045: if ((*s_etat_processus).affichage_arguments == 'Y')
3046: {
3047: printf("\n STOF ");
3048:
3049: if ((*s_etat_processus).langue == 'F')
3050: {
3051: printf("(positionne les drapeaux d'état)\n\n");
3052: }
3053: else
3054: {
3055: printf("(set flags)\n\n");
3056: }
3057:
3058: printf("-> 1: %s\n", d_BIN);
3059:
3060: return;
3061: }
3062: else if ((*s_etat_processus).test_instruction == 'Y')
3063: {
3064: (*s_etat_processus).nombre_arguments = -1;
3065: return;
3066: }
3067:
3068: if (test_cfsf(s_etat_processus, 31) == d_vrai)
3069: {
3070: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
3071: {
3072: return;
3073: }
3074: }
3075:
3076: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3077: &s_objet) == d_erreur)
3078: {
3079: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
3080: return;
3081: }
3082:
3083: if ((*s_objet).type == BIN)
3084: {
3085: taille_bloc = sizeof(t_8_bits) * 8;
3086:
3087: for(i = 0; i < 8; (*s_etat_processus).drapeaux_etat[i++] = 0);
3088:
3089: for(i = 1; i <= 64; i++)
3090: {
3091: indice_drapeau = i - 1;
3092: indice_bloc = indice_drapeau / taille_bloc;
3093: indice_bit = indice_drapeau % taille_bloc;
3094: masque = ((t_8_bits) 1) << (taille_bloc - indice_bit - 1);
3095:
3096: if (((*((logical8 *) (*s_objet).objet)) &
3097: ((logical8) 1) << indice_drapeau) != 0)
3098: {
3099: (*s_etat_processus).drapeaux_etat[indice_bloc] |= masque;
3100: }
3101: }
3102: }
3103: else
3104: {
3105: liberation(s_etat_processus, s_objet);
3106:
3107: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
3108: return;
3109: }
3110:
3111: liberation(s_etat_processus, s_objet);
3112:
3113: return;
3114: }
3115:
3116:
3117: /*
3118: ================================================================================
3119: Fonction 'sto'
3120: ================================================================================
3121: Entrées : structure processus
3122: --------------------------------------------------------------------------------
3123: Sorties :
3124: --------------------------------------------------------------------------------
3125: Effets de bord : néant
3126: ================================================================================
3127: */
3128:
3129: void
3130: instruction_sto(struct_processus *s_etat_processus)
3131: {
3132: struct_objet *s_objet_1;
3133: struct_objet *s_objet_2;
3134:
3135: struct_variable s_variable;
3136:
3137: (*s_etat_processus).erreur_execution = d_ex;
3138:
3139: if ((*s_etat_processus).affichage_arguments == 'Y')
3140: {
3141: printf("\n STO ");
3142:
3143: if ((*s_etat_processus).langue == 'F')
3144: {
3145: printf("(affecte un objet à une variable)\n\n");
3146: }
3147: else
3148: {
3149: printf("(store an object in a variable)\n\n");
3150: }
3151:
3152: printf(" 2: %s, %s, %s, %s, %s, %s,\n"
3153: " %s, %s, %s, %s, %s,\n"
3154: " %s, %s, %s, %s, %s,\n"
3155: " %s, %s, %s, %s, %s,\n"
3156: " %s\n",
3157: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
3158: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
3159: d_SLB, d_PRC, d_MTX, d_SQL);
3160: printf(" 1: %s\n", d_NOM);
3161:
3162: return;
3163: }
3164: else if ((*s_etat_processus).test_instruction == 'Y')
3165: {
3166: (*s_etat_processus).nombre_arguments = -1;
3167: return;
3168: }
3169:
3170: if (test_cfsf(s_etat_processus, 31) == d_vrai)
3171: {
3172: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
3173: {
3174: return;
3175: }
3176: }
3177:
3178: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3179: &s_objet_1) == d_erreur)
3180: {
3181: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
3182: return;
3183: }
3184:
3185: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3186: &s_objet_2) == d_erreur)
3187: {
3188: liberation(s_etat_processus, s_objet_1);
3189:
3190: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
3191: return;
3192: }
3193:
3194: if ((*s_objet_1).type != NOM)
3195: {
3196: liberation(s_etat_processus, s_objet_1);
3197: liberation(s_etat_processus, s_objet_2);
3198:
3199: (*s_etat_processus).erreur_execution = d_ex_nom_invalide;
3200: return;
3201: }
3202:
3203: if (recherche_variable(s_etat_processus, (*((struct_nom *)
3204: (*s_objet_1).objet)).nom) == d_vrai)
3205: {
3206: /*
3207: * La variable est accessible.
3208: */
3209:
1.27 bertrand 3210: if ((*(*s_etat_processus).pointeur_variable_courante)
3211: .variable_verrouillee == d_vrai)
1.1 bertrand 3212: {
3213: liberation(s_etat_processus, s_objet_1);
3214: liberation(s_etat_processus, s_objet_2);
3215:
3216: (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee;
3217: return;
3218: }
3219:
1.27 bertrand 3220: if ((*(*s_etat_processus).pointeur_variable_courante).objet == NULL)
1.1 bertrand 3221: {
3222: if (recherche_variable_partagee(s_etat_processus,
1.27 bertrand 3223: (*(*s_etat_processus).pointeur_variable_courante).nom,
3224: (*(*s_etat_processus).pointeur_variable_courante)
3225: .variable_partagee, (*(*s_etat_processus)
1.59 bertrand 3226: .pointeur_variable_courante).origine) == NULL)
1.1 bertrand 3227: {
1.57 bertrand 3228: if (((*s_etat_processus).autorisation_nom_implicite == 'N') &&
3229: ((*((struct_nom *) (*s_objet_1).objet)).symbole
3230: == d_faux))
1.25 bertrand 3231: {
3232: liberation(s_etat_processus, s_objet_1);
3233: liberation(s_etat_processus, s_objet_2);
3234:
3235: (*s_etat_processus).erreur_systeme = d_es;
3236: (*s_etat_processus).erreur_execution =
3237: d_ex_creation_variable_globale;
3238: return;
3239: }
3240:
1.1 bertrand 3241: if ((s_variable.nom = malloc((strlen((*((struct_nom *)
3242: (*s_objet_1).objet)).nom) + 1) *
3243: sizeof(unsigned char))) == NULL)
3244: {
3245: (*s_etat_processus).erreur_systeme =
3246: d_es_allocation_memoire;
3247: return;
3248: }
3249:
3250: strcpy(s_variable.nom, (*((struct_nom *)
3251: (*s_objet_1).objet)).nom);
3252: s_variable.niveau = 1;
3253:
3254: /*
3255: * Le niveau 0 correspond aux définitions. Les variables
3256: * commencent à 1 car elles sont toujours incluses dans
3257: * une définition.
3258: */
3259:
3260: s_variable.objet = s_objet_2;
3261:
3262: if (creation_variable(s_etat_processus, &s_variable, 'V', 'P')
3263: == d_erreur)
3264: {
3265: return;
3266: }
3267:
3268: (*s_etat_processus).erreur_systeme = d_es;
3269: }
3270: else
3271: {
3272: liberation(s_etat_processus, (*(*s_etat_processus)
1.58 bertrand 3273: .pointeur_variable_partagee_courante).objet);
3274: (*(*s_etat_processus).pointeur_variable_partagee_courante)
3275: .objet = s_objet_2;
1.1 bertrand 3276:
3277: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.58 bertrand 3278: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 3279: {
3280: (*s_etat_processus).erreur_systeme = d_es_processus;
3281: return;
3282: }
3283: }
3284: }
3285: else
3286: {
1.57 bertrand 3287: if (((*s_etat_processus).autorisation_nom_implicite == 'N') &&
3288: ((*((struct_nom *) (*s_objet_1).objet)).symbole == d_faux))
1.25 bertrand 3289: {
1.27 bertrand 3290: if ((*(*s_etat_processus).pointeur_variable_courante)
3291: .niveau == 1)
1.25 bertrand 3292: {
3293: liberation(s_etat_processus, s_objet_1);
3294: liberation(s_etat_processus, s_objet_2);
3295:
3296: (*s_etat_processus).erreur_execution =
3297: d_ex_creation_variable_globale;
3298: return;
3299: }
3300: }
3301:
1.1 bertrand 3302: liberation(s_etat_processus,
1.27 bertrand 3303: (*(*s_etat_processus).pointeur_variable_courante).objet);
3304: (*(*s_etat_processus).pointeur_variable_courante).objet =
3305: s_objet_2;
1.1 bertrand 3306: }
3307: }
3308: else
3309: {
3310: /*
3311: * La variable n'est pas accessible ou n'existe pas et on crée
3312: * une variable globale.
3313: */
3314:
1.57 bertrand 3315: if (((*s_etat_processus).autorisation_nom_implicite == 'N') &&
3316: ((*((struct_nom *) (*s_objet_1).objet)).symbole == d_faux))
1.25 bertrand 3317: {
3318: liberation(s_etat_processus, s_objet_1);
3319: liberation(s_etat_processus, s_objet_2);
3320:
3321: (*s_etat_processus).erreur_systeme = d_es;
3322: (*s_etat_processus).erreur_execution =
3323: d_ex_creation_variable_globale;
3324: return;
3325: }
3326:
1.1 bertrand 3327: if ((s_variable.nom = malloc((strlen((*((struct_nom *)
3328: (*s_objet_1).objet)).nom) + 1) * sizeof(unsigned char)))
3329: == NULL)
3330: {
3331: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
3332: return;
3333: }
3334:
3335: strcpy(s_variable.nom, (*((struct_nom *) (*s_objet_1).objet)).nom);
3336: s_variable.niveau = 1;
3337:
3338: /*
3339: * Le niveau 0 correspond aux définitions. Les variables
3340: * commencent à 1 car elles sont toujours incluses dans
3341: * une définition.
3342: */
3343:
3344: s_variable.objet = s_objet_2;
3345:
3346: if (creation_variable(s_etat_processus, &s_variable, 'V', 'P')
3347: == d_erreur)
3348: {
3349: return;
3350: }
3351:
3352: (*s_etat_processus).erreur_systeme = d_es;
3353: }
3354:
3355: liberation(s_etat_processus, s_objet_1);
3356:
3357: return;
3358: }
3359:
3360:
3361: /*
3362: ================================================================================
3363: Fonction 'syseval'
3364: ================================================================================
3365: Entrées : pointeur sur une struct_processus
3366: --------------------------------------------------------------------------------
3367: Sorties :
3368: --------------------------------------------------------------------------------
3369: Effets de bord : néant
3370: ================================================================================
3371: */
3372:
3373: void
3374: instruction_syseval(struct_processus *s_etat_processus)
3375: {
3376: char **arguments;
3377:
3378: int ios;
3379: int pipes_entree[2];
3380: int pipes_erreur[2];
3381: int pipes_sortie[2];
3382: int status;
3383:
1.64 ! bertrand 3384: integer8 longueur_ecriture;
! 3385: integer8 longueur_traitee;
! 3386:
1.1 bertrand 3387: logical1 drapeau_fin;
3388: logical1 presence_stdin;
3389:
3390: long i;
3391: long nombre_arguments;
3392:
3393: pid_t pid;
3394:
3395: struct_liste_chainee *l_element_courant;
3396: struct_liste_chainee *l_element_precedent;
3397: struct_liste_chainee *l_element_stdin;
3398:
3399: struct_objet *s_objet;
3400: struct_objet *s_objet_composite;
3401: struct_objet *s_objet_resultat;
3402: struct_objet *s_objet_temporaire;
3403:
3404: struct sigaction action_courante;
3405: struct sigaction action_passee;
3406:
1.49 bertrand 3407: unsigned char *ligne;
1.1 bertrand 3408: unsigned char *ptr;
3409: unsigned char *ptr2;
3410: unsigned char registre_autorisation_empilement_programme;
3411: unsigned char *registre_instruction_courante;
3412: unsigned char *registre_programme;
3413: unsigned char *tampon;
3414:
3415: unsigned long longueur_lecture;
3416: unsigned long longueur_tampon;
3417: unsigned long nombre_iterations;
3418: unsigned long nombre_lignes;
3419: unsigned long pointeur;
3420: unsigned long registre_position_courante;
3421:
3422: (*s_etat_processus).erreur_execution = d_ex;
3423:
3424: if ((*s_etat_processus).affichage_arguments == 'Y')
3425: {
3426: printf("\n SYSEVAL ");
3427:
3428: if ((*s_etat_processus).langue == 'F')
3429: {
3430: printf("(exécute une commande système)\n\n");
3431: }
3432: else
3433: {
3434: printf("(execute a shell command)\n\n");
3435: }
3436:
3437: printf(" 1: %s\n", d_CHN);
3438: printf("-> 1: %s\n\n", d_LST);
3439:
3440: printf(" 1: %s\n", d_LST);
3441: printf("-> 1: %s\n", d_LST);
3442:
3443: return;
3444: }
3445: else if ((*s_etat_processus).test_instruction == 'Y')
3446: {
3447: (*s_etat_processus).nombre_arguments = -1;
3448: return;
3449: }
3450:
3451: if (test_cfsf(s_etat_processus, 31) == d_vrai)
3452: {
3453: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
3454: {
3455: return;
3456: }
3457: }
3458:
3459: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3460: &s_objet) == d_erreur)
3461: {
3462: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
3463: return;
3464: }
3465:
3466: s_objet_composite = NULL;
3467: l_element_stdin = NULL;
3468: presence_stdin = d_faux;
3469:
3470: if ((*s_objet).type == LST)
3471: {
3472: s_objet_composite = s_objet;
3473: s_objet = (*((struct_liste_chainee *) (*s_objet_composite)
3474: .objet)).donnee;
3475: l_element_stdin = (*((struct_liste_chainee *) (*s_objet_composite)
3476: .objet)).suivant;
3477:
3478: l_element_courant = l_element_stdin;
3479:
3480: if (l_element_courant == NULL)
3481: {
3482: liberation(s_etat_processus, s_objet_composite);
3483:
3484: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
3485: return;
3486: }
3487:
3488: while(l_element_courant != NULL)
3489: {
3490: if ((*(*l_element_courant).donnee).type != CHN)
3491: {
3492: liberation(s_etat_processus, s_objet_composite);
3493:
3494: (*s_etat_processus).erreur_execution =
3495: d_ex_erreur_type_argument;
3496: return;
3497: }
3498:
3499: l_element_courant = (*l_element_courant).suivant;
3500: }
3501:
3502: presence_stdin = d_vrai;
3503: }
3504:
3505: if ((*s_objet).type == CHN)
3506: {
3507: registre_autorisation_empilement_programme =
3508: (*s_etat_processus).autorisation_empilement_programme;
3509: registre_instruction_courante =
3510: (*s_etat_processus).instruction_courante;
3511: registre_programme = (*s_etat_processus).definitions_chainees;
3512: registre_position_courante = (*s_etat_processus).position_courante;
3513:
3514: (*s_etat_processus).position_courante = 0;
3515: (*s_etat_processus).autorisation_empilement_programme = 'N';
3516:
3517: /*
3518: * Échappement des guillemets
3519: */
3520:
1.50 bertrand 3521: if (((*s_etat_processus).definitions_chainees =
3522: formateur_flux(s_etat_processus, (unsigned char *)
3523: (*s_objet).objet, &longueur_traitee)) == NULL)
1.1 bertrand 3524: {
1.50 bertrand 3525: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
3526: return;
1.1 bertrand 3527: }
3528:
3529: /*
3530: * Scission de la chaîne en différents arguments
3531: */
3532:
3533: nombre_arguments = 0;
3534: drapeau_fin = d_faux;
3535:
3536: do
3537: {
3538: if (recherche_instruction_suivante(s_etat_processus) == d_erreur)
3539: {
1.50 bertrand 3540: free((*s_etat_processus).definitions_chainees);
3541:
1.1 bertrand 3542: (*s_etat_processus).autorisation_empilement_programme =
3543: registre_autorisation_empilement_programme;
3544: (*s_etat_processus).instruction_courante =
3545: registre_instruction_courante;
3546: (*s_etat_processus).definitions_chainees = registre_programme;
3547: (*s_etat_processus).position_courante =
3548: registre_position_courante;
3549:
3550: return;
3551: }
3552:
3553: if ((*(*s_etat_processus).instruction_courante) !=
3554: d_code_fin_chaine)
3555: {
3556: if ((s_objet_temporaire = allocation(s_etat_processus, CHN))
3557: == NULL)
3558: {
1.50 bertrand 3559: free((*s_etat_processus).definitions_chainees);
3560:
1.1 bertrand 3561: (*s_etat_processus).autorisation_empilement_programme =
3562: registre_autorisation_empilement_programme;
3563: (*s_etat_processus).instruction_courante =
3564: registre_instruction_courante;
3565: (*s_etat_processus).definitions_chainees =
3566: registre_programme;
3567: (*s_etat_processus).position_courante =
3568: registre_position_courante;
3569:
3570: (*s_etat_processus).erreur_systeme =
3571: d_es_allocation_memoire;
3572: return;
3573: }
3574:
3575: (*s_objet_temporaire).objet = (*s_etat_processus)
3576: .instruction_courante;
3577:
3578: /*
3579: * S'il y a des guillemets en début de chaîne, il y en
3580: * a aussi à la fin de la chaîne et on les ôte. Les
3581: * guillements intermédiaires sont protégés par une
3582: * séquence d'échappement qui est enlevée.
3583: */
3584:
3585: if ((*s_etat_processus).instruction_courante[0] == '"')
3586: {
3587: if (strlen((*s_etat_processus).instruction_courante) >= 2)
3588: {
3589: ptr = (*s_etat_processus).instruction_courante;
3590: ptr2 = ptr + 1;
3591:
3592: while((*ptr2) != d_code_fin_chaine)
3593: {
3594: *ptr++ = *ptr2++;
3595: }
3596:
3597: (*(--ptr)) = d_code_fin_chaine;
3598: }
3599: }
3600:
3601: if (empilement(s_etat_processus,
3602: &((*s_etat_processus).l_base_pile),
3603: s_objet_temporaire) == d_erreur)
3604: {
1.50 bertrand 3605: free((*s_etat_processus).definitions_chainees);
3606:
3607: (*s_etat_processus).autorisation_empilement_programme =
3608: registre_autorisation_empilement_programme;
3609: (*s_etat_processus).instruction_courante =
3610: registre_instruction_courante;
3611: (*s_etat_processus).definitions_chainees =
3612: registre_programme;
3613: (*s_etat_processus).position_courante =
3614: registre_position_courante;
1.1 bertrand 3615: return;
3616: }
3617: }
3618: else
3619: {
3620: free((*s_etat_processus).instruction_courante);
3621: drapeau_fin = d_vrai;
3622: }
3623:
3624: nombre_arguments++;
3625: } while(drapeau_fin == d_faux);
3626:
1.50 bertrand 3627: free((*s_etat_processus).definitions_chainees);
3628:
1.1 bertrand 3629: (*s_etat_processus).autorisation_empilement_programme =
3630: registre_autorisation_empilement_programme;
3631: (*s_etat_processus).instruction_courante =
3632: registre_instruction_courante;
3633: (*s_etat_processus).definitions_chainees = registre_programme;
3634: (*s_etat_processus).position_courante = registre_position_courante;
3635:
3636: if ((arguments = malloc(nombre_arguments * sizeof(char *))) == NULL)
3637: {
3638: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
3639: return;
3640: }
3641:
3642: l_element_courant = (*s_etat_processus).l_base_pile;
3643: nombre_arguments--;
3644:
3645: for(i = nombre_arguments, arguments[i--] = NULL; i >= 0; i--)
3646: {
3647: arguments[i] = (char *) (*(*l_element_courant).donnee).objet;
3648: l_element_courant = (*l_element_courant).suivant;
3649: }
3650:
3651: action_courante.sa_handler = SIG_IGN;
3652: action_courante.sa_flags = SA_NODEFER | SA_ONSTACK;
3653:
3654: if (sigaction(SIGINT, &action_courante, &action_passee) != 0)
3655: {
3656: for(i = 0; i < nombre_arguments; i++)
3657: {
3658: depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3659: &s_objet_temporaire);
3660: liberation(s_etat_processus, s_objet_temporaire);
3661: }
3662:
3663: free(arguments);
3664: (*s_etat_processus).erreur_systeme = d_es_signal;
3665: return;
3666: }
3667:
3668: if (pipe(pipes_entree) != 0)
3669: {
3670: (*s_etat_processus).erreur_systeme = d_es_processus;
3671: return;
3672: }
3673:
3674: if (pipe(pipes_sortie) != 0)
3675: {
3676: (*s_etat_processus).erreur_systeme = d_es_processus;
3677: return;
3678: }
3679:
3680: if (pipe(pipes_erreur) != 0)
3681: {
3682: (*s_etat_processus).erreur_systeme = d_es_processus;
3683: return;
3684: }
3685:
3686: fflush(NULL);
3687:
3688: verrouillage_threads_concurrents(s_etat_processus);
3689: pid = fork();
3690: deverrouillage_threads_concurrents(s_etat_processus);
3691:
3692: if (pid < 0)
3693: {
3694: if (close(pipes_entree[0]) != 0)
3695: {
3696: (*s_etat_processus).erreur_systeme = d_es_processus;
3697: return;
3698: }
3699:
3700: if (close(pipes_entree[1]) != 0)
3701: {
3702: (*s_etat_processus).erreur_systeme = d_es_processus;
3703: return;
3704: }
3705:
3706: if (close(pipes_sortie[0]) != 0)
3707: {
3708: (*s_etat_processus).erreur_systeme = d_es_processus;
3709: return;
3710: }
3711:
3712: if (close(pipes_sortie[1]) != 0)
3713: {
3714: (*s_etat_processus).erreur_systeme = d_es_processus;
3715: return;
3716: }
3717:
3718: if (close(pipes_erreur[0]) != 0)
3719: {
3720: (*s_etat_processus).erreur_systeme = d_es_processus;
3721: return;
3722: }
3723:
3724: if (close(pipes_erreur[1]) != 0)
3725: {
3726: (*s_etat_processus).erreur_systeme = d_es_processus;
3727: return;
3728: }
3729:
3730: (*s_etat_processus).erreur_systeme = d_es_processus;
3731: return;
3732: }
3733: else if (pid == 0)
3734: {
3735: if (close(pipes_entree[1]) != 0)
3736: {
3737: (*s_etat_processus).erreur_systeme = d_es_processus;
3738: return;
3739: }
3740:
3741: if (close(pipes_sortie[0]) != 0)
3742: {
3743: (*s_etat_processus).erreur_systeme = d_es_processus;
3744: return;
3745: }
3746:
3747: if (close(pipes_erreur[0]) != 0)
3748: {
3749: (*s_etat_processus).erreur_systeme = d_es_processus;
3750: return;
3751: }
3752:
3753: if (pipes_entree[0] != STDIN_FILENO)
3754: {
3755: if (dup2(pipes_entree[0], STDIN_FILENO) == -1)
3756: {
3757: (*s_etat_processus).erreur_systeme = d_es_processus;
3758: return;
3759: }
3760: }
3761:
3762: if (pipes_sortie[1] != STDOUT_FILENO)
3763: {
3764: if (dup2(pipes_sortie[1], STDOUT_FILENO) == -1)
3765: {
3766: (*s_etat_processus).erreur_systeme = d_es_processus;
3767: return;
3768: }
3769: }
3770:
3771: if (pipes_sortie[1] != STDERR_FILENO)
3772: {
3773: if (dup2(pipes_sortie[1], STDERR_FILENO) == -1)
3774: {
3775: (*s_etat_processus).erreur_systeme = d_es_processus;
3776: return;
3777: }
3778: }
3779:
3780: if (nombre_arguments != 0)
3781: {
3782: execvp(arguments[0], arguments);
3783: }
3784: else
3785: {
3786: exit(EXIT_SUCCESS);
3787: }
3788:
3789: /*
3790: * L'appel système execvp() a généré une erreur et n'a pu exécuter
3791: * argument[0] (fichier non exécutable ou inexistant).
3792: */
3793:
3794: close(pipes_entree[0]);
3795: close(pipes_sortie[1]);
3796:
3797: for(i = 0; i < nombre_arguments; i++)
3798: {
3799: depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3800: &s_objet_temporaire);
3801: liberation(s_etat_processus, s_objet_temporaire);
3802: }
3803:
3804: free(arguments);
3805: (*s_etat_processus).erreur_systeme = d_es_processus;
3806:
3807: /*
3808: * Envoi d'une erreur dans le pipe idoine. On ne regarde pas
3809: * le nombre d'octets écrits car l'erreur ne pourra de toute
3810: * façon pas être traitée.
3811: */
3812:
3813: write_atomic(s_etat_processus, pipes_erreur[1], " ", 1);
3814: close(pipes_erreur[1]);
3815:
3816: exit(EXIT_SUCCESS);
3817: }
3818: else
3819: {
3820: if (close(pipes_entree[0]) != 0)
3821: {
3822: (*s_etat_processus).erreur_systeme = d_es_processus;
3823: return;
3824: }
3825:
3826: if (close(pipes_sortie[1]) != 0)
3827: {
3828: (*s_etat_processus).erreur_systeme = d_es_processus;
3829: return;
3830: }
3831:
3832: if (close(pipes_erreur[1]) != 0)
3833: {
3834: (*s_etat_processus).erreur_systeme = d_es_processus;
3835: return;
3836: }
3837:
3838: if (presence_stdin == d_vrai)
3839: {
3840: l_element_courant = l_element_stdin;
3841:
3842: while(l_element_courant != NULL)
3843: {
1.49 bertrand 3844: if ((ligne = formateur_flux(s_etat_processus,
3845: (unsigned char *) (*(*l_element_courant).donnee)
3846: .objet, &longueur_ecriture)) == NULL)
3847: {
3848: (*s_etat_processus).erreur_systeme =
3849: d_es_allocation_memoire;
3850: return;
3851: }
1.1 bertrand 3852:
1.41 bertrand 3853: # ifndef SEMAPHORES_NOMMES
3854: if (sem_post(&((*s_etat_processus).semaphore_fork))
3855: != 0)
3856: # else
3857: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
3858: # endif
1.1 bertrand 3859: {
3860: (*s_etat_processus).erreur_systeme = d_es_processus;
3861: return;
3862: }
3863:
3864: while(write_atomic(s_etat_processus,
1.49 bertrand 3865: pipes_entree[1], ligne,
1.1 bertrand 3866: longueur_ecriture) != longueur_ecriture)
3867: {
1.41 bertrand 3868: # ifndef SEMAPHORES_NOMMES
3869: while(sem_wait(&((*s_etat_processus)
3870: .semaphore_fork)) != 0)
3871: # else
3872: while(sem_wait((*s_etat_processus)
3873: .semaphore_fork) != 0)
3874: # endif
1.1 bertrand 3875: {
1.37 bertrand 3876: (*s_etat_processus).erreur_systeme =
3877: d_es_processus;
3878: return;
1.1 bertrand 3879: }
3880:
3881: if (longueur_ecriture == -1)
3882: {
3883: (*s_etat_processus).erreur_systeme = d_es_processus;
3884: return;
3885: }
3886:
1.41 bertrand 3887: # ifndef SEMAPHORES_NOMMES
3888: if (sem_post(&((*s_etat_processus)
3889: .semaphore_fork)) != 0)
3890: # else
3891: if (sem_post((*s_etat_processus)
3892: .semaphore_fork) != 0)
3893: # endif
1.1 bertrand 3894: {
3895: (*s_etat_processus).erreur_systeme = d_es_processus;
3896: return;
3897: }
3898: }
3899:
1.49 bertrand 3900: free(ligne);
3901:
1.1 bertrand 3902: while(write_atomic(s_etat_processus,
3903: pipes_entree[1], "\n", 1) != 1)
3904: {
1.41 bertrand 3905: # ifndef SEMAPHORES_NOMMES
3906: while(sem_wait(&((*s_etat_processus)
3907: .semaphore_fork)) != 0)
3908: # else
3909: while(sem_wait((*s_etat_processus)
3910: .semaphore_fork) != 0)
3911: # endif
1.1 bertrand 3912: {
1.40 bertrand 3913: if (errno != EINTR)
3914: {
3915: (*s_etat_processus).erreur_systeme =
3916: d_es_processus;
3917: return;
3918: }
1.1 bertrand 3919: }
3920:
3921: if (longueur_ecriture == -1)
3922: {
3923: (*s_etat_processus).erreur_systeme = d_es_processus;
3924: return;
3925: }
3926:
1.41 bertrand 3927: # ifndef SEMAPHORES_NOMMES
3928: if (sem_post(&((*s_etat_processus)
3929: .semaphore_fork)) != 0)
3930: # else
3931: if (sem_post((*s_etat_processus)
3932: .semaphore_fork) != 0)
3933: # endif
1.1 bertrand 3934: {
3935: (*s_etat_processus).erreur_systeme = d_es_processus;
3936: return;
3937: }
3938: }
3939:
1.41 bertrand 3940: # ifndef SEMAPHORES_NOMMES
3941: while(sem_wait(&((*s_etat_processus).semaphore_fork))
3942: != 0)
3943: # else
3944: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
3945: # endif
1.1 bertrand 3946: {
1.40 bertrand 3947: if (errno != EINTR)
3948: {
3949: (*s_etat_processus).erreur_systeme = d_es_processus;
3950: return;
3951: }
1.1 bertrand 3952: }
3953:
3954: l_element_courant = (*l_element_courant).suivant;
3955: }
3956: }
3957:
3958: if (close(pipes_entree[1]) != 0)
3959: {
3960: (*s_etat_processus).erreur_systeme = d_es_processus;
3961: return;
3962: }
3963:
3964: do
3965: {
3966: if (kill(pid, 0) != 0)
3967: {
3968: break;
3969: }
3970:
3971: /*
3972: * Récupération de la valeur de retour du processus détaché
3973: */
3974:
1.41 bertrand 3975: # ifndef SEMAPHORES_NOMMES
3976: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
3977: # else
3978: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
3979: # endif
1.1 bertrand 3980: {
3981: (*s_etat_processus).erreur_systeme = d_es_processus;
3982: return;
3983: }
3984:
3985: if (waitpid(pid, &status, 0) == -1)
3986: {
1.41 bertrand 3987: # ifndef SEMAPHORES_NOMMES
3988: if (sem_post(&((*s_etat_processus).semaphore_fork))
3989: != 0)
3990: # else
3991: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
3992: # endif
1.1 bertrand 3993: {
1.37 bertrand 3994: (*s_etat_processus).erreur_systeme = d_es_processus;
3995: return;
1.1 bertrand 3996: }
3997:
3998: (*s_etat_processus).erreur_systeme = d_es_processus;
3999: return;
4000: }
4001:
1.41 bertrand 4002: # ifndef SEMAPHORES_NOMMES
4003: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
4004: # else
4005: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
4006: # endif
1.1 bertrand 4007: {
1.40 bertrand 4008: if (errno != EINTR)
4009: {
4010: (*s_etat_processus).erreur_systeme = d_es_processus;
4011: return;
4012: }
1.1 bertrand 4013: }
4014: } while((!WIFEXITED(status)) && (!WIFSIGNALED(status)));
4015:
4016: longueur_lecture = 256;
4017: pointeur = 0;
4018: nombre_iterations = 1;
4019:
4020: if ((tampon = malloc((longueur_lecture + 1) *
4021: sizeof(unsigned char))) == NULL)
4022: {
4023: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4024: return;
4025: }
4026:
1.49 bertrand 4027: tampon[0] = d_code_fin_chaine;
4028:
1.41 bertrand 4029: # ifndef SEMAPHORES_NOMMES
4030: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
4031: # else
4032: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
4033: # endif
1.8 bertrand 4034: {
4035: (*s_etat_processus).erreur_systeme = d_es_processus;
4036: return;
4037: }
1.1 bertrand 4038:
4039: while((ios = read_atomic(s_etat_processus,
4040: pipes_sortie[0], &(tampon[pointeur]),
4041: longueur_lecture)) > 0)
4042: {
1.41 bertrand 4043: # ifndef SEMAPHORES_NOMMES
4044: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
4045: # else
4046: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
4047: # endif
1.1 bertrand 4048: {
1.37 bertrand 4049: (*s_etat_processus).erreur_systeme = d_es_processus;
4050: return;
1.1 bertrand 4051: }
4052:
4053: tampon[pointeur + ios] = d_code_fin_chaine;
4054: pointeur += longueur_lecture;
4055: nombre_iterations++;
4056:
4057: if ((tampon = realloc(tampon,
4058: ((nombre_iterations * longueur_lecture) + 1) *
4059: sizeof(unsigned char))) == NULL)
4060: {
4061: (*s_etat_processus).erreur_systeme =
4062: d_es_allocation_memoire;
4063: return;
4064: }
4065:
1.41 bertrand 4066: # ifndef SEMAPHORES_NOMMES
4067: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
4068: # else
4069: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
4070: # endif
1.1 bertrand 4071: {
4072: (*s_etat_processus).erreur_systeme = d_es_processus;
4073: return;
4074: }
4075: }
4076:
1.41 bertrand 4077: # ifndef SEMAPHORES_NOMMES
4078: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
4079: # else
4080: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
4081: # endif
1.1 bertrand 4082: {
1.40 bertrand 4083: if (errno != EINTR)
4084: {
4085: (*s_etat_processus).erreur_systeme = d_es_processus;
4086: return;
4087: }
1.1 bertrand 4088: }
4089:
4090: if (ios == -1)
4091: {
4092: (*s_etat_processus).erreur_systeme = d_es_processus;
4093: return;
4094: }
4095:
4096: if (close(pipes_sortie[0]) != 0)
4097: {
4098: (*s_etat_processus).erreur_systeme = d_es_processus;
4099: return;
4100: }
4101:
4102: /*
4103: * Transformation de la chaîne en liste
4104: */
4105:
1.50 bertrand 4106: longueur_tampon = strlen(tampon);
1.1 bertrand 4107:
4108: for(i = 0, ptr = tampon, nombre_lignes = 0;
4109: i < (long) longueur_tampon; i++, ptr++)
4110: {
4111: if ((*ptr) == d_code_retour_chariot)
4112: {
4113: nombre_lignes++;
4114: (*ptr) = d_code_fin_chaine;
4115: }
4116: }
4117:
4118: if ((s_objet_resultat = allocation(s_etat_processus, LST))
4119: == NULL)
4120: {
4121: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4122: return;
4123: }
4124:
4125: if (nombre_lignes == 0)
4126: {
4127: (*s_objet_resultat).objet = NULL;
4128: }
4129: else
4130: {
4131: if (((*s_objet_resultat).objet =
4132: allocation_maillon(s_etat_processus)) == NULL)
4133: {
4134: (*s_etat_processus).erreur_systeme =
4135: d_es_allocation_memoire;
4136: return;
4137: }
4138:
4139: l_element_precedent = NULL;
4140: l_element_courant = (struct_liste_chainee *)
4141: (*s_objet_resultat).objet;
4142:
4143: for(i = 0, ptr = tampon; i < (long) nombre_lignes; i++)
4144: {
4145: if (((*l_element_courant).donnee =
4146: allocation(s_etat_processus, CHN)) == NULL)
4147: {
4148: (*s_etat_processus).erreur_systeme =
4149: d_es_allocation_memoire;
4150: return;
4151: }
4152:
4153: if (((*(*l_element_courant).donnee).objet =
1.50 bertrand 4154: analyse_flux(s_etat_processus, ptr,
1.51 bertrand 4155: strlen(ptr))) == NULL)
1.1 bertrand 4156: {
4157: (*s_etat_processus).erreur_systeme =
4158: d_es_allocation_memoire;
4159: return;
4160: }
4161:
4162: while((*ptr) != d_code_fin_chaine)
4163: {
4164: ptr++;
4165: }
4166:
4167: ptr++;
4168:
4169: if (((*l_element_courant).suivant =
4170: allocation_maillon(s_etat_processus)) == NULL)
4171: {
4172: (*s_etat_processus).erreur_systeme =
4173: d_es_allocation_memoire;
4174: return;
4175: }
4176:
4177: l_element_precedent = l_element_courant;
4178: l_element_courant = (*l_element_courant).suivant;
4179: }
4180:
4181: free(l_element_courant);
4182:
4183: if (l_element_precedent != NULL)
4184: {
4185: (*l_element_precedent).suivant = NULL;
4186: }
4187: }
4188:
4189: free(tampon);
4190: }
4191:
4192: if (sigaction(SIGINT, &action_passee, NULL) != 0)
4193: {
4194: for(i = 0; i < nombre_arguments; i++)
4195: {
4196: depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4197: &s_objet_temporaire);
4198: liberation(s_etat_processus, s_objet_temporaire);
4199: }
4200:
4201: free(arguments);
4202: (*s_etat_processus).erreur_systeme = d_es_signal;
4203: return;
4204: }
4205:
4206: for(i = 0; i < nombre_arguments; i++)
4207: {
4208: depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4209: &s_objet_temporaire);
4210: liberation(s_etat_processus, s_objet_temporaire);
4211: }
4212:
4213: if ((tampon = malloc(sizeof(unsigned char))) == NULL)
4214: {
4215: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4216: return;
4217: }
4218:
1.41 bertrand 4219: # ifndef SEMAPHORES_NOMMES
4220: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
4221: # else
4222: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
4223: # endif
1.1 bertrand 4224: {
4225: (*s_etat_processus).erreur_systeme = d_es_processus;
4226: return;
4227: }
4228:
4229: if (read_atomic(s_etat_processus, pipes_erreur[0], tampon, 1) > 0)
4230: {
4231: // Le processus fils renvoie une erreur.
4232:
4233: (*s_etat_processus).erreur_execution = d_ex_erreur_processus;
4234: liberation(s_etat_processus, s_objet_resultat);
4235: }
4236: else if (empilement(s_etat_processus,
4237: &((*s_etat_processus).l_base_pile), s_objet_resultat)
4238: == d_erreur)
4239: {
1.41 bertrand 4240: # ifndef SEMAPHORES_NOMMES
4241: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
4242: # else
4243: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
4244: # endif
1.1 bertrand 4245: {
1.40 bertrand 4246: if (errno != EINTR)
4247: {
4248: (*s_etat_processus).erreur_systeme = d_es_processus;
4249: return;
4250: }
1.1 bertrand 4251: }
4252:
4253: if (close(pipes_erreur[0]) != 0)
4254: {
4255: (*s_etat_processus).erreur_systeme = d_es_processus;
4256: return;
4257: }
4258:
4259: free(tampon);
4260: return;
4261: }
4262:
1.41 bertrand 4263: # ifndef SEMAPHORES_NOMMES
4264: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
4265: # else
4266: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
4267: # endif
1.1 bertrand 4268: {
1.40 bertrand 4269: if (errno != EINTR)
4270: {
4271: (*s_etat_processus).erreur_systeme = d_es_processus;
4272: return;
4273: }
1.1 bertrand 4274: }
4275:
4276: if (close(pipes_erreur[0]) != 0)
4277: {
4278: (*s_etat_processus).erreur_systeme = d_es_processus;
4279: return;
4280: }
4281:
4282: free(arguments);
4283: free(tampon);
4284: }
4285: else
4286: {
4287: if (presence_stdin == d_vrai)
4288: {
4289: s_objet = s_objet_composite;
4290: }
4291:
4292: liberation(s_etat_processus, s_objet);
4293:
4294: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
4295: return;
4296: }
4297:
4298: if (presence_stdin == d_vrai)
4299: {
4300: s_objet = s_objet_composite;
4301: }
4302:
4303: liberation(s_etat_processus, s_objet);
4304:
4305: return;
4306: }
4307:
4308:
4309: /*
4310: ================================================================================
4311: Fonction 'sign'
4312: ================================================================================
4313: Entrées :
4314: --------------------------------------------------------------------------------
4315: Sorties :
4316: --------------------------------------------------------------------------------
4317: Effets de bord : néant
4318: ================================================================================
4319: */
4320:
4321: void
4322: instruction_sign(struct_processus *s_etat_processus)
4323: {
4324: real8 norme;
4325:
4326: struct_liste_chainee *l_element_courant;
4327: struct_liste_chainee *l_element_precedent;
4328:
4329: struct_objet *s_copie_argument;
4330: struct_objet *s_objet_argument;
4331: struct_objet *s_objet_resultat;
4332:
4333: (*s_etat_processus).erreur_execution = d_ex;
4334:
4335: if ((*s_etat_processus).affichage_arguments == 'Y')
4336: {
4337: printf("\n SIGN ");
4338:
4339: if ((*s_etat_processus).langue == 'F')
4340: {
4341: printf("(signe)\n\n");
4342: }
4343: else
4344: {
4345: printf("(sign)\n\n");
4346: }
4347:
4348: printf(" 1: %s, %s\n", d_INT, d_REL);
4349: printf("-> 1: %s\n\n", d_INT);
4350:
4351: printf(" 1: %s\n", d_CPL);
4352: printf("-> 1: %s\n\n", d_CPL);
4353:
4354: printf(" 1: %s, %s\n", d_NOM, d_ALG);
4355: printf("-> 1: %s\n\n", d_ALG);
4356:
4357: printf(" 1: %s\n", d_RPN);
4358: printf("-> 1: %s\n", d_RPN);
4359:
4360: return;
4361: }
4362: else if ((*s_etat_processus).test_instruction == 'Y')
4363: {
4364: (*s_etat_processus).nombre_arguments = 1;
4365: return;
4366: }
4367:
4368: if (test_cfsf(s_etat_processus, 31) == d_vrai)
4369: {
4370: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
4371: {
4372: return;
4373: }
4374: }
4375:
4376: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4377: &s_objet_argument) == d_erreur)
4378: {
4379: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
4380: return;
4381: }
4382:
4383: /*
4384: --------------------------------------------------------------------------------
4385: Signe d'un entier
4386: --------------------------------------------------------------------------------
4387: */
4388:
4389: if ((*s_objet_argument).type == INT)
4390: {
4391: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
4392: {
4393: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4394: return;
4395: }
4396:
4397: if ((*((integer8 *) (*s_objet_argument).objet)) > 0)
4398: {
4399: (*((integer8 *) (*s_objet_resultat).objet)) = 1;
4400: }
4401: else if ((*((integer8 *) (*s_objet_argument).objet)) < 0)
4402: {
4403: (*((integer8 *) (*s_objet_resultat).objet)) = -1;
4404: }
4405: else
4406: {
4407: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
4408: }
4409: }
4410:
4411: /*
4412: --------------------------------------------------------------------------------
4413: Signe d'un réel
4414: --------------------------------------------------------------------------------
4415: */
4416:
4417: else if ((*s_objet_argument).type == REL)
4418: {
4419: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
4420: {
4421: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4422: return;
4423: }
4424:
4425: if ((*((real8 *) (*s_objet_argument).objet)) > 0)
4426: {
4427: (*((integer8 *) (*s_objet_resultat).objet)) = 1;
4428: }
4429: else if ((*((real8 *) (*s_objet_argument).objet)) < 0)
4430: {
4431: (*((integer8 *) (*s_objet_resultat).objet)) = -1;
4432: }
4433: else
4434: {
4435: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
4436: }
4437: }
4438:
4439: /*
4440: --------------------------------------------------------------------------------
4441: Vecteur unité dans la direction du complexe
4442: --------------------------------------------------------------------------------
4443: */
4444:
4445: else if ((*s_objet_argument).type == CPL)
4446: {
4447: if ((s_objet_resultat = allocation(s_etat_processus, CPL)) == NULL)
4448: {
4449: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4450: return;
4451: }
4452:
1.4 bertrand 4453: if (((*((struct_complexe16 *) (*s_objet_argument).objet)).partie_reelle
4454: != 0) || ((*((struct_complexe16 *) (*s_objet_argument).objet))
4455: .partie_imaginaire != 0))
4456: {
4457: f77absc_((struct_complexe16 *) (*s_objet_argument).objet, &norme);
4458: f77divisioncr_((struct_complexe16 *) (*s_objet_argument).objet,
4459: &norme, (struct_complexe16 *) (*s_objet_resultat).objet);
4460: }
4461: else
4462: {
4463: (*((struct_complexe16 *) (*s_objet_argument).objet))
4464: .partie_reelle = 0;
4465: (*((struct_complexe16 *) (*s_objet_argument).objet))
4466: .partie_imaginaire = 0;
4467: }
1.1 bertrand 4468: }
4469:
4470: /*
4471: --------------------------------------------------------------------------------
4472: Signe d'un nom
4473: --------------------------------------------------------------------------------
4474: */
4475:
4476: else if ((*s_objet_argument).type == NOM)
4477: {
4478: if ((s_objet_resultat = allocation(s_etat_processus, ALG)) == NULL)
4479: {
4480: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4481: return;
4482: }
4483:
4484: if (((*s_objet_resultat).objet =
4485: allocation_maillon(s_etat_processus)) == NULL)
4486: {
4487: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4488: return;
4489: }
4490:
4491: l_element_courant = (*s_objet_resultat).objet;
4492:
4493: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
4494: == NULL)
4495: {
4496: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4497: return;
4498: }
4499:
4500: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4501: .nombre_arguments = 0;
4502: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4503: .fonction = instruction_vers_niveau_superieur;
4504:
4505: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4506: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
4507: {
4508: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4509: return;
4510: }
4511:
4512: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4513: .nom_fonction, "<<");
4514:
4515: if (((*l_element_courant).suivant =
4516: allocation_maillon(s_etat_processus)) == NULL)
4517: {
4518: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4519: return;
4520: }
4521:
4522: l_element_courant = (*l_element_courant).suivant;
4523: (*l_element_courant).donnee = s_objet_argument;
4524:
4525: if (((*l_element_courant).suivant =
4526: allocation_maillon(s_etat_processus)) == NULL)
4527: {
4528: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4529: return;
4530: }
4531:
4532: l_element_courant = (*l_element_courant).suivant;
4533:
4534: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
4535: == NULL)
4536: {
4537: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4538: return;
4539: }
4540:
4541: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4542: .nombre_arguments = 1;
4543: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4544: .fonction = instruction_sign;
4545:
4546: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4547: .nom_fonction = malloc(5 * sizeof(unsigned char))) == NULL)
4548: {
4549: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4550: return;
4551: }
4552:
4553: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4554: .nom_fonction, "SIGN");
4555:
4556: if (((*l_element_courant).suivant =
4557: allocation_maillon(s_etat_processus)) == NULL)
4558: {
4559: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4560: return;
4561: }
4562:
4563: l_element_courant = (*l_element_courant).suivant;
4564:
4565: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
4566: == NULL)
4567: {
4568: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4569: return;
4570: }
4571:
4572: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4573: .nombre_arguments = 0;
4574: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4575: .fonction = instruction_vers_niveau_inferieur;
4576:
4577: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4578: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
4579: {
4580: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4581: return;
4582: }
4583:
4584: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4585: .nom_fonction, ">>");
4586:
4587: (*l_element_courant).suivant = NULL;
4588: s_objet_argument = NULL;
4589: }
4590:
4591: /*
4592: --------------------------------------------------------------------------------
4593: Signe d'une expression
4594: --------------------------------------------------------------------------------
4595: */
4596:
4597: else if (((*s_objet_argument).type == ALG) ||
4598: ((*s_objet_argument).type == RPN))
4599: {
4600: if ((s_copie_argument = copie_objet(s_etat_processus, s_objet_argument,
4601: 'N')) == NULL)
4602: {
4603: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4604: return;
4605: }
4606:
4607: l_element_courant = (struct_liste_chainee *)
4608: (*s_copie_argument).objet;
4609: l_element_precedent = l_element_courant;
4610:
4611: while((*l_element_courant).suivant != NULL)
4612: {
4613: l_element_precedent = l_element_courant;
4614: l_element_courant = (*l_element_courant).suivant;
4615: }
4616:
4617: if (((*l_element_precedent).suivant =
4618: allocation_maillon(s_etat_processus)) == NULL)
4619: {
4620: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4621: return;
4622: }
4623:
4624: if (((*(*l_element_precedent).suivant).donnee =
4625: allocation(s_etat_processus, FCT)) == NULL)
4626: {
4627: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4628: return;
4629: }
4630:
4631: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
4632: .donnee).objet)).nombre_arguments = 1;
4633: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
4634: .donnee).objet)).fonction = instruction_sign;
4635:
4636: if (((*((struct_fonction *) (*(*(*l_element_precedent)
4637: .suivant).donnee).objet)).nom_fonction =
4638: malloc(5 * sizeof(unsigned char))) == NULL)
4639: {
4640: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4641: return;
4642: }
4643:
4644: strcpy((*((struct_fonction *) (*(*(*l_element_precedent)
4645: .suivant).donnee).objet)).nom_fonction, "SIGN");
4646:
4647: (*(*l_element_precedent).suivant).suivant = l_element_courant;
4648:
4649: s_objet_resultat = s_copie_argument;
4650: }
4651:
4652: /*
4653: --------------------------------------------------------------------------------
4654: Fonction signe impossible à réaliser
4655: --------------------------------------------------------------------------------
4656: */
4657:
4658: else
4659: {
4660: liberation(s_etat_processus, s_objet_argument);
4661:
4662: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
4663: return;
4664: }
4665:
4666: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4667: s_objet_resultat) == d_erreur)
4668: {
4669: return;
4670: }
4671:
4672: liberation(s_etat_processus, s_objet_argument);
4673:
4674: return;
4675: }
4676:
4677:
4678: /*
4679: ================================================================================
4680: Fonction 'select'
4681: ================================================================================
4682: Entrées : pointeur sur une struct_processus
4683: --------------------------------------------------------------------------------
4684: Sorties :
4685: --------------------------------------------------------------------------------
4686: Effets de bord : néant
4687: ================================================================================
4688: */
4689:
4690: void
4691: instruction_select(struct_processus *s_etat_processus)
4692: {
4693: (*s_etat_processus).erreur_execution = d_ex;
4694:
4695: if ((*s_etat_processus).affichage_arguments == 'Y')
4696: {
4697: printf("\n SELECT ");
4698:
4699: if ((*s_etat_processus).langue == 'F')
4700: {
4701: printf("(structure de contrôle)\n\n");
4702: printf(" Utilisation :\n\n");
4703: }
4704: else
4705: {
4706: printf("(control statement)\n\n");
4707: printf(" Usage:\n\n");
4708: }
4709:
4710: printf(" SELECT (expression test)\n");
4711: printf(" CASE (clause 1) THEN (expression 1) END\n");
4712: printf(" CASE (clause 2) THEN (expression 2) END\n");
4713: printf(" ...\n");
4714: printf(" CASE (clause n) THEN (expression n) END\n");
4715: printf(" DEFAULT\n");
4716: printf(" (expression)\n");
4717: printf(" END\n\n");
4718:
4719: printf(" SELECT (expression test)\n");
4720: printf(" CASE (clause 1) THEN (expression 1) END\n");
4721: printf(" (expression)\n");
4722: printf(" CASE (clause 2) THEN (expression 2) END\n");
4723: printf(" END\n");
4724:
4725: return;
4726: }
4727: else if ((*s_etat_processus).test_instruction == 'Y')
4728: {
4729: (*s_etat_processus).nombre_arguments = -1;
4730: return;
4731: }
4732:
4733: empilement_pile_systeme(s_etat_processus);
4734:
4735: if ((*s_etat_processus).erreur_systeme != d_es)
4736: {
4737: return;
4738: }
4739:
4740: (*(*s_etat_processus).l_base_pile_systeme).type_cloture = 'C';
4741: (*(*s_etat_processus).l_base_pile_systeme).clause = 'S';
4742:
4743: return;
4744: }
4745:
4746:
4747: /*
4748: ================================================================================
4749: Fonction 'std'
4750: ================================================================================
4751: Entrées : pointeur sur une struct_processus
4752: --------------------------------------------------------------------------------
4753: Sorties :
4754: --------------------------------------------------------------------------------
4755: Effets de bord : néant
4756: ================================================================================
4757: */
4758:
4759: void
4760: instruction_std(struct_processus *s_etat_processus)
4761: {
4762: (*s_etat_processus).erreur_execution = d_ex;
4763:
4764: if ((*s_etat_processus).affichage_arguments == 'Y')
4765: {
4766: printf("\n STD ");
4767:
4768: if ((*s_etat_processus).langue == 'F')
4769: {
4770: printf("(format standard)\n\n");
4771: printf(" Aucun argument\n");
4772: }
4773: else
4774: {
4775: printf("(standard format)\n\n");
4776: printf(" No argument\n");
4777: }
4778:
4779: return;
4780: }
4781: else if ((*s_etat_processus).test_instruction == 'Y')
4782: {
4783: (*s_etat_processus).nombre_arguments = -1;
4784: return;
4785: }
4786:
4787: if (test_cfsf(s_etat_processus, 31) == d_vrai)
4788: {
4789: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
4790: {
4791: return;
4792: }
4793: }
4794:
4795: cf(s_etat_processus, 49);
4796: cf(s_etat_processus, 50);
4797:
4798: return;
4799: }
4800:
4801:
4802: /*
4803: ================================================================================
4804: Fonction 'sci'
4805: ================================================================================
4806: Entrées : pointeur sur une struct_processus
4807: --------------------------------------------------------------------------------
4808: Sorties :
4809: --------------------------------------------------------------------------------
4810: Effets de bord : néant
4811: ================================================================================
4812: */
4813:
4814: void
4815: instruction_sci(struct_processus *s_etat_processus)
4816: {
4817: struct_objet *s_objet_argument;
4818: struct_objet *s_objet;
4819:
4820: logical1 i43;
4821: logical1 i44;
4822:
4823: unsigned char *valeur_binaire;
4824:
4825: unsigned long i;
4826: unsigned long j;
4827:
4828: (*s_etat_processus).erreur_execution = d_ex;
4829:
4830: if ((*s_etat_processus).affichage_arguments == 'Y')
4831: {
4832: printf("\n SCI ");
4833:
4834: if ((*s_etat_processus).langue == 'F')
4835: {
4836: printf("(format scientifique)\n\n");
4837: }
4838: else
4839: {
4840: printf("(scientific format)\n\n");
4841: }
4842:
4843: printf(" 1: %s\n", d_INT);
4844:
4845: return;
4846: }
4847: else if ((*s_etat_processus).test_instruction == 'Y')
4848: {
4849: (*s_etat_processus).nombre_arguments = -1;
4850: return;
4851: }
4852:
4853: if (test_cfsf(s_etat_processus, 31) == d_vrai)
4854: {
4855: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
4856: {
4857: return;
4858: }
4859: }
4860:
4861: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4862: &s_objet_argument) == d_erreur)
4863: {
4864: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
4865: return;
4866: }
4867:
4868: if ((*s_objet_argument).type == INT)
4869: {
4870: if (((*((integer8 *) (*s_objet_argument).objet)) >= 0) &&
4871: ((*((integer8 *) (*s_objet_argument).objet)) <= 15))
4872: {
4873: if ((s_objet = allocation(s_etat_processus, BIN)) == NULL)
4874: {
4875: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4876: return;
4877: }
4878:
4879: (*((logical8 *) (*s_objet).objet)) =
4880: (*((integer8 *) (*s_objet_argument).objet));
4881:
4882: i43 = test_cfsf(s_etat_processus, 43);
4883: i44 = test_cfsf(s_etat_processus, 44);
4884:
4885: sf(s_etat_processus, 44);
4886: cf(s_etat_processus, 43);
4887:
4888: if ((valeur_binaire = formateur(s_etat_processus, 0, s_objet))
4889: == NULL)
4890: {
4891: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4892: return;
4893: }
4894:
4895: if (i43 == d_vrai)
4896: {
4897: sf(s_etat_processus, 43);
4898: }
4899: else
4900: {
4901: cf(s_etat_processus, 43);
4902: }
4903:
4904: if (i44 == d_vrai)
4905: {
4906: sf(s_etat_processus, 44);
4907: }
4908: else
4909: {
4910: cf(s_etat_processus, 44);
4911: }
4912:
4913: for(j = 53, i = strlen(valeur_binaire) - 2; i >= 2; i--)
4914: {
4915: if (valeur_binaire[i] == '0')
4916: {
4917: cf(s_etat_processus, j++);
4918: }
4919: else
4920: {
4921: sf(s_etat_processus, j++);
4922: }
4923: }
4924:
4925: for(; j <= 56; cf(s_etat_processus, j++));
4926:
4927: cf(s_etat_processus, 49);
4928: sf(s_etat_processus, 50);
4929:
4930: free(valeur_binaire);
4931: liberation(s_etat_processus, s_objet);
4932: }
4933: else
4934: {
4935: liberation(s_etat_processus, s_objet_argument);
4936:
4937: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
4938: return;
4939: }
4940: }
4941: else
4942: {
4943: liberation(s_etat_processus, s_objet_argument);
4944:
4945: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
4946: return;
4947: }
4948:
4949: liberation(s_etat_processus, s_objet_argument);
4950:
4951: return;
4952: }
4953:
4954: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>