/****************************** Module Header *******************************
*
* Module Name: alt_1.e
*
* Copyright (c) Netlabs EPM Distribution Project 2002
*
* $Id$
*
* ===========================================================================
*
* This file is part of the Netlabs EPM Distribution package and is free
* software. You can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* Netlabs EPM Distribution. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
****************************************************************************/
compile if not defined( SMALL) -- If compiled separately
EA_comment 'This defines the Alt_1 command.'
define
INCLUDING_FILE = 'ALT_1.E'
include 'stdconst.e'
const
tryinclude 'mycnf.e'
const
compile if not defined( NLS_LANGUAGE)
NLS_LANGUAGE = 'ENGLISH'
compile endif
include NLS_LANGUAGE'.e'
defmain
'Alt_1'
compile endif
; ---------------------------------------------------------------------------
; Loads a filename under the cursor.
; - Many parts are taken from the macros of Greg Jarvis.
; - Note that definitions for supported modes are found with FindDef, not
; with Alt_1.
; - Outdated parts were moved to the end and commented out.
defc Alt_1, A_1
universal vepm_pointer
do once = 1 to 1
getline LineStr
rc = -1 -- Not processed
LoadFilename = ''
LoadLine = ''
LoadCol = ''
SearchStr = ''
Spec = ''
mouse_setpointer WAIT_POINTER
-- Shell or .DOS DIR
call Alt1ProcessCmdDir( LineStr, LoadFilename)
--dprintf( 'Alt1ProcessCmdDir: rc = 'rc)
if rc <> -1 then
leave
endif
-- .Tree
call Alt1ProcessTree( LineStr, LoadFilename)
--dprintf( 'Alt1ProcessTree: rc = 'rc)
if rc <> -1 then
leave
endif
-- .Output from grep
call Alt1ProcessGrepLog( LineStr, LoadFilename)
--dprintf( 'Alt1ProcessGrepLog: rc = 'rc)
if rc <> -1 then
leave
endif
-- include
call Alt1ProcessInclude( LineStr, LoadFilename)
--dprintf( 'Alt1ProcessInclude: rc = 'rc)
if rc <> -1 then
leave
endif
-- import (PYTHON)
call Alt1ProcessPythonImport( LineStr, LoadFilename)
--dprintf( 'Alt1ProcessImport: rc = 'rc)
if rc <> -1 then
leave
endif
-- Compile error (IBM, Watcom)
call Alt1ProcessCompileError( LineStr, LoadFilename, LoadLine, LoadCol)
--dprintf( 'Alt1ProcessCompileError: rc = 'rc)
if rc <> -1 then
leave
endif
-- IPFC error
call Alt1ProcessIpfcError( LineStr, LoadFilename, LoadLine)
--dprintf( 'Alt1ProcessIpfcError: rc = 'rc)
if rc <> -1 then
leave
endif
-- REXX error (Classic, Object)
call Alt1ProcessRexxError( LineStr, LoadFilename, LoadLine)
--dprintf( 'Alt1ProcessRexxError: rc = 'rc)
if rc <> -1 then
leave
endif
-- Compile error (POSIX, JAVA)
call Alt1ProcessPosixError( LineStr, LoadFilename, LoadLine, LoadCol)
--dprintf( 'Alt1ProcessPosixError: rc = 'rc)
if rc <> -1 then
leave
endif
-- Saxon error
call Alt1ProcessSaxonError( LineStr, LoadFilename, LoadLine, LoadCol)
--dprintf( 'Alt1ProcessSaxonError: rc = 'rc)
if rc <> -1 then
leave
endif
-- PYTHON error
call Alt1ProcessPythonError( LineStr, LoadFilename, LoadLine, LoadCol)
--dprintf( 'Alt1ProcessPythonError: rc = 'rc)
if rc <> -1 then
leave
endif
-- Marked one-line string
call Alt1ProcessMarkedString( LineStr, LoadFilename)
--dprintf( 'Alt1ProcessMarkedString: rc = 'rc)
if rc <> -1 then
leave
endif
-- Word under cursor
call Alt1ProcessWord( LineStr, LoadFilename, SearchStr, LoadLine, LoadCol)
--dprintf( 'Alt1ProcessWord: rc = 'rc)
if rc <> -1 then
leave
endif
enddo
do once = 1 to 1
if not rc & LoadFilename then
-- Found by Alt1FindLoadFile
--dprintf( 'Alt_1: rc = 0, found.')
leave
elseif not rc & not LoadFilename then
-- Ensure that rc is set, file not found
rc = 13 -- Invalid data
--dprintf( 'Alt_1: LoadFilename = empty.')
leave
elseif rc = 31 then
-- Alt1FindLoadFile canceled
--dprintf( 'Alt_1: rc = 31, canceled.')
leave
elseif rc = 123 then
-- Only placeholders
--dprintf( 'Alt_1: Only placeholders.')
leave
endif
Spec = LoadFilename
-- Alt1FindLoadFile was not successful
call Parse_Filename( Spec)
-- Alt1FindSpecInTree -> Alt1SelectTreeDir gives the opportunity to
-- search in an entered tree if previous searches were not successful.
TreeDir = ''
if SearchStr = '' then
call Alt1FindSpecInTree( Spec, TreeDir, '', LoadLine, LoadCol)
else
call Alt1FindSpecInTree( Spec, TreeDir, SearchStr)
endif
enddo
mouse_setpointer vepm_pointer
if rc = 31 then
'SayError Command canceled.'
elseif rc = 13 then
'SayError No filename specified.'
elseif rc = 123 then
'SayError Only placeholders specified.'
elseif rc then
'SayError Filename under cursor not found.'
endif
; ---------------------------------------------------------------------------
; shell or .DOS DIR, Sets LoadLine.
defproc Alt1ProcessCmdDir( LineStr, var LoadFilename)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
call pSave_Pos( SavedPos)
getsearch SavedSearch
Cmd = ''
ShellDir = ''
if IsAShell() then
-- Search (reverse) in command shell buffer for the prompt and retrieve
-- the current directory and the cmd and its parameters
-- goto previous prompt line.
-- This is similar to ShellGetPrevDir, but here also Cmd is processed.
SavedRc = rc
call ShellGotoNextPrompt( 'P')
Params = ''
if not rc then
call ShellParseLineDirCmd( .line, ShellDir, Cmd)
parse value Cmd with Cmd Params
endif
rc = SavedRc
call pRestore_Pos( SavedPos)
elseif upcase( leftstr( .filename, 8)) = '.DOS DIR' then -- if a .DOS DIR buffer,
parse value upcase( .filename) with '.DOS DIR' Params -- retrieve params from the title
Cmd = 'DIR'
CurDir = directory() -- get current directory
endif
if upcase( Cmd) <> 'DIR' then -- if "dir" executed as last cmd in .command_shell_ or if .DOS DIR
leave
endif
Flags = ''
FileSpec = ''
Dir = ''
FullName = ''
call Alt1ParseDirParams( Params, Flags, FileSpec) -- parse Params and DIRCMD env var, set Flags and FileSpec
if pos( 'B', Flags) then -- if DIR /B, lines are filenames only and there is no "Directory of" line
Name = LineStr
pWildCard = verify( FileSpec, '*?', 'M')
if pWildCard then -- if a wildcard is used
pBackSlash = lastpos( '\', FileSpec, pWildCard ) -- find the last '\' preceding the wildcard
if pBackSlash then -- if found, set dir to FileSpec up to but not
if pos( ':', FileSpec) = pBackSlash - 1 then -- if root dir
DirName = leftstr( FileSpec, pBackSlash) -- including the found '\'
else -- else
DirName = leftstr( FileSpec, pBackSlash - 1) -- excluding the found '\'
endif
else
DirName = '' -- else there is no dir in the FileSpec
endif
else
DirName = FileSpec -- else (no wildcards) the FileSpec is the dir
endif
-- Check if DirName is fully qualified
if substr( DirName, 1, 2) = '\\' then -- UNC names must be fully qualified, because CD is not allowed
Dir = DirName
elseif substr( DirName, 2, 2) = ':\' then
Dir = DirName
elseif substr( DirName, 2, 1) = ':' then -- drive with relative path
CurDrive = upcase( substr( CurDir, 1, 2)) -- drive of prompt dir
Drive = upcase( substr( DirName, 1, 2)) -- specified drive
if upcase( leftstr( .filename, 8)) = '.DOS DIR' then -- .DOS DIR cannot change current dir so use it
Dir = DirName
elseif CurDrive = Drive then
Dir = strip( CurDir, 'T', '\')'\'substr( DirName, 3)
else -- if shell session, find current dir of specified drive in previous CD commands
PrevDir = ''
CdDir = ''
do while (PrevDir = '')
repeatfind -- find the previous prompt
if rc <> 0 then -- if prompt not found
leave
endif
Next = ''
Rest = ''
call ShellParseLineDirCmd( Next, Rest)
parse value upcase( strip( Rest)) with 'CD'CdParam
if strip( CdParam) > '' then
parse value strip( Rest) with 3 CdParam -- get case back
endif
CdParam = strip( CdParam)
if upcase( leftstr( CdParam, 2)) = Drive then
if substr( CdParam, 3, 1) = '\' then -- cd full_path found
PrevDir = CdParam
else -- cd relative_path found
ThisCdDir = substr( CdParam, 3)
if CdDir = '' then
CdDir = ThisCdDir
elseif ThisCdDir > '' then
CdDir = strip( ThisCdDir, 'T', '\')'\'CdDir
endif
--sayerror 'CdDir = 'CdDir
endif
elseif upcase( leftstr( Next, 2)) = Drive then -- drive found in prompt
PrevDir = Next
endif
enddo
setsearch SavedSearch
call pRestore_Pos( SavedPos)
--'SayError Drive = 'Drive', PrevDir = 'PrevDir', CdDir = 'CdDir', DirName = 'DirName
if PrevDir = '' then
if CdDir > '' then
Dir = Drive''strip( CdDir, 'T', '\')'\'substr( DirName, 3)
else
Dir = DirName
endif
else
if CdDir > '' then
PrevDir = strip( PrevDir, 'T', '\')'\'CdDir
endif
--sayerror 'PrevDir = 'PrevDir
-- use found dir and append specified path without drive
Dir = strip( PrevDir, 'T', '\')'\'substr( DirName, 3)
endif
endif
else -- relative path without drive
-- use CurDir
if leftstr( DirName, 1) == '\' then -- if path starts with '\'
Dir = leftstr( CurDir, 2)''DirName -- prepend the current drive
else
Dir = strip( CurDir, 'T', '\')'\'DirName -- else prepend entire current dir
endif
endif
-- Build FullName from Dir and Name
if substr( Name, 2, 2) = ':\' | substr( Name, 1, 2) = '\\' then -- if fully qualified
FullName = Name
elseif rightstr( Dir, 1) = ':' then -- if drive without a path
FullName = Dir''Name
else
FullName = strip( Dir, 'T', '\')'\'Name
endif
elseif pos( 'F', flags) then -- if DIR /F, then the line is the fully-qualified filename
-- Note: DIR /F /B is resolved to DIR /B.
FullName = LineStr
else -- if not DIR /F or DIR /B, then parse the dir listing
Name = ''
-- Check if word under cursor is fully qualified
p1 = pos( ':\', LineStr)
p2 = pos( '\\', LineStr)
if p1 > 0 then
FullName = strip( substr( LineStr, p1 - 1))
elseif p2 > 0 then
FullName = strip( substr( LineStr, p2))
endif
if FullName = '' then
if verify( word( LineStr, 1), DIR_DATETIME_CHARS) = 0 & -- date
Alt1VerifyTime( word( LineStr, 2), DIR_DATETIME_CHARS) then -- time
-- probably a dir listing, not FAT
NameIsDir = (word( LineStr, 3) = '
')
if verify( word( LineStr, 3), DIR_SIZE_CHARS) = 0 | -- size
NameIsDir then
if verify( word( LineStr, 4), DIR_SIZE_CHARS) = 0 then -- EAsize
if verify( word( LineStr, 5), DIR_ATTRIB_CHARS) = 0 & -- attribs if /v specified
length( word( LineStr, 5)) = 4 &
word( LineStr, 6) <> '' then
Name = subword( LineStr, 6)
else
Name = subword( LineStr, 5)
endif
else
--sayerror 'non-FAT EA size is invalid'
endif
else
--sayerror 'non-FAT size is invalid'
endif
elseif verify( word( LineStr, words( LineStr) - 1), DIR_DATETIME_CHARS) = 0 & -- date
Alt1VerifyTime( word( LineStr, words( LineStr)), DIR_DATETIME_CHARS) then -- time
-- probably a dir listing, FAT
--sayerror 'passed FAT code date/time verify'
Next = word( LineStr, words( LineStr) - 2)
NameIsDir = (Next = '')
if verify( Next, DIR_SIZE_CHARS) = 0 | -- size
NameIsDir then
p = wordindex( LineStr, words( LineStr) - 2) -- col of 3rdlast word
Name = strip( substr( LineStr, 1, p - 1))
HasExtCol = ((substr( Name, 9, 1) = ' ') & (pos( Name, '.') = 0)) -- listing with separated extension column
do once2 = 1 to 1
if not HasExtCol then
leave
endif
Ext = substr( Name, 9 + 1)
if Ext = '' then
leave
endif
Name = strip( substr( Name, 1, 9 - 1))'.'Ext
enddo
endif
else -- both FAT and non-FAT date/time edits failed
--sayerror 'Unable to identify format (FAT/non-FAT)'
endif
--sayerror 'Name = 'Name', NameIsDir = 'NameIsDir
if Name > '' then
-- Determine listed dir language-independently
fFoundDir = 0
fCheckNext = 0
l = .line
do while fFoundDir = 0
-- search upwards
l = l - 1
if l < 1 then
leave
endif
getline CurDirLineStr, l
-- Find the Next empty line
if CurDirLineStr = '' then
fCheckNext = 1 -- Next line contains the current dir (Directory of ...)
elseif fCheckNext then
p1 = lastpos( ':\', CurDirLineStr)
p2 = lastpos( '\\', CurDirLineStr)
if p1 > 0 then
Dir = strip( substr( CurDirLineStr, p1 - 1))
fFoundDir = 1
findrc = 0
leave
elseif p2 > 0 then
Dir = strip( substr( CurDirLineStr, p2))
fFoundDir = 1
findrc = 0
leave
else -- Maybe user added an empty line to dir listing
fCheckNext = 0
endif
endif
enddo
if fFoundDir then
-- Handle 4os2 output that lists not only the name of the dir, but
-- appends the wildcard segment, if specified:
lp = lastpos( '\', Dir)
lastseg = substr( Dir, lp)
if verify( lastseg, '*?', 'M') then
-- Strip last segment
Dir = substr( Dir, 1, lp - 1)
endif
-- Build FullName
FullName = strip( Dir, 'T', '\')'\'Name
endif
else
'SayError Unable to parse file name from directory listing.'
findrc = 2
leave
endif
endif -- if FullName = ''
endif -- if DIR /B
if FullName = '' then
FullName = Name
endif
-- Successfully parsed
LoadFilename = NepmdQueryFullName( FullName)
findrc = 2 -- File not found
if NepmdFileExists( LoadFilename) then
findrc = 0
EditArgs = EnquoteFileSpec( LoadFilename)
'DialogLoadFile 'EditArgs
elseif NepmdDirExists( LoadFilename) then
findrc = 0
'Dir 'EnquoteFileSpec( LoadFilename)
else
findrc = 2
'SayError No such file/dir: 'LoadFilename
endif
enddo
rc = findrc
return
; ---------------------------------------------------------------------------
; .Tree.
defproc Alt1ProcessTree( LineStr, var LoadFilename)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
if upcase( leftstr( .filename, 5)) <> '.TREE' then
leave
endif
TreeListName = GetTreeListFilename()
if not TreeListName then
leave
endif
-- Successfully parsed
LoadFilename = TreeListName
findrc = 2 -- File not found
if substr( LineStr, 31, 1) = '>' then
if isadefc( 'TreeDir') then
'TreeDir' EnquoteFileSpec( TreeListName'\*')
else
'Dir' EnquoteFileSpec( TreeListName)
endif
else
EditArgs = EnquoteFileSpec( TreeListName)
'DialogLoadFile 'EditArgs
endif
findrc = rc
enddo
rc = findrc
return
; ---------------------------------------------------------------------------
; .Output from grep (Gnu).
defproc Alt1ProcessGrepLog( LineStr, var LoadFilename)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
LogFilenameStr = '.OUTPUT FROM GREP'
if upcase( leftstr( .filename, length( LogFilenameStr))) <> LogFilenameStr then
leave
endif
-- Handle GNU grep output like fully_qualified_filename:lineno:text
-- New: get current dir from line 1 to handle relative paths.
parse value textline( 2) with 'Current directory = 'CurDir
if substr( LineStr, 1, 2) = '\\' | substr( LineStr, 2, 2) = ':\' then -- fully qualified
parse value substr( LineStr, 3) with Next':'LineNumber':'Rest
LoadFileName = substr( LineStr, 1, 2 + length( Next))
LoadFileName = translate( LoadFileName, '\', '/')
else
parse value LineStr with FileSpec':'LineNumber':'Rest
if LineNumber then
FileSpec = translate( FileSpec, '\', '/')
LoadFileName = GetFullName( FileSpec, CurDir)
else
LoadFileName = ''
endif
endif
if not LoadFileName then
leave
endif
-- Successfully parsed
findrc = 2 -- File not found
if Rest & IsNum( LineNumber) then
EditArgs = EnquoteFileSpec( LoadFilename) "'GoTo "LineNumber"'"
'DialogLoadFile 'EditArgs
else
EditArgs = EnquoteFileSpec( LoadFilename)
'DialogLoadFile 'EditArgs
endif
findrc = rc
enddo
rc = findrc
return
; ---------------------------------------------------------------------------
; include (multiple modes).
; Should work with any preprocesor, filetype, past to future
defproc Alt1ProcessInclude( LineStr, var LoadFilename)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
LineStr = strip( LineStr)
CurMode = GetMode()
parse value lowcase( LineStr) with word1 word2 .
if rightstr( word1, 7) <> 'include' then -- if first word ends in "include"
leave
endif
delim = leftstr( word2, 1)
fPrependCurrentDir = 1
if pos( delim, "'" || '"') > 0 then -- file has quote delimiters?
parse value LineStr with . (delim) Spec (delim) .
elseif delim = '<' then
parse value LineStr with . '<' Spec '>' .
if CurMode = 'C' then
fPrependCurrentDir = 0
if lowcase( ' 'rightstr( Spec, 2)) <> '.h' then -- Support newer C++ includes w/o '.h'
Spec = Spec'.h'
endif
endif
else
Spec = word2 -- file has no delimiters, eg. MAKE !include file
endif
if not Spec then
leave
endif
-- Successfully parsed
LoadFilename = Spec
findrc = 2 -- File not found
-- Find Filename and execute DialogLoadFile if found
LoadFilename = Alt1FindLoadFile( Spec)
findrc = rc
if findrc & Spec then
-- Nothing found, but searched. Pass Spec, but with rc:
LoadFilename = Spec
endif
enddo
rc = findrc
return
; ---------------------------------------------------------------------------
defproc Alt1GetPythonSpec( LineStr, wp)
RestWords = subword( LineStr, wp + 1)
RestCol = wordindex( LineStr, wp + 1)
if .col < RestCol then
-- Cursor is not after 'import', get all words
Spec = RestWords
Spec = translate( Spec, ' ', ','\9)
Spec = SpaceStr( Spec, 1)
else
-- Cursor is after 'import', get word under cursor
Seps = ' ,'\9
WordUnderCursor = GetWordUnderCursor( Seps)
Spec = WordUnderCursor
endif
return Spec
; ---------------------------------------------------------------------------
; import (PYTHON). Mainly by Greg Jarvis.
defproc Alt1ProcessPythonImport( LineStr, var LoadFilename)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
CurMode = GetMode()
if CurMode <> 'PYTHON' then
leave
endif
/*
mode python
SET PYTHONPATH=M:/python/Lib;M:/python/Lib/plat-os2emx;M:/python/Lib/lib-dynload;M:/python/Lib/site-packages
import sys, cStringIO, select, socket
from base.codes import *
from base import device, utils, msg
*/
parse value lowcase( LineStr) with word1 word2 .
Dir = ''
Spec = ''
if word1 = 'from' & word2 then -- if first word equals "from"
if pos( '.', word2) then
parse value word2 with Dir '.' Spec
else
Dir = word2
wp = wordpos( 'import', LineStr)
if not wp then
leave
endif
Spec = Alt1GetPythonSpec( LineStr, wp)
endif
elseif word1 = 'import' & word2 then -- if first word equals "import"
wp = 1
Spec = Alt1GetPythonSpec( LineStr, wp)
endif
if not Spec then
leave
endif
-- Successfully parsed
-- For simpleness: take only first word if not find in the following,
-- even when multple words from a list were parsed
LoadFilename = word( Spec, 1)'.py'
findrc = 2 -- File not found
--dprintf( 'Alt1ProcessPythonImport: Spec = 'Spec', findrc = 'findrc)
-- Search all elements of Spec
do i = 1 to words( Spec)
-- Find Filename and execute DialogLoadFile if found
ThisSpec = word( Spec, i)'.py'
if Dir then
ThisSpec = Dir'/'ThisSpec
endif
LoadFilename = Alt1FindLoadFile( ThisSpec)
if LoadFilename then
leave
endif
enddo
findrc = rc
if findrc & Spec then
-- Nothing found, but searched. Pass Spec, but with rc:
LoadFilename = Spec
endif
enddo
rc = findrc
return
; ---------------------------------------------------------------------------
; Output from icc and others. The env. is usually only set locally for the
; make process.
defproc Alt1ProcessCompileError( LineStr, var LoadFilename, var LoadLine,
var LoadCol)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
LoadLine = ''
LoadCol = ''
ErrorMsg = ''
LineStr = strip( LineStr)
/*
file.c(343:6) : error EDC0277: Syntax error: possible missing ';' or ','?
file.c(343:1) : error EDC0045: Undeclared identifier This.
NMAKE : fatal error U1077: 'C:\OS2\CMD.EXE' : return code '12'
Stop.
NMAKE : fatal error U1077: 'C:\OS2\CMD.EXE' : return code '255'
Stop.
IPF errors converted by HText.cmd
mk.ipf(2): Warning 121: Invalid head level [toc=]
*****(***): Warning 105: Illegal context for tag [euserdoc]
*****(***): Error 150: Document has no vocabulary
*/
-- jbl 11/15/88: The C compiler error line can have a line number in
-- parentheses, like "/epm/i/iproto.h(196)". Get the number.
p = pos( '(', LineStr)
if not p then
leave
endif
-- Parse filename, LoadLine and LoadCol
parse value LineStr with Spec '(' num ')' Rest
if verify( num, '0123456789:') then -- if other chars than number or colon
-- Not found
leave
endif
if Spec <> '' & not verify( Spec, '*') then -- if only placeholders
-- Not found, avoid further searching
LoadFilename = Spec
findrc = 123 -- ERROR_INVALID_NAME
leave
endif
parse value num with LoadLine ':' LoadCol -- LAM: CSet/2 includes column
-- Successfully parsed
LoadFilename = Spec
findrc = 2 -- File not found
-- Parse ErrorMsg
Rest = strip( Rest)
if leftstr( Rest, 1) = ':' then
Rest = substr( Rest, 2)
Rest = strip( Rest)
endif
ErrorMsg = Rest
-- Find Filename and execute DialogLoadFile if found
if LoadCol then
--dprintf( 'Alt1ProcessCompileError: LoadFilename = Alt1FindLoadFile( 'Spec', 'LoadLine', 'LoadCol')')
LoadFilename = Alt1FindLoadFile( Spec, '', LoadLine, LoadCol)
else
--dprintf( 'Alt1ProcessCompileError: LoadFilename = Alt1FindLoadFile( 'Spec', 'LoadLine')')
LoadFilename = Alt1FindLoadFile( Spec, '', LoadLine)
endif
findrc = rc
if not findrc & ErrorMsg then
-- This is not written to the MsgBox:
'SayErrorMsg 'ErrorMsg
endif
if findrc & Spec then
-- Nothing found, but searched. Pass Spec, but with rc:
LoadFilename = Spec
endif
enddo
rc = findrc
--dprintf( 'Alt1ProcessCompileError: LoadFilename = 'LoadFilename', rc = 'rc)
return
; ---------------------------------------------------------------------------
; Output from IPFC.
defproc Alt1ProcessIpfcError( LineStr, var LoadFilename, var LoadLine)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
LoadLine = ''
ErrorMsg = ''
LineStr = strip( LineStr)
/*
<*****:***> Error 109: Cannot open file [nonexist.IPF]
Warning 120: Ignoring text before :h1 tag
*/
if leftstr( LineStr, 1) <> '<' then
leave
endif
parse value LineStr with '<'Spec':'LoadLine'>' ErrorMsg
if not verify( Spec, '*') then -- if only placeholders
-- Not found, avoid further searching
LoadFilename = Spec
findrc = 123 -- ERROR_INVALID_NAME
leave
endif
if not IsUInt( LoadLine) then
-- Not found
leave
endif
ErrorMsg = strip( ErrorMsg)
-- Successfully parsed
LoadFilename = Spec
findrc = 2 -- File not found
-- Find Filename and execute DialogLoadFile if found
LoadFilename = Alt1FindLoadFile( Spec, '', LoadLine)
findrc = rc
if not findrc & ErrorMsg then
-- This is not written to the MsgBox:
'SayErrorMsg 'ErrorMsg
endif
if findrc & Spec then
-- Nothing found, but searched. Pass Spec, but with rc:
LoadFilename = Spec
endif
enddo
rc = findrc
--dprintf( 'Alt1ProcessIpfcError: LoadFilename = 'LoadFilename', rc = 'rc)
return
; ---------------------------------------------------------------------------
; Output from REXX.
; Filenames are fully qualified.
defproc Alt1ProcessRexxError( LineStr, var LoadFilename, var LoadLine)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
LoadLine = ''
ErrorNum = ''
ErrorMsg = ''
LineStr = strip( LineStr)
/*
-- Test with a space added in comment begin of ErrorMsg to make the
-- E compiler happy. Its check doesn't handle strings correctly.
-- Classic REXX:
REX0006: Error 6 running C:\testerr.cmd, line 56: Unmatched "/ *" or quote
REX0006: Error 6 running
F:\Apps\NEPMD\myepm\macros\test-files\test-modes\createchangelog.cmd, line 56:
Unmatched "/ *" or quote
-- Object REXX:
56 *-* RepDir = 'G:\dev\netlabs\nepmd
REX0006E: Error 6 running C:\testerr.cmd line 56: Unmatched "/ *" or quote
REX0203E: Error 6.2: Unmatched single quote (')
56 *-* RepDir = 'G:\dev\netlabs\nepmd
REX0006E: Error 6 running F:\Apps\NEPMD\myepm\macros\test-files\test-modes\createchangelog.cmd line 56: Unmatched "/ *" or quote
REX0203E: Error 6.2: Unmatched single quote (')
*/
-- Concatenate all lines of error msg first
-- Find the begin of the error msg
ErrorLineStr = ''
do l = 1 to 3
if pos( 'REX', LineStr) = 1 then
ErrorLineStr = LineStr
leave
else
PrevLine = .line - l
if PrevLine <= 1 then
leave
endif
-- Prepend previous line
LineStr = strip( textline( PrevLine)) LineStr
endif
enddo
if not ErrorLineStr then
-- Not found
leave
endif
-- Parse the entire error msg, append next line until ErrorMsg found
do l = 1 to 3
parse value ErrorLineStr with 'REX'ErrorNum':' . . 'running' LoadFilename 'line' LoadLine':' ErrorMsg
--dprintf( 'ErrorLineStr = 'ErrorLineStr)
if ErrorMsg then
leave
endif
-- End not found, append next line
ErrorLineStr = ErrorLineStr strip( textline( .line + l))
enddo
if not ErrorMsg then
-- Not found
leave
endif
-- Strip spaces
LoadFilename = strip( LoadFilename)
LoadLine = strip( LoadLine)
ErrorMsg = strip( ErrorMsg)
-- Strip trailing comma of Classic REXX
if rightstr( LoadFilename, 1) = ',' then
LoadFilename = leftstr( LoadFilename, length( LoadFilename) - 1)
endif
--dprintf( ' ErrorNum = 'ErrorNum', LoadFilename = 'LoadFilename', LoadLine = 'LoadLine', ErrorMsg = 'ErrorMsg)
if not LoadFilename then
leave
endif
-- Successfully parsed, LoadFilename is fully qualified and set
findrc = 2 -- File not found
if Exist( LoadFilename) then
findrc = 0
endif
EditArgs = EnquoteFileSpec( LoadFilename) "'GoTo "LoadLine"'"
if IsUInt( LoadLine) then
EditArgs = EditArgs "'GoTo "LoadLine"'"
endif
'DialogLoadFile 'EditArgs
if ErrorNum then
ErrorMsg = 'REX'ErrorNum': 'ErrorMsg
endif
if ErrorMsg then
-- This is not written to the MsgBox:
'SayErrorMsg 'ErrorMsg
endif
enddo
rc = findrc
return
; ---------------------------------------------------------------------------
; Compile error (POSIX, JAVA). Mainly by Greg Jarvis.
defproc Alt1ProcessPosixError( LineStr, var LoadFilename, var LoadLine,
var LoadCol)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
LoadLine = ''
LoadCol = ''
ErrorMsg = ''
LineStr = strip( LineStr)
/*
ink.c:9:22: inklevel.h: No such file or directory
ink.c: In function `main':
ink.c:37: error: `PARPORT' undeclared (first use in this function)
https://www.os2world.com/forum/index.php/topic,3033.msg34330.html#msg34330
gcc -Wall -Zomf -c -O2 bitcat2.c -o bitcat2.obj
bitcat2.c: In function 'main':
bitcat2.c:36:29: warning: pointer targets in passing argument 2 of 'WinRegisterClass' differ in signedness [-Wpointer-sign]
36 | WinRegisterClass(hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0);
| ^~~~~~~~~~~~~
| |
| CHAR * {aka char *}
In file included from W:/usr/include/os2.h:39,
from bitcat2.c:4:
W:/usr/include/os2emx.h:6138:47: note: expected 'PCSZ' {aka 'const unsigned char *'} but argument is of type 'CHAR *' {aka 'char *'}
6138 | BOOL APIENTRY WinRegisterClass (HAB hab, PCSZ pszClassName, PFNWP pfnWndProc,
| ~~~~~^~~~~~~~~~~~
bitcat2.c:39:53: warning: pointer targets in passing argument 4 of 'WinCreateStdWindow' differ in signedness [-Wpointer-sign]
39 | &flFrameFlags, szClientClass, NULL,
| ^~~~~~~~~~~~~
| |
| CHAR * {aka char *}
In file included from W:/usr/include/os2.h:39,
from bitcat2.c:4:
W:/usr/include/os2emx.h:6003:33: note: expected 'PCSZ' {aka 'const unsigned char *'} but argument is of type 'CHAR *' {aka 'char *'}
6003 | PULONG pflCreateFlags, PCSZ pszClientClass, PCSZ pszTitle,
| ~~~~~^~~~~~~~~~~~~~
bitcat2.c: In function 'ClientWndProc':
bitcat2.c:70:57: warning: pointer targets in passing argument 3 of 'DevOpenDC' differ in signedness [-Wpointer-sign]
70 | hdcMemory = DevOpenDC(hab, OD_MEMORY, "*", 0L, NULL, 0);
| ^~~
| |
| char *
In file included from W:/usr/include/os2.h:39,
from bitcat2.c:4:
W:/usr/include/os2emx.h:9979:51: note: expected 'PCSZ' {aka 'const unsigned char *'} but argument is of type 'char *'
9979 | HDC APIENTRY DevOpenDC (HAB hab, LONG lType, PCSZ pszToken, LONG lCount,
| ~~~~~^~~~~~~~
gcc -Zomf bitcat2.obj bitcat2.def -o bitcat2.exe
*/
CheckWord = word( LineStr, 1)
if rightstr( CheckWord, 1) <> ':' then
leave
endif
-- Parse reversed word
RevCheckWord = reverse( CheckWord)
parse value RevCheckWord with ':'RevCol':'RevLine':'RevSpec
if not IsUInt( RevLine) then
RevCol = ''
parse value RevCheckWord with ':'RevLine':'RevSpec
if not IsUInt( RevLine) then
leave
endif
endif
if RevSpec then
Spec = reverse( RevSpec)
else
-- Not found
leave
endif
if RevLine then
LoadLine = reverse( RevLine)
endif
if RevCol then
LoadCol = reverse( RevCol)
endif
-- Successfully parsed
LoadFilename = Spec
findrc = 2 -- File not found
--dprintf( 'Alt1ProcessPosixError: Spec = 'Spec', findrc = 'findrc)
-- Parse ErrorMsg
ErrorMsg = strip( subword( LineStr, 2))
-- Find Filename and execute DialogLoadFile if found
if LoadCol then
LoadFilename = Alt1FindLoadFile( Spec, '', LoadLine, LoadCol)
elseif LoadLine then
LoadFilename = Alt1FindLoadFile( Spec, '', LoadLine)
else
LoadFilename = Alt1FindLoadFile( Spec)
endif
findrc = rc
if not findrc & ErrorMsg then
-- This is not written to the MsgBox:
'SayErrorMsg 'ErrorMsg
endif
if findrc & Spec then
-- Nothing found, but searched. Pass Spec, but with rc:
LoadFilename = Spec
endif
enddo
rc = findrc
return
; ---------------------------------------------------------------------------
; SAXON error. Mainly by Greg Jarvis.
defproc Alt1ProcessSaxonError( LineStr, var LoadFilename, var LoadLine,
var LoadCol)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
LoadLine = ''
LoadCol = ''
ErrorMsg = ''
/*
Error on line 113 column 44 of file:/E:/MSRC/ipf/wiki.xsl:
Error at xsl:template on line 34 of file:/e:/msrc/ipf/wiki.xsl:
*/
if not pos( 'file:', LineStr) then
leave
endif
parse value LineStr with 'line' LoadLine . 'of file:' Spec .
parse value LineStr with . 'column' LoadCol .
Spec = strip( strip( Spec, 'T', ':'), 'L', '/')
-- Successfully parsed
LoadFilename = Spec
findrc = 2 -- File not found
-- Parse ErrorMsg
CheckLineStr = upcase( LineStr)
if word( CheckLineStr, 1) = 'ERROR' then
wp = wordpos( 'ON', CheckLineStr, 2)
if wp then
ErrorMsg = subword( LineStr, 1, wp - 1)
endif
endif
-- Find Filename and execute DialogLoadFile if found
if LoadCol then
LoadFilename = Alt1FindLoadFile( Spec, '', LoadLine, LoadCol)
elseif LoadLine then
LoadFilename = Alt1FindLoadFile( Spec, '', LoadLine)
else
LoadFilename = Alt1FindLoadFile( Spec)
endif
findrc = rc
if not findrc & ErrorMsg then
-- This is not written to the MsgBox:
'SayErrorMsg 'ErrorMsg
endif
if findrc & Spec then
-- Nothing found, but searched. Pass Spec, but with rc:
LoadFilename = Spec
endif
enddo
rc = findrc
return
; ---------------------------------------------------------------------------
; PYTHON traceback and syntax. Mainly by Greg Jarvis.
defproc Alt1ProcessPythonError( LineStr, var LoadFilename, var LoadLine,
var LoadCol)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
LoadLine = ''
LoadCol = ''
ErrorMsg = ''
-- Traceback (most recent call last):
/*
File "E:\msrc\hplip\hplip-2.7.7\makeuri.py", line 36, in ?
from base import device, utils
File "base/device.py", line 36, in ?
import utils, status, pml, service, tui
File "base/utils.py", line 37, in ?
import pexpect
File "base/pexpect.py", line 84, in ?
raise ImportError (str(e) + " A critical module was not found.")
ImportError: No module named resource A critical module was not found.
File "E:\APPS\NEPMD\myepm\macros\alt_1.e", line 1
/ ****************************** Module Header *******************************
^
SyntaxError: invalid syntax
*/
if word( LineStr, 1) <> 'File' then
leave
endif
parse value LineStr with '"' Spec '", line' LoadLine ','
--dprintf( 'LoadLine = 'LoadLine', LineStr = 'LineStr)
if not Spec then
leave
endif
if not IsUInt( LoadLine) then
leave
endif
-- Successfully parsed
LoadFilename = Spec
findrc = 2 -- File not found
ThisLine = .line + 2
do while word( textline( ThisLine), 1) == 'File'
ThisLine = ThisLine + 2
enddo
ThisLineStr = textline( ThisLine)
if strip( ThisLineStr) == '^' then
NextLineStr = textline( ThisLine + 1)
ErrorMsg = strip( NextLineStr)
-- LoadCol is only set if cursor is on the last 'File' line.
MsgIndent = Max( 1, verify( NextLineStr, ' '\t)) - 1 -- 0 in shell
TraceIndent = 4
LoadCol = Max( pos( '^', ThisLineStr) - TraceIndent - MsgIndent, 1)
else
ErrorMsg = strip( ThisLineStr)
endif
--dprintf( 'Alt1ProcessPythonError: LoadCol = 'LoadCol', ErrorMsg = 'ErrorMsg)
-- Find Filename and execute DialogLoadFile if found
if LoadCol then
LoadFilename = Alt1FindLoadFile( Spec, '', LoadLine, LoadCol)
else
LoadFilename = Alt1FindLoadFile( Spec, '', LoadLine)
endif
findrc = rc
--dprintf( 'Alt1ProcessPythonError: findrc = 'findrc' for Spec = 'Spec', LoadFilename = 'LoadFilename)
if not findrc & ErrorMsg then
-- This is not written to the MsgBox:
'SayErrorMsg 'ErrorMsg
endif
if findrc & Spec then
-- Nothing found, but searched. Pass Spec, but with rc
LoadFilename = Spec
endif
enddo
rc = findrc
return
; ---------------------------------------------------------------------------
; Marked one-line string
defproc Alt1ProcessMarkedString( LineStr, var LoadFilename)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
fCursorOnMark = 0
getmark mkfirstline, mklastline, mkfirstcol, mklastcol, mkfid
do once2 = 1 to 1
getfileid fid
-- Ignore multiple marked lines
if mkfid <> fid then
leave
elseif mkfirstline > .line then
leave
elseif mklastline < .line then
leave
elseif not InMark() then
leave
endif
fCursorOnMark = 1
enddo
if not fCursorOnMark then
leave
endif
Spec = substr( LineStr, mkfirstcol, mklastcol - mkfirstcol + 1)
if Spec = '' then
leave
endif
-- Successfully parsed
LoadFilename = Spec
findrc = 2 -- File not found
if IsUrl( Spec) then
-- Load URL
Url = Spec
'OpenUrlDlg' Url
findrc = rc
leave
endif
-- Find Filename and execute DialogLoadFile if found
LoadFilename = Alt1FindLoadFile( Spec)
findrc = rc
if findrc & Spec then
-- Nothing found, but searched. Pass Spec, but with rc:
LoadFilename = Spec
endif
enddo
rc = findrc
return
; ---------------------------------------------------------------------------
; Word under cursor, optionally with appended search string or pos.
defproc Alt1ProcessWord( LineStr, var LoadFilename, var SearchStr,
var LoadLine, var LoadCol)
do once = 1 to 1
findrc = -1 -- findrc <> -1 means processed
LoadFilename = ''
Url = GetUrlUnderCursor()
if Url <> '' then
-- Load URL
'OpenUrlDlg' Url
findrc = rc
leave
endif
-- Tests:
-- 1 -- EDIT.E:"defc Edit", STDCTRL.E:"defc DialogLoadFile"
-- 2 -- EDIT.E:"defc Edit", STDCTRL.E:DialogLoadFile
-- 3 -- EDIT.E:"defc Edit", "STDCTRL.E":DialogLoadFile
-- 4 -- EDIT.E:"defc Edit", "STDCTRL.E":"defc DialogLoadFile"
-- 5 -- F:\Apps\NEPMD\myepm\macros\EDIT.E:"defc Edit", "F:\Apps\NEPMD\myepm\macros\STDCTRL.E":"defc DialogLoadFile"
-- 6 -- EDIT.E, STDCTRL.E
-- 7 -- EDIT.E:122:4
-- 8 -- EDIT.E:"122":4
-- 9 -- EDIT.E:"1599":4
--10 -- EDIT.E:122
Spec = '' -- Determined file specifier under cursor
CurCol = .col
LineLen = length( LineStr)
SeparatorList = "'"||'(){}[]<>,;|+ '\9'#'
ThisStr = ''
pColonBefore = 0
pColonAfter = 0
fEnquoted = 0
Str1 = ''
Str2 = ''
Str3 = ''
fEnquoted1 = 0
fEnquoted2 = 0
fEnquoted3 = 0
call Alt1GetStrAtPos( LineStr, LineLen, CurCol, SeparatorList,
ThisStr, pColonBefore, pColonAfter, fEnquoted)
--dprintf( '1) fEnquoted = 'fEnquoted', ThisStr = >'ThisStr'<, pColonBefore = 'pColonBefore', pColonAfter = 'pColonAfter', CurCol = 'CurCol)
if pColonBefore then
Str2 = ThisStr
fEnquoted2 = fEnquoted
else
-- No search string or line number specified: No more parsing.
Str1 = ThisStr
fEnquoted1 = fEnquoted
endif
FirstpColonAfter = pColonAfter
if pColonBefore & pColonAfter then
-- CurCol started on Str2 of 3.
-- Get Str3 and then go back to CurCol from search before.
SavedStr = ThisStr
SavedCol = CurCol
SavedpColonBefore = pColonBefore
SavedpColonAfter = pColonAfter
CurCol = pColonAfter + 1
call Alt1GetStrAtPos( LineStr, LineLen, CurCol, SeparatorList,
ThisStr, pColonBefore, pColonAfter, fEnquoted)
--dprintf( '2) fEnquoted = 'fEnquoted', ThisStr = >'ThisStr'<, pColonBefore = 'pColonBefore', pColonAfter = 'pColonAfter', CurCol = 'CurCol)
Str3 = ThisStr
fEnquoted3 = fEnquoted
ThisStr = SavedStr
CurCol = SavedCol
pColonBefore = SavedpColonBefore
pColonAfter = SavedpColonAfter
endif
if pColonBefore then
-- CurCol started on Str2 of 2 or in Str3 of 3.
Str1 = ThisStr
fEnquoted1 = fEnquoted
CurCol = pColonBefore - 1
call Alt1GetStrAtPos( LineStr, LineLen, CurCol, SeparatorList,
ThisStr, pColonBefore, pColonAfter, fEnquoted)
--dprintf( '3) fEnquoted = 'fEnquoted', ThisStr = >'ThisStr'<, pColonBefore = 'pColonBefore', pColonAfter = 'pColonAfter', CurCol = 'CurCol)
Str1 = ThisStr
fEnquoted1 = fEnquoted
elseif pColonAfter then
-- CurCol started on Str1 of 2 or 3.
Str1 = ThisStr
CurCol = pColonAfter + 1
call Alt1GetStrAtPos( LineStr, LineLen, CurCol, SeparatorList,
ThisStr, pColonBefore, pColonAfter, fEnquoted)
--dprintf( '4) fEnquoted = 'fEnquoted', ThisStr = >'ThisStr'<, pColonBefore = 'pColonBefore', pColonAfter = 'pColonAfter', CurCol = 'CurCol)
Str2 = ThisStr
fEnquoted2 = fEnquoted
endif
if pColonBefore & pColonAfter & FirstpColonAfter = 0 then
-- CurCol started on the Str3, not on Str2.
-- Go 1 Str left and copy vars and get Str1.
CurCol = pColonBefore - 1
call Alt1GetStrAtPos( LineStr, LineLen, CurCol, SeparatorList,
ThisStr, pColonBefore, pColonAfter, fEnquoted)
--dprintf( '5) fEnquoted = 'fEnquoted', ThisStr = >'ThisStr'<, pColonBefore = 'pColonBefore', pColonAfter = 'pColonAfter', CurCol = 'CurCol)
--dprintf( ' Vars before copy: Str1 = >'Str1'<, Str2 = >'Str2'<, Str3 = >'Str3'<')
Str3 = Str2
Str2 = Str1
Str1 = ThisStr
fEnquoted3 = fEnquoted2
fEnquoted2 = fEnquoted1
fEnquoted1 = fEnquoted
endif
if pColonBefore & pColonAfter & FirstpColonAfter > 0 then
-- CurCol started on the Str1.
-- Go 1 Str right to get Str3.
CurCol = pColonAfter + 1
call Alt1GetStrAtPos( LineStr, LineLen, CurCol, SeparatorList,
ThisStr, pColonBefore, pColonAfter, fEnquoted)
--dprintf( '6) fEnquoted = 'fEnquoted', ThisStr = >'ThisStr'<, pColonBefore = 'pColonBefore', pColonAfter = 'pColonAfter', CurCol = 'CurCol)
Str3 = ThisStr
fEnquoted3 = fEnquoted
endif
--dprintf( 'Alt1ProcessWord: Str1 = >'Str1'<, Str2 = >'Str2'<, Str3 = >'Str3'<')
--dprintf( 'Alt1ProcessWord: fEnquoted1 = 'fEnquoted1', fEnquoted2 = 'fEnquoted2', fEnquoted3 = 'fEnquoted3)
LoadLine = ''
LoadCol = ''
SearchStr = ''
if Str1 = '' then
findrc = 13
--'SayError No filename under cursor.'
leave
else
Spec = Str1
endif
-- Spec:line
if IsUInt( Str2) & not fEnquoted2 then
LoadLine = Str2
--dprintf( 'Alt1ProcessWord 1: LoadLine = 'LoadLine)
-- Spec:line:col
if IsUInt( Str3) & not fEnquoted3 then
LoadCol = Str3
endif
-- Spec:string
elseif Str2 <> '' then
SearchStr = Str2
--dprintf( 'Alt1ProcessWord 2: SearchStr = 'SearchStr)
endif
-- Successfully parsed
LoadFilename = Spec
findrc = 2 -- File not found
-- Find Filename and execute DialogLoadFile if found
if SearchStr <> '' then
LoadFilename = Alt1FindLoadFile( Spec, SearchStr)
--dprintf( 'Alt1ProcessWord 3: LoadFilename = 'LoadFilename', Spec = 'Spec', SearchStr = 'SearchStr', rc = 'rc)
elseif LoadLine <> '' then
LoadFilename = Alt1FindLoadFile( Spec, '', LoadLine, LoadCol)
--dprintf( 'Alt1ProcessWord 4: LoadFilename = 'LoadFilename', Spec = 'Spec', LoadLine = 'LoadLine', LoadCol = 'LoadCol', rc = 'rc)
else
LoadFilename = Alt1FindLoadFile( Spec)
--dprintf( 'Alt1ProcessWord 5: LoadFilename = 'LoadFilename', Spec = 'Spec', rc = 'rc)
endif
findrc = rc
if findrc & Spec then
-- Nothing found, but searched. Pass Spec, but with rc:
LoadFilename = Spec
endif
enddo
rc = findrc
--dprintf( 'Alt1ProcessWord: rc = 'rc' for Spec = 'Spec', LoadFilename = 'LoadFilename)
return
; ---------------------------------------------------------------------------
; Called by Alt1ProcessWord if not a URL.
defproc Alt1GetStrAtPos( LineStr, LineLen, CurCol, SeparatorList,
var ThisStr, var pColonBefore, var pColonAfter, var fEnquoted)
ThisStr = ''
pColonBefore = 0
pColonAfter = 0
do once = 1 to 1
fEnquoted = IsEnquoted( LineStr, CurCol)
CurChar = substr( LineStr, CurCol, 1)
NextChar = substr( LineStr, CurCol + 1, 1)
if not fEnquoted then
-- If cursor is on a colon, set CurCol to the string before.
-- Ignore drive specifiers.
if CurChar = ':' & not pos( NextChar, '\/') & CurCol > 1 then
CurCol = CurCol - 1
fEnquoted = IsEnquoted( LineStr, CurCol)
CurChar = substr( LineStr, CurCol, 1)
endif
-- If cursor is on the opening double quote, take that as enquoted
-- and advance CurCol
if CurChar = '"' then
fEnquoted = 1
CurCol = CurCol + 1
CurChar = substr( LineStr, CurCol, 1)
endif
endif
if fEnquoted then
if CurCol > 1 then
p1 = lastpos( '"', LineStr, CurCol - 1)
else
p1 = 0
endif
p2 = pos( '"', LineStr, CurCol)
if not (p1 & p2 & p2 > p1) then
fEnquoted = 0
else
-- String without double quotes
ThisStr = substr( LineStr, p1 + 1, p2 - p1 - 1)
-- Find ':' before or after ThisString
if p1 > 1 then
CharBefore = substr( LineStr, p1 - 1, 1)
if CharBefore = ':' then
pColonBefore = p1 - 1
endif
endif
if p2 < LineLen then
CharAfter = substr( LineStr, p2 + 1, 1)
if CharAfter = ':' then
pColonAfter = p2 + 1
endif
endif
endif
endif
if not fEnquoted then
SavedCol = .col
.col = CurCol
rcx = Find_Token( StartCol, EndCol, SeparatorList, '')
.col = SavedCol
fWordFound = (rcx == 1)
if not fWordFound then
leave
endif
if StartCol > 1 then
CharBefore = substr( LineStr, StartCol - 1, 1)
endif
if EndCol < LineLen then
CharAfter = substr( LineStr, EndCol + 1, 1)
endif
-- Find ':' before cursor in LineStr up to StartCol
pStart = Max( 1, CurCol - 1)
do forever
lp1 = lastpos( ':', LineStr, pStart)
if lp1 < StartCol then
leave
endif
-- Ignore drives in Spec
lp2 = lastpos( ':\', LineStr, pStart)
if lp2 = lp1 then
pStart = lp1 - 1
iterate
endif
lp2 = lastpos( ':/', LineStr, pStart)
if lp2 = lp1 then
pStart = lp1 - 1
iterate
endif
-- ':' before cursor found, use this as separator
StartCol = lp1 + 1
pColonBefore = lp1
leave
enddo
-- Find ':' after cursor in LineStr up to EndCol + 1
pStart = CurCol
do forever
p1 = pos( ':', LineStr, pStart)
if p1 > EndCol + 1 | not p1 then
leave
endif
-- Ignore drives in Spec
p2 = lastpos( ':\', LineStr, pStart)
if p2 = p1 then
pStart = p1 + 2
iterate
endif
p2 = lastpos( ':/', LineStr, pStart)
if p2 = p1 then
pStart = p1 + 2
iterate
endif
-- ':' after cursor found, use this as separator
EndCol = p1 - 1
pColonAfter = p1
leave
enddo
-- String without optional ':' after or before the cursor
ThisStr = substr( LineStr, StartCol, Max( 0, EndCol - StartCol + 1))
endif
enddo
return
; ---------------------------------------------------------------------------
; Finds and loads Filename.
; Returns LoadFilename, if found, otherwise empty.
; Sets rc > 0 for a standard error code, rc < 0 for an ETK error code, set
; by defc edit, or rc = 0 on success.
; o Filename can be a name, including wildcards.
; o SearchPath is determined from ProjectDir and an optional SearchDir for
; the file's mode.
defproc Alt1FindLoadFile( Filename)
do once = 1 to 1
SearchStr = arg( 2)
OpenLine = arg( 3)
OpenCol = arg( 4)
LoadFilename = ''
--dprintf( 'Alt1FindLoadFile( 'Filename', 'SearchStr', 'OpenLine', 'OpenCol')')
if Filename = '' then
-- Not found
leave
endif
if leftstr( Filename, 2) <> '//' then
-- Convert slashes to backslashes
Filename = translate( Filename, '\', '/')
endif
-- Strip trailing backslash if not a root dir
if rightstr( Filename, 1) = '\' & rightstr( Filename, 2) <> ':\' then
Filename = leftstr( Filename, length( Filename) - 1)
endif
-- Expand env vars and equal char
call Parse_Filename( Filename)
-- Get SearchPath: SearchPath for mode or work dir with appended
-- UserDir!v;ProjectDir!v;NetlabsDir!v
fAddProjectTree = 1
fAddNepmdDirs = 1
SearchPath = GetExtendedSearchPath( Filename, '', fAddProjectTree,
fAddNepmdDirs)
-- Every check for existing names returns always 0 for wildcards in name.
Cmd = ''
if OpenLine <> '' & IsNum( OpenLine) then
Cmd = 'AtEvent AfterStartup GoTo 'strip( OpenLine OpenCol)
elseif SearchStr <> '' then
Cmd = 'AtEvent AfterStartup FindStringInCode 'SearchStr
endif
--dprintf( 'Alt1FindLoadFile: Cmd = 'Cmd)
-- SearchPath may have recursion specified by appended '!', optionally
-- followed by 'v', 'f' or a number. FindFileInList handles that.
-- No need to add SubPaths here.
-- The specified Cmd is executed by FindFileInList for wildcards.
LoadFilename = FindFileInList( Filename, SearchPath, '', Cmd)
--dprintf( 'Alt1FindLoadFile: rc of FindFileInList = 'rc', Filename = 'Filename', SearchPath = 'SearchPath', LoadFilename = 'LoadFilename)
SavedRc = rc
if LoadFilename then
EditArgs = EnquoteFileSpec( LoadFilename)" '"Cmd"'"
'DialogLoadFile 'EditArgs
endif
rc = SavedRc
enddo
return LoadFilename
; ---------------------------------------------------------------------------
; This is called after previous searches have failed or were not processed.
; StartDir was entered by the user.
; If OpenLine is not a number, it is assumed that a SearchStr is specified.
; OpenCol is ignored then.
defproc Alt1FindSpecInTree( var Spec)
StartDir = arg( 2)
SearchStr = arg( 3)
OpenLine = arg( 4)
OpenCol = arg( 5)
--dprintf( 'Alt1FindSpecInTree: var Spec = 'Spec', StartDir = 'StartDir', SearchStr = 'SearchStr', OpenLine = 'OpenLine', OpenCol = 'OpenCol)
do once = 1 to 1
-- Handle fully-qualified Spec
if substr( Spec, 2, 2) = ':\' | -- fully qualified local spec
substr( Spec, 1, 2) = '\\' then -- fully qualified UNC spec
if Exist( Spec) then
leave
endif
Drive = GetFileSpec( 'D', Spec)
Path = GetFileSpec( 'P', Spec)
Name = GetFileSpec( 'N', Spec)
StartDir = Drive''Path
if Path <> '\' then
StartDir = strip( StartDir, 'T', '\')
endif
Spec = Name
endif
-- First check for Spec in dir of current file
rc = 0
ThisDir = NepmdQueryFullname( .filename'\..')
if rc then
leave
endif
-- Always strip trailing backslash for easier processing
ThisDir = strip( ThisDir, 'T', '\')
Next = ThisDir'\'Spec
if Exist( ThisDir'\'Spec) then
Spec = Next
leave
endif
-- Then check for Spec in dir of last prompt
ShellDir = ShellGetPrevDir()
if ShellDir <> '' then
ThisDir = ShellDir -- was determined before
ThisDir = strip( ThisDir, 'T', '\')
Next = ThisDir'\'Spec
if Exist( ThisDir'\'Spec) then
Spec = Next
leave
endif
endif
-- Then check for Spec in StartDir
if StartDir <> '' then
Next = StartDir'\'Spec
if Exist( StartDir'\'Spec) then
Spec = Next
leave
endif
else
StartDir = ThisDir
-- Re-append backslash for root dirs
if rightstr( StartDir, 1) = ':' then
StartDir = StartDir'\'
endif
endif
-- Search in tree and remove maybe relative path from Spec
SpecName = GetFileSpec( 'N', Spec)
Alt1SelectTreeDir( StartDir, SpecName, SearchDir, SearchName)
if SearchDir = '' then
rc = 31
leave
endif
SearchSpec = strip( SearchDir, 't', '\')'\'SearchName
--dprintf( 'Alt1FindSpecInTree( 'SpecName', 'Dir', 'SearchStr', 'OpenLine', 'OpenCol')')
if OpenLine <> '' then
if IsNum( OpenLine) then
SearchCmd = 'GoTo 'strip( OpenLine OpenCol)
elseif SearchStr <> '' then
--SearchCmd = 'FindTop 'SearchStr
SearchCmd = 'FindStringInCode 'SearchStr
else
SearchCmd = ''
endif
call SearchFileInTree( SearchName, SearchDir'!v', '', SearchCmd)
else
call SearchFileInTree( SearchName, SearchDir'!v')
endif
if rc then
call Alt1FindSpecInTree( SearchName, SearchDir, SearchStr,
OpenLine, OpenCol)
endif
enddo
return
; ---------------------------------------------------------------------------
defproc Alt1SelectTreeDir( DirEntry, SpecName, var SearchDir, var SearchName)
SearchDir = ''
SearchName = ''
Title = 'Find file "'SpecName'" in tree'
Text = 'Start in directory:'
Text = Text''copies( ' ', Max( 100 - length( Text), 0))
parse value EntryBox( Title,
'/'OK__MSG'/Change ~name.../'CANCEL__MSG,
DirEntry,
0,
240,
atoi( 1) || atoi( 0) || atol( 0) ||
Text) with Button 2 Dir \0
Dir = strip( Dir)
if Button = \1 then -- OK
SearchDir = Dir
SearchName = SpecName
return
elseif Button = \2 then -- Change name
SearchName = Alt1SelectName( SpecName, DirEntry)
return
else
return
endif
; ---------------------------------------------------------------------------
defproc Alt1SelectName
NameEntry = arg( 1)
DirEntry = arg( 2)
Title = 'Find file "'NameEntry'"'
Text = 'Enter new name:'
Text = Text''copies( ' ', Max( 100 - length( Text), 0))
parse value EntryBox( Title,
'/'OK__MSG'/Return',
NameEntry,
0,
240,
atoi( 1) || atoi( 0) || atol( 0) ||
Text) with Button 2 NewName \0
Name = strip( Name)
if Button = \1 then -- OK: Set new name
-- Restart Alt1SelectTreeDir with new name
call Alt1SelectTreeDir( DirEntry, NewName, Dummy1, Dummy2)
return
else -- Return or Esc: Keep NameEntry and DirEntry
-- Restart Alt1SelectTreeDir with old name
call Alt1SelectTreeDir( DirEntry, NameEntry, Dummy1, Dummy2)
return
endif
; ---------------------------------------------------------------------------
defproc Alt1ParseDirParams( Params, var Flags, var FileSpec)
-- Parse DIRCMD into Flags
DirCmd = Get_Env( 'DIRCMD')
TempStr = DirCmd
do while TempStr <> ''
parse value TempStr with Arg1 TempStr
if leftstr( Arg1, 1) = '/' then
ch = substr( Arg1, 2, 1)
if ch = '-' then
flagpos = pos( substr( Arg1, 3, 1), Flags)
if flagpos then
Flags = delstr( Flags, flagpos, 1)
endif
else
if pos( ch, flags) = 0 then
Flags = Flags''ch
endif
endif
endif
enddo
-- Parse Params into FileSpec and Flags
TempStr = Params
do while TempStr <> ''
-- Parse leading options
parse value TempStr with Arg1 TempStr
if leftstr( Arg1, 1) = '/' then
ch = upcase( substr( Arg1, 2, 1))
if ch = '-' then
pFlag = pos( substr( Arg1, 3, 1), Flags)
if pFlag then
Flags = delstr( Flags, pFlag, 1)
endif
else
if pos( ch, Flags) = 0 then
Flags = Flags''ch
endif
endif
else
TempStr = Arg1 TempStr
-- Parse trailing options
parse value TempStr with FileSpec '/'TempStr
FileSpec = strip( FileSpec)
if TempStr <> '' then
TempStr = '/'TempStr
endif
endif
enddo
return
; ---------------------------------------------------------------------------
defproc Alt1VerifyTime
TimeWord = arg( 1)
DateTimeChars = arg( 2)
BadTimeCharPos = verify( TimeWord, DateTimeChars)
fIsTime = 0
do once = 1 to 1
if BadTimeCharPos = 0 then
fIsTime = 1
leave
endif
-- Allow trailing a or p strings
if BadTimeCharPos = length( TimeWord) then
if verify( rightstr( TimeWord, 1), 'ap') = 0 then
fIsTime = 1
leave
endif
endif
enddo
return fIsTime
; ---------------------------------------------------------------------------
; Removed processing of outdated types:
; Host: abbrev( LISTFILE)
; Host: procs*.index
; .Output from grep (RY)
; .Output from gsee (LAM)
; LaMail .ndx
; *.use *.xrf
compile if 0
-- host_LT is outdated
universal host_LT -- Used with LAMPDQ.E
compile if HOST_SUPPORT
universal hostdrive
compile endif
[...]
-------- Outdated ----------------------------------------------------- Host: abbrev( LISTFILE) output
-- LAMPDQ support for LISTFILE output
compile if HOST_SUPPORT
-- 5/11/88: make Alt-1 work on lists of host files.
-- This works best with Larry Margolis's PDQ support (SLPDQ), and only
-- when the name of the list file is "LIST OUTPUT", as is true when
-- I'm using LaMail. I have to have some way of knowing it's a list
-- of host files.
;; if .filename ="LIST OUTPUT" then
-- 10/21/88 (LAM): Make work for any abbreviation of LISTFILE, not just
-- LIST, and ignore extra spaces on left and info on right [e.g., output
-- from LISTFILE (ALLOC ].
parse value .filename with file ext .
if ext = 'OUTPUT' & file = substr( 'LISTFILE', 1, length( file)) then
parse value LineStr with fn ft fm .
parse value .userstring with '[lt:'lt']'
if lt = '' then
lt = host_lt
endif
'Edit 'substr( hostdrive, 1, 1)''lt':'fn ft fm
alt1rc = rc
leave
endif
compile endif -- HOST_SUPPORT
-------- Outdated ----------------------------------------------------- Host: procs*.index
-- E3PROCS index support
-- 11/10/88: Load Files Directly From The INDEX File. By TJR
-- Now loads files from the E3PROCS INDEX hostfile. It is
-- assumed that someday there will be an EOS2PROCS INDEX of
-- the same format, therefore this macro was written to
-- look for any H:*PROCS INDEX file. A sincere attempt is
-- made to open the file and move to the macro of interest.
compile if HOST_SUPPORT
fn = .filename
parse value .filename with filename filetyp fmode . -- Not as crude, TJR
if ('INDEX' = filetyp & 'PROCS' = rightstr( filename, 5)) then
if VmFile( fn, ft) then
parse value LineStr with proc fn ft uid node date .
if ('PROCS' <> ft) then -- Is the current line an entry?
getline LineStr, .line - 1 -- Go back one line and try again.
parse value LineStr with proc fn ft uid node date .
if ('PROCS' <> ft) then -- One more time. . . .
sayerror 'Cursor is not at a PROCS index entry. No file loaded.'
alt1rc = 13
leave
endif
endif -- If we're here, must be an entry!
compile if HOST_SUPPORT = 'EMUL' or HOST_SUPPORT = 'SRPI'
if substr( .filename, 3, 1) = ':' then
lt = substr( .filename, 2, 1)
else
lt = host_lt
endif
'Edit' hostdrive''lt':'fn ft fmode
compile else
'Edit' hostdrive''fn ft fmode
compile endif
alt1rc = rc
top -- Goto top of file.
do forever
getsearch oldsearch
'xcom l '\1''date''\1 -- Try to get the procedure.
setsearch oldsearch
if rc then
sayerror proc' macro added by 'uid' on 'date' was not found.'
top -- Go back to the top.
beginline -- Move to beginning.
leave
else
getline LineStr
if (uid = substr( LineStr, lastpos( 'by ', LineStr) + 3,
length( uid))) then
sayerror proc' macro added by 'uid' on 'date'.'
beginline -- Move to beginning.
leave
else
'+1'
endif
endif
enddo
endif
endif
-- End of TJR's INDEX file modifications.
compile endif -- HOST_SUPPORT
-----------------------------------------------------------------------
-- Grep support
-- Determine grep version: Gnu or Ralph Yozzo's grep
fGnuGrep = ''
-- Support reloaded grep outputs: .Output from grep ...
lp = lastpos( '\', word( .filename, 1))
if substr( .filename, lp + 1, 17) = '.Output from grep' then
parse value textline( 1) with 'SEARCH:'Next
if Next > '' then
fGnuGrep = 0
else
fGnuGrep = 1
endif
endif
-------- Outdated ----------------------------------------------------- .Output from grep (RY)
-- 11/03/88: Open file specified by GREP and move to current line! TJR
-- Use the name ".grep" as the signature, so I can load multiple grep lists.
-- See GREP.E. jbl.
if substr( .filename, 1, 5) = ".grep" | -- TJR's GREP
fGnuGrep = 0 then -- LAM's GREP
call pSave_Pos( SavedPos)
display -2
getsearch SavedSearch
'xcom l . File #. -' -- Find previous file
setsearch SavedSearch
display 2
if rc then
'SayError No files found.'
leave
else
getline LineStr2
call pRestore_Pos( SavedPos)
parse value LineStr2 with "==> " filename " <=="
Spec = filename
LoadFilename = Alt1FindLoadFile( Spec)
alt1findfilerc = rc
if alt1findfilerc = 0 then
'Edit' LoadFilename
endif
;;compile if 1 -- LAM: I use /L
; Now supports both; if line starts with a number, assume /L; if not, do search.
parse value LineStr with num ')'
if pos( '(', num) & not pos( ' ', num) then
parse value num with . '(' num
endif
parse value num with num ':' LoadCol
if IsNum( num) then
y = num
x = 1
.cursory = .windowheight % 2
if IsNum( LoadCol) then
x = LoadCol
endif
'PostMe GoTo' y x
leave
endif
;;compile else -- TJR doesn't
parse value LineStr with "==>" tempstr
if tempstr = '' then
-- Let it be hilighted by the built-in stuff...
--'PostMe xcom l '\158''OrgLineStr\158'eaf+' -- ALT-158 is the search delim
display -2
getsearch SavedSearch
'xcom l '\1''LineStr\1'eaf+'
setsearch SavedSearch
display 2
if rc then
sayerror substr( LineStr2, 1, 60)'. . . Not Found.'
endif
endif
leave
;;compile endif
endif
endif
-- End of TJRs 11/03/88 Modifications!
-------- Outdated ----------------------------------------------------- .Output from gsee
if substr( .filename, 1, 17) = '.Output from gsee' then -- LAM's GSEE
parse value LineStr with name '.' ext 13 52 path
if substr( LineStr, 9, 1) = '.' & substr( LineStr, 53, 1) = ':' then
if length( path) > 3 then
path = path'\'
endif
Spec = path''strip( name)'.'ext
LoadFilename = Alt1FindLoadFile( Spec)
alt1findfilerc = rc
if alt1findfilerc = 0 then
'Edit' LoadFilename
endif
leave
endif
endif
-------- Outdated ----------------------------------------------------- LaMail .ndx
-- LaMail index support
if upcase( rightstr( .filename, 4)) = '.NDX' then
parse value OrgLineStr with 28 fn ft . 84 ext
if pos( \1, ext) then
'Edit' substr( .filename, 1, length( .filename) - 4)'\'fn'.'ft
alt1rc = rc
leave
endif
endif
-------- Outdated ----------------------------------------------------- *.use *.xrf
-- C-USED support
-- If the filetype is USE or XRF, do C-USED feature.
ext = substr( upcase( .filename), lastpos( '.', upcase( .filename)) + 1)
if ext = 'USE' or ext = 'XRF' then
if substr( LineStr, 1, 1) = ' ' then -- child line
parse value LineStr with . infunc LoadLine file
for i = .line - 1 to 1 by -1 -- search upward for parent line
getline LineStr, i
if substr( LineStr, 1, 1) <> ' ' then
parse value LineStr with func .
leave
endif
endfor
Spec = file
LoadFilename = Alt1FindLoadFile( Spec)
alt1findfilerc = rc
if alt1findfilerc = 0 then
'Edit' LoadFilename
endif
top
display -2
getsearch SavedSearch
'xcom l /'infunc
setsearch SavedSearch
display 2
if rc then
leave
endif
display -2
getsearch SavedSearch
'xcom l /'func
setsearch SavedSearch
display 2
if not rc then
sayerror 'Found 'func' in 'infunc' in 'file'.'
endif
else -- parent line
parse value LineStr with func LoadLine file
if LoadLine = '#' then -- might have a '#' in 2nd column
parse value file with LoadLine file
endif
Spec = file
LoadFilename = Alt1FindLoadFile( Spec)
alt1findfilerc = rc
if alt1findfilerc = 0 then
'Edit' LoadFilename
endif
top
display -2
getsearch SavedSearch
'xcom l /'func
setsearch SavedSearch
display 2
if not rc then
sayerror 'Found 'func' in 'file'.'
endif
endif
leave
endif
-----------------------------------------------------------------------
compile endif -- 0