Hi Ted,

Ted Unangst wrote on Thu, Mar 13, 2014 at 12:01:32AM -0400:

> I noticed something strange about man ls with and without locale set.
> 
> The "-C      Force multi-column output;" line wraps differently
> depending on whether output is ascii or utf8. The word "a" appears on
> a different line.

I see.  Not only do OpenBSD developers pay attention to detail
when *writing* manuals, some apparently do the same when *reading*
manuals, so jmc@'s efforts are not wholly wasted.  =:c)

I just committed the fix, see below.  You made me visit my favourite
can of worms again, term_flushln(): thanks for that.

Yours,
  Ingo


CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected]        2014/03/13 13:23:11

Modified files:
        usr.bin/mandoc : term.c 

Log message:
In -Tutf8 mode, make sure that hyphens get counted against the output line
length even when they are breakable.  Before this, a line containing N
breakable hyphens could get up to N characters wider than the right margin
in -Tutf8 output mode.
Issue reported by tedu@ on bugs@.


Index: term.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/term.c,v
retrieving revision 1.77
diff -u -p -r1.77 term.c
--- term.c      22 Jan 2014 20:58:35 -0000      1.77
+++ term.c      13 Mar 2014 19:16:50 -0000
@@ -179,6 +179,13 @@ term_flushln(struct termp *p)
                             ASCII_BREAK == p->buf[j]))
                                jhy = j;
 
+                       /*
+                        * Hyphenation now decided, put back a real
+                        * hyphen such that we get the correct width.
+                        */
+                       if (ASCII_HYPH == p->buf[j])
+                               p->buf[j] = '-';
+
                        vend += (*p->width)(p, p->buf[j]);
                }
 
@@ -242,12 +249,6 @@ term_flushln(struct termp *p)
                                (*p->advance)(p, vbl);
                                p->viscol += vbl;
                                vbl = 0;
-                       }
-
-                       if (ASCII_HYPH == p->buf[i]) {
-                               (*p->letter)(p, '-');
-                               p->viscol += (*p->width)(p, '-');
-                               continue;
                        }
 
                        (*p->letter)(p, p->buf[i]);

Reply via email to