Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1996
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
/*
30
			    VERSION INFORMATION
31
			    ===================
32
 
33
--------------------------------------------------------------------------
34
$Header: /u/g/release/CVSROOT/Source/src/installers/680x0/common/glopt.c,v 1.1.1.1 1998/01/17 15:55:49 release Exp $
35
--------------------------------------------------------------------------
36
$Log: glopt.c,v $
37
 * Revision 1.1.1.1  1998/01/17  15:55:49  release
38
 * First version to be checked into rolling release.
39
 *
40
Revision 1.1.1.1  1997/10/13 12:42:53  ma
41
First version.
42
 
43
Revision 1.1.1.1  1997/03/14 07:50:12  ma
44
Imported from DRA
45
 
46
 * Revision 1.2  1996/09/20  13:51:32  john
47
 * *** empty log message ***
48
 *
49
 * Revision 1.1.1.1  1996/09/20  10:56:54  john
50
 *
51
 * Revision 1.1.1.1  1996/03/26  15:45:11  john
52
 *
53
 * Revision 1.2  93/04/19  13:34:06  13:34:06  ra (Robert Andrews)
54
 * lint-like corrections.
55
 *
56
 * Revision 1.1  93/02/22  17:15:45  17:15:45  ra (Robert Andrews)
57
 * Initial revision
58
 *
59
--------------------------------------------------------------------------
60
*/
61
 
62
 
63
 
64
 
65
#include "config.h"
66
#include "common_types.h"
67
#include "tags.h"
68
#include "externs.h"
69
#include "expmacs.h"
70
#include "shapemacs.h"
71
#include "exp.h"
72
#include "basicread.h"
73
#include "flags.h"
74
#include "table_fns.h"
75
#include "installglob.h"
76
#include "check.h"
77
#include "glopt.h"
78
 
79
 
80
void glopt
81
    PROTO_N ( (dp) )
82
    PROTO_T ( dec * dp )
83
{
84
  if (!writable_strings && !strcmp(dp -> dec_u.dec_val.dec_id, "_strcpy"))
85
   {
86
     exp i = dp -> dec_u.dec_val.dec_exp;
87
     exp t = pt(i);
88
     if (t == nilexp)
89
       return;
90
 
91
     while (1)
92
      {
93
        if (!last(t) && !last(bro(t)) && last(bro(bro(t))) &&
94
            name(bro(bro(bro(t)))) == apply_tag &&
95
            son(bro(bro(bro(t)))) == t)
96
          {
97
            exp dest = bro(t);
98
            exp source = bro(dest);
99
 
100
            if (name(source) == name_tag && isglob(son(source)) &&
101
                isvar(son(source)) && no(son(source)) == 1)
102
              {
103
                dec * source_dec = brog(son(source));
104
                if (!source_dec -> dec_u.dec_val.extnamed &&
105
                    son(source_dec -> dec_u.dec_val.dec_exp) != nilexp)
106
                  {
107
                    exp source_def = son(son(source));
108
                    shape sha = sh(source_def);
109
                    if (name(source_def) == string_tag &&
110
                         ptno(source_def) == 8)
111
                     {
112
                       char * s = nostr(source_def);
113
                       long n, j;
114
                       int l = shape_size(sha) / 8;
115
                       for (j=0; j < l && s[j] != 0; ++j);
116
                       if (j < l)
117
                        {
118
	                   exp q;
119
                           exp to_change = bro(source);
120
	                   exp idsc = getexp(sh(bro(source)), nilexp, 0,
121
                                              dest, nilexp,
122
                                              0, 2, ident_tag);
123
	                   exp n1 = getexp(sh(dest), nilexp, 0, idsc,
124
                                             nilexp, 0, 0, name_tag);
125
	                   exp n2 = getexp(sh(dest), nilexp, 0, idsc, n1,
126
                                             0, 0, name_tag);
127
                           exp_list el;
128
 
129
                           pt(idsc) = n2;
130
 
131
                           q = f_assign(n1, f_contents(sha, source));
132
                           el.start = q;
133
                           el.end = q;
134
                           el.number = 1;
135
                           q = f_sequence(el, n2);
136
                           clearlast(dest);
137
                           bro(dest) = q;
138
                           setfather(idsc, q);
139
                           kill_exp(t, t);
140
                           replace(to_change, idsc, idsc);
141
                           t = i;
142
                        };
143
                     };
144
                  };
145
              };
146
          };
147
 
148
        if (pt(t) == nilexp)
149
          return;
150
        t = pt(t);
151
      };
152
   };
153
 
154
  if (!writable_strings && !strcmp(dp -> dec_u.dec_val.dec_id, "_strlen"))
155
   {
156
     exp i = dp -> dec_u.dec_val.dec_exp;
157
     exp t = pt(i);
158
     if (t == nilexp)
159
       return;
160
 
161
     while (1)
162
      {
163
        if (!last(t) && last(bro(t)) &&
164
            name(bro(bro(t))) == apply_tag &&
165
            son(bro(bro(t))) == t)
166
          {
167
            exp st = bro(t);
168
 
169
            if (name(st) == name_tag && isglob(son(st)) &&
170
                isvar(son(st)) && no(son(st)) == 1)
171
              {
172
                dec * source_dec = brog(son(st));
173
                if (!source_dec -> dec_u.dec_val.extnamed &&
174
                    son(source_dec -> dec_u.dec_val.dec_exp) != nilexp)
175
                  {
176
                    exp st_def = son(son(st));
177
                    shape sha = sh(st_def);
178
                    if (name(st_def) == string_tag &&
179
                         ptno(st_def) == 8)
180
                     {
181
                       char * s = nostr(st_def);
182
                       long n, j;
183
                       int l = shape_size(sha) / 8;
184
                       for (j=0; j < l && s[j] != 0; ++j);
185
                       if (j < l)
186
                        {
187
                           exp to_change = bro(st);
188
                           exp res = getexp(sh(to_change), nilexp, 0,
189
                               nilexp, nilexp, 0, j, val_tag);
190
                           kill_exp(t, t);
191
                           replace(to_change, res, nilexp);
192
                           t = i;
193
                        };
194
                     };
195
                  };
196
              };
197
          };
198
 
199
        if (pt(t) == nilexp)
200
          return;
201
        t = pt(t);
202
      };
203
   };
204
 
205
 
206
 
207
  return;
208
}