home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* */
- /* I took ERRPARSE.E from E3 PROCS, made a few optimizations, then added */
- /* a CL command to call the OS/2 Compile/Link program from within EOS2 and */
- /* show the user all errors, if there were any. I also changed the */
- /* comments on the error lines from "/*=====> Error message <=====*/" to */
- /* "/*====> Error message <====*/", since I liked having the downwards- */
- /* pointing arrows to remind me that the error message referred to the */
- /* line below the message. */
- /* */
- /* Larry Margolis */
- /* */
- /****************************************************************************/
- /* */
- /* ERRPARSE.E - A C error parser. */
- /* by Steven Christensen */
- /* */
- /* If you are like me, while developing a C program, it is sometimes */
- /* difficult to relate the IBM C compiler's messages to the error. */
- /* Often they scroll past the screen, or if you put them in a file, */
- /* you must jump back and forth and search for that particular line */
- /* number. */
- /* */
- /* [enter ERRPARSE] */
- /* */
- /* But no more! ERRPARSE.E will take the file of errors (generated */
- /* by directing output to the file <sourcename>.ERR) and construct a */
- /* C comment, and insert it before the error in the source file. */
- /* */
- /* You can then use the Ctrl-N key to go to the Next error, and */
- /* all the while correcting errors as you go. */
- /* */
- /* When you are done correcting, you type a Ctrl-O to Obliterate the */
- /* error comments from the source before saving your file. */
- /* */
- /* If you happen to forget to delete the error lines, no problem, since */
- /* they are C comments, the compiler will ignore them! */
- /* */
- /* To use: When you compile your program "file.c", direct the output to */
- /* a file "file.err". You then use E to edit the source file, */
- /* and at the command line type Alt-Q. Typing Ctrl-N passes you */
- /* to the Next error, while Ctrl-O removes the error comments. */
- /* You can also invoke the parser from the DOS command line by: */
- /* e file.c 'errparse' */
- /* */
- /* Known restrictions: There is one - your source file cannot contain */
- /* comment lines that begin with the C comment start plus "=====> " */
- /* in column one. The Ctrl-O will delete them. */
- /* */
- /* Installation: Put the line "include 'errparse.e' in MYKEYS.E */
- /* */
- /* Change History (most recent first): */
- /* ================================== */
- /* 8-19-88 - Now correctly parses files made by the OS/2 command */
- /* "cc filename.c 2> filename.err" (i.e. with IBM C header) */
- /* */
- /****************************************************************************/
-
- compile if not defined(EPM)
- include 'stdconst.e'
- compile endif
-
- compile if EPM
- definit
- universal activemenu,defaultmenu
- ; 'loaddefaultmenu C_menu'
- buildsubmenu defaultmenu, 19, 'Compile', '', 0 , 0
- buildmenuitem defaultmenu, 19, 1900, 'Compile', 'CC', 0, 0
- buildmenuitem defaultmenu, 19, 1901, 'Compile & Link', 'CL', 0, 0
- buildmenuitem defaultmenu, 19, 1902, 'Make', 'MAKE', 0, 16384
- buildmenuitem defaultmenu, 19, 1903, \0, '', 4, 0
- buildmenuitem defaultmenu, 19, 1904, 'Find Next Error'\9'Ctrl+N', 'EPNEXT',0, 0
- buildmenuitem defaultmenu, 19, 1905, 'Obliterate Error Msgs'\9'Ctrl+O', 'EOBLIT',0, 0
- if activemenu=defaultmenu then showmenu activemenu; endif
-
- defselect
- universal activemenu, defaultmenu
-
- ft = filetype()
- SetMenuAttribute( 19, 16384, (ft = 'C' or ft = 'MAK'))
- if activemenu=defaultmenu then showmenu activemenu; endif
-
- ;defselect
- ; universal activemenu,defaultmenu
- ; ft = filetype()
- ; if (ft = 'C' or ft = 'MAK') & activemenu <> 'C_menu' then
- ; activemenu = 'C_menu'
- ; showmenu activemenu
- ; elseif activemenu = 'C_menu' then
- ; activemenu = defaultmenu /* show the default EPM menu */
- ; showmenu activemenu
- ; endif
-
- compile endif
-
- defc cl= call cl('CL',arg(1))
- defc cc= call cl('CC',arg(1))
- defproc cl=
- universal vTEMP_PATH
- cl=arg(1)
- infile=arg(2)
- if infile='' then
- infile=.filename
- old_mod = .modify
- 'Eoblit' -- Delete error messages from last time, if any.
- if old_mod then 'save'; endif
- else
- if not exist(infile) then
- sayerror 'Source file' infile 'not found.'
- return
- endif
- endif
- compile if EPM -- Open a new edit window, execute the command, and edit the output.
- 'open "clopen 'cl infile'"'
-
- defc clopen =
- universal vTEMP_PATH
- parse arg cl infile
- -- Note: 2>&1 redirects STDERR to same place as STDOUT for OS/2.
- quietshell 'dos 'cl infile' >'vTEMP_PATH'CL'getpminfo(5)'.ERR 2>&1'
- compile else
- sayerror 'Compiling'
- quietshell 'dos 'cl infile' >'vTEMP_PATH'cl.err 2>&1'
- compile endif
- if rc=(-2) then
- sayerror CL'.Exe not found'
- return
- endif
- if rc then
- orc = rc
- 'errparse'
- if orc=2 then
- 0
- 'EPnext' -- Position at first error
- else
- sayerror 'RC was 'orc
- endif
- else
- if cl='CL' then -- For CL can erase object file. Not for CC!
- indx = lastpos('\',infile)
- if not indx then indx = lastpos(':',infile) endif
- if indx then infile=substr(infile,indx+1) endif
- indx = pos('.',infile)
- if indx then infile=substr(infile,1,indx-1) endif
- call erasetemp(infile'.obj') -- Link succeeded; don't need .obj file.
- endif
- sayerror 'Compilation of 'infile' completed successfully.'
- compile if EPM
- 'xcom q'
- compile endif
- endif
-
- defc errparse = /* put error messages in the source file */
- universal vTEMP_PATH
- compile if EPM
- 'xcom e /d 'vTEMP_PATH'cl'getpminfo(5)'.err' /* edit the error file */
- compile else
- sayerror 'Parsing errors.'
- 'xcom e /d 'vTEMP_PATH'cl.err' /* edit the error file */
- compile endif
- getfileid fileid /* save the file ID */
- done=0
- while fileid.last>0 do /* start putting the errors in */
- /* start at bottom so line numbers are OK */
- getline temp,fileid.last,fileid
- parse value temp with filename '(' linenum ') :' message
- if linenum = '' then /* if there is a strange line, */
- leave /* stop processing here */
- /* (we reached the compiler banner) */
- else
- 'xcom e 'filename
- insertline '/*====> 'message' <====*/',linenum
- deleteline fileid.last,fileid
- done=1 -- Set flag saying we've seen an error.
- endif
- endwhile
- activatefile fileid
- .modify = 0 /* to quit the file */
- if not done then -- No error messages found. Must be:
- sayerror temp -- 'File not found', linker error or some such.
- else
- 'xcom q' -- Don't need error file any more.
- sayerror 'Press C_N to find Next error; C_O to Obliterate ===> lines.'
- endif
-
- defc EPNext=
- compile if not EPM
- cursor_data
- compile endif
- unmark
- getsearch old_search
- 'xcom l ./*====> .' /* find special comments */
- if rc <> 0 then
- sayerror 'No more errors found.'
- else
- refresh
- mark_block /* hilite errors */
- end_line
- mark_block
- begin_line
- '+1'
- endif
- setsearch old_search
-
- defc Eoblit=
- compile if not EPM
- sayerror 'Removing errors.'
- compile endif
- ; unmark /* get rid of marks */ -- Why? LAM
- startline = .line
- 0
- getsearch old_search
- 'xcom l ./*====> .' /* look for comment header */
- do forever
- if rc <> 0 then sayerror 1; leave; endif /* no more errors */
- if .col = 1 then /* the error must start in column one */
- deleteline
- if .line < startline then startline=startline-1; endif
- else
- '+1'
- endif
- repeatfind
- end
- setsearch old_search
- startline
- sayerror 'Error messages removed.'
-
- ; def a_q ='errparse' /* Errparse the file */
- def c_n ='EPNext' /* define Ctrl-N to find next error */
- def c_o ='Eoblit' /* Obliterate errors */
-
- /* End of ERRPARSE.E */
-