Subversion Repositories tendra.SVN

Rev

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

Rev 5 Rev 6
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 70... Line 100...
70
 
100
 
71
 
101
 
72
/* PROCEDURES */
102
/* PROCEDURES */
73
 
103
 
74
void glopt
104
void glopt
75
    PROTO_N ( (dp) )
-
 
76
    PROTO_T ( dec * dp )
105
(dec * dp)
77
{
106
{
78
  if (!writable_strings && !strcmp(dp -> dec_u.dec_val.dec_id, "strcpy"))
107
  if (!writable_strings && !strcmp(dp -> dec_u.dec_val.dec_id, "strcpy"))
79
   {
108
   {
80
     exp i = dp -> dec_u.dec_val.dec_exp;
109
     exp i = dp -> dec_u.dec_val.dec_exp;
81
     exp t = pt(i);
110
     exp t = pt(i);
Line 94... Line 123...
94
            if (name(source) == name_tag && isglob(son(source)) &&
123
            if (name(source) == name_tag && isglob(son(source)) &&
95
                isvar(son(source)) && no(son(source)) == 1)
124
                isvar(son(source)) && no(son(source)) == 1)
96
              {
125
              {
97
                dec * source_dec = brog(son(source));
126
                dec * source_dec = brog(son(source));
98
                if (!source_dec -> dec_u.dec_val.extnamed &&
127
                if (!source_dec -> dec_u.dec_val.extnamed &&
99
                    son(source_dec -> dec_u.dec_val.dec_exp) != nilexp)
128
                    son(source_dec -> dec_u.dec_val.dec_exp)!= nilexp)
100
                  {
129
                  {
101
                    exp source_def = son(son(source));
130
                    exp source_def = son(son(source));
102
                    shape sha = sh(source_def);
131
                    shape sha = sh(source_def);
103
                    if (name(source_def) == string_tag &&
132
                    if (name(source_def) == string_tag &&
104
                         props(source_def) == 8)
133
                         props(source_def) == 8)
105
                     {
134
                     {
106
                       char * s = nostr(source_def);
135
                       char * s = nostr(source_def);
107
                       int j;
136
                       int j;
108
                       int l = shape_size(sha) / 8;
137
                       int l = shape_size(sha) / 8;
109
                       for (j=0; j < l && s[j] != 0; ++j);
138
                       for (j=0; j < l && s[j]!= 0; ++j);
110
                       if (j < l)
139
                       if (j < l)
111
                        {
140
                        {
112
	                   exp q;
141
	                   exp q;
113
                           exp to_change = bro(source);
142
                           exp to_change = bro(source);
114
	                   exp idsc = getexp(sh(bro(source)), nilexp, 0,
143
	                   exp idsc = getexp(sh(bro(source)), nilexp, 0,
Line 164... Line 193...
164
            if (name(st) == name_tag && isglob(son(st)) &&
193
            if (name(st) == name_tag && isglob(son(st)) &&
165
                isvar(son(st)) && no(son(st)) == 1)
194
                isvar(son(st)) && no(son(st)) == 1)
166
              {
195
              {
167
                dec * source_dec = brog(son(st));
196
                dec * source_dec = brog(son(st));
168
                if (!source_dec -> dec_u.dec_val.extnamed &&
197
                if (!source_dec -> dec_u.dec_val.extnamed &&
169
                    son(source_dec -> dec_u.dec_val.dec_exp) != nilexp)
198
                    son(source_dec -> dec_u.dec_val.dec_exp)!= nilexp)
170
                  {
199
                  {
171
                    exp st_def = son(son(st));
200
                    exp st_def = son(son(st));
172
                    shape sha = sh(st_def);
201
                    shape sha = sh(st_def);
173
                    if (name(st_def) == string_tag &&
202
                    if (name(st_def) == string_tag &&
174
                         props(st_def) == 8)
203
                         props(st_def) == 8)
175
                     {
204
                     {
176
                       char * s = nostr(st_def);
205
                       char * s = nostr(st_def);
177
                       int j;
206
                       int j;
178
                       int l = shape_size(sha) / 8;
207
                       int l = shape_size(sha) / 8;
179
                       for (j=0; j < l && s[j] != 0; ++j);
208
                       for (j=0; j < l && s[j]!= 0; ++j);
180
                       if (j < l)
209
                       if (j < l)
181
                        {
210
                        {
182
                           exp to_change = bro(st);
211
                           exp to_change = bro(st);
183
                           exp res = getexp(sh(to_change), nilexp, 0,
212
                           exp res = getexp(sh(to_change), nilexp, 0,
184
                               nilexp, nilexp, 0, j, val_tag);
213
                               nilexp, nilexp, 0, j, val_tag);