1. ed.ex: BUG in function get_err_line()
- Posted by K_D_R Mar 24, 2013
- 1411 views
-- 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
2. Re: ed.ex: BUG in function get_err_line()
- Posted by K_D_R Apr 14, 2013
- 1298 views
-- edx: edited get_err_line() -- Now, on error, edx.ex opens file and positions cursor at the proper -- line and column. Also, this version does not assume that that the -- start_line reaches to the end of the line, which is not always true. -- include std/convert.e 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 integer start_slice, end_slice 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 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) 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(":", lower(err_lines[1])) if colon_pos then file_name = err_lines[1][1..colon_pos-1] start_slice = colon_pos +1 end_slice = start_slice +1 for x = start_slice to length(err_lines[1]) do end_slice = to_integer(err_lines[1][x]) if end_slice = -1 then exit else end_slice = x end if end for start_line = numeric(err_lines[1][start_slice.. end_slice]) error_message = delete_trailing_white(err_lines[2]) return file_name end if end if end if end if return "" end function
3. Re: ed.ex: BUG in function get_err_line()
- Posted by K_D_R Jun 04, 2013
- 1195 views
- Last edited Jun 05, 2013
-- vastly improved version of get_err_line() -- uses code derived from Irv Mullins' version gneui.ex include std/convert.e include std/io.e function get_err_line() -- try to get file name & line number from ex.err -- returns file_name, sets start_line, start_col, error_message sequence file_name object err_lines integer i = 0 err_lines = read_lines("ex.err") if atom(err_lines) then error_message = "" else error_message = trim_tail(err_lines[2]) for n = 1 to length(err_lines) do if find('^', err_lines[n]) then i = find(':',err_lines[1]) start_col = match("^", expand_tabs(STANDARD_TAB_WIDTH, err_lines[n])) file_name = err_lines[1][1..i-1] start_line = to_number(err_lines[1][i+1..$]) return file_name end if end for end if return "" end function
Comments and suggestions for improvement will be appreciated.
Ken Rhodes