Debian Codegraph @

auxil/caseconv.20000811

raw
1 #!/bin/csh
2 ################################################################
3 ## Copyright (C) 1998,1999 Joergen Backelin
4 ##
5 ## Bergman is distributed in the hope that it will be useful,
6 ## but WITHOUT ANY WARRANTY. No author or distributor
7 ## accepts responsibility to anyone for the consequences of using it
8 ## or for whether it serves any particular purpose or works at all,
9 ## unless (s)he says so in writing. Refer to the Bergman General
10 ## Public License for full details.
11
12 ## Everyone is granted permission to copy, modify and redistribute
13 ## bergman, but only under the conditions described in the
14 ## Bergman General Public License. A copy of this license is
15 ## supposed to have been given to you along with bergman so you
16 ## can know your rights and responsibilities. It should be in a
17 ## file named copyright. Among other things, the copyright notice
18 ## and this notice must be preserved on all copies.
19 ################################################################
20
21 # This might be called from a shell where the bergman
22 # environment variables are set. Alternatively:
23 #source ../bin/$MACHINE/shellenv #or something
24
25 # However, the machine type is relevant only for the conv
26 # variant to employ. Thus in this variant all relevant stuff simply
27 # should be given as five arguments, in the following order:
28 # src, auxil, xsrc, xauxil, conv.
29
30 # CHANGES:
31
32 # 2000-08-11: Added fv* and version files./JoeB
33
34 # 1999-11-26: Corrected -nt file compare test to -ot.
35
36 if ($#argv != 5) then
37 echo wrong number of arguments to caseconv\; should be 5, is $#argv
38 exit
39 endif
40
41 if ( ! ( -d $1)) then
42 echo \ The argument $1 to caseconv should have been a directory,
43 echo the original bergman source directory.
44 exit
45 endif
46
47 if ( ! ( -d $2)) then
48 echo \ The argument $2 to caseconv should have been a directory,
49 echo the original bergman auxiliary files directory.
50 exit
51 endif
52
53 if ( ! ( -d $3 || { mkdir $3 } )) then
54 echo \ The argument $3 to caseconv should have been a directory,
55 echo or have been possible to create as a new directory,
56 echo the switched cases bergman source directory.
57 exit
58 endif
59
60 if ( ! ( -d $4 || { mkdir $4 } )) then
61 echo \ The argument $4 to caseconv should have been a directory,
62 echo or have been possible to create as a new directory,
63 echo the switched cases bergman auxiliary files directory.
64 exit
65 endif
66
67 # We also should have the rights to make subdirectories and write
68 # on the catalogues 3 and 4. For the purpose, I create temporary
69 # directories Tstwrpr.tmp. If this doesn't work, then we exit with
70 # an error message.
71
72 # In theory, one reason for failure could be the user having created
73 # a file or a directory with this name. However, the use of permanent
74 # "tmp" files is not recommended ... .
75
76 if ( ! { mkdir $3/Tstwrpr.tmp } ) then
77 echo \ I could not write Tstwrpr.tmp on $3, whence I exit
78 echo Check your write access and try again
79 exit
80 endif
81 rmdir $3/Tstwrpr.tmp
82
83 if ( ! { mkdir $4/Tstwrpr.tmp } ) then
84 echo \ I could not write Tstwrpr.tmp on $4, whence I exit
85 echo Check your write access and try again
86 exit
87 endif
88 rmdir $4/Tstwrpr.tmp
89
90 # Here or earlier a compilation of "conv", the converter
91 # command to be used below in order to create the case
92 # converted source files, should be performed (if necessary?)
93 # Or, compiled converter could be provided as standards,
94 # together with the source file for emergencies and extensions.
95 # Right now, I just assume the converter to exist.
96
97 if ( ! ( -x $5)) then
98 echo \ The argument $5 to caseconv should have been an
99 echo executable file, the compiled case converter.
100 exit
101 endif
102
103 # We also should check whether or not execution of $5
104 # seems to work. The following is crude, but at least
105 # detects a few errors:
106
107 cat <<EOCAT >$3/Tstwrpr.tmp
108 % A minor test file
109 (COND ((COULD this Work?) T))
110 EOCAT
111 $5 $3/Tstwrpr.tmp $4/Tstwrpr.tmp
112 if ( ! ( -f $4/Tstwrpr.tmp )) then
113 echo \ Although $5 is an executable file, it does not
114 echo seem to work in this context. Check if it is of
115 echo the right architecture.
116 exit
117 endif
118 rm -f $3/Tstwrpr.tmp $4/Tstwrpr.tmp
119
120 # The first four arguments now are intelligible as directory
121 # names, as viewed from the present directory. However, we
122 # need to move around, and still find our way. Thus, let's
123 # define temporary variables, containing the full pathnames of
124 # the directories! This we do without use of pushd/popd, in
125 # order to suppress excess diagnostics printing.
126
127 setenv tmphere $cwd
128 cd $1; setenv tmpsrc $cwd; cd $tmphere
129 cd $2; setenv tmpauxil $cwd; cd $tmphere
130 cd $3; setenv tmpxsrc $cwd; cd $tmphere
131 cd $4; setenv tmpxauxil $cwd; cd $tmphere
132
133 #### However, we still may have the problem with $5. The file
134 #### might not be discernible from the other directories; and
135 #### I do not see how to perform an expansion of its full
136 #### pathname.
137
138 # Therefore, in this version I make a horrible amount of cd's,
139 # just in order never to execute the converter file from a
140 # place where it might not be found.
141
142 setenv tmpconv $5
143
144 # Here a make kind of update hopefully is performed:
145 # If some of the relevant source files are newer than their
146 # case converted counterparts, or such counterparts do not
147 # exist, then new conversion counterparts should be created.
148
149 # src files conversions --> xsrc:
150 cd $tmpsrc
151 foreach srcfl (*.sl redif.red)
152 if ( ! ( -e $tmpxsrc/$srcfl && { test $srcfl -ot $tmpxsrc/$srcfl } )) then
153 rm -f $tmpxsrc/$srcfl
154 cd $tmphere
155 $tmpconv $tmpsrc/$srcfl $tmpxsrc/$srcfl
156 cd $tmpsrc
157 endif
158 end
159
160 # if ( -f redif.red ) then
161 # rm -f $tmpxsrc/redif.red
162 # cd $tmphere
163 # $tmpconv $tmpsrc/redif.red $tmpxsrc/redif.red
164 # cd $tmpsrc
165 # endif
166
167
168 if ( -d stg ) then
169 cd stg
170 if ( ! ( -d $tmpxsrc/stg)) mkdir $tmpxsrc/stg
171 foreach srcfl (*.sl)
172 if ( ! ( -e $tmpxsrc/stg/$srcfl && { test $srcfl -ot $tmpxsrc/stg/$srcfl } )) then
173 rm -f $tmpxsrc/stg/$srcfl
174 cd $tmphere
175 $tmpconv $tmpsrc/stg/$srcfl $tmpxsrc/stg/$srcfl
176 cd $tmpsrc/stg
177 endif
178 end
179 cd $tmpsrc
180 endif
181
182 if ( -d anick ) then
183 cd anick
184 if ( ! ( -d $tmpxsrc/anick)) mkdir $tmpxsrc/anick
185 foreach srcfl (*.sl)
186 if ( ! ( -e $tmpxsrc/anick/$srcfl && { test $srcfl -ot $tmpxsrc/anick/$srcfl } )) then
187 rm -f $tmpxsrc/anick/$srcfl
188 cd $tmphere
189 $tmpconv $tmpsrc/anick/$srcfl $tmpxsrc/anick/$srcfl
190 cd $tmpsrc
191 endif
192 end
193 cd $tmpsrc/anick
194 endif
195
196 # auxil files conversions --> xauxil:
197 cd $tmpauxil
198 foreach srcfl (*.sl)
199 if ( ! ( -e $tmpxauxil/$srcfl && { test $srcfl -ot $tmpxauxil/$srcfl } )) then
200 rm -f $tmpxauxil/$srcfl
201 cd $tmphere
202 $tmpconv $tmpauxil/$srcfl $tmpxauxil/$srcfl
203 cd $tmpauxil
204 endif
205 end
206
207 cd $tmpxauxil
208 rm -f envtail* head* hook* fv* version
209 cd $tmpauxil
210 cp -p envtail* head* hook* fv* version $tmpxauxil
211
212 if ( -f caseconv ) cp -p caseconv $tmpxauxil
213
214 cd $tmphere
215
216 $tmpconv $tmpauxil/mkprimefile $tmpxauxil/mkprimefile