Subversion Repositories tendra.SVN

Rev

Rev 2 | Details | Compare with Previous | 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
/**********************************************************************
32
$Author: release $
33
$Date: 1998/01/17 15:56:05 $
34
$Revision: 1.1.1.1 $
35
$Log: glopt.c,v $
36
 * Revision 1.1.1.1  1998/01/17  15:56:05  release
37
 * First version to be checked into rolling release.
38
 *
39
 * Revision 1.4  1995/09/12  10:59:22  currie
40
 * gcc pedanttry
41
 *
42
 * Revision 1.3  1995/08/16  16:06:39  currie
43
 * Shortened some .h names
44
 *
45
 * Revision 1.2  1995/08/09  10:53:37  currie
46
 * apply_general bug
47
 *
48
 * Revision 1.1  1995/04/13  09:08:06  currie
49
 * Initial revision
50
 *
51
***********************************************************************/
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
void glopt
73
    PROTO_N ( (dp) )
74
    PROTO_T ( dec * dp )
75
{
76
  if (!strcmp(dp -> dec_u.dec_val.dec_id, "strcpy"))
77
   {
78
     exp i = dp -> dec_u.dec_val.dec_exp;
79
     exp t = pt(i);
80
     if (t == nilexp)
81
       return;
82
 
83
     while (1)
84
      {
85
        if (!last(t) && !last(bro(t)) && last(bro(bro(t))) &&
86
            name(bro(bro(bro(t)))) == apply_tag &&
87
            son(bro(bro(bro(t)))) == t)
88
          {
89
            exp dest = bro(t);
90
            exp source = bro(dest);
91
 
92
            if (name(source) == name_tag && isglob(son(source)) &&
93
                isvar(son(source)) && no(son(source)) == 1)
94
              {
95
                dec * source_dec = brog(son(source));
96
                if (!source_dec -> dec_u.dec_val.extnamed &&
97
                    son(source_dec -> dec_u.dec_val.dec_exp) != nilexp)
98
                  {
99
                    exp source_def = son(son(source));
100
                    shape sha = sh(source_def);
101
                    if (name(source_def) == string_tag &&
102
                         props(source_def) == 8)
103
                     {
104
                       char * s = nostr(source_def);
105
                       int j;
106
                       int l = shape_size(sha) / 8;
107
                       for (j=0; j < l && s[j] != 0; ++j);
108
                       if (j < l)
109
                        {
110
	                   exp q;
111
                           exp to_change = bro(source);
112
	                   exp idsc = getexp(sh(bro(source)), nilexp, 0,
113
                                              dest, nilexp,
114
                                              0, 2, ident_tag);
115
	                   exp n1 = getexp(sh(dest), nilexp, 0, idsc,
116
                                             nilexp, 0, 0, name_tag);
117
	                   exp n2 = getexp(sh(dest), nilexp, 0, idsc, n1,
118
                                             0, 0, name_tag);
119
                           exp_list el;
120
 
121
                           pt(idsc) = n2;
122
 
123
                           q = f_assign(n1, f_contents(sha, source));
124
                           el.start = q;
125
                           el.end = q;
126
                           el.number = 1;
127
                           q = f_sequence(el, n2);
128
                           clearlast(dest);
129
                           bro(dest) = q;
130
                           setfather(idsc, q);
131
                           replace(to_change, idsc, idsc);
132
                           t = pt(i);
133
                        };
134
                     };
135
                  };
136
              };
137
          };
138
 
139
        if (pt(t) == nilexp)
140
          return;
141
        t = pt(t);
142
      };
143
   };
144
  return;
145
}