9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# Copyright (C) 2000 by Peter J. Gawthrop
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.15 2000/10/17 09:53:05 peterg
## More on logic rep
##
## Revision 1.14 2000/10/17 08:36:56 peterg
## Included logic rep.
##
## Revision 1.13 2000/10/15 09:27:13 peterg
|
>
>
>
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# Copyright (C) 2000 by Peter J. Gawthrop
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.16 2000/10/17 13:45:18 peterg
## split up state and input - different defaults
##
## Revision 1.15 2000/10/17 09:53:05 peterg
## More on logic rep
##
## Revision 1.14 2000/10/17 08:36:56 peterg
## Included logic rep.
##
## Revision 1.13 2000/10/15 09:27:13 peterg
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
default='1.0'
;;
input)
lang=txt
textfile=$1_$2.$lang
infofile=mtt_list.$lang
moreinfofile=mtt_list_numpar.$lang
awk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
<$1_struc.txt >$infofile
cat $infofile $1_sympar.$lang> $moreinfofile
default='1.0'
;;
state)
lang=txt
textfile=$1_$2.$lang
infofile=mtt_list.$lang
moreinfofile=mtt_list_numpar.$lang
awk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
<$1_struc.txt >$infofile
cat $infofile $1_sympar.$lang> $moreinfofile
default='0.0'
;;
logic)
lang=txt
textfile=$1_$2.$lang
infofile=mtt_list.$lang
moreinfofile=mtt_list_numpar.$lang
awk '{if ($3=="MTT_SWITCH") printf("%s_logic\n", $4)}' rep=$2 \
<$1_struc.txt >$infofile
cat $infofile $1_sympar.$lang> $moreinfofile
default='1.0'
;;
*)
echo Representation $rep not implemented
exit
esac
# Create a string containing the variables
if [ -f "$textfile" ]; then
# Inform User
echo Checking $textfile
else
echo Creating $textfile
mtt_header $sys $rep $lang > $textfile
info=`cut -f1 $infofile | sort`
for new in $info; do
echo $new $default |\
awk '{printf("%s\t= %s; # Default\n",$1,$2)}' >> $textfile
done
exit
fi
# Remove tmp files
rm -f mtt_in_text mtt_in_info
# Strip files
strip_comments <$textfile | tr 'A-Z' 'a-z' >mtt_text
strip_comments <$infofile | tr 'A-Z' 'a-z' >mtt_info
strip_comments <$moreinfofile | tr 'A-Z' 'a-z' >mtt_moreinfo
# Use awk to check file
awk '{
if (FILENAME=="mtt_text") {
gsub("[\t ]" ,""); # Remove whitespace
split($0,a,"=");
text[a[1]] = a[2];
}
if (FILENAME=="mtt_info"){
info[$1] = default;
|
|
|
|
|
|
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
default='1.0'
;;
input)
lang=txt
textfile=$1_$2.$lang
infofile=mtt_list.$lang
moreinfofile=mtt_list_numpar.$lang
gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
<$1_struc.txt >$infofile
cat $infofile $1_sympar.$lang> $moreinfofile
default='1.0'
;;
state)
lang=txt
textfile=$1_$2.$lang
infofile=mtt_list.$lang
moreinfofile=mtt_list_numpar.$lang
gawk '{if ($1==rep) printf("%s\n", $4)}' rep=$2 \
<$1_struc.txt >$infofile
cat $infofile $1_sympar.$lang> $moreinfofile
default='0.0'
;;
logic)
lang=txt
textfile=$1_$2.$lang
infofile=mtt_list.$lang
moreinfofile=mtt_list_numpar.$lang
gawk '{if ($3=="MTT_SWITCH") printf("%s_logic\n", $4)}' rep=$2 \
<$1_struc.txt >$infofile
cat $infofile $1_sympar.$lang> $moreinfofile
default='1.0'
;;
*)
echo Representation $rep not implemented
exit
esac
# Create a string containing the variables
if [ -f "$textfile" ]; then
# Inform User
echo Checking $textfile
else
echo Creating $textfile
mtt_header $sys $rep $lang > $textfile
info=`cut -f1 $infofile | sort`
for new in $info; do
echo $new $default |\
gawk '{printf("%s\t= %s; # Default\n",$1,$2)}' >> $textfile
done
exit
fi
# Remove tmp files
rm -f mtt_in_text mtt_in_info
# Strip files
strip_comments <$textfile | tr 'A-Z' 'a-z' >mtt_text
strip_comments <$infofile | tr 'A-Z' 'a-z' >mtt_info
strip_comments <$moreinfofile | tr 'A-Z' 'a-z' >mtt_moreinfo
# Use awk to check file
gawk '{
if (FILENAME=="mtt_text") {
gsub("[\t ]" ,""); # Remove whitespace
split($0,a,"=");
text[a[1]] = a[2];
}
if (FILENAME=="mtt_info"){
info[$1] = default;
|
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
}
}' default=$default mtt_text mtt_info mtt_moreinfo
if [ -z "$update" ]; then
if [ -f "mtt_in_text" ]; then
echo "The following variables are defined in $textfile, but do not exist:"
sort mtt_in_text | awk '{printf("\t%s\n",$1)}'
echo Use mtt $sys $rep $lang to update
fi
if [ -f "mtt_in_info" ]; then
echo "The following variables exist, but are not defined in $textfile:"
sort mtt_in_info | awk '{printf("\t%s\n",$1)}'
echo Use mtt $sys $rep $lang to update
fi
exit
fi
answered=''
if [ -f "mtt_in_text" ]; then
in_text=`sort mtt_in_text`
echo "The following variables are defined in $textfile, but do not exist:"
sort mtt_in_text | awk '{printf("\t%s\n",$1)}'
while [ -z "$answered" ]; do
echo "Update $textfile (y/n)?"
read answer < /dev/tty
case $answer in
y)
|
|
|
|
|
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
}
}' default=$default mtt_text mtt_info mtt_moreinfo
if [ -z "$update" ]; then
if [ -f "mtt_in_text" ]; then
echo "The following variables are defined in $textfile, but do not exist:"
sort mtt_in_text | gawk '{printf("\t%s\n",$1)}'
echo Use mtt $sys $rep $lang to update
fi
if [ -f "mtt_in_info" ]; then
echo "The following variables exist, but are not defined in $textfile:"
sort mtt_in_info | gawk '{printf("\t%s\n",$1)}'
echo Use mtt $sys $rep $lang to update
fi
exit
fi
answered=''
if [ -f "mtt_in_text" ]; then
in_text=`sort mtt_in_text`
echo "The following variables are defined in $textfile, but do not exist:"
sort mtt_in_text | gawk '{printf("\t%s\n",$1)}'
while [ -z "$answered" ]; do
echo "Update $textfile (y/n)?"
read answer < /dev/tty
case $answer in
y)
|
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
esac
done
fi
answered=''
if [ -f "mtt_in_info" ]; then
echo "The following variables exist, but are not defined in $textfile:"
sort mtt_in_info | awk '{printf("\t%s\n",$1)}'
while [ -z "$answered" ]; do
echo "Update $textfile (y/n)?"
read answer < /dev/tty
case $answer in
y)
answered=yes
in_info=`sort mtt_in_info`
for new in $in_info; do
echo Adding $new
echo $new $default |\
awk '{printf("%s\t= %s; # Added by MTT on %s\n",$1,$2,strftime())}'\
>> $textfile
changed=yes
done
;;
n)
answered=yes
;;
*)
esac
done
fi
|
|
|
|
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
esac
done
fi
answered=''
if [ -f "mtt_in_info" ]; then
echo "The following variables exist, but are not defined in $textfile:"
sort mtt_in_info | gawk '{printf("\t%s\n",$1)}'
while [ -z "$answered" ]; do
echo "Update $textfile (y/n)?"
read answer < /dev/tty
case $answer in
y)
answered=yes
in_info=`sort mtt_in_info`
for new in $in_info; do
echo Adding $new
echo $new $default |\
gawk '{printf("%s\t= %s; # Added by MTT on %s\n",$1,$2,strftime())}'\
>> $textfile
changed=yes
done
;;
n)
answered=yes
;;
*)
esac
done
fi
|