home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 197_01 / findcom.cmd < prev    next >
OS/2 REXX Batch file  |  1979-12-31  |  1KB  |  58 lines

  1. ;    This hunts down mismatched comment problems in C
  2.  
  3. ;    start from the current position in the file
  4.  
  5.     !force search-forward "/*"
  6.     !if &seq $status FALSE
  7.         !goto nend
  8.     !endif
  9.  
  10. *nxtopen
  11.     ;record the position of the open comment
  12.     update-screen
  13.     set %oline $curline
  14.     set %opos $curcol
  15.  
  16.     ;find the first close comment
  17.     !force search-forward "*/"
  18.     !if &seq $status FALSE
  19.         write-message "%%No close to this open comment"
  20.         !return
  21.     !endif
  22.  
  23.     ;record the position of the close comment
  24.     set %cline $curline
  25.     set %cpos $curcol
  26.  
  27.     ;go back to the open and find the next open
  28.     set $curline %oline
  29.     set $curcol %opos
  30.  
  31.     ;and now find the next open
  32.     !force search-forward "/*"
  33.     !if &seq $status FALSE
  34.         write-message "No errors"
  35.         !return
  36.     !endif
  37.     set %nline $curline
  38.     set %npos $curcol
  39.  
  40.     ;compare the close to the next open
  41.     !if &less %cline %nline
  42.         !goto getnext
  43.     !endif
  44.     !if &and &equ %cline %nline &less %cpos %npos
  45.         !goto getnext
  46.     !endif
  47.  
  48.     ;report a mismatch
  49.     set $curline %oline
  50.     set $curcol %opos
  51.     write-message "%%This comment does not terminate properly"
  52.     !return
  53.  
  54. *getnext
  55.     set $curline %nline
  56.     set $curcol %npos
  57.     !goto nxtopen 
  58.