Hi Jan,

Jan Stary wrote on Fri, Sep 18, 2015 at 01:46:13PM +0200:

> In zipcloak.1, zipnote.1 and zipsplit.1,
> the `zipfile' argument is way more intented with mandoc:
> 
>       -       zipfile  Zipfile to encrypt entries in
>       +                    zipfile  Zipfile to encrypt entries in
> 
> the source being
> 
>       .SH ARGUMENTS
>       .in +13
>       .ti -13
>       zipfile  Zipfile to encrypt entries in
> 
> I don't really know roff,

See the "in" and "ti" entries in roff(7), REQUEST REFERENCE.

> but this seems to be "indent +13"
> and "temporaraily indent -13", which seems odd in the first place;

Yes, madness of the man(7) autogeneration tool, whatever it was.

> anyway, mandoc honors the .in but ignores the .ti, right?

Yes, as documented in roff(7).

> With these two lines deleted, groff and mandoc show the same.

The fact that .ti is unsupported was the reason why the port still
did USE_GROFF, but you are right that in this particular case,
the misindentation isn't a problem, so i'm fine with sthen@'s
commit removing it.

> Another difference is positioning the start of an .It text
> on the same line as the .It head, where groff starts a new line:
> 
>               --hh
>       -       ----hheellpp
>       -              Show a short help.
>       +       ----hheellpp Show a short help.
>  
> The source says
> 
>       .B \-\-help\
>       Show a short help.
> 
> Does mandoc respect the escaped space at end of line, while groff doesn't?
> In any case, this difference in rendering is hardly a problem.

The other way round.  Groff respects the escaped space, considers it
to overflow the space available for the tag, and breaks the line.
Mandoc sees that the space is at the end of a tag and discards it
in order to avoid whitespace at the end of a line.

However, trying to avoid trailing whitespace shouldn't prevent the
line break; fixed in the commit below.

Thanks,
  Ingo


CVSROOT:        /cvs
Module name:    src
Changes by:     schwa...@cvs.openbsd.org        2015/09/21 07:24:32

Modified files:
        usr.bin/mandoc : man_term.c mdoc_term.c term.c term.h 
        regress/usr.bin/mandoc/man/IP: spacing.in spacing.out_ascii 
        regress/usr.bin/mandoc/man/TP: Makefile 
        regress/usr.bin/mandoc/mdoc/Bl: tag.in tag.out_ascii 
Added files:
        regress/usr.bin/mandoc/man/TP: spacing.in spacing.out_ascii 

Log message:
Trailing whitespace is significant when determining the width of a tag
in mdoc(7) .Bl -tag and man(7) .TP, but not in man(7) .IP.
Quirk reported by Jan Stary <hans at stare dot cz> on ports@.


Index: term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.c,v
retrieving revision 1.249
retrieving revision 1.250
diff -Lterm.c -Lterm.c -u -p -r1.249 -r1.250
--- term.c
+++ term.c
@@ -78,6 +78,8 @@ term_end(struct termp *p)
  *    the next column.  However, if less than p->trailspace blanks,
  *    which can be 0, 1, or 2, remain to the right margin, the line
  *    will be broken.
+ *  - TERMP_BRTRSP: Consider trailing whitespace significant
+ *    when deciding whether the chunk fits or not.
  *  - TERMP_BRIND: If the chunk does not fit and the output line has
  *    to be broken, start the next line at the right margin instead
  *    of at the offset.  Used together with TERMP_NOBREAK for the tags
@@ -290,6 +292,10 @@ term_flushln(struct termp *p)
 
        } else if (TERMP_DANGLE & p->flags)
                return;
+
+       /* Trailing whitespace is significant in some columns. */
+       if (vis && vbl && (TERMP_BRTRSP & p->flags))
+               vis += vbl;
 
        /* If the column was overrun, break the line. */
        if (maxvis < vis + p->trailspace * (*p->width)(p, ' ')) {
Index: term.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.h,v
retrieving revision 1.115
retrieving revision 1.116
diff -Lterm.h -Lterm.h -u -p -r1.115 -r1.116
--- term.h
+++ term.h
@@ -77,12 +77,13 @@ struct      termp {
 #define        TERMP_BACKAFTER  (1 << 6)       /* Back up after next 
character. */
 #define        TERMP_BACKBEFORE (1 << 7)       /* Back up before next 
character. */
 #define        TERMP_NOBREAK    (1 << 8)       /* See term_flushln(). */
-#define        TERMP_BRIND      (1 << 9)       /* See term_flushln(). */
-#define        TERMP_DANGLE     (1 << 10)      /* See term_flushln(). */
-#define        TERMP_HANG       (1 << 11)      /* See term_flushln(). */
-#define        TERMP_NOSPLIT    (1 << 12)      /* Do not break line before 
.An. */
-#define        TERMP_SPLIT      (1 << 13)      /* Break line before .An. */
-#define        TERMP_NONEWLINE  (1 << 14)      /* No line break in nofill 
mode. */
+#define        TERMP_BRTRSP     (1 << 9)       /* See term_flushln(). */
+#define        TERMP_BRIND      (1 << 10)      /* See term_flushln(). */
+#define        TERMP_DANGLE     (1 << 11)      /* See term_flushln(). */
+#define        TERMP_HANG       (1 << 12)      /* See term_flushln(). */
+#define        TERMP_NOSPLIT    (1 << 13)      /* Do not break line before 
.An. */
+#define        TERMP_SPLIT      (1 << 14)      /* Break line before .An. */
+#define        TERMP_NONEWLINE  (1 << 15)      /* No line break in nofill 
mode. */
        int              *buf;          /* Output buffer. */
        enum termenc      enc;          /* Type of encoding. */
        const struct mchars *symtab;    /* Character table. */
Index: man_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_term.c,v
retrieving revision 1.183
retrieving revision 1.184
diff -Lman_term.c -Lman_term.c -u -p -r1.183 -r1.184
--- man_term.c
+++ man_term.c
@@ -671,7 +671,7 @@ pre_TP(DECL_ARGS)
 
        switch (n->type) {
        case ROFFT_HEAD:
-               p->flags |= TERMP_NOBREAK;
+               p->flags |= TERMP_NOBREAK | TERMP_BRTRSP;
                p->trailspace = 1;
                break;
        case ROFFT_BODY:
@@ -723,7 +723,7 @@ pre_TP(DECL_ARGS)
                p->offset = mt->offset + len;
                p->rmargin = p->maxrmargin;
                p->trailspace = 0;
-               p->flags &= ~TERMP_NOBREAK;
+               p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP);
                break;
        default:
                break;
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.325
retrieving revision 1.326
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.325 -r1.326
--- mdoc_term.c
+++ mdoc_term.c
@@ -802,7 +802,7 @@ termp_it_pre(DECL_ARGS)
                if (n->type != ROFFT_HEAD)
                        break;
 
-               p->flags |= TERMP_NOBREAK | TERMP_BRIND;
+               p->flags |= TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND;
                p->trailspace = 2;
 
                if (NULL == n->next || NULL == n->next->child)
@@ -974,7 +974,7 @@ termp_it_post(DECL_ARGS)
         * has munged them in the meanwhile.
         */
 
-       p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
+       p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND |
                        TERMP_DANGLE | TERMP_HANG);
        p->trailspace = 0;
 }

Reply via email to