[.GRC.ERIC.GREP] GREP stands for Generalized, Regular Expression Parser. GREP is used to search for special strings in files. It differs from the VMS SEARCH command in that it searches for patterns - not literal strings. GREP is a standard tool on the UNIX operating system, and has countless uses. GREP can replace many "specialty programs". Who needs a separate program to count the number of comments in a FORTRAN program? GREP can find all occurences of the symbols *!C when they occur in column 1 and the /LOG qualifier will tell you how many records were found and how many matches were made. If you had to send some software to a site, but you didn't want to leave your comments in the code, GREP could easily place all of the records that do NOT have the comment symbols in column 1 into a new file for shipment. One of the best applications of GREP comes about during code conversions. If the FORTRAN compiler at a target site isn't capable of using hollerith data or does not recognize the $ character in a format statement, for example, GREP can easily find these cases and print out appropriate line numbers. Recently I used GREP to search a final report for all occurrences of a section number: some number followed by a space or some number followed by a period and a number, followed by a space, etc. I was able to verify all of the references to section numbers with an output listing that included line numbers. GREP is a powerful tool and I've found that many laborious searches can be made simpler by using GREP and a little imagination. There are several versions of GREP floating around. This one comes from a book called Dr. Dobb's Toolbook of C in an article by Allen Holub (Prentice Hall, 1986, Chapter 14). I have placed a VMS command interface on top of GREP and I have removed some of the bugs that were in the original listing. The algorithm that is used for pattern matching originally comes from Software Tools in Pascal by Kernighan and Plauger (Addison-Wesley, 1981, Chapter 5). I have made it possible to search binary files with GREP as well as text files. I suggest that output be turned off (/NOOUTPUT) or directed to a file (/OUTPUT=file-spec) during a binary file search, so that control characters from the output record don't freeze up the terminal being used. In order to give GREP the flexibility needed to read many types of VMS files I had to replace all of the C I/O runtime library routines with standard FORTRAN I/O. GREP is invoked with the command GREP. The syntax used to des- cribe patterns is like the UNIX GREP command but the command interface is just like the VMS SEARCH command. I have done my best to make the output from GREP look just like SEARCH output also. A user's manual is included in this directory. ------------------------------------------------------------------------ Let me take this moment to say that UNIX is a trademark of Bell Laboratories and that this version of GREP brings me no financial reward. By creating this version of GREP I am admitting that the UNIX operating system has one up on VMS in a few areas - searching and parsing being one of those areas. I hope that Bell Labs and Dr. Dobbs see this as a complement to them both and not as any sort of Copyright infringement. ------------------------------------------------------------------------ THE FILES THEIR PURPOSE ------------------------------------------------------------------------ AAAREADME.GRC;1 This file COMPILE.COM;1 Command procedure to compile source FORTRANIO.CMN;1 Commons for FORTRANIO.FOR FORTRANIO.FOR;1 FORTRAN I/O routines for VMSGREP FORTRANIO.OBJ;1 FORTRANIO object code VMS 4.3 TOOLS.C;1 C routines for VMSGREP TOOLS.H;1 .H file for TOOLS.C TOOLS.OBJ;1 TOOLS object code VMS 4.3 (with VAXCRTL included) VMSGREP.C;1 VMSGREP C source VMSGREP.CLD;1 VMSGREP command definition file VMSGREP.DOC;1 VMSGREP manual (ready to print) VMSGREP.TXT;1 VMSGREP manual (unformatted) VMSGREP.EXE;1 VMSGREP executable VMS 4.3 VMSGREP.HLP;1 VMSGREP help file VMSGREP.OBJ;1 VMSGREP object code VMS 4.3 ------------------------------------------------------------------------ INSTALLATION $ ! Add GREP command to your DCLTABLES $ ! Make sure you have enough global sections to reinstall DCLTABLES $ ! When you log in again you will have the new command $ ! This requires privilege $ ! $ SET COMMAND/TABLE=SYS$LIBRARY:DCLTABLES/OUTPUT=SYS$LIBRARY:DCLTABLES - VMSGREP $ INSTALL:= $SYS$SYSTEM:INSTALL/COMMAND $ INSTALL REPLACE SYS$LIBRARY:DCLTABLES $ ! Add the help library to helplib $ ! This requires privilege $ ! $ LIBRARY/HELP SYS$HELP:HELPLIB VMSGREP.HLP NOTE: GRC$TOOLS is a logical that must be defined in the system logical name table. The logical GRC$TOOLS is used throughout the GRC tools on this DECUS tape and should point to the disk and directory containing VMSGREP.EXE. ------------------------------------------------------------------------ PRINTING THE MANUAL The manual is a formatted document ready for printing. It should be printed on a printer set up for 66 lines per page, preferably on standard 8 1/2 X 11 inch long paper, with 12 pitch. The printer must not insert margins at the left or at the top and bottom. To print this document with the standard VMS PRINT command simply type: $ PRINT/NOFEED VMSGREP.DOC ------------------------------------------------------------------------ COMPLEMENTS, SUGGESTIONS AND COMPLAINTS TO THE FOLLOWING: Eric Andresen General Research Corporation 5383 Hollister Avenue Santa Barbara, CA 93111 (805)964-7724 Ext. 332 ------------------------------------------------------------------------