[BACK]Return to term.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/term.c between version 1.80 and 1.81

version 1.80, 2009/06/22 10:40:04 version 1.81, 2009/06/22 12:04:05
Line 205  void
Line 205  void
 term_flushln(struct termp *p)  term_flushln(struct termp *p)
 {  {
         int              i, j;          int              i, j;
         size_t           vsz, vis, maxvis, mmax, bp;          size_t           vbl, vsz, vis, maxvis, mmax, bp;
   
         /*          /*
          * First, establish the maximum columns of "visible" content.           * First, establish the maximum columns of "visible" content.
Line 250  term_flushln(struct termp *p)
Line 250  term_flushln(struct termp *p)
                 }                  }
   
                 /*                  /*
                  * Do line-breaking.  If we're greater than our                   * Choose the number of blanks to prepend: no blank at the
                  * break-point and already in-line, break to the next                   * beginning of a line, one between words -- but do not
                  * line and start writing.  If we're at the line start,                   * actually write them yet.
                  * then write out the word (TODO: hyphenate) and break  
                  * in a subsequent loop invocation.  
                  */                   */
                   vbl = (size_t)(0 == vis ? 0 : 1);
   
                 if ( ! (TERMP_NOBREAK & p->flags)) {                  /*
                         if (vis && vis + vsz > bp) {                   * Find out whether we would exceed the right margin.
                                 putchar('\n');                   * If so, break to the next line.  (TODO: hyphenate)
                    * Otherwise, write the chosen number of blanks now.
                    */
                   if (vis && vis + vbl + vsz > bp) {
                           putchar('\n');
                           if (TERMP_NOBREAK & p->flags) {
                                   for (j = 0; j < (int)p->rmargin; j++)
                                           putchar(' ');
                                   vis = p->rmargin - p->offset;
                           } else {
                                 for (j = 0; j < (int)p->offset; j++)                                  for (j = 0; j < (int)p->offset; j++)
                                         putchar(' ');                                          putchar(' ');
                                 vis = 0;                                  vis = 0;
                         }                          }
                 } else if (vis && vis + vsz > bp) {                  } else {
                         putchar('\n');                          for (j = 0; j < (int)vbl; j++)
                         for (j = 0; j < (int)p->rmargin; j++)  
                                 putchar(' ');                                  putchar(' ');
                         vis = p->rmargin - p->offset;                          vis += vbl;
                 }                  }
   
                 /*                  /*
                  * Prepend a space if we're not already at the beginning                   * Finally, write out the word.
                  * of the line, then the word.  
                  */                   */
   
                 if (0 < vis++)  
                         putchar(' ');  
   
                 for ( ; i < (int)p->col; i++) {                  for ( ; i < (int)p->col; i++) {
                         if (' ' == p->buf[i])                          if (' ' == p->buf[i])
                                 break;                                  break;
Line 292  term_flushln(struct termp *p)
Line 294  term_flushln(struct termp *p)
          * cause a newline and offset at the right margin.           * cause a newline and offset at the right margin.
          */           */
   
         if ((TERMP_NOBREAK & p->flags) && vis > maxvis) {          if ((TERMP_NOBREAK & p->flags) && vis >= maxvis) {
                 if ( ! (TERMP_NONOBREAK & p->flags)) {                  if ( ! (TERMP_NONOBREAK & p->flags)) {
                         putchar('\n');                          putchar('\n');
                         for (i = 0; i < (int)p->rmargin; i++)                          for (i = 0; i < (int)p->rmargin; i++)
Line 309  term_flushln(struct termp *p)
Line 311  term_flushln(struct termp *p)
   
         if (p->flags & TERMP_NOBREAK) {          if (p->flags & TERMP_NOBREAK) {
                 if ( ! (TERMP_NONOBREAK & p->flags))                  if ( ! (TERMP_NONOBREAK & p->flags))
                         for ( ; vis <= maxvis; vis++)                          for ( ; vis < maxvis; vis++)
                                 putchar(' ');                                  putchar(' ');
         } else          } else
                 putchar('\n');                  putchar('\n');

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.81

CVSweb