![]() ![]() | ![]() |
1.1 bertrand 1: /*
2: ================================================================================
1.48 ! bertrand 3: RPL/2 (R) version 4.1.13
1.47 bertrand 4: Copyright (C) 1989-2013 Dr. BERTRAND Joël
1.1 bertrand 5:
6: This file is part of RPL/2.
7:
8: RPL/2 is free software; you can redistribute it and/or modify it
9: under the terms of the CeCILL V2 License as published by the french
10: CEA, CNRS and INRIA.
11:
12: RPL/2 is distributed in the hope that it will be useful, but WITHOUT
13: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14: FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License
15: for more details.
16:
17: You should have received a copy of the CeCILL License
18: along with RPL/2. If not, write to info@cecill.info.
19: ================================================================================
20: */
21:
22:
1.13 bertrand 23: #include "rpl-conv.h"
1.1 bertrand 24:
25:
26: /*
27: ================================================================================
28: Fonction 'r->d'
29: ================================================================================
30: Entrées : pointeur sur une structure struct_processus
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_r_vers_d(struct_processus *s_etat_processus)
40: {
41: struct_liste_chainee *l_element_courant;
42: struct_liste_chainee *l_element_precedent;
43:
44: struct_objet *s_copie_argument;
45: struct_objet *s_objet_argument;
46: struct_objet *s_objet_resultat;
47:
48: if ((*s_etat_processus).affichage_arguments == 'Y')
49: {
50: printf("\n R->D ");
51:
52: if ((*s_etat_processus).langue == 'F')
53: {
54: printf("(radians vers degrés)\n\n");
55: }
56: else
57: {
58: printf("(radians to degrees)\n\n");
59: }
60:
61: printf(" 1: %s, %s\n", d_INT, d_REL);
62: printf("-> 1: %s\n\n", d_REL);
63:
64: printf(" 1: %s, %s\n", d_NOM, d_ALG);
65: printf("-> 1: %s\n\n", d_ALG);
66:
67: printf(" 1: %s\n", d_RPN);
68: printf("-> 1: %s\n", d_RPN);
69:
70: return;
71: }
72: else if ((*s_etat_processus).test_instruction == 'Y')
73: {
74: (*s_etat_processus).nombre_arguments = -1;
75: return;
76: }
77:
78: if (test_cfsf(s_etat_processus, 31) == d_vrai)
79: {
80: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
81: {
82: return;
83: }
84: }
85:
86: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
87: &s_objet_argument) == d_erreur)
88: {
89: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
90: return;
91: }
92:
93: /*
94: --------------------------------------------------------------------------------
95: Conversion d'un entier ou d'un réel
96: --------------------------------------------------------------------------------
97: */
98:
99: if (((*s_objet_argument).type == INT) ||
100: ((*s_objet_argument).type == REL))
101: {
102: if ((s_objet_resultat = allocation(s_etat_processus, REL)) == NULL)
103: {
104: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
105: return;
106: }
107:
108: if ((*s_objet_argument).type == INT)
109: {
110: (*((real8 *) (*s_objet_resultat).objet)) =
111: (real8) (*((integer8 *) (*s_objet_argument).objet));
112: }
113: else
114: {
115: (*((real8 *) (*s_objet_resultat).objet)) =
116: (*((real8 *) (*s_objet_argument).objet));
117: }
118:
119: conversion_radians_vers_degres((real8 *) (*s_objet_resultat).objet);
120: }
121:
122: /*
123: --------------------------------------------------------------------------------
124: Conversion d'un nom
125: --------------------------------------------------------------------------------
126: */
127:
128: else if ((*s_objet_argument).type == NOM)
129: {
130: if ((s_objet_resultat = allocation(s_etat_processus, ALG)) == NULL)
131: {
132: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
133: return;
134: }
135:
136: if (((*s_objet_resultat).objet =
137: allocation_maillon(s_etat_processus)) == NULL)
138: {
139: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
140: return;
141: }
142:
143: l_element_courant = (*s_objet_resultat).objet;
144:
145: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
146: == NULL)
147: {
148: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
149: return;
150: }
151:
152: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
153: .nombre_arguments = 0;
154: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
155: .fonction = instruction_vers_niveau_superieur;
156:
157: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
158: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
159: {
160: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
161: return;
162: }
163:
164: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
165: .nom_fonction, "<<");
166:
167: if (((*l_element_courant).suivant =
168: allocation_maillon(s_etat_processus)) == NULL)
169: {
170: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
171: return;
172: }
173:
174: l_element_courant = (*l_element_courant).suivant;
175: (*l_element_courant).donnee = s_objet_argument;
176:
177: if (((*l_element_courant).suivant =
178: allocation_maillon(s_etat_processus)) == NULL)
179: {
180: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
181: return;
182: }
183:
184: l_element_courant = (*l_element_courant).suivant;
185:
186: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
187: == NULL)
188: {
189: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
190: return;
191: }
192:
193: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
194: .nombre_arguments = 1;
195: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
196: .fonction = instruction_r_vers_d;
197:
198: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
199: .nom_fonction = malloc(5 * sizeof(unsigned char))) == NULL)
200: {
201: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
202: return;
203: }
204:
205: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
206: .nom_fonction, "R->D");
207:
208: if (((*l_element_courant).suivant =
209: allocation_maillon(s_etat_processus)) == NULL)
210: {
211: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
212: return;
213: }
214:
215: l_element_courant = (*l_element_courant).suivant;
216:
217: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
218: == NULL)
219: {
220: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
221: return;
222: }
223:
224: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
225: .nombre_arguments = 0;
226: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
227: .fonction = instruction_vers_niveau_inferieur;
228:
229: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
230: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
231: {
232: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
233: return;
234: }
235:
236: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
237: .nom_fonction, ">>");
238:
239: (*l_element_courant).suivant = NULL;
240: s_objet_argument = NULL;
241: }
242:
243: /*
244: --------------------------------------------------------------------------------
245: Conversion d'une expression
246: --------------------------------------------------------------------------------
247: */
248:
249: else if (((*s_objet_argument).type == ALG) ||
250: ((*s_objet_argument).type == RPN))
251: {
252: if ((s_copie_argument = copie_objet(s_etat_processus,
253: s_objet_argument, 'N')) == NULL)
254: {
255: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
256: return;
257: }
258:
259: l_element_courant = (struct_liste_chainee *)
260: (*s_copie_argument).objet;
261: l_element_precedent = l_element_courant;
262:
263: while((*l_element_courant).suivant != NULL)
264: {
265: l_element_precedent = l_element_courant;
266: l_element_courant = (*l_element_courant).suivant;
267: }
268:
269: if (((*l_element_precedent).suivant =
270: allocation_maillon(s_etat_processus)) == NULL)
271: {
272: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
273: return;
274: }
275:
276: if (((*(*l_element_precedent).suivant).donnee =
277: allocation(s_etat_processus, FCT)) == NULL)
278: {
279: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
280: return;
281: }
282:
283: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
284: .donnee).objet)).nombre_arguments = 1;
285: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
286: .donnee).objet)).fonction = instruction_r_vers_d;
287:
288: if (((*((struct_fonction *) (*(*(*l_element_precedent)
289: .suivant).donnee).objet)).nom_fonction =
290: malloc(5 * sizeof(unsigned char))) == NULL)
291: {
292: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
293: return;
294: }
295:
296: strcpy((*((struct_fonction *) (*(*(*l_element_precedent)
297: .suivant).donnee).objet)).nom_fonction, "R->D");
298:
299: (*(*l_element_precedent).suivant).suivant = l_element_courant;
300:
301: s_objet_resultat = s_copie_argument;
302: }
303:
304: /*
305: --------------------------------------------------------------------------------
306: Réalisation impossible de la fonction R->D
307: --------------------------------------------------------------------------------
308: */
309:
310: else
311: {
312: liberation(s_etat_processus, s_objet_argument);
313:
314: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
315: return;
316: }
317:
318: liberation(s_etat_processus, s_objet_argument);
319:
320: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
321: s_objet_resultat) == d_erreur)
322: {
323: return;
324: }
325:
326: return;
327: }
328:
329:
330: /*
331: ================================================================================
332: Fonction 'return'
333: ================================================================================
334: Entrées : pointeur sur une structure struct_processus
335: --------------------------------------------------------------------------------
336: Sorties :
337: --------------------------------------------------------------------------------
338: Effets de bord : néant
339: ================================================================================
340: */
341:
342: void
343: instruction_return(struct_processus *s_etat_processus)
344: {
345: logical1 erreur;
346: logical1 fin_boucle;
347: logical1 fin_scrutation;
348: logical1 presence_compteur;
349:
350: unsigned char *instruction_majuscule;
351: unsigned char *tampon;
352:
353: unsigned long registre_position_courante;
354:
355: struct_liste_chainee *tampon_expression;
356:
357: void (*fonction)();
358:
359: (*s_etat_processus).erreur_execution = d_ex;
360:
361: if ((*s_etat_processus).affichage_arguments == 'Y')
362: {
363: printf("\n RETURN ");
364:
365: if ((*s_etat_processus).langue == 'F')
366: {
367: printf("(retour d'une routine)\n\n");
368: printf(" Aucun argument\n");
369: }
370: else
371: {
372: printf("(return from a routine)\n\n");
373: printf(" No argument\n");
374: }
375:
376: return;
377: }
378: else if ((*s_etat_processus).test_instruction == 'Y')
379: {
380: (*s_etat_processus).nombre_arguments = -1;
381: return;
382: }
383:
384: if ((*s_etat_processus).niveau_courant == ((*s_etat_processus)
385: .niveau_initial + 1))
386: {
387: /*
388: * On ne peut rien dépiler !
389: */
390:
391: if ((*s_etat_processus).mode_execution_programme == 'Y')
392: {
393: (*s_etat_processus).requete_arret = 'Y';
394: }
395:
396: return;
397: }
398:
399: tampon = (*s_etat_processus).instruction_courante;
400: tampon_expression = (*s_etat_processus).expression_courante;
401:
402: fin_boucle = d_faux;
403:
404: if ((*s_etat_processus).mode_execution_programme == 'Y')
405: {
406: while(fin_boucle == d_faux)
407: {
408: erreur = recherche_instruction_suivante(s_etat_processus);
409:
410: if (erreur == d_erreur)
411: {
412: return;
413: }
414:
415: if (recherche_variable(s_etat_processus,
416: (*s_etat_processus).instruction_courante) == d_faux)
417: {
418: (*s_etat_processus).erreur_systeme = d_es;
419: instruction_majuscule = conversion_majuscule(
420: (*s_etat_processus).instruction_courante);
421:
422: if (instruction_majuscule == NULL)
423: {
424: return;
425: }
426:
427: /*
428: * Traitement de la pile système par les différentes
429: * instructions.
430: */
431:
432: if ((strcmp(instruction_majuscule, "IF") == 0) ||
433: (strcmp(instruction_majuscule, "IFERR") == 0) ||
434: (strcmp(instruction_majuscule, "DO") == 0) ||
435: (strcmp(instruction_majuscule, "WHILE") == 0) ||
436: (strcmp(instruction_majuscule, "FOR") == 0) ||
1.39 bertrand 437: (strcmp(instruction_majuscule, "FORALL") == 0) ||
1.1 bertrand 438: (strcmp(instruction_majuscule, "START") == 0) ||
1.39 bertrand 439: (strcmp(instruction_majuscule, "SELECT") == 0) ||
440: (strcmp(instruction_majuscule, "CRITICAL") == 0)
1.1 bertrand 441: || (strcmp(instruction_majuscule, "CASE") == 0)
442: || (strcmp(instruction_majuscule, "<<") == 0))
443: {
444: if (strcmp(instruction_majuscule, "<<") == 0)
445: {
446: analyse(s_etat_processus, NULL);
447: }
448: else if ((strcmp(instruction_majuscule, "FOR") == 0) ||
1.40 bertrand 449: (strcmp(instruction_majuscule, "FORALL") == 0) ||
1.1 bertrand 450: (strcmp(instruction_majuscule, "START") == 0))
451: {
452: empilement_pile_systeme(s_etat_processus);
453:
454: if ((*s_etat_processus).erreur_systeme != d_es)
455: {
456: return;
457: }
458:
459: (*(*s_etat_processus).l_base_pile_systeme)
460: .type_cloture = 'L';
461: }
462: else
463: {
464: /*
465: * Si on passe sur un début de boucle FOR ou START,
466: * les champs de la pile système sont initialisés à
467: * NULL, ce qui permet de les libérer de façon correcte
468: * lors du dépilement.
469: */
470:
471: empilement_pile_systeme(s_etat_processus);
472:
473: if ((*s_etat_processus).erreur_systeme != d_es)
474: {
475: return;
476: }
477: }
478: }
479: else if ((strcmp(instruction_majuscule, "END") == 0) ||
480: (strcmp(instruction_majuscule, "NEXT") == 0) ||
481: (strcmp(instruction_majuscule, "STEP") == 0) ||
482: (strcmp(instruction_majuscule, ">>") == 0))
483: {
484: if (strcmp(instruction_majuscule, ">>") == 0)
485: {
486: registre_position_courante = (*s_etat_processus)
487: .position_courante;
488:
489: analyse(s_etat_processus, NULL);
490:
491: fin_boucle = ((registre_position_courante !=
492: (*s_etat_processus).position_courante) ||
493: ((*s_etat_processus).retour_routine_evaluation
494: == 'Y'))
495: ? d_vrai : d_faux;
496:
497: if (fin_boucle == d_faux)
498: {
499: if ((*s_etat_processus).niveau_courant ==
500: (*s_etat_processus).niveau_initial)
501: {
502: fin_boucle = d_vrai;
503: }
504: }
505: }
506: else if (((strcmp(instruction_majuscule, "NEXT") == 0) ||
1.39 bertrand 507: (strcmp(instruction_majuscule, "STEP") == 0)) &&
508: ((*(*s_etat_processus).l_base_pile_systeme)
509: .type_cloture != 'L'))
1.1 bertrand 510: {
511: /*
512: * Libération des compteurs de boucle.
513: */
514:
1.40 bertrand 515: presence_compteur = (((*(*s_etat_processus)
516: .l_base_pile_systeme).type_cloture == 'F') ||
517: ((*(*s_etat_processus).l_base_pile_systeme)
518: .type_cloture == 'A')) ? d_vrai : d_faux;
1.1 bertrand 519:
520: if (((*(*s_etat_processus).l_base_pile_systeme)
521: .type_cloture != 'S') &&
522: (presence_compteur == d_faux))
523: {
524: (*s_etat_processus).erreur_execution =
525: d_ex_erreur_traitement_boucle;
526: return;
527: }
528:
529: if (presence_compteur == d_vrai)
530: {
531: if (recherche_variable(s_etat_processus,
532: (*(*s_etat_processus).l_base_pile_systeme)
533: .nom_variable) == d_faux)
534: {
535: (*s_etat_processus).erreur_systeme = d_es;
536: (*s_etat_processus).erreur_execution =
537: d_ex_erreur_traitement_boucle;
538: return;
539: }
540:
1.21 bertrand 541: if ((*(*s_etat_processus)
542: .pointeur_variable_courante).objet == NULL)
1.1 bertrand 543: {
544: (*s_etat_processus).erreur_systeme = d_es;
545: (*s_etat_processus).erreur_execution =
546: d_ex_variable_partagee;
547: return;
548: }
549:
1.39 bertrand 550: (*s_etat_processus).niveau_courant--;
1.1 bertrand 551:
1.42 bertrand 552: if (retrait_variables_par_niveau(
1.39 bertrand 553: s_etat_processus) == d_erreur)
1.1 bertrand 554: {
1.39 bertrand 555: return;
1.1 bertrand 556: }
557: }
558:
559: depilement_pile_systeme(s_etat_processus);
1.11 bertrand 560:
561: if ((*s_etat_processus).erreur_systeme != d_es)
562: {
563: return;
564: }
1.1 bertrand 565: }
566: else
567: {
1.39 bertrand 568: if ((*s_etat_processus).l_base_pile_systeme == NULL)
569: {
570: (*s_etat_processus).erreur_systeme =
571: d_es_processus;
572: return;
573: }
574:
575: if ((*(*s_etat_processus).l_base_pile_systeme)
576: .type_cloture == 'Q')
577: {
578: if (pthread_mutex_unlock(
579: &mutex_sections_critiques) != 0)
580: {
581: (*s_etat_processus).erreur_systeme =
582: d_es_processus;
583: return;
584: }
585:
586: (*s_etat_processus).sections_critiques--;
587: }
588:
1.1 bertrand 589: depilement_pile_systeme(s_etat_processus);
590:
591: if ((*s_etat_processus).erreur_systeme != d_es)
592: {
593: return;
594: }
595: }
596: }
597:
598: free(instruction_majuscule);
599: }
600:
601: free((*s_etat_processus).instruction_courante);
602: }
603: }
604: else
605: {
606: while(fin_boucle == d_faux)
607: {
608: if ((*s_etat_processus).expression_courante == NULL)
609: {
610: (*s_etat_processus).expression_courante = tampon_expression;
611:
612: (*s_etat_processus).erreur_execution =
613: d_ex_erreur_traitement_boucle;
614: return;
615: }
616:
617: (*s_etat_processus).expression_courante =
618: (*(*s_etat_processus).expression_courante).suivant;
619:
620: if ((*s_etat_processus).expression_courante == NULL)
621: {
622: (*s_etat_processus).expression_courante = tampon_expression;
623:
624: (*s_etat_processus).erreur_execution =
625: d_ex_erreur_traitement_boucle;
626: return;
627: }
628:
629: fin_scrutation = d_faux;
630:
631: do
632: {
633: while((*(*(*s_etat_processus).expression_courante)
634: .donnee).type != FCT)
635: {
636: (*s_etat_processus).expression_courante =
637: (*(*s_etat_processus).expression_courante).suivant;
638:
639: if ((*s_etat_processus).expression_courante == NULL)
640: {
641: (*s_etat_processus).expression_courante =
642: tampon_expression;
643:
644: (*s_etat_processus).erreur_execution =
645: d_ex_erreur_traitement_boucle;
646: return;
647: }
648: }
649:
650: if ((*((struct_fonction *) (*(*(*s_etat_processus)
651: .expression_courante).donnee).objet))
652: .nombre_arguments != 0)
653: {
654: (*s_etat_processus).expression_courante =
655: (*(*s_etat_processus).expression_courante).suivant;
656:
657: if ((*s_etat_processus).expression_courante == NULL)
658: {
659: (*s_etat_processus).expression_courante =
660: tampon_expression;
661:
662: (*s_etat_processus).erreur_execution =
663: d_ex_erreur_traitement_boucle;
664: return;
665: }
666: }
667: else
668: {
669: fin_scrutation = d_vrai;
670: tampon_expression = (*s_etat_processus).expression_courante;
671: }
672: } while(fin_scrutation == d_faux);
673:
674: fonction = (*((struct_fonction *) (*(*(*s_etat_processus)
675: .expression_courante).donnee).objet)).fonction;
676:
677: /*
678: * Traitement de la pile système par les différentes
679: * instructions.
680: */
681:
682: if ((fonction == instruction_if) ||
683: (fonction == instruction_iferr) ||
684: (fonction == instruction_do) ||
685: (fonction == instruction_while) ||
686: (fonction == instruction_for) ||
1.39 bertrand 687: (fonction == instruction_forall) ||
1.1 bertrand 688: (fonction == instruction_start) ||
689: (fonction == instruction_select) ||
1.39 bertrand 690: (fonction == instruction_critical) ||
1.1 bertrand 691: (fonction == instruction_case) ||
692: (fonction == instruction_vers_niveau_superieur))
693: {
694: if (fonction == instruction_vers_niveau_superieur)
695: {
696: analyse(s_etat_processus,
697: instruction_vers_niveau_superieur);
698: }
699: else if ((fonction == instruction_for) ||
1.40 bertrand 700: (fonction == instruction_forall) ||
1.1 bertrand 701: (fonction == instruction_start))
702: {
703: empilement_pile_systeme(s_etat_processus);
704:
705: if ((*s_etat_processus).erreur_systeme != d_es)
706: {
707: return;
708: }
709:
710: (*(*s_etat_processus).l_base_pile_systeme)
711: .type_cloture = 'L';
712: }
713: else
714: {
715: /*
716: * Si on passe sur un début de boucle FOR ou START,
717: * les champs de la pile système sont initialisés à
718: * NULL, ce qui permet de les libérer de façon correcte
719: * lors du dépilement.
720: */
721:
722: empilement_pile_systeme(s_etat_processus);
723:
724: if ((*s_etat_processus).erreur_systeme != d_es)
725: {
726: return;
727: }
728: }
729: }
730: else if ((fonction == instruction_end) ||
731: (fonction == instruction_next) ||
732: (fonction == instruction_step) ||
733: (fonction == instruction_vers_niveau_inferieur))
734: {
735: if (fonction == instruction_vers_niveau_inferieur)
736: {
737: analyse(s_etat_processus,
738: instruction_vers_niveau_inferieur);
739:
1.6 bertrand 740: fin_boucle = ((*(*s_etat_processus)
741: .expression_courante).suivant == NULL)
1.1 bertrand 742: ? d_vrai : d_faux;
743:
744: if (fin_boucle == d_faux)
745: {
746: if ((*s_etat_processus).niveau_courant ==
747: (*s_etat_processus).niveau_initial)
748: {
749: fin_boucle = d_vrai;
750: }
751: }
752: }
753: else if (((fonction == instruction_next) ||
754: (fonction == instruction_step)) &&
755: ((*(*s_etat_processus).l_base_pile_systeme)
756: .type_cloture != 'L'))
757: {
758: /*
759: * Libération des compteurs de boucle.
760: */
761:
1.40 bertrand 762: presence_compteur = (((*(*s_etat_processus)
763: .l_base_pile_systeme).type_cloture == 'F') ||
764: ((*(*s_etat_processus).l_base_pile_systeme)
765: .type_cloture == 'A')) ? d_vrai : d_faux;
1.1 bertrand 766:
767: if (((*(*s_etat_processus).l_base_pile_systeme)
768: .type_cloture != 'S') &&
769: (presence_compteur == d_faux))
770: {
771: (*s_etat_processus).erreur_execution =
772: d_ex_erreur_traitement_boucle;
773: return;
774: }
775:
776: if (presence_compteur == d_vrai)
777: {
778: if (recherche_variable(s_etat_processus,
779: (*(*s_etat_processus).l_base_pile_systeme)
780: .nom_variable) == d_faux)
781: {
782: (*s_etat_processus).erreur_systeme = d_es;
783: (*s_etat_processus).erreur_execution =
784: d_ex_erreur_traitement_boucle;
785: return;
786: }
787:
1.21 bertrand 788: if ((*(*s_etat_processus).pointeur_variable_courante)
1.1 bertrand 789: .objet == NULL)
790: {
791: (*s_etat_processus).erreur_systeme = d_es;
792: (*s_etat_processus).erreur_execution =
793: d_ex_variable_partagee;
794: return;
795: }
796:
1.39 bertrand 797: (*s_etat_processus).niveau_courant--;
1.1 bertrand 798:
1.42 bertrand 799: if (retrait_variables_par_niveau(s_etat_processus)
1.39 bertrand 800: == d_erreur)
1.1 bertrand 801: {
1.39 bertrand 802: return;
1.1 bertrand 803: }
804: }
805:
806: depilement_pile_systeme(s_etat_processus);
807: }
808: else
809: {
1.39 bertrand 810: if ((*s_etat_processus).l_base_pile_systeme == NULL)
811: {
812: (*s_etat_processus).erreur_systeme =
813: d_es_processus;
814: return;
815: }
816:
817: if ((*(*s_etat_processus).l_base_pile_systeme)
818: .type_cloture == 'Q')
819: {
820: if (pthread_mutex_unlock(
821: &mutex_sections_critiques) != 0)
822: {
823: (*s_etat_processus).erreur_systeme =
824: d_es_processus;
825: return;
826: }
827:
828: (*s_etat_processus).sections_critiques--;
829: }
830:
1.1 bertrand 831: depilement_pile_systeme(s_etat_processus);
832:
833: if ((*s_etat_processus).erreur_systeme != d_es)
834: {
835: return;
836: }
837: }
838: }
839: }
840: }
841:
842: if ((*s_etat_processus).mode_execution_programme != 'Y')
843: {
844: if ((*s_etat_processus).expression_courante == NULL)
845: {
846: (*s_etat_processus).expression_courante = tampon_expression;
847:
848: (*s_etat_processus).erreur_execution =
849: d_ex_erreur_traitement_boucle;
850: return;
851: }
852:
853: (*s_etat_processus).expression_courante =
854: (*(*s_etat_processus).expression_courante).suivant;
855: }
856:
857: (*s_etat_processus).instruction_courante = tampon;
858: (*s_etat_processus).expression_courante = tampon_expression;
859:
860: return;
861: }
862:
863:
864: /*
865: ================================================================================
866: Fonction 'rdm'
867: ================================================================================
868: Entrées : pointeur sur une structure struct_processus
869: --------------------------------------------------------------------------------
870: Sorties :
871: --------------------------------------------------------------------------------
872: Effets de bord : néant
873: ================================================================================
874: */
875:
876: void
877: instruction_rdm(struct_processus *s_etat_processus)
878: {
879: struct_liste_chainee *l_element_courant;
880:
881: struct_objet *s_objet_dimensions;
882: struct_objet *s_objet_initial;
883: struct_objet *s_objet_redimensionne;
884:
885: logical1 argument_nom;
886: logical1 drapeau_fin_objet_originel;
887: logical1 variable_partagee;
888:
889: unsigned long i;
890: unsigned long j;
891: unsigned long k;
892: unsigned long l;
893: unsigned long nombre_colonnes;
894: unsigned long nombre_dimensions;
895: unsigned long nombre_lignes;
896:
897: (*s_etat_processus).erreur_execution = d_ex;
898:
899: if ((*s_etat_processus).affichage_arguments == 'Y')
900: {
901: printf("\n RDM ");
902:
903: if ((*s_etat_processus).langue == 'F')
904: {
905: printf("(redimensionnement)\n\n");
906: }
907: else
908: {
909: printf("(resizing)\n\n");
910: }
911:
912: printf(" 2: %s, %s, %s, %s, %s, %s, %s\n", d_NOM,
913: d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX);
914: printf(" 1: %s\n", d_LST);
915: printf("-> 1: %s, %s, %s, %s, %s, %s\n",
916: d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX);
917: return;
918: }
919: else if ((*s_etat_processus).test_instruction == 'Y')
920: {
921: (*s_etat_processus).nombre_arguments = -1;
922: return;
923: }
924:
925: if (test_cfsf(s_etat_processus, 31) == d_vrai)
926: {
927: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
928: {
929: return;
930: }
931: }
932:
933: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
934: &s_objet_dimensions) == d_erreur)
935: {
936: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
937: return;
938: }
939:
940: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
941: &s_objet_initial) == d_erreur)
942: {
943: liberation(s_etat_processus, s_objet_dimensions);
944:
945: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
946: return;
947: }
948:
949: variable_partagee = d_faux;
950:
951: if ((*s_objet_initial).type == NOM)
952: {
953: argument_nom = d_vrai;
954:
955: if (recherche_variable(s_etat_processus, (*((struct_nom *)
956: (*s_objet_initial).objet)).nom) == d_faux)
957: {
958: (*s_etat_processus).erreur_systeme = d_es;
959: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
960:
961: liberation(s_etat_processus, s_objet_initial);
962: liberation(s_etat_processus, s_objet_dimensions);
963:
964: return;
965: }
966:
967: liberation(s_etat_processus, s_objet_initial);
968:
1.21 bertrand 969: if ((*(*s_etat_processus).pointeur_variable_courante)
970: .variable_verrouillee == d_vrai)
1.1 bertrand 971: {
972: (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee;
973:
974: liberation(s_etat_processus, s_objet_dimensions);
975: return;
976: }
977:
1.21 bertrand 978: s_objet_initial = (*(*s_etat_processus).pointeur_variable_courante)
979: .objet;
1.1 bertrand 980:
981: if (s_objet_initial == NULL)
982: {
983: if (recherche_variable_partagee(s_etat_processus,
1.21 bertrand 984: (*(*s_etat_processus).pointeur_variable_courante).nom,
985: (*(*s_etat_processus).pointeur_variable_courante)
986: .variable_partagee, (*(*s_etat_processus)
1.44 bertrand 987: .pointeur_variable_courante).origine) == NULL)
1.1 bertrand 988: {
989: (*s_etat_processus).erreur_systeme = d_es;
990: (*s_etat_processus).erreur_execution =
991: d_ex_variable_non_definie;
992:
993: liberation(s_etat_processus, s_objet_dimensions);
994:
995: return;
996: }
997:
998: variable_partagee = d_vrai;
999: }
1000: }
1001: else
1002: {
1003: argument_nom = d_faux;
1004: }
1005:
1006: if ((*s_objet_dimensions).type != LST)
1007: {
1008: if (variable_partagee == d_vrai)
1009: {
1010: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1011: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1012: {
1013: (*s_etat_processus).erreur_systeme = d_es_processus;
1014: return;
1015: }
1016: }
1017:
1018: liberation(s_etat_processus, s_objet_dimensions);
1019:
1020: if (argument_nom == d_faux)
1021: {
1022: liberation(s_etat_processus, s_objet_initial);
1023: }
1024:
1025: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1026: return;
1027: }
1028:
1029: l_element_courant = (*s_objet_dimensions).objet;
1030: nombre_dimensions = 0;
1031:
1032: while(l_element_courant != NULL)
1033: {
1034: nombre_dimensions++;
1035: l_element_courant = (*l_element_courant).suivant;
1036: }
1037:
1038: if ((nombre_dimensions != 1) && (nombre_dimensions != 2))
1039: {
1040: if (variable_partagee == d_vrai)
1041: {
1042: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1043: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1044: {
1045: (*s_etat_processus).erreur_systeme = d_es_processus;
1046: return;
1047: }
1048: }
1049:
1050: liberation(s_etat_processus, s_objet_dimensions);
1051:
1052: if (argument_nom == d_faux)
1053: {
1054: liberation(s_etat_processus, s_objet_initial);
1055: }
1056:
1057: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
1058: return;
1059: }
1060:
1061: nombre_colonnes = 0;
1062: nombre_lignes = 0;
1063:
1064: l_element_courant = (*s_objet_dimensions).objet;
1065:
1066: while(l_element_courant != NULL)
1067: {
1068: if ((*(*l_element_courant).donnee).type != INT)
1069: {
1070: if (variable_partagee == d_vrai)
1071: {
1072: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1073: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1074: {
1075: (*s_etat_processus).erreur_systeme = d_es_processus;
1076: return;
1077: }
1078: }
1079:
1080: liberation(s_etat_processus, s_objet_dimensions);
1081:
1082: if (argument_nom == d_faux)
1083: {
1084: liberation(s_etat_processus, s_objet_initial);
1085: }
1086:
1087: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1088: return;
1089: }
1090:
1091: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
1092: {
1093: if (variable_partagee == d_vrai)
1094: {
1095: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1096: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1097: {
1098: (*s_etat_processus).erreur_systeme = d_es_processus;
1099: return;
1100: }
1101: }
1102:
1103: liberation(s_etat_processus, s_objet_dimensions);
1104:
1105: if (argument_nom == d_faux)
1106: {
1107: liberation(s_etat_processus, s_objet_initial);
1108: }
1109:
1110: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
1111: return;
1112: }
1113:
1114: if (nombre_lignes == 0)
1115: {
1116: nombre_lignes = (*((integer8 *)
1117: (*(*l_element_courant).donnee).objet));
1118: }
1119: else
1120: {
1121: nombre_colonnes = (*((integer8 *)
1122: (*(*l_element_courant).donnee).objet));
1123: }
1124:
1125: l_element_courant = (*l_element_courant).suivant;
1126: }
1127:
1128: if ((s_objet_redimensionne = allocation(s_etat_processus, NON)) == NULL)
1129: {
1130: if (variable_partagee == d_vrai)
1131: {
1132: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1133: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1134: {
1135: (*s_etat_processus).erreur_systeme = d_es_processus;
1136: return;
1137: }
1138: }
1139:
1140: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1141: return;
1142: }
1143:
1144: /*
1145: --------------------------------------------------------------------------------
1146: Redimensionnement aboutissant à un vecteur
1147: --------------------------------------------------------------------------------
1148: */
1149:
1150: if (nombre_dimensions == 1)
1151: {
1152: if ((*s_objet_initial).type == VIN)
1153: {
1154: (*s_objet_redimensionne).type = VIN;
1155:
1156: if (((*s_objet_redimensionne).objet =
1157: malloc(sizeof(struct_vecteur))) == NULL)
1158: {
1159: if (variable_partagee == d_vrai)
1160: {
1161: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1162: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1163: {
1164: (*s_etat_processus).erreur_systeme = d_es_processus;
1165: return;
1166: }
1167: }
1168:
1169: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1170: return;
1171: }
1172:
1173: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'I';
1174: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille =
1175: nombre_lignes;
1176:
1177: if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau
1178: = malloc(nombre_lignes * sizeof(integer8))) == NULL)
1179: {
1180: if (variable_partagee == d_vrai)
1181: {
1182: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1183: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1184: {
1185: (*s_etat_processus).erreur_systeme = d_es_processus;
1186: return;
1187: }
1188: }
1189:
1190: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1191: return;
1192: }
1193:
1194: for(i = 0; i < nombre_lignes; i++)
1195: {
1196: if (i < (*((struct_vecteur *) (*s_objet_initial).objet)).taille)
1197: {
1198: ((integer8 *) (*((struct_vecteur *)
1199: (*s_objet_redimensionne).objet)).tableau)[i] =
1200: ((integer8 *) (*((struct_vecteur *)
1201: (*s_objet_initial).objet)).tableau)[i];
1202: }
1203: else
1204: {
1205: ((integer8 *) (*((struct_vecteur *)
1206: (*s_objet_redimensionne).objet)).tableau)[i] = 0;
1207: }
1208: }
1209: }
1210: else if ((*s_objet_initial).type == VRL)
1211: {
1212: (*s_objet_redimensionne).type = VRL;
1213:
1214: if (((*s_objet_redimensionne).objet =
1215: malloc(sizeof(struct_vecteur))) == NULL)
1216: {
1217: if (variable_partagee == d_vrai)
1218: {
1219: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1220: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1221: {
1222: (*s_etat_processus).erreur_systeme = d_es_processus;
1223: return;
1224: }
1225: }
1226:
1227: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1228: return;
1229: }
1230:
1231: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'R';
1232: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille =
1233: nombre_lignes;
1234:
1235: if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau
1236: = malloc(nombre_lignes * sizeof(real8))) == NULL)
1237: {
1238: if (variable_partagee == d_vrai)
1239: {
1240: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1241: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1242: {
1243: (*s_etat_processus).erreur_systeme = d_es_processus;
1244: return;
1245: }
1246: }
1247:
1248: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1249: return;
1250: }
1251:
1252: for(i = 0; i < nombre_lignes; i++)
1253: {
1254: if (i < (*((struct_vecteur *) (*s_objet_initial).objet)).taille)
1255: {
1256: ((real8 *) (*((struct_vecteur *)
1257: (*s_objet_redimensionne).objet)).tableau)[i] =
1258: ((real8 *) (*((struct_vecteur *)
1259: (*s_objet_initial).objet)).tableau)[i];
1260: }
1261: else
1262: {
1263: ((real8 *) (*((struct_vecteur *)
1264: (*s_objet_redimensionne).objet)).tableau)[i] =
1265: (real8) 0;
1266: }
1267: }
1268: }
1269: else if ((*s_objet_initial).type == VCX)
1270: {
1271: (*s_objet_redimensionne).type = VCX;
1272:
1273: if (((*s_objet_redimensionne).objet =
1274: malloc(sizeof(struct_vecteur))) == NULL)
1275: {
1276: if (variable_partagee == d_vrai)
1277: {
1278: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1279: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1280: {
1281: (*s_etat_processus).erreur_systeme = d_es_processus;
1282: return;
1283: }
1284: }
1285:
1286: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1287: return;
1288: }
1289:
1290: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'C';
1291: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille =
1292: nombre_lignes;
1293:
1294: if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau
1295: = malloc(nombre_lignes * sizeof(struct_complexe16)))
1296: == NULL)
1297: {
1298: if (variable_partagee == d_vrai)
1299: {
1300: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1301: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1302: {
1303: (*s_etat_processus).erreur_systeme = d_es_processus;
1304: return;
1305: }
1306: }
1307:
1308: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1309: return;
1310: }
1311:
1312: for(i = 0; i < nombre_lignes; i++)
1313: {
1314: if (i < (*((struct_vecteur *) (*s_objet_initial).objet)).taille)
1315: {
1316: ((struct_complexe16 *) (*((struct_vecteur *)
1317: (*s_objet_redimensionne).objet)).tableau)[i]
1318: .partie_reelle = ((struct_complexe16 *)
1319: (*((struct_vecteur *) (*s_objet_initial).objet))
1320: .tableau)[i].partie_reelle;
1321: ((struct_complexe16 *) (*((struct_vecteur *)
1322: (*s_objet_redimensionne).objet)).tableau)[i]
1323: .partie_imaginaire = ((struct_complexe16 *)
1324: (*((struct_vecteur *) (*s_objet_initial).objet))
1325: .tableau)[i].partie_imaginaire;
1326: }
1327: else
1328: {
1329: ((struct_complexe16 *) (*((struct_vecteur *)
1330: (*s_objet_redimensionne).objet)).tableau)[i]
1331: .partie_reelle = (real8) 0;
1332: ((struct_complexe16 *) (*((struct_vecteur *)
1333: (*s_objet_redimensionne).objet)).tableau)[i]
1334: .partie_imaginaire = (real8) 0;
1335: }
1336: }
1337: }
1338: else if ((*s_objet_initial).type == MIN)
1339: {
1340: (*s_objet_redimensionne).type = VIN;
1341:
1342: if (((*s_objet_redimensionne).objet =
1343: malloc(sizeof(struct_vecteur))) == NULL)
1344: {
1345: if (variable_partagee == d_vrai)
1346: {
1347: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1348: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1349: {
1350: (*s_etat_processus).erreur_systeme = d_es_processus;
1351: return;
1352: }
1353: }
1354:
1355: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1356: return;
1357: }
1358:
1359: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'I';
1360: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille =
1361: nombre_lignes;
1362:
1363: if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau
1364: = malloc(nombre_lignes * sizeof(integer8))) == NULL)
1365: {
1366: if (variable_partagee == d_vrai)
1367: {
1368: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1369: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1370: {
1371: (*s_etat_processus).erreur_systeme = d_es_processus;
1372: return;
1373: }
1374: }
1375:
1376: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1377: return;
1378: }
1379:
1380: drapeau_fin_objet_originel = d_faux;
1381: for(i = 0, j = 0, k = 0; i < nombre_lignes; i++)
1382: {
1383: if (drapeau_fin_objet_originel == d_faux)
1384: {
1385: ((integer8 *) (*((struct_vecteur *)
1386: (*s_objet_redimensionne).objet)).tableau)[i] =
1387: ((integer8 **) (*((struct_matrice *)
1388: (*s_objet_initial).objet)).tableau)[j][k];
1389:
1390: if ((++k) >= (*((struct_matrice *) (*s_objet_initial)
1391: .objet)).nombre_colonnes)
1392: {
1393: k = 0;
1394:
1395: if ((++j) >= (*((struct_matrice *) (*s_objet_initial)
1396: .objet)).nombre_lignes)
1397: {
1398: drapeau_fin_objet_originel = d_vrai;
1399: }
1400: }
1401: }
1402: else
1403: {
1404: ((integer8 *) (*((struct_vecteur *)
1405: (*s_objet_redimensionne).objet)).tableau)[i] = 0;
1406: }
1407: }
1408: }
1409: else if ((*s_objet_initial).type == MRL)
1410: {
1411: (*s_objet_redimensionne).type = VRL;
1412:
1413: if (((*s_objet_redimensionne).objet =
1414: malloc(sizeof(struct_vecteur))) == NULL)
1415: {
1416: if (variable_partagee == d_vrai)
1417: {
1418: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1419: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1420: {
1421: (*s_etat_processus).erreur_systeme = d_es_processus;
1422: return;
1423: }
1424: }
1425:
1426: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1427: return;
1428: }
1429:
1430: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'R';
1431: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille =
1432: nombre_lignes;
1433:
1434: if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau
1435: = malloc(nombre_lignes * sizeof(real8))) == NULL)
1436: {
1437: if (variable_partagee == d_vrai)
1438: {
1439: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1440: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1441: {
1442: (*s_etat_processus).erreur_systeme = d_es_processus;
1443: return;
1444: }
1445: }
1446:
1447: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1448: return;
1449: }
1450:
1451: drapeau_fin_objet_originel = d_faux;
1452: for(i = 0, j = 0, k = 0; i < nombre_lignes; i++)
1453: {
1454: if (drapeau_fin_objet_originel == d_faux)
1455: {
1456: ((real8 *) (*((struct_vecteur *)
1457: (*s_objet_redimensionne).objet)).tableau)[i] =
1458: ((real8 **) (*((struct_matrice *)
1459: (*s_objet_initial).objet)).tableau)[j][k];
1460:
1461: if ((++k) >= (*((struct_matrice *) (*s_objet_initial)
1462: .objet)).nombre_colonnes)
1463: {
1464: k = 0;
1465:
1466: if ((++j) >= (*((struct_matrice *) (*s_objet_initial)
1467: .objet)).nombre_lignes)
1468: {
1469: drapeau_fin_objet_originel = d_vrai;
1470: }
1471: }
1472: }
1473: else
1474: {
1475: ((real8 *) (*((struct_vecteur *)
1476: (*s_objet_redimensionne).objet)).tableau)[i] =
1477: (real8) 0;
1478: }
1479: }
1480: }
1481: else if ((*s_objet_initial).type == MCX)
1482: {
1483: (*s_objet_redimensionne).type = VCX;
1484:
1485: if (((*s_objet_redimensionne).objet =
1486: malloc(sizeof(struct_vecteur))) == NULL)
1487: {
1488: if (variable_partagee == d_vrai)
1489: {
1490: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1491: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1492: {
1493: (*s_etat_processus).erreur_systeme = d_es_processus;
1494: return;
1495: }
1496: }
1497:
1498: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1499: return;
1500: }
1501:
1502: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'C';
1503: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille =
1504: nombre_lignes;
1505:
1506: if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau
1507: = malloc(nombre_lignes * sizeof(struct_complexe16)))
1508: == NULL)
1509: {
1510: if (variable_partagee == d_vrai)
1511: {
1512: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1513: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1514: {
1515: (*s_etat_processus).erreur_systeme = d_es_processus;
1516: return;
1517: }
1518: }
1519:
1520: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1521: return;
1522: }
1523:
1524: drapeau_fin_objet_originel = d_faux;
1525: for(i = 0, j = 0, k = 0; i < nombre_lignes; i++)
1526: {
1527: if (drapeau_fin_objet_originel == d_faux)
1528: {
1529: ((struct_complexe16 *) (*((struct_vecteur *)
1530: (*s_objet_redimensionne).objet)).tableau)[i]
1531: .partie_reelle = ((struct_complexe16 **)
1532: (*((struct_matrice *) (*s_objet_initial).objet))
1533: .tableau)[j][k].partie_reelle;
1534: ((struct_complexe16 *) (*((struct_vecteur *)
1535: (*s_objet_redimensionne).objet)).tableau)[i]
1536: .partie_imaginaire = ((struct_complexe16 **)
1537: (*((struct_matrice *) (*s_objet_initial).objet))
1538: .tableau)[j][k].partie_imaginaire;
1539:
1540: if ((++k) >= (*((struct_matrice *) (*s_objet_initial)
1541: .objet)).nombre_colonnes)
1542: {
1543: k = 0;
1544:
1545: if ((++j) >= (*((struct_matrice *) (*s_objet_initial)
1546: .objet)).nombre_lignes)
1547: {
1548: drapeau_fin_objet_originel = d_vrai;
1549: }
1550: }
1551: }
1552: else
1553: {
1554: ((struct_complexe16 *) (*((struct_vecteur *)
1555: (*s_objet_redimensionne).objet)).tableau)[i]
1556: .partie_reelle = 0;
1557: ((struct_complexe16 *) (*((struct_vecteur *)
1558: (*s_objet_redimensionne).objet)).tableau)[i]
1559: .partie_imaginaire = 0;
1560: }
1561: }
1562: }
1563: else
1564: {
1565: if (variable_partagee == d_vrai)
1566: {
1567: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1568: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1569: {
1570: (*s_etat_processus).erreur_systeme = d_es_processus;
1571: return;
1572: }
1573: }
1574:
1575: if (argument_nom == d_faux)
1576: {
1577: liberation(s_etat_processus, s_objet_initial);
1578: }
1579:
1580: liberation(s_etat_processus, s_objet_dimensions);
1581: free(s_objet_redimensionne);
1582:
1583: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1584: return;
1585: }
1586: }
1587:
1588: /*
1589: --------------------------------------------------------------------------------
1590: Redimensionnement aboutissant à une matrice
1591: --------------------------------------------------------------------------------
1592: */
1593:
1594: else
1595: {
1596: if ((*s_objet_initial).type == VIN)
1597: {
1598: (*s_objet_redimensionne).type = MIN;
1599:
1600: if (((*s_objet_redimensionne).objet =
1601: malloc(sizeof(struct_matrice))) == NULL)
1602: {
1603: if (variable_partagee == d_vrai)
1604: {
1605: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1606: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1607: {
1608: (*s_etat_processus).erreur_systeme = d_es_processus;
1609: return;
1610: }
1611: }
1612:
1613: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1614: return;
1615: }
1616:
1617: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'I';
1618: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1619: .nombre_lignes = nombre_lignes;
1620: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1621: .nombre_colonnes = nombre_colonnes;
1622:
1623: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
1624: = malloc(nombre_lignes * sizeof(integer8 *)))
1625: == NULL)
1626: {
1627: if (variable_partagee == d_vrai)
1628: {
1629: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1630: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1631: {
1632: (*s_etat_processus).erreur_systeme = d_es_processus;
1633: return;
1634: }
1635: }
1636:
1637: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1638: return;
1639: }
1640:
1641: for(i = 0, k = 0; i < nombre_lignes; i++)
1642: {
1643: if ((((integer8 **) (*((struct_matrice *)
1644: (*s_objet_redimensionne).objet)).tableau)[i] =
1645: malloc(nombre_colonnes * sizeof(integer8))) == NULL)
1646: {
1647: if (variable_partagee == d_vrai)
1648: {
1649: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1650: .pointeur_variable_partagee_courante).mutex))
1651: != 0)
1.1 bertrand 1652: {
1653: (*s_etat_processus).erreur_systeme = d_es_processus;
1654: return;
1655: }
1656: }
1657:
1658: (*s_etat_processus).erreur_systeme =
1659: d_es_allocation_memoire;
1660: return;
1661: }
1662:
1663: for(j = 0; j < nombre_colonnes; j++)
1664: {
1665: if (k < (*((struct_vecteur *) (*s_objet_initial)
1666: .objet)).taille)
1667: {
1668: ((integer8 **) (*((struct_matrice *)
1669: (*s_objet_redimensionne).objet)).tableau)
1670: [i][j] = ((integer8 *) (*((struct_vecteur *)
1671: (*s_objet_initial).objet)).tableau)[k++];
1672: }
1673: else
1674: {
1675: ((integer8 **) (*((struct_matrice *)
1676: (*s_objet_redimensionne).objet)).tableau)
1677: [i][j] = 0;
1678: }
1679: }
1680: }
1681: }
1682: else if ((*s_objet_initial).type == VRL)
1683: {
1684: (*s_objet_redimensionne).type = MRL;
1685:
1686: if (((*s_objet_redimensionne).objet =
1687: malloc(sizeof(struct_matrice))) == NULL)
1688: {
1689: if (variable_partagee == d_vrai)
1690: {
1691: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1692: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1693: {
1694: (*s_etat_processus).erreur_systeme = d_es_processus;
1695: return;
1696: }
1697: }
1698:
1699: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1700: return;
1701: }
1702:
1703: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'R';
1704: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1705: .nombre_lignes = nombre_lignes;
1706: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1707: .nombre_colonnes = nombre_colonnes;
1708:
1709: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
1710: = malloc(nombre_lignes * sizeof(real8 *)))
1711: == NULL)
1712: {
1713: if (variable_partagee == d_vrai)
1714: {
1715: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1716: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1717: {
1718: (*s_etat_processus).erreur_systeme = d_es_processus;
1719: return;
1720: }
1721: }
1722:
1723: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1724: return;
1725: }
1726:
1727: for(i = 0, k = 0; i < nombre_lignes; i++)
1728: {
1729: if ((((real8 **) (*((struct_matrice *)
1730: (*s_objet_redimensionne).objet)).tableau)[i] =
1731: malloc(nombre_colonnes * sizeof(real8))) == NULL)
1732: {
1733: if (variable_partagee == d_vrai)
1734: {
1735: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1736: .pointeur_variable_partagee_courante).mutex))
1737: != 0)
1.1 bertrand 1738: {
1739: (*s_etat_processus).erreur_systeme = d_es_processus;
1740: return;
1741: }
1742: }
1743:
1744: (*s_etat_processus).erreur_systeme =
1745: d_es_allocation_memoire;
1746: return;
1747: }
1748:
1749: for(j = 0; j < nombre_colonnes; j++)
1750: {
1751: if (k < (*((struct_vecteur *) (*s_objet_initial)
1752: .objet)).taille)
1753: {
1754: ((real8 **) (*((struct_matrice *)
1755: (*s_objet_redimensionne).objet)).tableau)
1756: [i][j] = ((real8 *) (*((struct_vecteur *)
1757: (*s_objet_initial).objet)).tableau)[k++];
1758: }
1759: else
1760: {
1761: ((real8 **) (*((struct_matrice *)
1762: (*s_objet_redimensionne).objet)).tableau)
1763: [i][j] = (real8) 0;
1764: }
1765: }
1766: }
1767: }
1768: else if ((*s_objet_initial).type == VCX)
1769: {
1770: (*s_objet_redimensionne).type = MCX;
1771:
1772: if (((*s_objet_redimensionne).objet =
1773: malloc(sizeof(struct_matrice))) == NULL)
1774: {
1775: if (variable_partagee == d_vrai)
1776: {
1777: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1778: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1779: {
1780: (*s_etat_processus).erreur_systeme = d_es_processus;
1781: return;
1782: }
1783: }
1784:
1785: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1786: return;
1787: }
1788:
1789: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'C';
1790: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1791: .nombre_lignes = nombre_lignes;
1792: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1793: .nombre_colonnes = nombre_colonnes;
1794:
1795: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
1796: = malloc(nombre_lignes * sizeof(struct_complexe16 *)))
1797: == NULL)
1798: {
1799: if (variable_partagee == d_vrai)
1800: {
1801: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1802: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1803: {
1804: (*s_etat_processus).erreur_systeme = d_es_processus;
1805: return;
1806: }
1807: }
1808:
1809: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1810: return;
1811: }
1812:
1813: for(i = 0, k = 0; i < nombre_lignes; i++)
1814: {
1815: if ((((struct_complexe16 **) (*((struct_matrice *)
1816: (*s_objet_redimensionne).objet)).tableau)[i] =
1817: malloc(nombre_colonnes *
1818: sizeof(struct_complexe16))) == NULL)
1819: {
1820: if (variable_partagee == d_vrai)
1821: {
1822: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1823: .pointeur_variable_partagee_courante).mutex))
1824: != 0)
1.1 bertrand 1825: {
1826: (*s_etat_processus).erreur_systeme = d_es_processus;
1827: return;
1828: }
1829: }
1830:
1831: (*s_etat_processus).erreur_systeme =
1832: d_es_allocation_memoire;
1833: return;
1834: }
1835:
1836: for(j = 0; j < nombre_colonnes; j++)
1837: {
1838: if (k < (*((struct_vecteur *) (*s_objet_initial)
1839: .objet)).taille)
1840: {
1841: ((struct_complexe16 **) (*((struct_matrice *)
1842: (*s_objet_redimensionne).objet)).tableau)
1843: [i][j].partie_reelle =
1844: ((struct_complexe16 *) (*((struct_vecteur *)
1845: (*s_objet_initial).objet)).tableau)[k]
1846: .partie_reelle;
1847: ((struct_complexe16 **) (*((struct_matrice *)
1848: (*s_objet_redimensionne).objet)).tableau)
1849: [i][j].partie_imaginaire =
1850: ((struct_complexe16 *) (*((struct_vecteur *)
1851: (*s_objet_initial).objet)).tableau)[k++]
1852: .partie_imaginaire;
1853: }
1854: else
1855: {
1856: ((struct_complexe16 **) (*((struct_matrice *)
1857: (*s_objet_redimensionne).objet)).tableau)
1858: [i][j].partie_reelle = (real8) 0;
1859: ((struct_complexe16 **) (*((struct_matrice *)
1860: (*s_objet_redimensionne).objet)).tableau)
1861: [i][j].partie_imaginaire = (real8) 0;
1862: }
1863: }
1864: }
1865: }
1866: else if ((*s_objet_initial).type == MIN)
1867: {
1868: (*s_objet_redimensionne).type = MIN;
1869:
1870: if (((*s_objet_redimensionne).objet =
1871: malloc(sizeof(struct_matrice))) == NULL)
1872: {
1873: if (variable_partagee == d_vrai)
1874: {
1875: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1876: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1877: {
1878: (*s_etat_processus).erreur_systeme = d_es_processus;
1879: return;
1880: }
1881: }
1882:
1883: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1884: return;
1885: }
1886:
1887: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'I';
1888: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1889: .nombre_lignes = nombre_lignes;
1890: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1891: .nombre_colonnes = nombre_colonnes;
1892:
1893: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
1894: = malloc(nombre_lignes * sizeof(integer8 *)))
1895: == NULL)
1896: {
1897: if (variable_partagee == d_vrai)
1898: {
1899: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1900: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1901: {
1902: (*s_etat_processus).erreur_systeme = d_es_processus;
1903: return;
1904: }
1905: }
1906:
1907: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1908: return;
1909: }
1910:
1911: drapeau_fin_objet_originel = d_faux;
1912:
1913: for(i = 0, k = 0, l = 0; i < nombre_lignes; i++)
1914: {
1915: if ((((integer8 **) (*((struct_matrice *)
1916: (*s_objet_redimensionne).objet)).tableau)[i] =
1917: malloc(nombre_colonnes *
1918: sizeof(integer8))) == NULL)
1919: {
1920: if (variable_partagee == d_vrai)
1921: {
1922: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1923: .pointeur_variable_partagee_courante).mutex))
1924: != 0)
1.1 bertrand 1925: {
1926: (*s_etat_processus).erreur_systeme = d_es_processus;
1927: return;
1928: }
1929: }
1930:
1931: (*s_etat_processus).erreur_systeme =
1932: d_es_allocation_memoire;
1933: return;
1934: }
1935:
1936: for(j = 0; j < nombre_colonnes; j++)
1937: {
1938: if (drapeau_fin_objet_originel == d_faux)
1939: {
1940: ((integer8 **) (*((struct_matrice *)
1941: (*s_objet_redimensionne).objet)).tableau)
1942: [i][j] = ((integer8 **) (*((struct_matrice *)
1943: (*s_objet_initial).objet)).tableau)[k][l];
1944:
1945: if ((++l) >= (*((struct_matrice *) (*s_objet_initial)
1946: .objet)).nombre_colonnes)
1947: {
1948: l = 0;
1949:
1950: if ((++k) >= (*((struct_matrice *)
1951: (*s_objet_initial).objet)).nombre_lignes)
1952: {
1953: drapeau_fin_objet_originel = d_vrai;
1954: }
1955: }
1956: }
1957: else
1958: {
1959: ((integer8 **) (*((struct_matrice *)
1960: (*s_objet_redimensionne).objet)).tableau)
1961: [i][j] = 0;
1962: }
1963: }
1964: }
1965: }
1966: else if ((*s_objet_initial).type == MRL)
1967: {
1968: (*s_objet_redimensionne).type = MRL;
1969:
1970: if (((*s_objet_redimensionne).objet =
1971: malloc(sizeof(struct_matrice))) == NULL)
1972: {
1973: if (variable_partagee == d_vrai)
1974: {
1975: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1976: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1977: {
1978: (*s_etat_processus).erreur_systeme = d_es_processus;
1979: return;
1980: }
1981: }
1982:
1983: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1984: return;
1985: }
1986:
1987: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'R';
1988: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1989: .nombre_lignes = nombre_lignes;
1990: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1991: .nombre_colonnes = nombre_colonnes;
1992:
1993: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
1994: = malloc(nombre_lignes * sizeof(real8 *)))
1995: == NULL)
1996: {
1997: if (variable_partagee == d_vrai)
1998: {
1999: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2000: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 2001: {
2002: (*s_etat_processus).erreur_systeme = d_es_processus;
2003: return;
2004: }
2005: }
2006:
2007: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2008: return;
2009: }
2010:
2011: drapeau_fin_objet_originel = d_faux;
2012:
2013: for(i = 0, k = 0, l = 0; i < nombre_lignes; i++)
2014: {
2015: if ((((real8 **) (*((struct_matrice *)
2016: (*s_objet_redimensionne).objet)).tableau)[i] =
2017: malloc(nombre_colonnes *
2018: sizeof(real8))) == NULL)
2019: {
2020: if (variable_partagee == d_vrai)
2021: {
2022: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2023: .pointeur_variable_partagee_courante).mutex))
2024: != 0)
1.1 bertrand 2025: {
2026: (*s_etat_processus).erreur_systeme = d_es_processus;
2027: return;
2028: }
2029: }
2030:
2031: (*s_etat_processus).erreur_systeme =
2032: d_es_allocation_memoire;
2033: return;
2034: }
2035:
2036: for(j = 0; j < nombre_colonnes; j++)
2037: {
2038: if (drapeau_fin_objet_originel == d_faux)
2039: {
2040: ((real8 **) (*((struct_matrice *)
2041: (*s_objet_redimensionne).objet)).tableau)
2042: [i][j] = ((real8 **) (*((struct_matrice *)
2043: (*s_objet_initial).objet)).tableau)[k][l];
2044:
2045: if ((++l) >= (*((struct_matrice *) (*s_objet_initial)
2046: .objet)).nombre_colonnes)
2047: {
2048: l = 0;
2049:
2050: if ((++k) >= (*((struct_matrice *)
2051: (*s_objet_initial).objet)).nombre_lignes)
2052: {
2053: drapeau_fin_objet_originel = d_vrai;
2054: }
2055: }
2056: }
2057: else
2058: {
2059: ((real8 **) (*((struct_matrice *)
2060: (*s_objet_redimensionne).objet)).tableau)
2061: [i][j] = (real8) 0;
2062: }
2063: }
2064: }
2065: }
2066: else if ((*s_objet_initial).type == MCX)
2067: {
2068: (*s_objet_redimensionne).type = MCX;
2069:
2070: if (((*s_objet_redimensionne).objet =
2071: malloc(sizeof(struct_matrice))) == NULL)
2072: {
2073: if (variable_partagee == d_vrai)
2074: {
2075: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2076: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 2077: {
2078: (*s_etat_processus).erreur_systeme = d_es_processus;
2079: return;
2080: }
2081: }
2082:
2083: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2084: return;
2085: }
2086:
2087: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'C';
2088: (*((struct_matrice *) (*s_objet_redimensionne).objet))
2089: .nombre_lignes = nombre_lignes;
2090: (*((struct_matrice *) (*s_objet_redimensionne).objet))
2091: .nombre_colonnes = nombre_colonnes;
2092:
2093: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
2094: = malloc(nombre_lignes * sizeof(struct_complexe16 *)))
2095: == NULL)
2096: {
2097: if (variable_partagee == d_vrai)
2098: {
2099: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2100: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 2101: {
2102: (*s_etat_processus).erreur_systeme = d_es_processus;
2103: return;
2104: }
2105: }
2106:
2107: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2108: return;
2109: }
2110:
2111: drapeau_fin_objet_originel = d_faux;
2112:
2113: for(i = 0, k = 0, l = 0; i < nombre_lignes; i++)
2114: {
2115: if ((((struct_complexe16 **) (*((struct_matrice *)
2116: (*s_objet_redimensionne).objet)).tableau)[i] =
2117: malloc(nombre_colonnes *
2118: sizeof(struct_complexe16))) == NULL)
2119: {
2120: if (variable_partagee == d_vrai)
2121: {
2122: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2123: .pointeur_variable_partagee_courante).mutex))
2124: != 0)
1.1 bertrand 2125: {
2126: (*s_etat_processus).erreur_systeme = d_es_processus;
2127: return;
2128: }
2129: }
2130:
2131: (*s_etat_processus).erreur_systeme =
2132: d_es_allocation_memoire;
2133: return;
2134: }
2135:
2136: for(j = 0; j < nombre_colonnes; j++)
2137: {
2138: if (drapeau_fin_objet_originel == d_faux)
2139: {
2140: ((struct_complexe16 **) (*((struct_matrice *)
2141: (*s_objet_redimensionne).objet)).tableau)
2142: [i][j].partie_reelle = ((struct_complexe16 **)
2143: (*((struct_matrice *) (*s_objet_initial).objet))
2144: .tableau)[k][l].partie_reelle;
2145:
2146: ((struct_complexe16 **) (*((struct_matrice *)
2147: (*s_objet_redimensionne).objet)).tableau)
2148: [i][j].partie_imaginaire =
2149: ((struct_complexe16 **) (*((struct_matrice *)
2150: (*s_objet_initial).objet)).tableau)[k][l]
2151: .partie_imaginaire;
2152:
2153: if ((++l) >= (*((struct_matrice *) (*s_objet_initial)
2154: .objet)).nombre_colonnes)
2155: {
2156: l = 0;
2157:
2158: if ((++k) >= (*((struct_matrice *)
2159: (*s_objet_initial).objet)).nombre_lignes)
2160: {
2161: drapeau_fin_objet_originel = d_vrai;
2162: }
2163: }
2164: }
2165: else
2166: {
2167: ((struct_complexe16 **) (*((struct_matrice *)
2168: (*s_objet_redimensionne).objet)).tableau)
2169: [i][j].partie_reelle = (real8) 0;
2170: ((struct_complexe16 **) (*((struct_matrice *)
2171: (*s_objet_redimensionne).objet)).tableau)
2172: [i][j].partie_imaginaire = (real8) 0;
2173: }
2174: }
2175: }
2176: }
2177: else
2178: {
2179: if (variable_partagee == d_vrai)
2180: {
2181: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2182: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 2183: {
2184: (*s_etat_processus).erreur_systeme = d_es_processus;
2185: return;
2186: }
2187: }
2188:
2189: if (argument_nom == d_faux)
2190: {
2191: liberation(s_etat_processus, s_objet_initial);
2192: }
2193:
2194: liberation(s_etat_processus, s_objet_dimensions);
2195: free(s_objet_redimensionne);
2196:
2197: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
2198: return;
2199: }
2200: }
2201:
2202: liberation(s_etat_processus, s_objet_dimensions);
2203: liberation(s_etat_processus, s_objet_initial);
2204:
2205: if (argument_nom == d_faux)
2206: {
2207: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2208: s_objet_redimensionne) == d_erreur)
2209: {
2210: return;
2211: }
2212: }
2213: else
2214: {
2215: if (variable_partagee == d_vrai)
2216: {
1.43 bertrand 2217: (*(*s_etat_processus).pointeur_variable_partagee_courante).objet =
2218: s_objet_redimensionne;
1.1 bertrand 2219:
2220: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2221: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 2222: {
2223: (*s_etat_processus).erreur_systeme = d_es_processus;
2224: return;
2225: }
2226: }
2227: else
2228: {
1.21 bertrand 2229: (*(*s_etat_processus).pointeur_variable_courante).objet =
1.1 bertrand 2230: s_objet_redimensionne;
2231: }
2232: }
2233:
2234: return;
2235: }
2236:
2237: // vim: ts=4