Subject: bug#37633: Column part interpreted wrong in compilation mode

From: Bernd Paysan <[email-masked]>
Date: Sat, 05 Oct 2019 21:24:17 +0200

Am Samstag, 5. Oktober 2019, 21:14:38 CEST schrieb Eli Zaretskii:
> > From: Bernd Paysan <[email-masked]>
> > Cc: [email-masked], [email-masked]
> > Date: Sat, 05 Oct 2019 20:54:38 +0200
> > 
> > > We cannot use 'exact' here because there's no file per se: we only
> > > have the compiler output.  We must use 'approximate'.
> > 
> > The buffer that matters is not the compiler output, it's the buffer of the
> > source code.
> 
> But the column numbers are counted in the compiler output, and no one
> said that the compiler output must be encoded the same as the source
> file.

The column numbers are written as decimal digits in the compiler output.  They 
are not even calculated, they are just extracted.

Indeed, the compiler output can be in a different encoding, but it doesn't 
matter.  The navigation that needs to change is in the source code file.  This 
is compiler output from compiling an iso-latin encoded file, the compiler 
output itself is utf-8:

test-iso.c:3:23: error: ‘c’ undeclared (first use in this function)
    3 |  printf("test��� %i", c);
      |                       ^

The 23(-1) are the numbers of bytes to get from the start of line to the 
missing variable 'c'.  The three � are there, because the compilation buffer 
contains invalid characters now.  They are iso-latin characters, invalid in 
utf-8.  But this is irrelevant.  All the compilation mode does is extract the 
test-iso.c (file name), 3 (line number) and 23 (byte index).  Navigation 
happens in test-iso.c, it's a file (the C compiler can't access emacs 
buffers), autodetection is pretty reliable.

There might be some corner cases, where the suggested solution is not perfect, 
but it's much better than what we have now.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o id: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
https://net2o.de/