bugGNU roff - Bugs: bug #62142, [refer] reports incorrect line...

 
 

bug #62142: [refer] reports incorrect line numbers in diagnostics

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Sat 05 Mar 2022 03:06:22 PM UTC
   
 
Category:  Preprocessor refer Severity:  3 - Normal
Item Group:  Warning/Suspicious behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.23.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 05 Mar 2022 09:09:47 PM UTC, comment #2: 


commit 17b33b075c9486c3cad4725210b396964c4d141c
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sun Mar 6 03:59:02 2022 +1100

    [refer]: Fix Savannah #62142.

    Report correct line number in bibliography file diagnostics.

    * src/preproc/refer/refer.cpp (do_bib): Set line number to 1 upon
      successfully opening a bibliography file.

    Problem appears to date back to groff 1.02 (June 1991) at the latest.

    Fixes <https://savannah.gnu.org/bugs/?62142>.

    Also update editor aid comments; drop old-style Emacs file-local
    variable setting.


G. Branden Robinson <gbranden>
Group administrator
Sat 05 Mar 2022 05:04:48 PM UTC, comment #1: 

The fix is simple.  (I chopped out comment-related hunks.)


diff --git a/src/preproc/refer/refer.cpp b/src/preproc/refer/refer.cpp
index 3fb2175fb..e93064f73 100644
--- a/src/preproc/refer/refer.cpp
+++ b/src/preproc/refer/refer.cpp
@@ -1115,6 +1114,7 @@ void do_bib(const char *filename)
     }
     current_filename = filename;
   }
+  current_lineno = 1;
   enum {
     START, MIDDLE, BODY, BODY_START, BODY_BLANK, BODY_DOT
     } state = START;


Naturally I have a regression test as well...our first one ever for refer(1).

G. Branden Robinson <gbranden>
Group administrator
Sat 05 Mar 2022 03:06:22 PM UTC, original submission:  

When processing the attached file (from bug #60657), refer(1) issues diagnostics with incorrect line numbers.


$ refer -e -p ./test.ref testref2.mm >/dev/null
refer:test.ref:579: invalid input character code 136
refer:test.ref:579: invalid input character code 137
refer:test.ref:616: invalid input character code 136
refer:test.ref:616: invalid input character code 137
refer:test.ref:701: invalid input character code 136
refer:test.ref:701: invalid input character code 137
refer:test.ref:725: invalid input character code 136
refer:test.ref:725: invalid input character code 137
$ for ln in 579 616 701 725; do sed -n ${ln}p ./test.ref; done
%I Hermann, "puis" Presses universitaires de France, "puis" Dunod
%Q Ecole d'\*'et\*'e de physique th\*'eorique ()
%D [1979]
%C  Paris


If we subtract 3 from each of these line numbers, we get some lines with UTF-8 sequences.


$ for ln in 579 616 701 725; do ln=$((ln - 3)); sed -n ${ln}p ./test.ref | xxd | grep '[89a-f][89a-f]'; done
00000000: 2554 20c2 8855 6e69 7665 7273 6974 5c2a  %T ..Universit\*
00000010: 2765 2064 6520 4772 656e 6f62 6c65 2e20  'e de Grenoble.
00000030: 5c2a 2765 2064 6520 7068 7973 6971 7565  \*'e de physique
00000050: 8943 6f75 7273 2064 6f6e 6e5c 2a27 6573  .Cours donn\*'es
000000b0: 7061 7220 432e 205b 435c 2a27 6563 696c  par C. [C\*'ecil
00000000: 2554 20c2 884c 6520 c289 6861 7361 7264  %T ..Le ..hasard
00000050: 5e75 7420 3139 3836 205c 2a27 6564 2e20  ^ut 1986 \*'ed.
00000060: 7061 7220 4a65 616e 2053 6f75 6c65 7469  par Jean Souleti
00000070: 652c 204a 6561 6e20 5661 6e6e 696d 656e  e, Jean Vannimen
00000000: 2554 20c2 884c 6573 20c2 8950 6574 6974  %T ..Les ..Petit
00000020: 666f 726d 6174 6971 7565 7320 6465 2074  formatiques de t
00000030: 7261 6974 656d 656e 7420 6465 2074 6578  raitement de tex
00000000: 2554 20c2 8849 424d 2046 7261 6e63 652e  %T ..IBM France.
00000010: 2045 6475 6361 7469 6f6e 2063 6f6d 6d65   Education comme
00000040: 2e2e 20c2 8953 7570 706f 7274 2064 6520  .. ..Support de


(My regex catches some false positives.)

We can see the UTF-8 sequences "c2 88" and "c2 89" multiple times.

Possibly related, the input file is a mixture of ISO-8859 (-1 or -15) and UTF-8.


$ isutf8 test2.ref
test2.ref: line 407, char 20, byte 12283: After a first byte between E1 and EC, expecting the 2nd byte between 80 and BF.


So, let's try to track down what is frotzing the line counter.

G. Branden Robinson <gbranden>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #52957:  test.ref added by gbranden (37KiB - application/octet-stream)
file #52958:  testref2.mm added by gbranden (64B - text/x-troff-mm)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-03-05 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.23.0
    2022-03-05 gbranden StatusNone In Progress
        Assigned toNone gbranden
    2022-03-05 gbranden Attached File- Added test.ref, #52957
        Attached File- Added testref2.mm, #52958

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code