View previous topic :: View next topic
|
Author |
Message |
deepak.kec
New User
Joined: 26 Feb 2007 Posts: 71 Location: bangalore
|
|
|
|
Hi All,
Did some one has any REXX tool to remove dead codes from a cobol program?
Suggestion to write such a tool will also be helpful.
Thanks to all for providing me help and support. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
Once You define exactly what You mean by "dead code"
writing such a tool would range from easy to impossible (*)
(*) looking at the source code only |
|
Back to top |
|
|
deepak.kec
New User
Joined: 26 Feb 2007 Posts: 71 Location: bangalore
|
|
|
|
i mean to say that source code which is commented out and is present along the source code. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
differentiating between comments and 'commented code' is rather difficult,
if not impossible.
Dead code is usually a reference to code that will never be executed.
removal of comments from a source module, will only reduce the size of the source module. will have no effect on the object.
but, in answer to your question.
a REXX EDIT macro easily can distinguish between comments and those lines which are not comments.
FIND 'PROCEDURE DIV' first, hoping of course that the Procedure Div statement is not in a copybook.
FIND '*' 7 will do the trick, but you have to insure that the bounds include the lineno columns (1-6).
find_RC = RC
create a do loop
if find_rc <> 0 then exit the loop
you could then load the source line via an ISPF Macro LINE command.
once into a REXX variable the fun begins.
How to interrogate the data in the variable to determine if it is indeed 'commented code' or a real comment?
Once you have determined if it is 'dead code', you can issue an ISPF Macro DELETE .zcurr
then as last instruction in the DO Loop, F '*' 7 next |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2546 Location: Silicon Valley
|
|
|
|
Does your 'dead code' really happen that often that you need to write a program?
I suggest excluding all the lines, then find all with '*' in col 7 (or whatever it is) then scroll up and down while deleting the problem lines. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
I don't remember which version of COBOL it was, but I remember seeing a compile listing where dead code was documented at the bottom of the listing. It could then be removed manually. Why write a REXX program if the compiler will spot it for you? |
|
Back to top |
|
|
deepak.kec
New User
Joined: 26 Feb 2007 Posts: 71 Location: bangalore
|
|
|
|
We use Cobol version 2 but the compiler doesn't document the dead code at the bottow.
Dead Code are the redundant code which have been commented and are of no use now.
thanks Dick Brenholtz. Hope ur suggestion helps me |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
The "dead code" I was referring to is code that will never be executed because of the logic coded, for instance a paragraph that is never performed or cannot be executed because of "fall through" logic. The compiler stated that no instructions were generated in the object module since the code will never be executed. |
|
Back to top |
|
|
|