Annotation of rpl/src/instructions_s1.c, revision 1.51
1.1 bertrand 1: /*
2: ================================================================================
1.48 bertrand 3: RPL/2 (R) version 4.1.9
1.44 bertrand 4: Copyright (C) 1989-2012 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: empilement_pile_systeme(s_etat_processus);
1.14 bertrand 2576:
2577: if ((*s_etat_processus).erreur_systeme != d_es)
2578: {
2579: return;
2580: }
2581:
1.1 bertrand 2582: (*(*s_etat_processus).l_base_pile_systeme).type_cloture = 'S';
2583:
2584: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2585: &s_objet_1) == d_erreur)
2586: {
2587: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
2588: return;
2589: }
2590:
1.12 bertrand 2591: if (((*s_objet_1).type != INT) && ((*s_objet_1).type != REL))
1.1 bertrand 2592: {
2593: liberation(s_etat_processus, s_objet_1);
2594:
2595: (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle;
2596: return;
2597: }
2598:
2599: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2600: &s_objet_2) == d_erreur)
2601: {
2602: liberation(s_etat_processus, s_objet_1);
2603:
2604: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
2605: return;
2606: }
2607:
1.12 bertrand 2608: if (((*s_objet_2).type != INT) && ((*s_objet_2).type != REL))
1.1 bertrand 2609: {
2610: liberation(s_etat_processus, s_objet_1);
2611: liberation(s_etat_processus, s_objet_2);
2612:
2613: (*s_etat_processus).erreur_execution = d_ex_erreur_traitement_boucle;
2614: return;
2615: }
2616:
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:
2919: if (retrait_variable_par_niveau(s_etat_processus) == d_erreur)
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 (pthread_mutex_lock(&((*(*s_etat_processus)
3223: .s_liste_variables_partagees).mutex)) != 0)
3224: {
3225: (*s_etat_processus).erreur_systeme = d_es_processus;
3226: return;
3227: }
3228:
3229: if (recherche_variable_partagee(s_etat_processus,
1.27 bertrand 3230: (*(*s_etat_processus).pointeur_variable_courante).nom,
3231: (*(*s_etat_processus).pointeur_variable_courante)
3232: .variable_partagee, (*(*s_etat_processus)
3233: .pointeur_variable_courante).origine) == d_faux)
1.1 bertrand 3234: {
3235: if (pthread_mutex_unlock(&((*(*s_etat_processus)
3236: .s_liste_variables_partagees).mutex)) != 0)
3237: {
3238: (*s_etat_processus).erreur_systeme = d_es_processus;
3239: return;
3240: }
3241:
1.25 bertrand 3242: if ((*s_etat_processus).autorisation_nom_implicite == 'N')
3243: {
3244: liberation(s_etat_processus, s_objet_1);
3245: liberation(s_etat_processus, s_objet_2);
3246:
3247: (*s_etat_processus).erreur_systeme = d_es;
3248: (*s_etat_processus).erreur_execution =
3249: d_ex_creation_variable_globale;
3250: return;
3251: }
3252:
1.1 bertrand 3253: if ((s_variable.nom = malloc((strlen((*((struct_nom *)
3254: (*s_objet_1).objet)).nom) + 1) *
3255: sizeof(unsigned char))) == NULL)
3256: {
3257: (*s_etat_processus).erreur_systeme =
3258: d_es_allocation_memoire;
3259: return;
3260: }
3261:
3262: strcpy(s_variable.nom, (*((struct_nom *)
3263: (*s_objet_1).objet)).nom);
3264: s_variable.niveau = 1;
3265:
3266: /*
3267: * Le niveau 0 correspond aux définitions. Les variables
3268: * commencent à 1 car elles sont toujours incluses dans
3269: * une définition.
3270: */
3271:
3272: s_variable.objet = s_objet_2;
3273:
3274: if (creation_variable(s_etat_processus, &s_variable, 'V', 'P')
3275: == d_erreur)
3276: {
3277: return;
3278: }
3279:
3280: (*s_etat_processus).erreur_systeme = d_es;
3281: }
3282: else
3283: {
3284: liberation(s_etat_processus, (*(*s_etat_processus)
3285: .s_liste_variables_partagees).table
3286: [(*(*s_etat_processus).s_liste_variables_partagees)
3287: .position_variable].objet);
3288:
3289: (*(*s_etat_processus).s_liste_variables_partagees).table
3290: [(*(*s_etat_processus).s_liste_variables_partagees)
3291: .position_variable].objet = s_objet_2;
3292:
3293: if (pthread_mutex_unlock(&((*(*s_etat_processus)
3294: .s_liste_variables_partagees).mutex)) != 0)
3295: {
3296: (*s_etat_processus).erreur_systeme = d_es_processus;
3297: return;
3298: }
3299: }
3300: }
3301: else
3302: {
1.25 bertrand 3303: if ((*s_etat_processus).autorisation_nom_implicite == 'N')
3304: {
1.27 bertrand 3305: if ((*(*s_etat_processus).pointeur_variable_courante)
3306: .niveau == 1)
1.25 bertrand 3307: {
3308: liberation(s_etat_processus, s_objet_1);
3309: liberation(s_etat_processus, s_objet_2);
3310:
3311: (*s_etat_processus).erreur_execution =
3312: d_ex_creation_variable_globale;
3313: return;
3314: }
3315: }
3316:
1.1 bertrand 3317: liberation(s_etat_processus,
1.27 bertrand 3318: (*(*s_etat_processus).pointeur_variable_courante).objet);
3319: (*(*s_etat_processus).pointeur_variable_courante).objet =
3320: s_objet_2;
1.1 bertrand 3321: }
3322: }
3323: else
3324: {
3325: /*
3326: * La variable n'est pas accessible ou n'existe pas et on crée
3327: * une variable globale.
3328: */
3329:
1.25 bertrand 3330: if ((*s_etat_processus).autorisation_nom_implicite == 'N')
3331: {
3332: liberation(s_etat_processus, s_objet_1);
3333: liberation(s_etat_processus, s_objet_2);
3334:
3335: (*s_etat_processus).erreur_systeme = d_es;
3336: (*s_etat_processus).erreur_execution =
3337: d_ex_creation_variable_globale;
3338: return;
3339: }
3340:
1.1 bertrand 3341: if ((s_variable.nom = malloc((strlen((*((struct_nom *)
3342: (*s_objet_1).objet)).nom) + 1) * sizeof(unsigned char)))
3343: == NULL)
3344: {
3345: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
3346: return;
3347: }
3348:
3349: strcpy(s_variable.nom, (*((struct_nom *) (*s_objet_1).objet)).nom);
3350: s_variable.niveau = 1;
3351:
3352: /*
3353: * Le niveau 0 correspond aux définitions. Les variables
3354: * commencent à 1 car elles sont toujours incluses dans
3355: * une définition.
3356: */
3357:
3358: s_variable.objet = s_objet_2;
3359:
3360: if (creation_variable(s_etat_processus, &s_variable, 'V', 'P')
3361: == d_erreur)
3362: {
3363: return;
3364: }
3365:
3366: (*s_etat_processus).erreur_systeme = d_es;
3367: }
3368:
3369: liberation(s_etat_processus, s_objet_1);
3370:
3371: return;
3372: }
3373:
3374:
3375: /*
3376: ================================================================================
3377: Fonction 'syseval'
3378: ================================================================================
3379: Entrées : pointeur sur une struct_processus
3380: --------------------------------------------------------------------------------
3381: Sorties :
3382: --------------------------------------------------------------------------------
3383: Effets de bord : néant
3384: ================================================================================
3385: */
3386:
3387: void
3388: instruction_syseval(struct_processus *s_etat_processus)
3389: {
3390: char **arguments;
3391:
3392: int ios;
3393: int pipes_entree[2];
3394: int pipes_erreur[2];
3395: int pipes_sortie[2];
3396: int status;
3397:
3398: logical1 drapeau_fin;
3399: logical1 presence_stdin;
3400:
3401: long i;
1.50 bertrand 3402: long longueur_traitee;
1.1 bertrand 3403: long nombre_arguments;
3404:
3405: pid_t pid;
3406:
3407: ssize_t longueur_ecriture;
3408:
3409: struct_liste_chainee *l_element_courant;
3410: struct_liste_chainee *l_element_precedent;
3411: struct_liste_chainee *l_element_stdin;
3412:
3413: struct_objet *s_objet;
3414: struct_objet *s_objet_composite;
3415: struct_objet *s_objet_resultat;
3416: struct_objet *s_objet_temporaire;
3417:
3418: struct sigaction action_courante;
3419: struct sigaction action_passee;
3420:
1.49 bertrand 3421: unsigned char *ligne;
1.1 bertrand 3422: unsigned char *ptr;
3423: unsigned char *ptr2;
3424: unsigned char registre_autorisation_empilement_programme;
3425: unsigned char *registre_instruction_courante;
3426: unsigned char *registre_programme;
3427: unsigned char *tampon;
3428:
3429: unsigned long longueur_lecture;
3430: unsigned long longueur_tampon;
3431: unsigned long nombre_iterations;
3432: unsigned long nombre_lignes;
3433: unsigned long pointeur;
3434: unsigned long registre_position_courante;
3435:
3436: (*s_etat_processus).erreur_execution = d_ex;
3437:
3438: if ((*s_etat_processus).affichage_arguments == 'Y')
3439: {
3440: printf("\n SYSEVAL ");
3441:
3442: if ((*s_etat_processus).langue == 'F')
3443: {
3444: printf("(exécute une commande système)\n\n");
3445: }
3446: else
3447: {
3448: printf("(execute a shell command)\n\n");
3449: }
3450:
3451: printf(" 1: %s\n", d_CHN);
3452: printf("-> 1: %s\n\n", d_LST);
3453:
3454: printf(" 1: %s\n", d_LST);
3455: printf("-> 1: %s\n", d_LST);
3456:
3457: return;
3458: }
3459: else if ((*s_etat_processus).test_instruction == 'Y')
3460: {
3461: (*s_etat_processus).nombre_arguments = -1;
3462: return;
3463: }
3464:
3465: if (test_cfsf(s_etat_processus, 31) == d_vrai)
3466: {
3467: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
3468: {
3469: return;
3470: }
3471: }
3472:
3473: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3474: &s_objet) == d_erreur)
3475: {
3476: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
3477: return;
3478: }
3479:
3480: s_objet_composite = NULL;
3481: l_element_stdin = NULL;
3482: presence_stdin = d_faux;
3483:
3484: if ((*s_objet).type == LST)
3485: {
3486: s_objet_composite = s_objet;
3487: s_objet = (*((struct_liste_chainee *) (*s_objet_composite)
3488: .objet)).donnee;
3489: l_element_stdin = (*((struct_liste_chainee *) (*s_objet_composite)
3490: .objet)).suivant;
3491:
3492: l_element_courant = l_element_stdin;
3493:
3494: if (l_element_courant == NULL)
3495: {
3496: liberation(s_etat_processus, s_objet_composite);
3497:
3498: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
3499: return;
3500: }
3501:
3502: while(l_element_courant != NULL)
3503: {
3504: if ((*(*l_element_courant).donnee).type != CHN)
3505: {
3506: liberation(s_etat_processus, s_objet_composite);
3507:
3508: (*s_etat_processus).erreur_execution =
3509: d_ex_erreur_type_argument;
3510: return;
3511: }
3512:
3513: l_element_courant = (*l_element_courant).suivant;
3514: }
3515:
3516: presence_stdin = d_vrai;
3517: }
3518:
3519: if ((*s_objet).type == CHN)
3520: {
3521: registre_autorisation_empilement_programme =
3522: (*s_etat_processus).autorisation_empilement_programme;
3523: registre_instruction_courante =
3524: (*s_etat_processus).instruction_courante;
3525: registre_programme = (*s_etat_processus).definitions_chainees;
3526: registre_position_courante = (*s_etat_processus).position_courante;
3527:
3528: (*s_etat_processus).position_courante = 0;
3529: (*s_etat_processus).autorisation_empilement_programme = 'N';
3530:
3531: /*
3532: * Échappement des guillemets
3533: */
3534:
1.50 bertrand 3535: if (((*s_etat_processus).definitions_chainees =
3536: formateur_flux(s_etat_processus, (unsigned char *)
3537: (*s_objet).objet, &longueur_traitee)) == NULL)
1.1 bertrand 3538: {
1.50 bertrand 3539: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
3540: return;
1.1 bertrand 3541: }
3542:
3543: /*
3544: * Scission de la chaîne en différents arguments
3545: */
3546:
3547: nombre_arguments = 0;
3548: drapeau_fin = d_faux;
3549:
3550: do
3551: {
3552: if (recherche_instruction_suivante(s_etat_processus) == d_erreur)
3553: {
1.50 bertrand 3554: free((*s_etat_processus).definitions_chainees);
3555:
1.1 bertrand 3556: (*s_etat_processus).autorisation_empilement_programme =
3557: registre_autorisation_empilement_programme;
3558: (*s_etat_processus).instruction_courante =
3559: registre_instruction_courante;
3560: (*s_etat_processus).definitions_chainees = registre_programme;
3561: (*s_etat_processus).position_courante =
3562: registre_position_courante;
3563:
3564: return;
3565: }
3566:
3567: if ((*(*s_etat_processus).instruction_courante) !=
3568: d_code_fin_chaine)
3569: {
3570: if ((s_objet_temporaire = allocation(s_etat_processus, CHN))
3571: == NULL)
3572: {
1.50 bertrand 3573: free((*s_etat_processus).definitions_chainees);
3574:
1.1 bertrand 3575: (*s_etat_processus).autorisation_empilement_programme =
3576: registre_autorisation_empilement_programme;
3577: (*s_etat_processus).instruction_courante =
3578: registre_instruction_courante;
3579: (*s_etat_processus).definitions_chainees =
3580: registre_programme;
3581: (*s_etat_processus).position_courante =
3582: registre_position_courante;
3583:
3584: (*s_etat_processus).erreur_systeme =
3585: d_es_allocation_memoire;
3586: return;
3587: }
3588:
3589: (*s_objet_temporaire).objet = (*s_etat_processus)
3590: .instruction_courante;
3591:
3592: /*
3593: * S'il y a des guillemets en début de chaîne, il y en
3594: * a aussi à la fin de la chaîne et on les ôte. Les
3595: * guillements intermédiaires sont protégés par une
3596: * séquence d'échappement qui est enlevée.
3597: */
3598:
3599: if ((*s_etat_processus).instruction_courante[0] == '"')
3600: {
3601: if (strlen((*s_etat_processus).instruction_courante) >= 2)
3602: {
3603: ptr = (*s_etat_processus).instruction_courante;
3604: ptr2 = ptr + 1;
3605:
3606: while((*ptr2) != d_code_fin_chaine)
3607: {
3608: *ptr++ = *ptr2++;
3609: }
3610:
3611: (*(--ptr)) = d_code_fin_chaine;
3612: }
3613: }
3614:
3615: if (empilement(s_etat_processus,
3616: &((*s_etat_processus).l_base_pile),
3617: s_objet_temporaire) == d_erreur)
3618: {
1.50 bertrand 3619: free((*s_etat_processus).definitions_chainees);
3620:
3621: (*s_etat_processus).autorisation_empilement_programme =
3622: registre_autorisation_empilement_programme;
3623: (*s_etat_processus).instruction_courante =
3624: registre_instruction_courante;
3625: (*s_etat_processus).definitions_chainees =
3626: registre_programme;
3627: (*s_etat_processus).position_courante =
3628: registre_position_courante;
1.1 bertrand 3629: return;
3630: }
3631: }
3632: else
3633: {
3634: free((*s_etat_processus).instruction_courante);
3635: drapeau_fin = d_vrai;
3636: }
3637:
3638: nombre_arguments++;
3639: } while(drapeau_fin == d_faux);
3640:
1.50 bertrand 3641: free((*s_etat_processus).definitions_chainees);
3642:
1.1 bertrand 3643: (*s_etat_processus).autorisation_empilement_programme =
3644: registre_autorisation_empilement_programme;
3645: (*s_etat_processus).instruction_courante =
3646: registre_instruction_courante;
3647: (*s_etat_processus).definitions_chainees = registre_programme;
3648: (*s_etat_processus).position_courante = registre_position_courante;
3649:
3650: if ((arguments = malloc(nombre_arguments * sizeof(char *))) == NULL)
3651: {
3652: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
3653: return;
3654: }
3655:
3656: l_element_courant = (*s_etat_processus).l_base_pile;
3657: nombre_arguments--;
3658:
3659: for(i = nombre_arguments, arguments[i--] = NULL; i >= 0; i--)
3660: {
3661: arguments[i] = (char *) (*(*l_element_courant).donnee).objet;
3662: l_element_courant = (*l_element_courant).suivant;
3663: }
3664:
3665: action_courante.sa_handler = SIG_IGN;
3666: action_courante.sa_flags = SA_NODEFER | SA_ONSTACK;
3667:
3668: if (sigaction(SIGINT, &action_courante, &action_passee) != 0)
3669: {
3670: for(i = 0; i < nombre_arguments; i++)
3671: {
3672: depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3673: &s_objet_temporaire);
3674: liberation(s_etat_processus, s_objet_temporaire);
3675: }
3676:
3677: free(arguments);
3678: (*s_etat_processus).erreur_systeme = d_es_signal;
3679: return;
3680: }
3681:
3682: if (pipe(pipes_entree) != 0)
3683: {
3684: (*s_etat_processus).erreur_systeme = d_es_processus;
3685: return;
3686: }
3687:
3688: if (pipe(pipes_sortie) != 0)
3689: {
3690: (*s_etat_processus).erreur_systeme = d_es_processus;
3691: return;
3692: }
3693:
3694: if (pipe(pipes_erreur) != 0)
3695: {
3696: (*s_etat_processus).erreur_systeme = d_es_processus;
3697: return;
3698: }
3699:
3700: fflush(NULL);
3701:
3702: verrouillage_threads_concurrents(s_etat_processus);
3703: pid = fork();
3704: deverrouillage_threads_concurrents(s_etat_processus);
3705:
3706: if (pid < 0)
3707: {
3708: if (close(pipes_entree[0]) != 0)
3709: {
3710: (*s_etat_processus).erreur_systeme = d_es_processus;
3711: return;
3712: }
3713:
3714: if (close(pipes_entree[1]) != 0)
3715: {
3716: (*s_etat_processus).erreur_systeme = d_es_processus;
3717: return;
3718: }
3719:
3720: if (close(pipes_sortie[0]) != 0)
3721: {
3722: (*s_etat_processus).erreur_systeme = d_es_processus;
3723: return;
3724: }
3725:
3726: if (close(pipes_sortie[1]) != 0)
3727: {
3728: (*s_etat_processus).erreur_systeme = d_es_processus;
3729: return;
3730: }
3731:
3732: if (close(pipes_erreur[0]) != 0)
3733: {
3734: (*s_etat_processus).erreur_systeme = d_es_processus;
3735: return;
3736: }
3737:
3738: if (close(pipes_erreur[1]) != 0)
3739: {
3740: (*s_etat_processus).erreur_systeme = d_es_processus;
3741: return;
3742: }
3743:
3744: (*s_etat_processus).erreur_systeme = d_es_processus;
3745: return;
3746: }
3747: else if (pid == 0)
3748: {
3749: if (close(pipes_entree[1]) != 0)
3750: {
3751: (*s_etat_processus).erreur_systeme = d_es_processus;
3752: return;
3753: }
3754:
3755: if (close(pipes_sortie[0]) != 0)
3756: {
3757: (*s_etat_processus).erreur_systeme = d_es_processus;
3758: return;
3759: }
3760:
3761: if (close(pipes_erreur[0]) != 0)
3762: {
3763: (*s_etat_processus).erreur_systeme = d_es_processus;
3764: return;
3765: }
3766:
3767: if (pipes_entree[0] != STDIN_FILENO)
3768: {
3769: if (dup2(pipes_entree[0], STDIN_FILENO) == -1)
3770: {
3771: (*s_etat_processus).erreur_systeme = d_es_processus;
3772: return;
3773: }
3774: }
3775:
3776: if (pipes_sortie[1] != STDOUT_FILENO)
3777: {
3778: if (dup2(pipes_sortie[1], STDOUT_FILENO) == -1)
3779: {
3780: (*s_etat_processus).erreur_systeme = d_es_processus;
3781: return;
3782: }
3783: }
3784:
3785: if (pipes_sortie[1] != STDERR_FILENO)
3786: {
3787: if (dup2(pipes_sortie[1], STDERR_FILENO) == -1)
3788: {
3789: (*s_etat_processus).erreur_systeme = d_es_processus;
3790: return;
3791: }
3792: }
3793:
3794: if (nombre_arguments != 0)
3795: {
3796: execvp(arguments[0], arguments);
3797: }
3798: else
3799: {
3800: exit(EXIT_SUCCESS);
3801: }
3802:
3803: /*
3804: * L'appel système execvp() a généré une erreur et n'a pu exécuter
3805: * argument[0] (fichier non exécutable ou inexistant).
3806: */
3807:
3808: close(pipes_entree[0]);
3809: close(pipes_sortie[1]);
3810:
3811: for(i = 0; i < nombre_arguments; i++)
3812: {
3813: depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3814: &s_objet_temporaire);
3815: liberation(s_etat_processus, s_objet_temporaire);
3816: }
3817:
3818: free(arguments);
3819: (*s_etat_processus).erreur_systeme = d_es_processus;
3820:
3821: /*
3822: * Envoi d'une erreur dans le pipe idoine. On ne regarde pas
3823: * le nombre d'octets écrits car l'erreur ne pourra de toute
3824: * façon pas être traitée.
3825: */
3826:
3827: write_atomic(s_etat_processus, pipes_erreur[1], " ", 1);
3828: close(pipes_erreur[1]);
3829:
3830: exit(EXIT_SUCCESS);
3831: }
3832: else
3833: {
3834: if (close(pipes_entree[0]) != 0)
3835: {
3836: (*s_etat_processus).erreur_systeme = d_es_processus;
3837: return;
3838: }
3839:
3840: if (close(pipes_sortie[1]) != 0)
3841: {
3842: (*s_etat_processus).erreur_systeme = d_es_processus;
3843: return;
3844: }
3845:
3846: if (close(pipes_erreur[1]) != 0)
3847: {
3848: (*s_etat_processus).erreur_systeme = d_es_processus;
3849: return;
3850: }
3851:
3852: if (presence_stdin == d_vrai)
3853: {
3854: l_element_courant = l_element_stdin;
3855:
3856: while(l_element_courant != NULL)
3857: {
1.49 bertrand 3858: if ((ligne = formateur_flux(s_etat_processus,
3859: (unsigned char *) (*(*l_element_courant).donnee)
3860: .objet, &longueur_ecriture)) == NULL)
3861: {
3862: (*s_etat_processus).erreur_systeme =
3863: d_es_allocation_memoire;
3864: return;
3865: }
1.1 bertrand 3866:
1.41 bertrand 3867: # ifndef SEMAPHORES_NOMMES
3868: if (sem_post(&((*s_etat_processus).semaphore_fork))
3869: != 0)
3870: # else
3871: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
3872: # endif
1.1 bertrand 3873: {
3874: (*s_etat_processus).erreur_systeme = d_es_processus;
3875: return;
3876: }
3877:
3878: while(write_atomic(s_etat_processus,
1.49 bertrand 3879: pipes_entree[1], ligne,
1.1 bertrand 3880: longueur_ecriture) != longueur_ecriture)
3881: {
1.41 bertrand 3882: # ifndef SEMAPHORES_NOMMES
3883: while(sem_wait(&((*s_etat_processus)
3884: .semaphore_fork)) != 0)
3885: # else
3886: while(sem_wait((*s_etat_processus)
3887: .semaphore_fork) != 0)
3888: # endif
1.1 bertrand 3889: {
1.37 bertrand 3890: (*s_etat_processus).erreur_systeme =
3891: d_es_processus;
3892: return;
1.1 bertrand 3893: }
3894:
3895: if (longueur_ecriture == -1)
3896: {
3897: (*s_etat_processus).erreur_systeme = d_es_processus;
3898: return;
3899: }
3900:
1.41 bertrand 3901: # ifndef SEMAPHORES_NOMMES
3902: if (sem_post(&((*s_etat_processus)
3903: .semaphore_fork)) != 0)
3904: # else
3905: if (sem_post((*s_etat_processus)
3906: .semaphore_fork) != 0)
3907: # endif
1.1 bertrand 3908: {
3909: (*s_etat_processus).erreur_systeme = d_es_processus;
3910: return;
3911: }
3912: }
3913:
1.49 bertrand 3914: free(ligne);
3915:
1.1 bertrand 3916: while(write_atomic(s_etat_processus,
3917: pipes_entree[1], "\n", 1) != 1)
3918: {
1.41 bertrand 3919: # ifndef SEMAPHORES_NOMMES
3920: while(sem_wait(&((*s_etat_processus)
3921: .semaphore_fork)) != 0)
3922: # else
3923: while(sem_wait((*s_etat_processus)
3924: .semaphore_fork) != 0)
3925: # endif
1.1 bertrand 3926: {
1.40 bertrand 3927: if (errno != EINTR)
3928: {
3929: (*s_etat_processus).erreur_systeme =
3930: d_es_processus;
3931: return;
3932: }
1.1 bertrand 3933: }
3934:
3935: if (longueur_ecriture == -1)
3936: {
3937: (*s_etat_processus).erreur_systeme = d_es_processus;
3938: return;
3939: }
3940:
1.41 bertrand 3941: # ifndef SEMAPHORES_NOMMES
3942: if (sem_post(&((*s_etat_processus)
3943: .semaphore_fork)) != 0)
3944: # else
3945: if (sem_post((*s_etat_processus)
3946: .semaphore_fork) != 0)
3947: # endif
1.1 bertrand 3948: {
3949: (*s_etat_processus).erreur_systeme = d_es_processus;
3950: return;
3951: }
3952: }
3953:
1.41 bertrand 3954: # ifndef SEMAPHORES_NOMMES
3955: while(sem_wait(&((*s_etat_processus).semaphore_fork))
3956: != 0)
3957: # else
3958: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
3959: # endif
1.1 bertrand 3960: {
1.40 bertrand 3961: if (errno != EINTR)
3962: {
3963: (*s_etat_processus).erreur_systeme = d_es_processus;
3964: return;
3965: }
1.1 bertrand 3966: }
3967:
3968: l_element_courant = (*l_element_courant).suivant;
3969: }
3970: }
3971:
3972: if (close(pipes_entree[1]) != 0)
3973: {
3974: (*s_etat_processus).erreur_systeme = d_es_processus;
3975: return;
3976: }
3977:
3978: do
3979: {
3980: if (kill(pid, 0) != 0)
3981: {
3982: break;
3983: }
3984:
3985: /*
3986: * Récupération de la valeur de retour du processus détaché
3987: */
3988:
1.41 bertrand 3989: # ifndef SEMAPHORES_NOMMES
3990: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
3991: # else
3992: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
3993: # endif
1.1 bertrand 3994: {
3995: (*s_etat_processus).erreur_systeme = d_es_processus;
3996: return;
3997: }
3998:
3999: if (waitpid(pid, &status, 0) == -1)
4000: {
1.41 bertrand 4001: # ifndef SEMAPHORES_NOMMES
4002: if (sem_post(&((*s_etat_processus).semaphore_fork))
4003: != 0)
4004: # else
4005: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
4006: # endif
1.1 bertrand 4007: {
1.37 bertrand 4008: (*s_etat_processus).erreur_systeme = d_es_processus;
4009: return;
1.1 bertrand 4010: }
4011:
4012: (*s_etat_processus).erreur_systeme = d_es_processus;
4013: return;
4014: }
4015:
1.41 bertrand 4016: # ifndef SEMAPHORES_NOMMES
4017: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
4018: # else
4019: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
4020: # endif
1.1 bertrand 4021: {
1.40 bertrand 4022: if (errno != EINTR)
4023: {
4024: (*s_etat_processus).erreur_systeme = d_es_processus;
4025: return;
4026: }
1.1 bertrand 4027: }
4028: } while((!WIFEXITED(status)) && (!WIFSIGNALED(status)));
4029:
4030: longueur_lecture = 256;
4031: pointeur = 0;
4032: nombre_iterations = 1;
4033:
4034: if ((tampon = malloc((longueur_lecture + 1) *
4035: sizeof(unsigned char))) == NULL)
4036: {
4037: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4038: return;
4039: }
4040:
1.49 bertrand 4041: tampon[0] = d_code_fin_chaine;
4042:
1.41 bertrand 4043: # ifndef SEMAPHORES_NOMMES
4044: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
4045: # else
4046: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
4047: # endif
1.8 bertrand 4048: {
4049: (*s_etat_processus).erreur_systeme = d_es_processus;
4050: return;
4051: }
1.1 bertrand 4052:
4053: while((ios = read_atomic(s_etat_processus,
4054: pipes_sortie[0], &(tampon[pointeur]),
4055: longueur_lecture)) > 0)
4056: {
1.41 bertrand 4057: # ifndef SEMAPHORES_NOMMES
4058: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
4059: # else
4060: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
4061: # endif
1.1 bertrand 4062: {
1.37 bertrand 4063: (*s_etat_processus).erreur_systeme = d_es_processus;
4064: return;
1.1 bertrand 4065: }
4066:
4067: tampon[pointeur + ios] = d_code_fin_chaine;
4068: pointeur += longueur_lecture;
4069: nombre_iterations++;
4070:
4071: if ((tampon = realloc(tampon,
4072: ((nombre_iterations * longueur_lecture) + 1) *
4073: sizeof(unsigned char))) == NULL)
4074: {
4075: (*s_etat_processus).erreur_systeme =
4076: d_es_allocation_memoire;
4077: return;
4078: }
4079:
1.41 bertrand 4080: # ifndef SEMAPHORES_NOMMES
4081: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
4082: # else
4083: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
4084: # endif
1.1 bertrand 4085: {
4086: (*s_etat_processus).erreur_systeme = d_es_processus;
4087: return;
4088: }
4089: }
4090:
1.41 bertrand 4091: # ifndef SEMAPHORES_NOMMES
4092: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
4093: # else
4094: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
4095: # endif
1.1 bertrand 4096: {
1.40 bertrand 4097: if (errno != EINTR)
4098: {
4099: (*s_etat_processus).erreur_systeme = d_es_processus;
4100: return;
4101: }
1.1 bertrand 4102: }
4103:
4104: if (ios == -1)
4105: {
4106: (*s_etat_processus).erreur_systeme = d_es_processus;
4107: return;
4108: }
4109:
4110: if (close(pipes_sortie[0]) != 0)
4111: {
4112: (*s_etat_processus).erreur_systeme = d_es_processus;
4113: return;
4114: }
4115:
4116: /*
4117: * Transformation de la chaîne en liste
4118: */
4119:
1.50 bertrand 4120: longueur_tampon = strlen(tampon);
1.1 bertrand 4121:
4122: for(i = 0, ptr = tampon, nombre_lignes = 0;
4123: i < (long) longueur_tampon; i++, ptr++)
4124: {
4125: if ((*ptr) == d_code_retour_chariot)
4126: {
4127: nombre_lignes++;
4128: (*ptr) = d_code_fin_chaine;
4129: }
4130: }
4131:
4132: if ((s_objet_resultat = allocation(s_etat_processus, LST))
4133: == NULL)
4134: {
4135: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4136: return;
4137: }
4138:
4139: if (nombre_lignes == 0)
4140: {
4141: (*s_objet_resultat).objet = NULL;
4142: }
4143: else
4144: {
4145: if (((*s_objet_resultat).objet =
4146: allocation_maillon(s_etat_processus)) == NULL)
4147: {
4148: (*s_etat_processus).erreur_systeme =
4149: d_es_allocation_memoire;
4150: return;
4151: }
4152:
4153: l_element_precedent = NULL;
4154: l_element_courant = (struct_liste_chainee *)
4155: (*s_objet_resultat).objet;
4156:
4157: for(i = 0, ptr = tampon; i < (long) nombre_lignes; i++)
4158: {
4159: if (((*l_element_courant).donnee =
4160: allocation(s_etat_processus, CHN)) == NULL)
4161: {
4162: (*s_etat_processus).erreur_systeme =
4163: d_es_allocation_memoire;
4164: return;
4165: }
4166:
4167: if (((*(*l_element_courant).donnee).objet =
1.50 bertrand 4168: analyse_flux(s_etat_processus, ptr,
1.51 ! bertrand 4169: strlen(ptr))) == NULL)
1.1 bertrand 4170: {
4171: (*s_etat_processus).erreur_systeme =
4172: d_es_allocation_memoire;
4173: return;
4174: }
4175:
4176: while((*ptr) != d_code_fin_chaine)
4177: {
4178: ptr++;
4179: }
4180:
4181: ptr++;
4182:
4183: if (((*l_element_courant).suivant =
4184: allocation_maillon(s_etat_processus)) == NULL)
4185: {
4186: (*s_etat_processus).erreur_systeme =
4187: d_es_allocation_memoire;
4188: return;
4189: }
4190:
4191: l_element_precedent = l_element_courant;
4192: l_element_courant = (*l_element_courant).suivant;
4193: }
4194:
4195: free(l_element_courant);
4196:
4197: if (l_element_precedent != NULL)
4198: {
4199: (*l_element_precedent).suivant = NULL;
4200: }
4201: }
4202:
4203: free(tampon);
4204: }
4205:
4206: if (sigaction(SIGINT, &action_passee, NULL) != 0)
4207: {
4208: for(i = 0; i < nombre_arguments; i++)
4209: {
4210: depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4211: &s_objet_temporaire);
4212: liberation(s_etat_processus, s_objet_temporaire);
4213: }
4214:
4215: free(arguments);
4216: (*s_etat_processus).erreur_systeme = d_es_signal;
4217: return;
4218: }
4219:
4220: for(i = 0; i < nombre_arguments; i++)
4221: {
4222: depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4223: &s_objet_temporaire);
4224: liberation(s_etat_processus, s_objet_temporaire);
4225: }
4226:
4227: if ((tampon = malloc(sizeof(unsigned char))) == NULL)
4228: {
4229: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4230: return;
4231: }
4232:
1.41 bertrand 4233: # ifndef SEMAPHORES_NOMMES
4234: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
4235: # else
4236: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
4237: # endif
1.1 bertrand 4238: {
4239: (*s_etat_processus).erreur_systeme = d_es_processus;
4240: return;
4241: }
4242:
4243: if (read_atomic(s_etat_processus, pipes_erreur[0], tampon, 1) > 0)
4244: {
4245: // Le processus fils renvoie une erreur.
4246:
4247: (*s_etat_processus).erreur_execution = d_ex_erreur_processus;
4248: liberation(s_etat_processus, s_objet_resultat);
4249: }
4250: else if (empilement(s_etat_processus,
4251: &((*s_etat_processus).l_base_pile), s_objet_resultat)
4252: == d_erreur)
4253: {
1.41 bertrand 4254: # ifndef SEMAPHORES_NOMMES
4255: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
4256: # else
4257: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
4258: # endif
1.1 bertrand 4259: {
1.40 bertrand 4260: if (errno != EINTR)
4261: {
4262: (*s_etat_processus).erreur_systeme = d_es_processus;
4263: return;
4264: }
1.1 bertrand 4265: }
4266:
4267: if (close(pipes_erreur[0]) != 0)
4268: {
4269: (*s_etat_processus).erreur_systeme = d_es_processus;
4270: return;
4271: }
4272:
4273: free(tampon);
4274: return;
4275: }
4276:
1.41 bertrand 4277: # ifndef SEMAPHORES_NOMMES
4278: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
4279: # else
4280: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
4281: # endif
1.1 bertrand 4282: {
1.40 bertrand 4283: if (errno != EINTR)
4284: {
4285: (*s_etat_processus).erreur_systeme = d_es_processus;
4286: return;
4287: }
1.1 bertrand 4288: }
4289:
4290: if (close(pipes_erreur[0]) != 0)
4291: {
4292: (*s_etat_processus).erreur_systeme = d_es_processus;
4293: return;
4294: }
4295:
4296: free(arguments);
4297: free(tampon);
4298: }
4299: else
4300: {
4301: if (presence_stdin == d_vrai)
4302: {
4303: s_objet = s_objet_composite;
4304: }
4305:
4306: liberation(s_etat_processus, s_objet);
4307:
4308: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
4309: return;
4310: }
4311:
4312: if (presence_stdin == d_vrai)
4313: {
4314: s_objet = s_objet_composite;
4315: }
4316:
4317: liberation(s_etat_processus, s_objet);
4318:
4319: return;
4320: }
4321:
4322:
4323: /*
4324: ================================================================================
4325: Fonction 'sign'
4326: ================================================================================
4327: Entrées :
4328: --------------------------------------------------------------------------------
4329: Sorties :
4330: --------------------------------------------------------------------------------
4331: Effets de bord : néant
4332: ================================================================================
4333: */
4334:
4335: void
4336: instruction_sign(struct_processus *s_etat_processus)
4337: {
4338: real8 norme;
4339:
4340: struct_liste_chainee *l_element_courant;
4341: struct_liste_chainee *l_element_precedent;
4342:
4343: struct_objet *s_copie_argument;
4344: struct_objet *s_objet_argument;
4345: struct_objet *s_objet_resultat;
4346:
4347: (*s_etat_processus).erreur_execution = d_ex;
4348:
4349: if ((*s_etat_processus).affichage_arguments == 'Y')
4350: {
4351: printf("\n SIGN ");
4352:
4353: if ((*s_etat_processus).langue == 'F')
4354: {
4355: printf("(signe)\n\n");
4356: }
4357: else
4358: {
4359: printf("(sign)\n\n");
4360: }
4361:
4362: printf(" 1: %s, %s\n", d_INT, d_REL);
4363: printf("-> 1: %s\n\n", d_INT);
4364:
4365: printf(" 1: %s\n", d_CPL);
4366: printf("-> 1: %s\n\n", d_CPL);
4367:
4368: printf(" 1: %s, %s\n", d_NOM, d_ALG);
4369: printf("-> 1: %s\n\n", d_ALG);
4370:
4371: printf(" 1: %s\n", d_RPN);
4372: printf("-> 1: %s\n", d_RPN);
4373:
4374: return;
4375: }
4376: else if ((*s_etat_processus).test_instruction == 'Y')
4377: {
4378: (*s_etat_processus).nombre_arguments = 1;
4379: return;
4380: }
4381:
4382: if (test_cfsf(s_etat_processus, 31) == d_vrai)
4383: {
4384: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
4385: {
4386: return;
4387: }
4388: }
4389:
4390: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4391: &s_objet_argument) == d_erreur)
4392: {
4393: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
4394: return;
4395: }
4396:
4397: /*
4398: --------------------------------------------------------------------------------
4399: Signe d'un entier
4400: --------------------------------------------------------------------------------
4401: */
4402:
4403: if ((*s_objet_argument).type == INT)
4404: {
4405: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
4406: {
4407: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4408: return;
4409: }
4410:
4411: if ((*((integer8 *) (*s_objet_argument).objet)) > 0)
4412: {
4413: (*((integer8 *) (*s_objet_resultat).objet)) = 1;
4414: }
4415: else if ((*((integer8 *) (*s_objet_argument).objet)) < 0)
4416: {
4417: (*((integer8 *) (*s_objet_resultat).objet)) = -1;
4418: }
4419: else
4420: {
4421: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
4422: }
4423: }
4424:
4425: /*
4426: --------------------------------------------------------------------------------
4427: Signe d'un réel
4428: --------------------------------------------------------------------------------
4429: */
4430:
4431: else if ((*s_objet_argument).type == REL)
4432: {
4433: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
4434: {
4435: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4436: return;
4437: }
4438:
4439: if ((*((real8 *) (*s_objet_argument).objet)) > 0)
4440: {
4441: (*((integer8 *) (*s_objet_resultat).objet)) = 1;
4442: }
4443: else if ((*((real8 *) (*s_objet_argument).objet)) < 0)
4444: {
4445: (*((integer8 *) (*s_objet_resultat).objet)) = -1;
4446: }
4447: else
4448: {
4449: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
4450: }
4451: }
4452:
4453: /*
4454: --------------------------------------------------------------------------------
4455: Vecteur unité dans la direction du complexe
4456: --------------------------------------------------------------------------------
4457: */
4458:
4459: else if ((*s_objet_argument).type == CPL)
4460: {
4461: if ((s_objet_resultat = allocation(s_etat_processus, CPL)) == NULL)
4462: {
4463: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4464: return;
4465: }
4466:
1.4 bertrand 4467: if (((*((struct_complexe16 *) (*s_objet_argument).objet)).partie_reelle
4468: != 0) || ((*((struct_complexe16 *) (*s_objet_argument).objet))
4469: .partie_imaginaire != 0))
4470: {
4471: f77absc_((struct_complexe16 *) (*s_objet_argument).objet, &norme);
4472: f77divisioncr_((struct_complexe16 *) (*s_objet_argument).objet,
4473: &norme, (struct_complexe16 *) (*s_objet_resultat).objet);
4474: }
4475: else
4476: {
4477: (*((struct_complexe16 *) (*s_objet_argument).objet))
4478: .partie_reelle = 0;
4479: (*((struct_complexe16 *) (*s_objet_argument).objet))
4480: .partie_imaginaire = 0;
4481: }
1.1 bertrand 4482: }
4483:
4484: /*
4485: --------------------------------------------------------------------------------
4486: Signe d'un nom
4487: --------------------------------------------------------------------------------
4488: */
4489:
4490: else if ((*s_objet_argument).type == NOM)
4491: {
4492: if ((s_objet_resultat = allocation(s_etat_processus, ALG)) == NULL)
4493: {
4494: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4495: return;
4496: }
4497:
4498: if (((*s_objet_resultat).objet =
4499: allocation_maillon(s_etat_processus)) == NULL)
4500: {
4501: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4502: return;
4503: }
4504:
4505: l_element_courant = (*s_objet_resultat).objet;
4506:
4507: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
4508: == NULL)
4509: {
4510: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4511: return;
4512: }
4513:
4514: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4515: .nombre_arguments = 0;
4516: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4517: .fonction = instruction_vers_niveau_superieur;
4518:
4519: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4520: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
4521: {
4522: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4523: return;
4524: }
4525:
4526: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4527: .nom_fonction, "<<");
4528:
4529: if (((*l_element_courant).suivant =
4530: allocation_maillon(s_etat_processus)) == NULL)
4531: {
4532: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4533: return;
4534: }
4535:
4536: l_element_courant = (*l_element_courant).suivant;
4537: (*l_element_courant).donnee = s_objet_argument;
4538:
4539: if (((*l_element_courant).suivant =
4540: allocation_maillon(s_etat_processus)) == NULL)
4541: {
4542: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4543: return;
4544: }
4545:
4546: l_element_courant = (*l_element_courant).suivant;
4547:
4548: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
4549: == NULL)
4550: {
4551: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4552: return;
4553: }
4554:
4555: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4556: .nombre_arguments = 1;
4557: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4558: .fonction = instruction_sign;
4559:
4560: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4561: .nom_fonction = malloc(5 * sizeof(unsigned char))) == NULL)
4562: {
4563: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4564: return;
4565: }
4566:
4567: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4568: .nom_fonction, "SIGN");
4569:
4570: if (((*l_element_courant).suivant =
4571: allocation_maillon(s_etat_processus)) == NULL)
4572: {
4573: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4574: return;
4575: }
4576:
4577: l_element_courant = (*l_element_courant).suivant;
4578:
4579: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
4580: == NULL)
4581: {
4582: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4583: return;
4584: }
4585:
4586: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4587: .nombre_arguments = 0;
4588: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4589: .fonction = instruction_vers_niveau_inferieur;
4590:
4591: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4592: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
4593: {
4594: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4595: return;
4596: }
4597:
4598: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
4599: .nom_fonction, ">>");
4600:
4601: (*l_element_courant).suivant = NULL;
4602: s_objet_argument = NULL;
4603: }
4604:
4605: /*
4606: --------------------------------------------------------------------------------
4607: Signe d'une expression
4608: --------------------------------------------------------------------------------
4609: */
4610:
4611: else if (((*s_objet_argument).type == ALG) ||
4612: ((*s_objet_argument).type == RPN))
4613: {
4614: if ((s_copie_argument = copie_objet(s_etat_processus, s_objet_argument,
4615: 'N')) == NULL)
4616: {
4617: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4618: return;
4619: }
4620:
4621: l_element_courant = (struct_liste_chainee *)
4622: (*s_copie_argument).objet;
4623: l_element_precedent = l_element_courant;
4624:
4625: while((*l_element_courant).suivant != NULL)
4626: {
4627: l_element_precedent = l_element_courant;
4628: l_element_courant = (*l_element_courant).suivant;
4629: }
4630:
4631: if (((*l_element_precedent).suivant =
4632: allocation_maillon(s_etat_processus)) == NULL)
4633: {
4634: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4635: return;
4636: }
4637:
4638: if (((*(*l_element_precedent).suivant).donnee =
4639: allocation(s_etat_processus, FCT)) == NULL)
4640: {
4641: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4642: return;
4643: }
4644:
4645: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
4646: .donnee).objet)).nombre_arguments = 1;
4647: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
4648: .donnee).objet)).fonction = instruction_sign;
4649:
4650: if (((*((struct_fonction *) (*(*(*l_element_precedent)
4651: .suivant).donnee).objet)).nom_fonction =
4652: malloc(5 * sizeof(unsigned char))) == NULL)
4653: {
4654: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4655: return;
4656: }
4657:
4658: strcpy((*((struct_fonction *) (*(*(*l_element_precedent)
4659: .suivant).donnee).objet)).nom_fonction, "SIGN");
4660:
4661: (*(*l_element_precedent).suivant).suivant = l_element_courant;
4662:
4663: s_objet_resultat = s_copie_argument;
4664: }
4665:
4666: /*
4667: --------------------------------------------------------------------------------
4668: Fonction signe impossible à réaliser
4669: --------------------------------------------------------------------------------
4670: */
4671:
4672: else
4673: {
4674: liberation(s_etat_processus, s_objet_argument);
4675:
4676: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
4677: return;
4678: }
4679:
4680: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4681: s_objet_resultat) == d_erreur)
4682: {
4683: return;
4684: }
4685:
4686: liberation(s_etat_processus, s_objet_argument);
4687:
4688: return;
4689: }
4690:
4691:
4692: /*
4693: ================================================================================
4694: Fonction 'select'
4695: ================================================================================
4696: Entrées : pointeur sur une struct_processus
4697: --------------------------------------------------------------------------------
4698: Sorties :
4699: --------------------------------------------------------------------------------
4700: Effets de bord : néant
4701: ================================================================================
4702: */
4703:
4704: void
4705: instruction_select(struct_processus *s_etat_processus)
4706: {
4707: (*s_etat_processus).erreur_execution = d_ex;
4708:
4709: if ((*s_etat_processus).affichage_arguments == 'Y')
4710: {
4711: printf("\n SELECT ");
4712:
4713: if ((*s_etat_processus).langue == 'F')
4714: {
4715: printf("(structure de contrôle)\n\n");
4716: printf(" Utilisation :\n\n");
4717: }
4718: else
4719: {
4720: printf("(control statement)\n\n");
4721: printf(" Usage:\n\n");
4722: }
4723:
4724: printf(" SELECT (expression test)\n");
4725: printf(" CASE (clause 1) THEN (expression 1) END\n");
4726: printf(" CASE (clause 2) THEN (expression 2) END\n");
4727: printf(" ...\n");
4728: printf(" CASE (clause n) THEN (expression n) END\n");
4729: printf(" DEFAULT\n");
4730: printf(" (expression)\n");
4731: printf(" END\n\n");
4732:
4733: printf(" SELECT (expression test)\n");
4734: printf(" CASE (clause 1) THEN (expression 1) END\n");
4735: printf(" (expression)\n");
4736: printf(" CASE (clause 2) THEN (expression 2) END\n");
4737: printf(" END\n");
4738:
4739: return;
4740: }
4741: else if ((*s_etat_processus).test_instruction == 'Y')
4742: {
4743: (*s_etat_processus).nombre_arguments = -1;
4744: return;
4745: }
4746:
4747: empilement_pile_systeme(s_etat_processus);
4748:
4749: if ((*s_etat_processus).erreur_systeme != d_es)
4750: {
4751: return;
4752: }
4753:
4754: (*(*s_etat_processus).l_base_pile_systeme).type_cloture = 'C';
4755: (*(*s_etat_processus).l_base_pile_systeme).clause = 'S';
4756:
4757: return;
4758: }
4759:
4760:
4761: /*
4762: ================================================================================
4763: Fonction 'std'
4764: ================================================================================
4765: Entrées : pointeur sur une struct_processus
4766: --------------------------------------------------------------------------------
4767: Sorties :
4768: --------------------------------------------------------------------------------
4769: Effets de bord : néant
4770: ================================================================================
4771: */
4772:
4773: void
4774: instruction_std(struct_processus *s_etat_processus)
4775: {
4776: (*s_etat_processus).erreur_execution = d_ex;
4777:
4778: if ((*s_etat_processus).affichage_arguments == 'Y')
4779: {
4780: printf("\n STD ");
4781:
4782: if ((*s_etat_processus).langue == 'F')
4783: {
4784: printf("(format standard)\n\n");
4785: printf(" Aucun argument\n");
4786: }
4787: else
4788: {
4789: printf("(standard format)\n\n");
4790: printf(" No argument\n");
4791: }
4792:
4793: return;
4794: }
4795: else if ((*s_etat_processus).test_instruction == 'Y')
4796: {
4797: (*s_etat_processus).nombre_arguments = -1;
4798: return;
4799: }
4800:
4801: if (test_cfsf(s_etat_processus, 31) == d_vrai)
4802: {
4803: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
4804: {
4805: return;
4806: }
4807: }
4808:
4809: cf(s_etat_processus, 49);
4810: cf(s_etat_processus, 50);
4811:
4812: return;
4813: }
4814:
4815:
4816: /*
4817: ================================================================================
4818: Fonction 'sci'
4819: ================================================================================
4820: Entrées : pointeur sur une struct_processus
4821: --------------------------------------------------------------------------------
4822: Sorties :
4823: --------------------------------------------------------------------------------
4824: Effets de bord : néant
4825: ================================================================================
4826: */
4827:
4828: void
4829: instruction_sci(struct_processus *s_etat_processus)
4830: {
4831: struct_objet *s_objet_argument;
4832: struct_objet *s_objet;
4833:
4834: logical1 i43;
4835: logical1 i44;
4836:
4837: unsigned char *valeur_binaire;
4838:
4839: unsigned long i;
4840: unsigned long j;
4841:
4842: (*s_etat_processus).erreur_execution = d_ex;
4843:
4844: if ((*s_etat_processus).affichage_arguments == 'Y')
4845: {
4846: printf("\n SCI ");
4847:
4848: if ((*s_etat_processus).langue == 'F')
4849: {
4850: printf("(format scientifique)\n\n");
4851: }
4852: else
4853: {
4854: printf("(scientific format)\n\n");
4855: }
4856:
4857: printf(" 1: %s\n", d_INT);
4858:
4859: return;
4860: }
4861: else if ((*s_etat_processus).test_instruction == 'Y')
4862: {
4863: (*s_etat_processus).nombre_arguments = -1;
4864: return;
4865: }
4866:
4867: if (test_cfsf(s_etat_processus, 31) == d_vrai)
4868: {
4869: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
4870: {
4871: return;
4872: }
4873: }
4874:
4875: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4876: &s_objet_argument) == d_erreur)
4877: {
4878: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
4879: return;
4880: }
4881:
4882: if ((*s_objet_argument).type == INT)
4883: {
4884: if (((*((integer8 *) (*s_objet_argument).objet)) >= 0) &&
4885: ((*((integer8 *) (*s_objet_argument).objet)) <= 15))
4886: {
4887: if ((s_objet = allocation(s_etat_processus, BIN)) == NULL)
4888: {
4889: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4890: return;
4891: }
4892:
4893: (*((logical8 *) (*s_objet).objet)) =
4894: (*((integer8 *) (*s_objet_argument).objet));
4895:
4896: i43 = test_cfsf(s_etat_processus, 43);
4897: i44 = test_cfsf(s_etat_processus, 44);
4898:
4899: sf(s_etat_processus, 44);
4900: cf(s_etat_processus, 43);
4901:
4902: if ((valeur_binaire = formateur(s_etat_processus, 0, s_objet))
4903: == NULL)
4904: {
4905: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4906: return;
4907: }
4908:
4909: if (i43 == d_vrai)
4910: {
4911: sf(s_etat_processus, 43);
4912: }
4913: else
4914: {
4915: cf(s_etat_processus, 43);
4916: }
4917:
4918: if (i44 == d_vrai)
4919: {
4920: sf(s_etat_processus, 44);
4921: }
4922: else
4923: {
4924: cf(s_etat_processus, 44);
4925: }
4926:
4927: for(j = 53, i = strlen(valeur_binaire) - 2; i >= 2; i--)
4928: {
4929: if (valeur_binaire[i] == '0')
4930: {
4931: cf(s_etat_processus, j++);
4932: }
4933: else
4934: {
4935: sf(s_etat_processus, j++);
4936: }
4937: }
4938:
4939: for(; j <= 56; cf(s_etat_processus, j++));
4940:
4941: cf(s_etat_processus, 49);
4942: sf(s_etat_processus, 50);
4943:
4944: free(valeur_binaire);
4945: liberation(s_etat_processus, s_objet);
4946: }
4947: else
4948: {
4949: liberation(s_etat_processus, s_objet_argument);
4950:
4951: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
4952: return;
4953: }
4954: }
4955: else
4956: {
4957: liberation(s_etat_processus, s_objet_argument);
4958:
4959: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
4960: return;
4961: }
4962:
4963: liberation(s_etat_processus, s_objet_argument);
4964:
4965: return;
4966: }
4967:
4968: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>