~vcs-imports/gawk/master

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
154
155
156
157
158
159
160
161
162
163
164
165
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
195
196
197
198
199
200
201
202
203
204
205
206
207
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
$! Compare_gawk_source.com
$!
$! This procedure compares the files in two directories and reports the
$! differences.
$!
$! It needs to be customized to the local site directories.
$!
$! This is used by me for these purposes:
$!     1. Compare the original source of a project with an existing
$!        VMS port.
$!     2. Compare the checked out repository of a project with the
$!        the local working copy to make sure they are in sync.
$!     3. Keep a copy directory up to date.  The third is needed by
$!        me because VMS Backup can create a saveset of files from a
$!        NFS mounted volume.
$!
$! First the files in the original source directory which is assumed to be
$! under source codde control are compared with the copy directory.
$!
$! Then the files are are only in the copy directory are listed.
$!
$! The result will five diagnostics about of files:
$!    1. Files that are not generation 1.
$!    2. Files missing in the copy directory.
$!    3. Files in the copy directory not in the source directory.
$!    4. Files different from the source directory.
$!    5. Files that VMS DIFF can not process.
$!
$! This needs to be run on an ODS-5 volume.
$!
$! If UPDATE is given as a second parameter, files missing or different in the
$! copy directory will be updated.
$!
$! By default:
$!    The source directory is source_root:[gawk.reference.gawk],
$!    the logical used on my system for the GNV Mecurial repository checkout.
$!    If source_root: is not defined, then src_root:[gawk] will be
$!    translated to something like DISK:[dir.gawk.reference.gawk]
$!    and then DISK:[dir.gawk.vms_source.gawk] will be used.
$!
$!    The copy directory is vms_root:[gawk]
$!    The UPDATE parameter is ignored.
$!
$!    This setting is used to make sure that the working vms directory
$!    and the VMS specific repository checkout directory have the same
$!    contents if they are different.
$!
$! If P1 is "SRCBCK" then this
$!     The source directory tree is: src_root:[gawk]
$!     The copy directory is src_root1:[gawk]
$!
$!   src_root1:[gawk] is used by me to work around that VMS backup will
$!   not use NFS as a source directory so I need to make a copy.
$!
$!   This is to make sure that the backup save set for the unmodified
$!   source is up to date.
$!
$!   If your repository checkout is not on an NFS mounted volume, you do not
$!   need to use this option or have the logical name src_root1 defined.
$!
$! If P1 is "VMSBCK" then this changes the two directories:
$!    The source directory is vms_root:[gawk]
$!    The copy directory is vms_root1:[gawk]
$!
$!   vms_root:
$!   src_root1:[gawk] is used by me to work around that VMS backup will
$!   not use NFS as a source directory so I need to make a copy.
$!
$!   This is to make sure that the backup save set for the unmodified
$!   source is up to date.
$!
$!   If your repository checkout is not on an NFS mounted volume, you do not
$!   need to use this option or have the logical name src_root1 defined.
$!
$! 02-Jan-2014   J. Malmberg
$!==========================================================================
$!
$! Update missing/changed files.
$update_file = 0
$if (p2 .eqs. "UPDATE")
$then
$   update_file = 1
$endif
$!
$myproc = f$environment("PROCEDURE")
$myprocdir = f$parse(myproc,,,"DIRECTORY") - "[" - "]" - "<" - ">"
$myprocdir = f$edit(myprocdir, "LOWERCASE")
$mydefault = f$environment("DEFAULT")
$mydir = f$parse(mydefault,,,"DIRECTORY")
$mydir = f$edit(mydir, "LOWERCASE")
$odelim = f$extract(0, 1, mydir)
$mydir = mydir - "[" - "]" - "<" - ">"
$mydev = f$parse(mydefault,,,"DEVICE")
$!
$ref = ""
$if P1 .eqs. ""
$then
$   ref_base_dir = myprocdir - ".vms"
$   wrk_base_dir = mydir
$   update_file = 0
$   resultd = f$parse("src_root:",,,,"NO_CONCEAL")
$   resultd = f$edit(resultd, "LOWERCASE")
$   resultd = resultd - "][" - "><" - ".;" - ".."
$   resultd_len = f$length(resultd) - 1
$   delim = f$extract(resultd_len, 1, resultd)
$   ref_root_base = mydir + delim
$   if f$locate(".reference.", resultd) .lt. resultd_len
$   then
$      resultd = resultd - ref_root_base - "reference." + "vms_source."
$   else
$      resultd = resultd - ref_root_base - "gnu." + "gnu_vms."
$   endif
$   ref = resultd + ref_base_dir
$   wrk = "VMS_ROOT:" + odelim + wrk_base_dir
$   resultd_len = f$length(resultd) - 1
$   resultd = f$extract(0, resultd_len, resultd) + delim
$   ref_root_dir = f$parse(resultd,,,"DIRECTORY")
$   ref_root_dir = f$edit(ref_root_dir, "LOWERCASE")
$   ref_root_dir = ref_root_dir - "[" - "]"
$   ref_base_dir = ref_root_dir + "." + ref_base_dir
$endif
$!
$if p1 .eqs. "SRCBCK"
$then
$   ref_base_dir = "gawk"
$   wrk_base_dir = "gawk"
$   ref = "src_root:[" + ref_base_dir
$   wrk = "src_root1:[" + wrk_base_dir
$   if update_file
$   then
$       if f$search("src_root1:[000000]gawk.dir") .eqs. ""
$       then
$           create/dir/prot=o:rwed src_root1:[gawk]
$       endif
$   endif
$endif
$!
$!
$if p1 .eqs. "VMSBCK"
$then
$   ref_base_dir = "gawk"
$   wrk_base_dir = "gawk"
$   ref = "vms_root:[" + ref_base_dir
$   wrk = "vms_root1:[" + wrk_base_dir
$   if update_file
$   then
$       if f$search("vms_root1:[000000]gawk.dir") .eqs. ""
$       then
$           create/dir/prot=o:rwed vms_root1:[gawk]
$       endif
$   endif
$endif
$!
$!
$if ref .eqs. ""
$then
$   write sys$output "Unknown compare type specified!"
$   exit 44
$endif
$!
$!
$!
$! Future - check the device types involved for the
$! the syntax to check.
$ODS2_SYNTAX = 0
$NFS_MANGLE = 0
$PWRK_MANGLE = 0
$!
$vax = f$getsyi("HW_MODEL") .lt. 1024
$if vax
$then
$   ODS2_SYNTAX = 1
$endif
$!
$report_missing = 1
$!
$if .not. ODS2_SYNTAX
$then
$   set proc/parse=extended
$endif
$!
$loop:
$  ref_spec = f$search("''ref'...]*.*;",1)
$  if ref_spec .eqs. "" then goto loop_end
$!
$  ref_dev = f$parse(ref_spec,,,"DEVICE")
$  ref_dir = f$parse(ref_spec,,,"DIRECTORY")
$  ref_dir = f$edit(ref_dir, "LOWERCASE")
$  ref_name = f$parse(ref_spec,,,"NAME")
$  ref_type = f$parse(ref_spec,,,"TYPE")
$!
$!
$  if f$locate(".CVS]", ref_dir) .lt. f$length(ref_dir) then goto loop
$  if f$locate(".cvs]", ref_dir) .lt. f$length(ref_dir) then goto loop
$  if f$locate(".$cvs]", ref_dir) .lt. f$length(ref_dir) then goto loop
$  if f$locate(".^.git", ref_dir) .lt. f$length(ref_dir) then goto loop
$  if f$locate(".$5ngit", ref_dir) .lt. f$length(ref_dir) then goto loop
$!
$  rel_path = ref_dir - "[" - ref_base_dir
$!  rel_path_len = f$length(rel_path) - 1
$!  delim = f$extract(rel_path_len, 1, rel_path)
$!  rel_path = rel_path - ".]" - ".>" - "]" - ">"
$!  rel_path = rel_path + delim
$!
$  if ODS2_SYNTAX
$  then
$  endif
$!
$  wrk_path = wrk + rel_path
$!
$  ref_name_type = ref_name + ref_type
$!
$  if ref_name_type .eqs. "CVS.DIR" then goto loop
$  if ref_name_type .eqs. "cvs.dir" then goto loop
$  if ref_name_type .eqs. "$CVS.DIR" then goto loop
$  if ref_name_type .eqs. "^.git.DIR" then goto loop
$  if ref_name_type .eqs. "$5ngit.DIR" then goto loop
$  if ref_name_type .eqs. "$5NGIT.DIR" then goto loop
$  if ODS2_SYNTAX
$  then
$!
$  endif
$!
$  wrk_spec = wrk_path + ref_name_type
$!
$!
$  wrk_chk = f$search(wrk_spec, 0)
$  if wrk_chk .eqs. ""
$  then
$    if report_missing
$    then
$      write sys$output "''wrk_spec' is missing"
$    endif
$    if update_file
$    then
$      copy/log 'ref_spec' 'wrk_spec'
$    endif
$    goto loop
$  endif
$!
$  wrk_name = f$parse(wrk_spec,,,"NAME")
$  wrk_type = f$parse(wrk_spec,,,"TYPE")
$  wrk_fname = wrk_name + wrk_type"
$  ref_fname = ref_name + ref_type
$!
$  if ref_fname .nes. wrk_fname
$  then
$    write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'"""
$  endif
$!
$  ref_type = f$edit(ref_type, "UPCASE")
$  if ref_type .eqs. ".DIR" then goto loop
$!
$  if ODS2_SYNTAX
$  then
$       ref_fname = f$edit(ref_fname, "LOWERCASE")
$  endif
$!
$! These files have records to long to diff, and we don't change them anyway.
$  ref_skip = 0
$  if ref_type .eqs. ".GMO" then ref_skip = 1
$  if ref_type .eqs. ".PDF" then ref_skip = 1
$  if ref_type .eqs. ".PNG" then ref_skip = 1
$  if ref_type .eqs. ".JPG" then ref_skip = 1
$  if ref_fname .eqs. "inftest.ok" then ref_skip = 1
$  if ref_fname .eqs. "longsub.in" then ref_skip = 1
$  if ref_fname .eqs. "longsub.ok" then ref_skip = 1
$  if ref_fname .eqs. "nasty2.ok" then ref_skip = 1
$  if ref_fname .eqs. "profile5.awk" then ref_skip = 1
$  if ref_fname .eqs. "profile5.ok" then ref_skip = 1
$  if ref_fname .eqs. "po.m4" then ref_skip = 1
$!
$!
$  if ref_skip .ne. 0
$  then
$    if report_missing
$    then
$        write sys$output "Skipping diff of ''ref_fname'"
$    endif
$    goto loop
$  endif
$!
$!
$  wrk_ver = f$parse(wrk_chk,,,"VERSION")
$  if wrk_ver .nes. ";1"
$  then
$    write sys$output "Version for ''wrk_spec' is not 1"
$  endif
$  set noon
$  diff/out=nl: 'wrk_spec' 'ref_spec'
$  if $severity .nes. "1"
$  then
$    write sys$output "''wrk_spec' is different from ''ref_spec'"
$    if update_file
$    then
$       delete 'wrk_spec';*
$       copy/log 'ref_spec' 'wrk_spec'
$    endif
$  endif
$  set on
$
$!
$  goto loop
$loop_end:
$!
$!
$missing_loop:
$! For missing loop, check the latest generation.
$  ref_spec = f$search("''wrk'...]*.*;")
$  if ref_spec .eqs. "" then goto missing_loop_end
$!
$  ref_dev = f$parse(ref_spec,,,"DEVICE")
$  ref_dir = f$parse(ref_spec,,,"DIRECTORY")
$  ref_dir = f$edit(ref_dir, "LOWERCASE")
$  ref_name = f$parse(ref_spec,,,"NAME")
$  ref_type = f$parse(ref_spec,,,"TYPE")
$!
$  rel_path = ref_dir - "[" - wrk_base_dir
$!
$!
$  wrk_path = ref + rel_path
$  wrk_spec = wrk_path + ref_name + ref_type
$  wrk_name = f$parse(wrk_spec,,,"NAME")
$  wrk_type = f$parse(wrk_spec,,,"TYPE")
$!
$  wrk_fname = wrk_name + wrk_type"
$  ref_fname = ref_name + ref_type
$!
$  wrk_skip = 0
$  ref_utype = f$edit(ref_type,"UPCASE")
$  ref_ufname = f$edit(ref_fname,"UPCASE")
$!
$!
$  if wrk_skip .eq. 0
$  then
$     wrk_chk = f$search(wrk_spec, 0)
$     if wrk_chk .eqs. ""
$     then
$         if report_missing
$         then
$             write sys$output "''wrk_spec' is missing"
$         endif
$         goto missing_loop
$     endif
$  else
$     goto missing_loop
$  endif
$!
$  if ref_fname .nes. wrk_fname
$  then
$    write sys$output "''wrk_spc' wrong name, should be ""''ref_fname'"""
$  endif
$!
$  if ref_utype .eqs. ".DIR" then goto missing_loop
$!
$  wrk_ver = f$parse(wrk_chk,,,"VERSION")
$  if wrk_ver .nes. ";1"
$  then
$    write sys$output "Version for ''wrk_spec' is not 1"
$  endif
$!
$  goto missing_loop
$!
$!
$missing_loop_end:
$!
$exit