Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra4/src/installers/80x86/common/glopt.c – Rev 2

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) 1997
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
 
31
/* 80x86/glopt.c */
32
 
33
/**********************************************************************
34
$Author: release $
35
$Date: 1998/01/17 15:55:51 $
36
$Revision: 1.1.1.1 $
37
$Log: glopt.c,v $
38
 * Revision 1.1.1.1  1998/01/17  15:55:51  release
39
 * First version to be checked into rolling release.
40
 *
41
 * Revision 1.3  1996/01/17  11:24:28  pwe
42
 * resurrect performance
43
 *
44
 * Revision 1.2  1995/01/30  12:56:13  pwe
45
 * Ownership -> PWE, tidy banners
46
 *
47
 * Revision 1.1  1994/10/27  14:15:22  jmf
48
 * Initial revision
49
 *
50
 * Revision 1.1  1994/07/12  14:32:29  jmf
51
 * Initial revision
52
 *
53
**********************************************************************/
54
 
55
 
56
 
57
#include "config.h"
58
#include "common_types.h"
59
#include "tags.h"
60
#include "externs.h"
61
#include "expmacs.h"
62
#include "shapemacs.h"
63
#include "exp.h"
64
#include "basicread.h"
65
#include "flags.h"
66
#include "table_fns.h"
67
#include "installglob.h"
68
#include "check.h"
69
#include "glopt.h"
70
 
71
 
72
/* PROCEDURES */
73
 
74
void glopt
75
    PROTO_N ( (dp) )
76
    PROTO_T ( dec * dp )
77
{
78
  if (!writable_strings && !strcmp(dp -> dec_u.dec_val.dec_id, "strcpy"))
79
   {
80
     exp i = dp -> dec_u.dec_val.dec_exp;
81
     exp t = pt(i);
82
     if (t == nilexp)
83
       return;
84
 
85
     while (1)
86
      {
87
        if (!last(t) && !last(bro(t)) && last(bro(bro(t))) &&
88
            name(bro(bro(bro(t)))) == apply_tag &&
89
            son(bro(bro(bro(t)))) == t)
90
          {
91
            exp dest = bro(t);
92
            exp source = bro(dest);
93
 
94
            if (name(source) == name_tag && isglob(son(source)) &&
95
                isvar(son(source)) && no(son(source)) == 1)
96
              {
97
                dec * source_dec = brog(son(source));
98
                if (!source_dec -> dec_u.dec_val.extnamed &&
99
                    son(source_dec -> dec_u.dec_val.dec_exp) != nilexp)
100
                  {
101
                    exp source_def = son(son(source));
102
                    shape sha = sh(source_def);
103
                    if (name(source_def) == string_tag &&
104
                         props(source_def) == 8)
105
                     {
106
                       char * s = nostr(source_def);
107
                       int j;
108
                       int l = shape_size(sha) / 8;
109
                       for (j=0; j < l && s[j] != 0; ++j);
110
                       if (j < l)
111
                        {
112
	                   exp q;
113
                           exp to_change = bro(source);
114
	                   exp idsc = getexp(sh(bro(source)), nilexp, 0,
115
                                              dest, nilexp,
116
                                              0, 2, ident_tag);
117
	                   exp n1 = getexp(sh(dest), nilexp, 0, idsc,
118
                                             nilexp, 0, 0,
119
						 name_tag);
120
	                   exp n2 = getexp(sh(dest), nilexp, 0, idsc, n1,
121
                                             0, 0, name_tag);
122
                           exp_list el;
123
 
124
                           pt(idsc) = n2;
125
 
126
                           q = f_assign(n1, f_contents(sha, source));
127
                           el.start = q;
128
                           el.end = q;
129
                           el.number = 1;
130
                           q = f_sequence(el, n2);
131
                           clearlast(dest);
132
                           bro(dest) = q;
133
                           setfather(idsc, q);
134
                           kill_exp(t, t);
135
                           replace(to_change, idsc, idsc);
136
                           t = i;
137
                        };
138
                     };
139
                  };
140
              };
141
          };
142
 
143
        if (pt(t) == nilexp)
144
          return;
145
        t = pt(t);
146
      };
147
   };
148
 
149
  if (!writable_strings && !strcmp(dp -> dec_u.dec_val.dec_id, "strlen"))
150
   {
151
     exp i = dp -> dec_u.dec_val.dec_exp;
152
     exp t = pt(i);
153
     if (t == nilexp)
154
       return;
155
 
156
     while (1)
157
      {
158
        if (!last(t) && last(bro(t)) &&
159
            name(bro(bro(t))) == apply_tag &&
160
            son(bro(bro(t))) == t)
161
          {
162
            exp st = bro(t);
163
 
164
            if (name(st) == name_tag && isglob(son(st)) &&
165
                isvar(son(st)) && no(son(st)) == 1)
166
              {
167
                dec * source_dec = brog(son(st));
168
                if (!source_dec -> dec_u.dec_val.extnamed &&
169
                    son(source_dec -> dec_u.dec_val.dec_exp) != nilexp)
170
                  {
171
                    exp st_def = son(son(st));
172
                    shape sha = sh(st_def);
173
                    if (name(st_def) == string_tag &&
174
                         props(st_def) == 8)
175
                     {
176
                       char * s = nostr(st_def);
177
                       int j;
178
                       int l = shape_size(sha) / 8;
179
                       for (j=0; j < l && s[j] != 0; ++j);
180
                       if (j < l)
181
                        {
182
                           exp to_change = bro(st);
183
                           exp res = getexp(sh(to_change), nilexp, 0,
184
                               nilexp, nilexp, 0, j, val_tag);
185
                           kill_exp(t, t);
186
                           replace(to_change, res, nilexp);
187
                           t = i;
188
                        };
189
                     };
190
                  };
191
              };
192
          };
193
 
194
        if (pt(t) == nilexp)
195
          return;
196
        t = pt(t);
197
      };
198
   };
199
 
200
 
201
 
202
  return;
203
}