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

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/tendra5-amd64/src/installers/680x0/common/glopt.c – Rev 6

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