Hi Manuel,
thanks for rightfully nagging - I shouldn't do late at night reviews. Regarding:
Manuel López-Ibáñez wrote:
> It is still not clear to me if line_len is the length of the line read
> or not, is it? If not, is there any way to actually get the length of
> the line?
Looking at the code in load_line, the line_len in
int trunc = load_line (input, &line, &line_len, NULL);
is the size of the buffer. That's not too bad but usually to large. However,
the actual line length is determined one line later:
len = gfc_wide_strlen (line);
which does a strlen on gfc_char_t which is uint32_t to accomodate unicode
characters.
Hence, I think
b->location
- = linemap_line_start (line_table, current_file->line++, 120);
+ = linemap_line_start (line_table, current_file->line++, line_len);
should use "len" instead of "line_len".
* * *
> > Namely, the previous code trims the output to show only the code around the
> > error location while the common-diagnostics code shows the whole line.
I just realized that all the space indentation got lost with Thunderbird - while
it still showed it in the edit window.
See attachment for a new attempt.
Using -fmessage-length= or COLUMNS explicitly works.
Fortran uses gcc/fortran/error.c's get_terminal_width() to determine the
terminal width. While the common code uses diagnostic_set_caret_max_width,
which does not seem to work reliably.
Playing around with it, the common approach seems to work with a normal
Xterm and gnome-terminal, but it fails with MobaXterm (Windows ssh client;
shows "echo $COLUMNS" in the shell correctly, but somehow that doesn't reach
GCC) - but using "COLUMNS=80 ~/gcc/gcc-trunk/bin/gfortran" works also with
MobaXterm. Yesterday, I tried KDE's konsole and it didn't seem to work there,
either. But I cannot check as the RHEL 6 here doesn't seem to have KDE.
Thus, it seems to be enough to transfer checks from get_terminal_width
to diagnostic_set_caret_max_width to fix this issue.
Tobias
Input file - all spaces, but at tab between "aaa'," and "'bg":
-------<cut test.f90>--------------------------------
print *,
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'bgfhkg'
end
-------</cut test.f90>--------------------------------
Using:
$ ~/gcc/gcc-4.9/bin/gfortran -ffree-line-length-none -pedantic test.f90
One gets with a pipe or wide terminal:
------------------------------------------------------------
test.f90:1.145:
print *,
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'bgfhkg'
1
Warning: Nonconforming tab character at (1)
------------------------------------------------------------
And with a small terminal:
------------------------------------------------------------
test.f90:1.145:
t *, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'bgf
1
Warning: Nonconforming tab character at (1)
------------------------------------------------------------
And with the new code, one gets for a small window:
$ ~/gcc/gcc-trunk/bin/gfortran -ffree-line-length-none -pedantic test.f90
test.f90:1:145:
------------------------------------------------------------
print *,
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'bgfhkg'
1
Warning: Nonconforming tab character at (1) [-Wtabs]
------------------------------------------------------------