![]() ![]() | ![]() |
1.1 bertrand 1: /*
2: ================================================================================
1.76 ! bertrand 3: RPL/2 (R) version 4.1.34
1.75 bertrand 4: Copyright (C) 1989-2021 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:
1.49 bertrand 353: integer8 registre_position_courante;
1.1 bertrand 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;
1.59 bertrand 419: instruction_majuscule = conversion_majuscule(s_etat_processus,
1.1 bertrand 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:
1.49 bertrand 889: integer8 i;
890: integer8 j;
891: integer8 k;
892: integer8 l;
893: integer8 nombre_colonnes;
894: integer8 nombre_dimensions;
895: integer8 nombre_lignes;
1.1 bertrand 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
1.49 bertrand 1178: = malloc(((size_t) nombre_lignes) * sizeof(integer8)))
1179: == NULL)
1.1 bertrand 1180: {
1181: if (variable_partagee == d_vrai)
1182: {
1183: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1184: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1185: {
1186: (*s_etat_processus).erreur_systeme = d_es_processus;
1187: return;
1188: }
1189: }
1190:
1191: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1192: return;
1193: }
1194:
1195: for(i = 0; i < nombre_lignes; i++)
1196: {
1197: if (i < (*((struct_vecteur *) (*s_objet_initial).objet)).taille)
1198: {
1199: ((integer8 *) (*((struct_vecteur *)
1200: (*s_objet_redimensionne).objet)).tableau)[i] =
1201: ((integer8 *) (*((struct_vecteur *)
1202: (*s_objet_initial).objet)).tableau)[i];
1203: }
1204: else
1205: {
1206: ((integer8 *) (*((struct_vecteur *)
1207: (*s_objet_redimensionne).objet)).tableau)[i] = 0;
1208: }
1209: }
1210: }
1211: else if ((*s_objet_initial).type == VRL)
1212: {
1213: (*s_objet_redimensionne).type = VRL;
1214:
1215: if (((*s_objet_redimensionne).objet =
1216: malloc(sizeof(struct_vecteur))) == NULL)
1217: {
1218: if (variable_partagee == d_vrai)
1219: {
1220: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1221: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1222: {
1223: (*s_etat_processus).erreur_systeme = d_es_processus;
1224: return;
1225: }
1226: }
1227:
1228: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1229: return;
1230: }
1231:
1232: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'R';
1233: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille =
1234: nombre_lignes;
1235:
1236: if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau
1.49 bertrand 1237: = malloc(((size_t) nombre_lignes) * sizeof(real8))) == NULL)
1.1 bertrand 1238: {
1239: if (variable_partagee == d_vrai)
1240: {
1241: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1242: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1243: {
1244: (*s_etat_processus).erreur_systeme = d_es_processus;
1245: return;
1246: }
1247: }
1248:
1249: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1250: return;
1251: }
1252:
1253: for(i = 0; i < nombre_lignes; i++)
1254: {
1255: if (i < (*((struct_vecteur *) (*s_objet_initial).objet)).taille)
1256: {
1257: ((real8 *) (*((struct_vecteur *)
1258: (*s_objet_redimensionne).objet)).tableau)[i] =
1259: ((real8 *) (*((struct_vecteur *)
1260: (*s_objet_initial).objet)).tableau)[i];
1261: }
1262: else
1263: {
1264: ((real8 *) (*((struct_vecteur *)
1265: (*s_objet_redimensionne).objet)).tableau)[i] =
1266: (real8) 0;
1267: }
1268: }
1269: }
1270: else if ((*s_objet_initial).type == VCX)
1271: {
1272: (*s_objet_redimensionne).type = VCX;
1273:
1274: if (((*s_objet_redimensionne).objet =
1275: malloc(sizeof(struct_vecteur))) == NULL)
1276: {
1277: if (variable_partagee == d_vrai)
1278: {
1279: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1280: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1281: {
1282: (*s_etat_processus).erreur_systeme = d_es_processus;
1283: return;
1284: }
1285: }
1286:
1287: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1288: return;
1289: }
1290:
1291: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'C';
1292: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille =
1293: nombre_lignes;
1294:
1295: if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau
1.49 bertrand 1296: = malloc(((size_t) nombre_lignes) *
1297: sizeof(struct_complexe16))) == NULL)
1.1 bertrand 1298: {
1299: if (variable_partagee == d_vrai)
1300: {
1301: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1302: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1303: {
1304: (*s_etat_processus).erreur_systeme = d_es_processus;
1305: return;
1306: }
1307: }
1308:
1309: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1310: return;
1311: }
1312:
1313: for(i = 0; i < nombre_lignes; i++)
1314: {
1315: if (i < (*((struct_vecteur *) (*s_objet_initial).objet)).taille)
1316: {
1317: ((struct_complexe16 *) (*((struct_vecteur *)
1318: (*s_objet_redimensionne).objet)).tableau)[i]
1319: .partie_reelle = ((struct_complexe16 *)
1320: (*((struct_vecteur *) (*s_objet_initial).objet))
1321: .tableau)[i].partie_reelle;
1322: ((struct_complexe16 *) (*((struct_vecteur *)
1323: (*s_objet_redimensionne).objet)).tableau)[i]
1324: .partie_imaginaire = ((struct_complexe16 *)
1325: (*((struct_vecteur *) (*s_objet_initial).objet))
1326: .tableau)[i].partie_imaginaire;
1327: }
1328: else
1329: {
1330: ((struct_complexe16 *) (*((struct_vecteur *)
1331: (*s_objet_redimensionne).objet)).tableau)[i]
1332: .partie_reelle = (real8) 0;
1333: ((struct_complexe16 *) (*((struct_vecteur *)
1334: (*s_objet_redimensionne).objet)).tableau)[i]
1335: .partie_imaginaire = (real8) 0;
1336: }
1337: }
1338: }
1339: else if ((*s_objet_initial).type == MIN)
1340: {
1341: (*s_objet_redimensionne).type = VIN;
1342:
1343: if (((*s_objet_redimensionne).objet =
1344: malloc(sizeof(struct_vecteur))) == NULL)
1345: {
1346: if (variable_partagee == d_vrai)
1347: {
1348: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1349: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1350: {
1351: (*s_etat_processus).erreur_systeme = d_es_processus;
1352: return;
1353: }
1354: }
1355:
1356: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1357: return;
1358: }
1359:
1360: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'I';
1361: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille =
1362: nombre_lignes;
1363:
1364: if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau
1.49 bertrand 1365: = malloc(((size_t) nombre_lignes) * sizeof(integer8)))
1366: == NULL)
1.1 bertrand 1367: {
1368: if (variable_partagee == d_vrai)
1369: {
1370: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1371: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1372: {
1373: (*s_etat_processus).erreur_systeme = d_es_processus;
1374: return;
1375: }
1376: }
1377:
1378: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1379: return;
1380: }
1381:
1382: drapeau_fin_objet_originel = d_faux;
1383: for(i = 0, j = 0, k = 0; i < nombre_lignes; i++)
1384: {
1385: if (drapeau_fin_objet_originel == d_faux)
1386: {
1387: ((integer8 *) (*((struct_vecteur *)
1388: (*s_objet_redimensionne).objet)).tableau)[i] =
1389: ((integer8 **) (*((struct_matrice *)
1390: (*s_objet_initial).objet)).tableau)[j][k];
1391:
1392: if ((++k) >= (*((struct_matrice *) (*s_objet_initial)
1393: .objet)).nombre_colonnes)
1394: {
1395: k = 0;
1396:
1397: if ((++j) >= (*((struct_matrice *) (*s_objet_initial)
1398: .objet)).nombre_lignes)
1399: {
1400: drapeau_fin_objet_originel = d_vrai;
1401: }
1402: }
1403: }
1404: else
1405: {
1406: ((integer8 *) (*((struct_vecteur *)
1407: (*s_objet_redimensionne).objet)).tableau)[i] = 0;
1408: }
1409: }
1410: }
1411: else if ((*s_objet_initial).type == MRL)
1412: {
1413: (*s_objet_redimensionne).type = VRL;
1414:
1415: if (((*s_objet_redimensionne).objet =
1416: malloc(sizeof(struct_vecteur))) == NULL)
1417: {
1418: if (variable_partagee == d_vrai)
1419: {
1420: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1421: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1422: {
1423: (*s_etat_processus).erreur_systeme = d_es_processus;
1424: return;
1425: }
1426: }
1427:
1428: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1429: return;
1430: }
1431:
1432: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'R';
1433: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille =
1434: nombre_lignes;
1435:
1436: if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau
1.49 bertrand 1437: = malloc(((size_t) nombre_lignes) * sizeof(real8))) == NULL)
1.1 bertrand 1438: {
1439: if (variable_partagee == d_vrai)
1440: {
1441: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1442: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1443: {
1444: (*s_etat_processus).erreur_systeme = d_es_processus;
1445: return;
1446: }
1447: }
1448:
1449: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1450: return;
1451: }
1452:
1453: drapeau_fin_objet_originel = d_faux;
1454: for(i = 0, j = 0, k = 0; i < nombre_lignes; i++)
1455: {
1456: if (drapeau_fin_objet_originel == d_faux)
1457: {
1458: ((real8 *) (*((struct_vecteur *)
1459: (*s_objet_redimensionne).objet)).tableau)[i] =
1460: ((real8 **) (*((struct_matrice *)
1461: (*s_objet_initial).objet)).tableau)[j][k];
1462:
1463: if ((++k) >= (*((struct_matrice *) (*s_objet_initial)
1464: .objet)).nombre_colonnes)
1465: {
1466: k = 0;
1467:
1468: if ((++j) >= (*((struct_matrice *) (*s_objet_initial)
1469: .objet)).nombre_lignes)
1470: {
1471: drapeau_fin_objet_originel = d_vrai;
1472: }
1473: }
1474: }
1475: else
1476: {
1477: ((real8 *) (*((struct_vecteur *)
1478: (*s_objet_redimensionne).objet)).tableau)[i] =
1479: (real8) 0;
1480: }
1481: }
1482: }
1483: else if ((*s_objet_initial).type == MCX)
1484: {
1485: (*s_objet_redimensionne).type = VCX;
1486:
1487: if (((*s_objet_redimensionne).objet =
1488: malloc(sizeof(struct_vecteur))) == NULL)
1489: {
1490: if (variable_partagee == d_vrai)
1491: {
1492: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1493: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1494: {
1495: (*s_etat_processus).erreur_systeme = d_es_processus;
1496: return;
1497: }
1498: }
1499:
1500: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1501: return;
1502: }
1503:
1504: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).type = 'C';
1505: (*((struct_vecteur *) (*s_objet_redimensionne).objet)).taille =
1506: nombre_lignes;
1507:
1508: if (((*((struct_vecteur *) (*s_objet_redimensionne).objet)).tableau
1.49 bertrand 1509: = malloc(((size_t) nombre_lignes) *
1510: sizeof(struct_complexe16))) == NULL)
1.1 bertrand 1511: {
1512: if (variable_partagee == d_vrai)
1513: {
1514: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1515: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1516: {
1517: (*s_etat_processus).erreur_systeme = d_es_processus;
1518: return;
1519: }
1520: }
1521:
1522: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1523: return;
1524: }
1525:
1526: drapeau_fin_objet_originel = d_faux;
1527: for(i = 0, j = 0, k = 0; i < nombre_lignes; i++)
1528: {
1529: if (drapeau_fin_objet_originel == d_faux)
1530: {
1531: ((struct_complexe16 *) (*((struct_vecteur *)
1532: (*s_objet_redimensionne).objet)).tableau)[i]
1533: .partie_reelle = ((struct_complexe16 **)
1534: (*((struct_matrice *) (*s_objet_initial).objet))
1535: .tableau)[j][k].partie_reelle;
1536: ((struct_complexe16 *) (*((struct_vecteur *)
1537: (*s_objet_redimensionne).objet)).tableau)[i]
1538: .partie_imaginaire = ((struct_complexe16 **)
1539: (*((struct_matrice *) (*s_objet_initial).objet))
1540: .tableau)[j][k].partie_imaginaire;
1541:
1542: if ((++k) >= (*((struct_matrice *) (*s_objet_initial)
1543: .objet)).nombre_colonnes)
1544: {
1545: k = 0;
1546:
1547: if ((++j) >= (*((struct_matrice *) (*s_objet_initial)
1548: .objet)).nombre_lignes)
1549: {
1550: drapeau_fin_objet_originel = d_vrai;
1551: }
1552: }
1553: }
1554: else
1555: {
1556: ((struct_complexe16 *) (*((struct_vecteur *)
1557: (*s_objet_redimensionne).objet)).tableau)[i]
1558: .partie_reelle = 0;
1559: ((struct_complexe16 *) (*((struct_vecteur *)
1560: (*s_objet_redimensionne).objet)).tableau)[i]
1561: .partie_imaginaire = 0;
1562: }
1563: }
1564: }
1565: else
1566: {
1567: if (variable_partagee == d_vrai)
1568: {
1569: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1570: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1571: {
1572: (*s_etat_processus).erreur_systeme = d_es_processus;
1573: return;
1574: }
1575: }
1576:
1577: if (argument_nom == d_faux)
1578: {
1579: liberation(s_etat_processus, s_objet_initial);
1580: }
1581:
1582: liberation(s_etat_processus, s_objet_dimensions);
1583: free(s_objet_redimensionne);
1584:
1585: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1586: return;
1587: }
1588: }
1589:
1590: /*
1591: --------------------------------------------------------------------------------
1592: Redimensionnement aboutissant à une matrice
1593: --------------------------------------------------------------------------------
1594: */
1595:
1596: else
1597: {
1598: if ((*s_objet_initial).type == VIN)
1599: {
1600: (*s_objet_redimensionne).type = MIN;
1601:
1602: if (((*s_objet_redimensionne).objet =
1603: malloc(sizeof(struct_matrice))) == NULL)
1604: {
1605: if (variable_partagee == d_vrai)
1606: {
1607: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1608: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1609: {
1610: (*s_etat_processus).erreur_systeme = d_es_processus;
1611: return;
1612: }
1613: }
1614:
1615: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1616: return;
1617: }
1618:
1619: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'I';
1620: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1621: .nombre_lignes = nombre_lignes;
1622: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1623: .nombre_colonnes = nombre_colonnes;
1624:
1625: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
1.49 bertrand 1626: = malloc(((size_t) nombre_lignes) * sizeof(integer8 *)))
1.1 bertrand 1627: == NULL)
1628: {
1629: if (variable_partagee == d_vrai)
1630: {
1631: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1632: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1633: {
1634: (*s_etat_processus).erreur_systeme = d_es_processus;
1635: return;
1636: }
1637: }
1638:
1639: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1640: return;
1641: }
1642:
1643: for(i = 0, k = 0; i < nombre_lignes; i++)
1644: {
1645: if ((((integer8 **) (*((struct_matrice *)
1646: (*s_objet_redimensionne).objet)).tableau)[i] =
1.49 bertrand 1647: malloc(((size_t) nombre_colonnes) * sizeof(integer8)))
1648: == NULL)
1.1 bertrand 1649: {
1650: if (variable_partagee == d_vrai)
1651: {
1652: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1653: .pointeur_variable_partagee_courante).mutex))
1654: != 0)
1.1 bertrand 1655: {
1656: (*s_etat_processus).erreur_systeme = d_es_processus;
1657: return;
1658: }
1659: }
1660:
1661: (*s_etat_processus).erreur_systeme =
1662: d_es_allocation_memoire;
1663: return;
1664: }
1665:
1666: for(j = 0; j < nombre_colonnes; j++)
1667: {
1668: if (k < (*((struct_vecteur *) (*s_objet_initial)
1669: .objet)).taille)
1670: {
1671: ((integer8 **) (*((struct_matrice *)
1672: (*s_objet_redimensionne).objet)).tableau)
1673: [i][j] = ((integer8 *) (*((struct_vecteur *)
1674: (*s_objet_initial).objet)).tableau)[k++];
1675: }
1676: else
1677: {
1678: ((integer8 **) (*((struct_matrice *)
1679: (*s_objet_redimensionne).objet)).tableau)
1680: [i][j] = 0;
1681: }
1682: }
1683: }
1684: }
1685: else if ((*s_objet_initial).type == VRL)
1686: {
1687: (*s_objet_redimensionne).type = MRL;
1688:
1689: if (((*s_objet_redimensionne).objet =
1690: malloc(sizeof(struct_matrice))) == NULL)
1691: {
1692: if (variable_partagee == d_vrai)
1693: {
1694: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1695: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1696: {
1697: (*s_etat_processus).erreur_systeme = d_es_processus;
1698: return;
1699: }
1700: }
1701:
1702: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1703: return;
1704: }
1705:
1706: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'R';
1707: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1708: .nombre_lignes = nombre_lignes;
1709: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1710: .nombre_colonnes = nombre_colonnes;
1711:
1712: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
1.49 bertrand 1713: = malloc(((size_t) nombre_lignes) * sizeof(real8 *)))
1.1 bertrand 1714: == NULL)
1715: {
1716: if (variable_partagee == d_vrai)
1717: {
1718: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1719: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1720: {
1721: (*s_etat_processus).erreur_systeme = d_es_processus;
1722: return;
1723: }
1724: }
1725:
1726: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1727: return;
1728: }
1729:
1730: for(i = 0, k = 0; i < nombre_lignes; i++)
1731: {
1732: if ((((real8 **) (*((struct_matrice *)
1733: (*s_objet_redimensionne).objet)).tableau)[i] =
1.49 bertrand 1734: malloc(((size_t) nombre_colonnes) * sizeof(real8)))
1735: == NULL)
1.1 bertrand 1736: {
1737: if (variable_partagee == d_vrai)
1738: {
1739: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1740: .pointeur_variable_partagee_courante).mutex))
1741: != 0)
1.1 bertrand 1742: {
1743: (*s_etat_processus).erreur_systeme = d_es_processus;
1744: return;
1745: }
1746: }
1747:
1748: (*s_etat_processus).erreur_systeme =
1749: d_es_allocation_memoire;
1750: return;
1751: }
1752:
1753: for(j = 0; j < nombre_colonnes; j++)
1754: {
1755: if (k < (*((struct_vecteur *) (*s_objet_initial)
1756: .objet)).taille)
1757: {
1758: ((real8 **) (*((struct_matrice *)
1759: (*s_objet_redimensionne).objet)).tableau)
1760: [i][j] = ((real8 *) (*((struct_vecteur *)
1761: (*s_objet_initial).objet)).tableau)[k++];
1762: }
1763: else
1764: {
1765: ((real8 **) (*((struct_matrice *)
1766: (*s_objet_redimensionne).objet)).tableau)
1767: [i][j] = (real8) 0;
1768: }
1769: }
1770: }
1771: }
1772: else if ((*s_objet_initial).type == VCX)
1773: {
1774: (*s_objet_redimensionne).type = MCX;
1775:
1776: if (((*s_objet_redimensionne).objet =
1777: malloc(sizeof(struct_matrice))) == NULL)
1778: {
1779: if (variable_partagee == d_vrai)
1780: {
1781: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1782: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1783: {
1784: (*s_etat_processus).erreur_systeme = d_es_processus;
1785: return;
1786: }
1787: }
1788:
1789: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1790: return;
1791: }
1792:
1793: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'C';
1794: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1795: .nombre_lignes = nombre_lignes;
1796: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1797: .nombre_colonnes = nombre_colonnes;
1798:
1799: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
1.49 bertrand 1800: = malloc(((size_t) nombre_lignes) *
1801: sizeof(struct_complexe16 *))) == NULL)
1.1 bertrand 1802: {
1803: if (variable_partagee == d_vrai)
1804: {
1805: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1806: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1807: {
1808: (*s_etat_processus).erreur_systeme = d_es_processus;
1809: return;
1810: }
1811: }
1812:
1813: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1814: return;
1815: }
1816:
1817: for(i = 0, k = 0; i < nombre_lignes; i++)
1818: {
1819: if ((((struct_complexe16 **) (*((struct_matrice *)
1820: (*s_objet_redimensionne).objet)).tableau)[i] =
1.49 bertrand 1821: malloc(((size_t) nombre_colonnes) *
1.1 bertrand 1822: sizeof(struct_complexe16))) == NULL)
1823: {
1824: if (variable_partagee == d_vrai)
1825: {
1826: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1827: .pointeur_variable_partagee_courante).mutex))
1828: != 0)
1.1 bertrand 1829: {
1830: (*s_etat_processus).erreur_systeme = d_es_processus;
1831: return;
1832: }
1833: }
1834:
1835: (*s_etat_processus).erreur_systeme =
1836: d_es_allocation_memoire;
1837: return;
1838: }
1839:
1840: for(j = 0; j < nombre_colonnes; j++)
1841: {
1842: if (k < (*((struct_vecteur *) (*s_objet_initial)
1843: .objet)).taille)
1844: {
1845: ((struct_complexe16 **) (*((struct_matrice *)
1846: (*s_objet_redimensionne).objet)).tableau)
1847: [i][j].partie_reelle =
1848: ((struct_complexe16 *) (*((struct_vecteur *)
1849: (*s_objet_initial).objet)).tableau)[k]
1850: .partie_reelle;
1851: ((struct_complexe16 **) (*((struct_matrice *)
1852: (*s_objet_redimensionne).objet)).tableau)
1853: [i][j].partie_imaginaire =
1854: ((struct_complexe16 *) (*((struct_vecteur *)
1855: (*s_objet_initial).objet)).tableau)[k++]
1856: .partie_imaginaire;
1857: }
1858: else
1859: {
1860: ((struct_complexe16 **) (*((struct_matrice *)
1861: (*s_objet_redimensionne).objet)).tableau)
1862: [i][j].partie_reelle = (real8) 0;
1863: ((struct_complexe16 **) (*((struct_matrice *)
1864: (*s_objet_redimensionne).objet)).tableau)
1865: [i][j].partie_imaginaire = (real8) 0;
1866: }
1867: }
1868: }
1869: }
1870: else if ((*s_objet_initial).type == MIN)
1871: {
1872: (*s_objet_redimensionne).type = MIN;
1873:
1874: if (((*s_objet_redimensionne).objet =
1875: malloc(sizeof(struct_matrice))) == NULL)
1876: {
1877: if (variable_partagee == d_vrai)
1878: {
1879: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1880: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1881: {
1882: (*s_etat_processus).erreur_systeme = d_es_processus;
1883: return;
1884: }
1885: }
1886:
1887: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1888: return;
1889: }
1890:
1891: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'I';
1892: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1893: .nombre_lignes = nombre_lignes;
1894: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1895: .nombre_colonnes = nombre_colonnes;
1896:
1897: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
1.49 bertrand 1898: = malloc(((size_t) nombre_lignes) * sizeof(integer8 *)))
1.1 bertrand 1899: == NULL)
1900: {
1901: if (variable_partagee == d_vrai)
1902: {
1903: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1904: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1905: {
1906: (*s_etat_processus).erreur_systeme = d_es_processus;
1907: return;
1908: }
1909: }
1910:
1911: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1912: return;
1913: }
1914:
1915: drapeau_fin_objet_originel = d_faux;
1916:
1917: for(i = 0, k = 0, l = 0; i < nombre_lignes; i++)
1918: {
1919: if ((((integer8 **) (*((struct_matrice *)
1920: (*s_objet_redimensionne).objet)).tableau)[i] =
1.49 bertrand 1921: malloc(((size_t) nombre_colonnes) *
1.1 bertrand 1922: sizeof(integer8))) == NULL)
1923: {
1924: if (variable_partagee == d_vrai)
1925: {
1926: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1927: .pointeur_variable_partagee_courante).mutex))
1928: != 0)
1.1 bertrand 1929: {
1930: (*s_etat_processus).erreur_systeme = d_es_processus;
1931: return;
1932: }
1933: }
1934:
1935: (*s_etat_processus).erreur_systeme =
1936: d_es_allocation_memoire;
1937: return;
1938: }
1939:
1940: for(j = 0; j < nombre_colonnes; j++)
1941: {
1942: if (drapeau_fin_objet_originel == d_faux)
1943: {
1944: ((integer8 **) (*((struct_matrice *)
1945: (*s_objet_redimensionne).objet)).tableau)
1946: [i][j] = ((integer8 **) (*((struct_matrice *)
1947: (*s_objet_initial).objet)).tableau)[k][l];
1948:
1949: if ((++l) >= (*((struct_matrice *) (*s_objet_initial)
1950: .objet)).nombre_colonnes)
1951: {
1952: l = 0;
1953:
1954: if ((++k) >= (*((struct_matrice *)
1955: (*s_objet_initial).objet)).nombre_lignes)
1956: {
1957: drapeau_fin_objet_originel = d_vrai;
1958: }
1959: }
1960: }
1961: else
1962: {
1963: ((integer8 **) (*((struct_matrice *)
1964: (*s_objet_redimensionne).objet)).tableau)
1965: [i][j] = 0;
1966: }
1967: }
1968: }
1969: }
1970: else if ((*s_objet_initial).type == MRL)
1971: {
1972: (*s_objet_redimensionne).type = MRL;
1973:
1974: if (((*s_objet_redimensionne).objet =
1975: malloc(sizeof(struct_matrice))) == NULL)
1976: {
1977: if (variable_partagee == d_vrai)
1978: {
1979: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 1980: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 1981: {
1982: (*s_etat_processus).erreur_systeme = d_es_processus;
1983: return;
1984: }
1985: }
1986:
1987: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1988: return;
1989: }
1990:
1991: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'R';
1992: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1993: .nombre_lignes = nombre_lignes;
1994: (*((struct_matrice *) (*s_objet_redimensionne).objet))
1995: .nombre_colonnes = nombre_colonnes;
1996:
1997: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
1.49 bertrand 1998: = malloc(((size_t) nombre_lignes) * sizeof(real8 *)))
1.1 bertrand 1999: == NULL)
2000: {
2001: if (variable_partagee == d_vrai)
2002: {
2003: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2004: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 2005: {
2006: (*s_etat_processus).erreur_systeme = d_es_processus;
2007: return;
2008: }
2009: }
2010:
2011: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2012: return;
2013: }
2014:
2015: drapeau_fin_objet_originel = d_faux;
2016:
2017: for(i = 0, k = 0, l = 0; i < nombre_lignes; i++)
2018: {
2019: if ((((real8 **) (*((struct_matrice *)
2020: (*s_objet_redimensionne).objet)).tableau)[i] =
1.49 bertrand 2021: malloc(((size_t) nombre_colonnes) *
1.1 bertrand 2022: sizeof(real8))) == NULL)
2023: {
2024: if (variable_partagee == d_vrai)
2025: {
2026: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2027: .pointeur_variable_partagee_courante).mutex))
2028: != 0)
1.1 bertrand 2029: {
2030: (*s_etat_processus).erreur_systeme = d_es_processus;
2031: return;
2032: }
2033: }
2034:
2035: (*s_etat_processus).erreur_systeme =
2036: d_es_allocation_memoire;
2037: return;
2038: }
2039:
2040: for(j = 0; j < nombre_colonnes; j++)
2041: {
2042: if (drapeau_fin_objet_originel == d_faux)
2043: {
2044: ((real8 **) (*((struct_matrice *)
2045: (*s_objet_redimensionne).objet)).tableau)
2046: [i][j] = ((real8 **) (*((struct_matrice *)
2047: (*s_objet_initial).objet)).tableau)[k][l];
2048:
2049: if ((++l) >= (*((struct_matrice *) (*s_objet_initial)
2050: .objet)).nombre_colonnes)
2051: {
2052: l = 0;
2053:
2054: if ((++k) >= (*((struct_matrice *)
2055: (*s_objet_initial).objet)).nombre_lignes)
2056: {
2057: drapeau_fin_objet_originel = d_vrai;
2058: }
2059: }
2060: }
2061: else
2062: {
2063: ((real8 **) (*((struct_matrice *)
2064: (*s_objet_redimensionne).objet)).tableau)
2065: [i][j] = (real8) 0;
2066: }
2067: }
2068: }
2069: }
2070: else if ((*s_objet_initial).type == MCX)
2071: {
2072: (*s_objet_redimensionne).type = MCX;
2073:
2074: if (((*s_objet_redimensionne).objet =
2075: malloc(sizeof(struct_matrice))) == NULL)
2076: {
2077: if (variable_partagee == d_vrai)
2078: {
2079: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2080: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 2081: {
2082: (*s_etat_processus).erreur_systeme = d_es_processus;
2083: return;
2084: }
2085: }
2086:
2087: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2088: return;
2089: }
2090:
2091: (*((struct_matrice *) (*s_objet_redimensionne).objet)).type = 'C';
2092: (*((struct_matrice *) (*s_objet_redimensionne).objet))
2093: .nombre_lignes = nombre_lignes;
2094: (*((struct_matrice *) (*s_objet_redimensionne).objet))
2095: .nombre_colonnes = nombre_colonnes;
2096:
2097: if (((*((struct_matrice *) (*s_objet_redimensionne).objet)).tableau
1.49 bertrand 2098: = malloc(((size_t) nombre_lignes)
2099: * sizeof(struct_complexe16 *))) == NULL)
1.1 bertrand 2100: {
2101: if (variable_partagee == d_vrai)
2102: {
2103: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2104: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 2105: {
2106: (*s_etat_processus).erreur_systeme = d_es_processus;
2107: return;
2108: }
2109: }
2110:
2111: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2112: return;
2113: }
2114:
2115: drapeau_fin_objet_originel = d_faux;
2116:
2117: for(i = 0, k = 0, l = 0; i < nombre_lignes; i++)
2118: {
2119: if ((((struct_complexe16 **) (*((struct_matrice *)
2120: (*s_objet_redimensionne).objet)).tableau)[i] =
1.49 bertrand 2121: malloc(((size_t) nombre_colonnes) *
1.1 bertrand 2122: sizeof(struct_complexe16))) == NULL)
2123: {
2124: if (variable_partagee == d_vrai)
2125: {
2126: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2127: .pointeur_variable_partagee_courante).mutex))
2128: != 0)
1.1 bertrand 2129: {
2130: (*s_etat_processus).erreur_systeme = d_es_processus;
2131: return;
2132: }
2133: }
2134:
2135: (*s_etat_processus).erreur_systeme =
2136: d_es_allocation_memoire;
2137: return;
2138: }
2139:
2140: for(j = 0; j < nombre_colonnes; j++)
2141: {
2142: if (drapeau_fin_objet_originel == d_faux)
2143: {
2144: ((struct_complexe16 **) (*((struct_matrice *)
2145: (*s_objet_redimensionne).objet)).tableau)
2146: [i][j].partie_reelle = ((struct_complexe16 **)
2147: (*((struct_matrice *) (*s_objet_initial).objet))
2148: .tableau)[k][l].partie_reelle;
2149:
2150: ((struct_complexe16 **) (*((struct_matrice *)
2151: (*s_objet_redimensionne).objet)).tableau)
2152: [i][j].partie_imaginaire =
2153: ((struct_complexe16 **) (*((struct_matrice *)
2154: (*s_objet_initial).objet)).tableau)[k][l]
2155: .partie_imaginaire;
2156:
2157: if ((++l) >= (*((struct_matrice *) (*s_objet_initial)
2158: .objet)).nombre_colonnes)
2159: {
2160: l = 0;
2161:
2162: if ((++k) >= (*((struct_matrice *)
2163: (*s_objet_initial).objet)).nombre_lignes)
2164: {
2165: drapeau_fin_objet_originel = d_vrai;
2166: }
2167: }
2168: }
2169: else
2170: {
2171: ((struct_complexe16 **) (*((struct_matrice *)
2172: (*s_objet_redimensionne).objet)).tableau)
2173: [i][j].partie_reelle = (real8) 0;
2174: ((struct_complexe16 **) (*((struct_matrice *)
2175: (*s_objet_redimensionne).objet)).tableau)
2176: [i][j].partie_imaginaire = (real8) 0;
2177: }
2178: }
2179: }
2180: }
2181: else
2182: {
2183: if (variable_partagee == d_vrai)
2184: {
2185: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2186: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 2187: {
2188: (*s_etat_processus).erreur_systeme = d_es_processus;
2189: return;
2190: }
2191: }
2192:
2193: if (argument_nom == d_faux)
2194: {
2195: liberation(s_etat_processus, s_objet_initial);
2196: }
2197:
2198: liberation(s_etat_processus, s_objet_dimensions);
2199: free(s_objet_redimensionne);
2200:
2201: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
2202: return;
2203: }
2204: }
2205:
2206: liberation(s_etat_processus, s_objet_dimensions);
2207: liberation(s_etat_processus, s_objet_initial);
2208:
2209: if (argument_nom == d_faux)
2210: {
2211: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2212: s_objet_redimensionne) == d_erreur)
2213: {
2214: return;
2215: }
2216: }
2217: else
2218: {
2219: if (variable_partagee == d_vrai)
2220: {
1.43 bertrand 2221: (*(*s_etat_processus).pointeur_variable_partagee_courante).objet =
2222: s_objet_redimensionne;
1.1 bertrand 2223:
2224: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1.43 bertrand 2225: .pointeur_variable_partagee_courante).mutex)) != 0)
1.1 bertrand 2226: {
2227: (*s_etat_processus).erreur_systeme = d_es_processus;
2228: return;
2229: }
2230: }
2231: else
2232: {
1.21 bertrand 2233: (*(*s_etat_processus).pointeur_variable_courante).objet =
1.1 bertrand 2234: s_objet_redimensionne;
2235: }
2236: }
2237:
2238: return;
2239: }
2240:
2241: // vim: ts=4