/***************************  REXX  *******************************/
/*     (c)  Copyright   Roger Lacroix   1995                      */
/*                                                                */
/* Designed, developed and programmed by Roger Lacroix            */
/******************************************************************/
/*                                                                */
/* CCHECK                                                         */
/*                                                                */
/* Purpose: The purpose of this macro is to make it easier to     */
/*          find unmatched comments and brackets in a C program.  */
/*                                                                */
/* Note: Run this rexx program wwhile you are editing a C program */
/*                                                                */
/******************************************************************/

address "ISPEXEC";

"ISREDIT MACRO (l1 l2)";

if l1 = '' then l1 = ".ZFIRST"
if l2 = '' then l2 = ".ZLAST"

Fstring.0 = "/*";
Fstring.1 = "*/";
Fstring.2 = "(" ;
Fstring.3 = ")" ;
Fstring.4 = "{" ;
Fstring.5 = "}" ;
Fstring.6 = "[" ;
Fstring.7 = "]" ;

Total = 7;

"ISREDIT EXCLUDE ALL" l1 l2;
"ISREDIT LOCATE" l1;
"ISREDIT LOCATE" l2;

do I = 0 to Total by 1;
   "ISREDIT SEEK '" || Fstring.I || "' ALL" l1 l2;
   "ISREDIT ( Cnt, Lines) = SEEK_COUNTS";
   Cnt.I = Cnt + 0;
   Lines.I = Lines + 0;
end;

"ISREDIT LOCATE" l1;
do I = 0 to Total-1 by 2;
    J = I+1;
    if (Cnt.I > 0 | Cnt.J > 0) then do;
       if Cnt.I = Cnt.J then Start = "   ";
       else do;
          start = "***";
         "ISREDIT FIND '" || Fstring.I || "'" l1 l2 "ALL";
         "ISREDIT FIND '" || Fstring.J || "'" l1 l2 "ALL";
       end;

       Msg = Start  Right(  FString.I, 2) '-'  Left(  Fstring.J, 2),
                    right( Cnt.I, 3)      '-' right( Cnt.J, 3);
      "ISREDIT LINE_AFTER" l1 "= MSGLINE '" || Msg || "'";
   end;
end;

return 0;