bugGNU troff - Bugs: bug #58016, Add an option...


bug #58016: Add an option "--label=<name>" to show an origin of diagnostics

Submitted by:  Bjarni Ingi Gislason <bjarniig>
Submitted on:  Sat 21 Mar 2020 07:12:14 PM UTC  
Category:  Core Severity:  1 - Wish
Item Group:  New feature Status:  Wont Fix
Privacy:  Public Assigned to:  G. Branden Robinson <gbranden>
Open/Closed:  Closed Planned Release:  None

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Thu 08 Oct 2020 12:28:57 PM UTC, comment #5: 

I don't think there's anything in this feature request that can't be resolved by completing work on Savannah #52463, which basically means formatting diagnostic messages as the GNU Coding Standards recommend.


...to which I would add some enhancements.

The diagnostic level (usually "fatal error", "error", or "warning"), followed by a colon and space, should be the first component of the "message" as described by the GNU manual above.

When a preprocessor injects diagnostic-emitting *roff requests into a file it processes, it is the processed file that is the emitter of the diagnostic, not the preprocessor.  I recently altered tbl(1) to reflect this principle.  Commit message shown below.

Finally, as noted in my message closing bug #57630, test-groff is not designed for use as a system executable.  People can fork it or put a modified copy in $HOME/bin if they want to, but I think it best serves groff if it remains in its role as a test tool for the groff build process.

Resolving as wontfix.

commit f75e156b621d3743368c58425f357e6cd52372a0
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sat Sep 26 10:41:29 2020 +1000

    src/preproc/tbl/table.cpp: Regularize diagnostics.

    * src/preproc/tbl/table.cpp (table::init_output):
      (table::compute_separation_factor): Use consistent format for
      diagnostic messages.
      + Do not spread a single diagnostic across multiple lines.
      + Report messages in GNU Coding Standards format, that is:
      + Report the name of the file the problem is in...
      + ...then the line number...
      + ...then the diagnostic severity level...
      + ...then the specific problem.

    Unfortunately source line numbers for tbl(1) tables can get a bit
    approximate and are badly off in some cases (I think it has to do with
    text blocks--I'll be investgating that soon), but that is a separate

    Continues the long process of fixing Savannah #52463.

    Here are examples of output before and after this change. \\ marks lines
    wrapped for the purpose of this commit message.


    $ groff -z -Tps -t -ms diag1-Tps.ms
    warning: file 'diag1-Tps.ms', around line 11:
      table wider than line width
    warning: file 'diag1-Tps.ms', around line 11:
      column separation set to zero
    warning: file 'diag1-Tps.ms', around line 101:
      table wider than line width
    warning: file 'diag1-Tps.ms', around line 96:
      table squeezed horizontally to fit line length
    $ groff -z -Tps -t -man diag2-Tps.man
    error: page 2: table will not fit on one page; use .TS H/.TH with a \\
    supporting macro package
    $ groff -z -Tutf8 -t -man diag3-Tutf8.man
    warning: page 3: table text block will not fit on one page
    warning: page 10: table text block will not fit on one page


    $ ../build/test-groff -z -Tps -t -ms diag1-Tps.ms
    diag1-Tps.ms: around line 11: warning: table wider than line width
    diag1-Tps.ms: around line 11: warning: column separation set to zero
    diag1-Tps.ms: around line 101: warning: table wider than line width
    diag1-Tps.ms: around line 96: warning: table squeezed horizontally to \\
    fit line length
    $ ../build/test-groff -z -Tps -t -man diag2-Tps.man
    diag2-Tps.man: around line 3660: error: table will not fit on page 2; \\
    use .TS H/.TH with a supporting macro package
    $ ../build/test-groff -z -Tutf8 -t -man diag3-Tutf8.man
    diag3-Tutf8.man: around line 536: warning: table text block will not \\
    fit on page 3
    diag3-Tutf8.man: around line 1361: warning: table text block will not \\
    fit on page 10

G. Branden Robinson <gbranden>
Project AdministratorIn charge of this item.
Tue 12 May 2020 11:20:37 PM UTC, comment #4: 

  There is no need to add code to "groff" in this case.

  Add it to "test-groff.in" and the makefiles that now produce output
on standard error.

  The relevant part for "test-groff.in" is the last part of the

  Patches (based on older master repository):

1) test-groff.in

  Add code to process the additional option "--label <output file>"

