ed.ex: BUG in function get_err_line()
- Posted by K_D_R
Mar 24, 2013
-- actually two bugs, I think
-- 1: the while loop only read < 6 lines from ex.err
-- 2: expand_tabs routine fails to set start_col
-- the following code guarantee's that that the ex.err
-- line containing the '^' marking the error start_col
-- will be read.
function get_err_line()
-- try to get file name & line number from ex.err
-- returns file_name, sets start_line, start_col, error_message
file_number err_file
sequence file_name
sequence err_lines
object temp_line
natural colon_pos
integer cont = TRUE
err_file = open("ex.err", "r")
if err_file = -1 then
error_message = ""
else
-- read the top of the ex.err error message file
err_lines = {}
-- while length(err_lines) < 6 do
while cont do
temp_line = gets(err_file)
if atom(temp_line) then
exit
end if
err_lines = append(err_lines, temp_line)
if find('^', temp_line) then
start_col = match("^", temp_line)-1
cont = FALSE
end if
end while
close(err_file)
-- look for file name, line, column and error message
if length(err_lines) > 1 and match("TASK ID ", err_lines[1]) then
err_lines = err_lines[2..$]
end if
if length(err_lines) > 0 then
if sequence(err_lines[1]) then
colon_pos = match(".e", lower(err_lines[1]))
if colon_pos then
if find(err_lines[1][colon_pos+2], "xXwWuU") then
colon_pos += 1
if find(err_lines[1][colon_pos+2], "xWuU") then
colon_pos += 1
end if
end if
file_name = err_lines[1][1..colon_pos+1]
start_line = numeric(err_lines[1][colon_pos+3..
length(err_lines[1])])
error_message = delete_trailing_white(err_lines[2])
----------------------------------------------------------
-- if length(err_lines) > 3 then
-- when this routine is used, the cursor is
-- positioned at the start of the line, but not on start_col
-- start_col = find('^', expand_tabs(STANDARD_TAB_WIDTH,
-- err_lines[length(err_lines)-1]))
-- end if
----------------------------------------------------------
return file_name
end if
end if
end if
end if
return ""
end function
Not Categorized, Please Help
|
|