Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
 
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
Line 23... Line 53...
23
 
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
29
 
59
 
30
 
60
 
31
/**********************************************************************
61
/**********************************************************************
32
$Author: release $
62
$Author: release $
33
$Date: 1998/01/17 15:55:46 $
63
$Date: 1998/01/17 15:55:46 $
34
$Revision: 1.1.1.1 $
64
$Revision: 1.1.1.1 $
35
$Log: aldefs.c,v $
65
$Log: aldefs.c,v $
36
 * Revision 1.1.1.1  1998/01/17  15:55:46  release
66
 * Revision 1.1.1.1  1998/01/17  15:55:46  release
37
 * First version to be checked into rolling release.
67
 * First version to be checked into rolling release.
38
 *
68
 *
39
 * Revision 1.1  1995/04/06  10:44:05  currie
69
 * Revision 1.1  1995/04/06  10:44:05  currie
40
 * Initial revision
70
 * Initial revision
41
 *
71
 *
42
***********************************************************************/
72
***********************************************************************/
43
 
73
 
Line 49... Line 79...
49
#include "basicread.h"
79
#include "basicread.h"
50
#include "messages_c.h"
80
#include "messages_c.h"
51
 
81
 
52
#include "aldefs.h"
82
#include "aldefs.h"
53
 
83
 
54
#define max(x,y) ((x)>(y)) ? (x) : (y)
84
#define max(x, y)	((x) > (y)) ? (x) : (y)
55
 
85
 
56
 
86
 
57
/* The alignment definitions form a set of simultaneous equations
87
/* The alignment definitions form a set of simultaneous equations
58
   of the form
88
   of the form
59
 
89
 
Line 70... Line 100...
70
   no further change occurs. Unite_sets is represented here by max.
100
   no further change occurs. Unite_sets is represented here by max.
71
*/
101
*/
72
 
102
 
73
/* PROCEDURES */
103
/* PROCEDURES */
74
 
104
 
75
void process_aldefs
105
void
76
    PROTO_Z ()
106
process_aldefs(void)
77
{
107
{
78
  aldef * my_aldef;
108
	aldef *my_aldef;
79
  int changed; /* records whether a change has been made */
109
	int changed; /* records whether a change has been made */
80
  int complete;
110
	int complete;
81
 
-
 
82
 
111
 
83
  do  /* iterate max until no change */
112
	/* iterate max until no change */
84
   {
113
	do {
85
     my_aldef = top_aldef;
114
		my_aldef = top_aldef;
86
     changed = 0;
115
		changed = 0;
87
     complete = 1;
116
		complete = 1;
88
     while (my_aldef != (aldef *)0)
117
		while (my_aldef != (aldef *)0) {
89
      {
-
 
90
        switch (my_aldef -> al.al_n)
118
			switch (my_aldef->al.al_n) {
91
         {
-
 
92
           case 1: break;
119
			case 1: break;
93
           case 2: {
120
			case 2: {
94
                     alignment a1;
121
				alignment a1;
95
                     alignment a2;
122
				alignment a2;
96
                     a2 = my_aldef -> al.al_val.al_join.b;
123
				a2 = my_aldef->al.al_val.al_join.b;
97
                     a1 = my_aldef -> al.al_val.al_join.a;
124
				a1 = my_aldef->al.al_val.al_join.a;
98
                     if (a1->al.al_n == 1 && a2->al.al_n == 1)
125
				if (a1->al.al_n == 1 && a2->al.al_n == 1) {
99
                      {
-
 
100
                        my_aldef -> al.al_n = 1;
126
					my_aldef->al.al_n = 1;
101
                        my_aldef -> al.al_val.al =
127
					my_aldef->al.al_val.al =
102
                            max(a1->al.al_val.al, a2->al.al_val.al);
128
					    max(a1->al.al_val.al, a2->al.al_val.al);
103
                        changed = 1;
129
					changed = 1;
104
                      }
-
 
105
                     else
130
				} else {
106
                        complete = 0;
131
					complete = 0;
-
 
132
				}
107
                     break;
133
				break;
108
                   };
134
			}
109
	   case 3: {
135
			case 3: {
110
		     alignment a1;
136
				alignment a1;
111
                     a1 = my_aldef -> al.al_val.al_join.a;
137
				a1 = my_aldef->al.al_val.al_join.a;
112
                     if (a1->al.al_n == 1)
138
				if (a1->al.al_n == 1) {
113
                      {
-
 
114
                        my_aldef -> al.al_n = 1;
139
					my_aldef->al.al_n = 1;
115
                        my_aldef -> al.al_val.al = a1->al.al_val.al;
140
					my_aldef->al.al_val.al = a1->al.al_val.al;
116
                        changed = 1;
141
					changed = 1;
117
                      }
-
 
118
                     else
142
				} else {
119
                        complete = 0;
143
					complete = 0;
-
 
144
				}
120
                     break;
145
				break;
121
		   };
146
			}
-
 
147
			default:
122
           default: failer(ILLEGAL_ALIGNMENT);
148
				failer(ILLEGAL_ALIGNMENT);
123
         };
149
			}
124
        my_aldef = my_aldef -> next_aldef;
150
			my_aldef = my_aldef->next_aldef;
125
      };
151
		}
126
   } while (changed) ;
152
	} while (changed);
127
 
153
 
128
  if (!complete)
154
	if (!complete) {
129
    failer(INCOMPLETE_ALIGNMENT_EQS);
155
		failer(INCOMPLETE_ALIGNMENT_EQS);
-
 
156
	}
130
  return;
157
	return;
131
}
158
}