2) doc/doc.am

  Add the option "--label <output file>" where "DOC_GROFF" or
"DOC_GROFF_ONLY" is used.

--- ../new-groff/test-groff.in        2020-05-12 22:28:53.000000000 +0000
+++ test-groff.in        2020-05-12 22:29:07.000000000 +0000
@@ -28,11 +28,23 @@ GROFF_BIN_PATH=$builddir

+if [ ! -d $srcdir/tmac/mdoc ] && [ ! -d $builddir/tmac/mdoc ] ; then
+  printf '%s\n' "${0}: Macros in the \".../tmac/mdoc\" directory can't be used" 1>&2
+  printf '\t%s\n'  "See the file \"PROBLEMS\" (or bug #51073)" 1>&2

+if test -n "$TEST_GROFF_TMAC_PATH"; then
@@ -47,4 +59,39 @@ $SEP$builddir/contrib/pdfmark\


-exec $builddir/groff -b -ww ${1+"$@"}
+for item ; do
+  if test "$lastitem" = '--label' ; then
+    filename=$item
+    break
+  fi
+  case "$item" in
+    --label) lastitem='--label'
+        continue
+    ;;
+  esac
+arguments=$(echo ${1+"$@"} | sed -e 's%--label  *[^ ]*%%' )
+if test -n "$filename" ; then
+  temp=$builddir/test-groff.error.${filename##**/}
+  $builddir/groff -b -ww $arguments  2> $temp
+  if test -s "$temp" ; then
+    sed -i -e \
+      's%stdin:%'"$filename"':%
+      s%<standard input>:%'"$filename"':%
+      T a; b
+      :a ; s%^%'"$filename"': %' \
+      $temp
+    cat $temp 1>&2
+  else
+    rm $temp
+  fi
+  exec $builddir/groff -b -ww $arguments

#### Part 2 for doc/doc.am ####

--- doc.am        2020-05-12 22:35:30.000000000 +0000
+++ ../../new-groff/doc/doc.am        2020-05-12 22:35:21.000000000 +0000
@@ -28,7 +28,7 @@ DOC_GROFF_ONLY=\
   $(GROFFBIN) -I$(abs_top_builddir) -M $(doc_srcdir) \
-        $(TFLAG) $(FFLAG) -Upet -ww
+        $(TFLAG) $(FFLAG) -Upet -ww -b


@@ -124,21 +124,21 @@ SUFFIXES += .me .ms .ps .html .txt .texi
# For simplicity, we always call preconv, grn, and eqn.
         $(GROFF_V)$(MKDIR_P) `dirname $@` \
-        && $(DOC_GROFF) -k -Tutf8 -ge -me >$@
+        && $(DOC_GROFF) -k -Tutf8 -ge -me --label $@ >$@
         $(GROFF_V)$(MKDIR_P) `dirname $@` \
-        && $(DOC_GROFF) -k -Tps -ge -me >$@
+        && $(DOC_GROFF) -k -Tps -ge -me --label $@ >$@

         $(GROFF_V)$(MKDIR_P) `dirname $@` \
         && $(DOC_GROFF) -P-p -P-b -P-I`basename $< | sed -e 's|.ms$$||'` \
-                        -P-D$(imagedir) -Thtml -ms >$@
+                        -P-D$(imagedir) -Thtml -ms --label $@ >$@
         $(GROFF_V)$(MKDIR_P) `dirname $@` \
-        && $(DOC_GROFF) -Tascii -ms -mwww >$@
+        && $(DOC_GROFF) -Tascii -ms -mwww --label $@ >$@
         $(GROFF_V)$(MKDIR_P) `dirname $@` \
-        && $(DOC_GROFF) -Tps -ms -mwww >$@
+        && $(DOC_GROFF) -Tps -ms -mwww --label $@ >$@

$(PROCESSEDEXAMPLEFILES): $(bin_PROGRAMS) $(prefixexecbin_PROGRAMS) gnu.eps
$(PROCESSEDEXAMPLEFILES): $(dist_devpsfont_DATA) $(nodist_devpsfont_DATA) $(hdtbltmac_DATA)
@@ -154,7 +154,8 @@ doc/pic.html: $(doc_srcdir)/pic.ms $(dev
         && cd $(doc_builddir) \
         && $(DOC_SED) $(doc_srcdir)/pic.ms \
            | $(DOC_GROFF_ONLY) -P-p -P-Ipic -P-D$(imagedir) -P-jpic \
-                               -Thtml -ms > pic.html
+                               -Thtml -ms \
+                                --label pic.html -- > pic.html

doc/examples.stamp: doc/groff.css
         @$(MKDIR_P) $(doc_builddir)
@@ -169,7 +170,8 @@ doc/webpage.html: $(doc_srcdir)/webpage.
         && cd $(doc_builddir) \
         && $(DOC_SED) $(doc_srcdir)/webpage.ms \
            | $(DOC_GROFF_ONLY) -P-jwebpage -P-nrpb -P-Iwebpage \
-                               -P-D$(imagedir) -Thtml -ms > webpage.html
+                               -P-D$(imagedir) -Thtml -ms \
+                                --label webpage.html -- > webpage.html

doc/grnexmpl.ps: doc/grnexmpl.me doc/grnexmpl.g

@@ -472,5 +474,7 @@ dist-gnueps:

# Local Variables:
+# fill-column: 72
# mode: makefile-automake
# End:
+# vim: set autoindent filetype=automake textwidth=72:

Bjarni Ingi Gislason <bjarniig>
Sat 09 May 2020 09:05:35 AM UTC, comment #3: 

Which, as we just noted in another thread on the mailing list, is the most common case (even if admittedly not universal, as e.g. Ralph observed).  But i really think we should not add weird, non-essential options bloating the user interface - merely to handle unusual corner cases.  That makes closing this ticket without acting on it even more desirable.

Ingo Schwarze <schwarze>
Project Member
Sat 09 May 2020 01:11:44 AM UTC, comment #2: 

Note that preconv effectively does this by default when its input is a real file.

G. Branden Robinson <gbranden>
Project AdministratorIn charge of this item.
Sun 22 Mar 2020 05:46:36 PM UTC, comment #1: 

I consider this bloat and not useful enough to justify making the user interface larger.  Also, groff(1) has no documented long options yet (apart from the totally useless --help and --version), so i strongly oppose adding any long options.  Note that POSIX also discourages long options and i think there is value in keeping roff tools close to UNIX standards: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02 - Utility Syntax Guidelines, guideline 3.

Also, most UNIX programs are able to read standard input and none provide such an option.  GNU troff is not special in any way that would encourage making an exception here.

So i suggest closing this ticket as "Invalid".

Ingo Schwarze <schwarze>
Project Member
Sat 21 Mar 2020 07:12:14 PM UTC, original submission:  

Subject: Add an option "--label=<name>" to show an origin of diagnostics

  "groff" has sometimes to read the standard input.
 In that case diagnostics are output with a "stdin" or
 a "<standard input>" label.

  If more than one file is processed in one run,
 one can't see from which file the output is.

  This is for example the case in Makefiles.

  "grep" has such a label.
 Its explanation is

        Display input actually coming from standard input as input
        coming from file LABEL.  This is especially useful when
        implementing tools like zgrep, e.g., gzip -cd foo.gz | grep
        --label=foo -H something.  See also the -H option.

  "diff" (same as '-L') and "diff3" have this option.

Bjarni Ingi Gislason <bjarniig>


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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by gbranden (Posted a comment)
  • -email is unavailable- added by schwarze (Posted a comment)
  • -email is unavailable- added by bjarniig (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-10-08 gbranden StatusNone => Wont Fix
        Assigned toNone => gbranden
        Open/ClosedOpen => Closed
    2020-03-22 schwarze Severity3 - Normal => 1 - Wish

    Back to the top

    Powered by Savane 3.5