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
|
############################################################################
#
# File: openchk.icn
#
# Subject: Procedure to aid in open/close debugging
#
# Author: David A. Gamey
#
# Date: March 14, 1995
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# Usage:
#
# OpenCheck()
#
# Subsequent opens and closes will write diagnostic information to &errout
# Useful for diagnosing situations where many files are opened and closed
# and there is a possibility that some files are not always being closed.
#
#############################################################################
procedure OpenCheck(p,x)
local f, e
static openS
if type(p) == "procedure" then
{
# Internal use, by intercept routines
if /openS then
{
write(&errout,"OpenCheck has not been initialized.")
runerr(500)
}
case p of
{
OpenCheck_open :
{
if ( f := p!x ) then
{
write( &errout, "Open of ", image(f), " succeeded." )
insert( openS, f )
}
else
{
writes( &errout, "Open of ")
every writes( &errout, image(!x) )
write( &errout, " failed." )
}
}
OpenCheck_close:
{
e := 1
&error :=: e
if ( f := p!x ) then
{
&error :=: e
write( &errout, "Close of ", image(f), " succeeded." )
delete( openS, f )
}
else
{
&error :=: e
write( &errout, "Close of ", image(f), " failed." )
}
}
default:
runerr(500)
}
write( &errout, *openS, " objects are open:" )
every write( &errout, " ", image(!sort( openS )) )
if type(f) == "file" then
return f
else
{
runerr(&errornumber,&errorvalue) # if error
fail
}
}
else
{
# Setup call comes here
if /p & /x then
if /openS := set() then
{
OpenCheck_open :=: open
OpenCheck_close :=: close
}
else
runerr(123, \p | \x )
}
return
end
procedure OpenCheck_open( x[] )
return OpenCheck(OpenCheck_open,x)
end
procedure OpenCheck_close( x[] )
return OpenCheck(OpenCheck_close,x)
end
|