[BACK]Return to term.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Diff for /src/usr.bin/mandoc/term.c between version 1.32 and 1.33

version 1.32, 2010/05/15 21:09:53 version 1.33, 2010/05/17 02:25:42
Line 130 
Line 130 
         int              i;     /* current input position in p->buf */          int              i;     /* current input position in p->buf */
         size_t           vis;   /* current visual position on output */          size_t           vis;   /* current visual position on output */
         size_t           vbl;   /* number of blanks to prepend to output */          size_t           vbl;   /* number of blanks to prepend to output */
         size_t           vend;  /* end of word visual position on output */          size_t           vend;  /* end of word visual position on output */
         size_t           bp;    /* visual right border position */          size_t           bp;    /* visual right border position */
         int              j;     /* temporary loop index */          int              j;     /* temporary loop index */
         int              jhy;   /* last hyphen before line overflow */          int              jhy;   /* last hyphen before line overflow */
Line 154 
Line 154 
   
         bp = TERMP_NOBREAK & p->flags ? mmax : maxvis;          bp = TERMP_NOBREAK & p->flags ? mmax : maxvis;
   
           /*
            * Indent the first line of a paragraph.
            */
           vbl = p->flags & TERMP_NOLPAD ? 0 : p->offset;
   
         /*          /*
          * FIXME: if bp is zero, we still output the first word before           * FIXME: if bp is zero, we still output the first word before
          * breaking the line.           * breaking the line.
          */           */
   
         vis = i = 0;          vis = vend = i = 0;
         while (i < (int)p->col) {          while (i < (int)p->col) {
   
                 /*                  /*
                  * Choose the number of blanks to prepend: no blank at the  
                  * beginning of a line, one between words -- but do not  
                  * actually write them yet.  
                  */  
                 vbl = (size_t)(0 == vis ? 0 : 1);  
                 vis += vbl;  
                 vend = vis;  
   
                 /*  
                  * Handle literal tab characters.                   * Handle literal tab characters.
                  */                   */
                 for (j = i; j < (int)p->col; j++) {                  for (j = i; j < (int)p->col; j++) {
                         if ('\t' != p->buf[j])                          if ('\t' != p->buf[j])
                                 break;                                  break;
                         /* Collapse tab with inter-word spacing. */                          vend = (vis/p->tabwidth+1)*p->tabwidth;
                         if (vis > 0 && j == i)  
                                 vend = vis - 1;  
                         vend = (vend/p->tabwidth+1)*p->tabwidth;  
                         vbl += vend - vis;                          vbl += vend - vis;
                         vis = vend;                          vis = vend;
                 }                  }
Line 196 
Line 189 
                 for (jhy = 0; j < (int)p->col; j++) {                  for (jhy = 0; j < (int)p->col; j++) {
                         if ((j && ' ' == p->buf[j]) || '\t' == p->buf[j])                          if ((j && ' ' == p->buf[j]) || '\t' == p->buf[j])
                                 break;                                  break;
                         else if (8 == p->buf[j])                          if (8 == p->buf[j])
                                 vend--;                                  vend--;
                         else {                          else {
                                 if (vend > vis && vend < bp &&                                  if (vend > vis && vend < bp &&
Line 207 
Line 200 
                 }                  }
   
                 /*                  /*
                  * Usually, indent the first line of each paragraph.  
                  */  
                 if (0 == i && ! (p->flags & TERMP_NOLPAD)) {  
                         p->viscol += p->offset;  
                         /* LINTED */  
                         for (j = 0; j < (int)p->offset; j++)  
                                 putchar(' ');  
                 }  
   
                 /*  
                  * Find out whether we would exceed the right margin.                   * Find out whether we would exceed the right margin.
                  * If so, break to the next line.  (TODO: hyphenate)                   * If so, break to the next line.
                  * Otherwise, write the chosen number of blanks now.  
                  */                   */
                 if (vend > bp && 0 == jhy && vis > vbl) {                  if (vend > bp && 0 == jhy && vis > 0) {
                         vend -= vis;                          vend -= vis;
                         putchar('\n');                          putchar('\n');
                         if (TERMP_NOBREAK & p->flags) {                          if (TERMP_NOBREAK & p->flags) {
Line 230 
Line 212 
                                         putchar(' ');                                          putchar(' ');
                                 vend += p->rmargin - p->offset;                                  vend += p->rmargin - p->offset;
                         } else {                          } else {
                                 p->viscol = p->offset;                                  p->viscol = 0;
                                 for (j = 0; j < (int)p->offset; j++)                                  vbl = p->offset;
                                         putchar(' ');  
                         }                          }
   
                         /* Remove the p->overstep width. */                          /* Remove the p->overstep width. */
   
                         bp += (int)/* LINTED */                          bp += (int)/* LINTED */
                                 p->overstep;                                  p->overstep;
                         p->overstep = 0;                          p->overstep = 0;
                 } else {  
                         p->viscol += vbl;  
                         for (j = 0; j < (int)vbl; j++)  
                                 putchar(' ');  
                 }                  }
   
                 /*                  /*
Line 250 
Line 229 
                 while (i < (int)p->col && '\t' == p->buf[i])                  while (i < (int)p->col && '\t' == p->buf[i])
                         i++;                          i++;
   
                 /*                  /* Write out the [remaining] word. */
                  * Finally, write out the word.  
                  */  
                 for ( ; i < (int)p->col; i++) {                  for ( ; i < (int)p->col; i++) {
                         if (vend > bp && jhy > 0 && i > jhy)                          if (vend > bp && jhy > 0 && i > jhy)
                                 break;                                  break;
                         if ('\t' == p->buf[i])                          if ('\t' == p->buf[i])
                                 break;                                  break;
                         if (' ' == p->buf[i]) {                          if (' ' == p->buf[i]) {
                                 i++;                                  while (' ' == p->buf[i]) {
                                           vbl++;
                                           i++;
                                   }
                                 break;                                  break;
                         }                          }
                         if (ASCII_NBRSP == p->buf[i])                          if (ASCII_NBRSP == p->buf[i]) {
                                 putchar(' ');                                  vbl++;
                         else                                  continue;
                                 putchar(p->buf[i]);                          }
   
                           /*
                            * Now we definitely know there will be
                            * printable characters to output,
                            * so write preceding white space now.
                            */
                           if (vbl) {
                                   for (j = 0; j < (int)vbl; j++)
                                           putchar(' ');
                                   p->viscol += vbl;
                                   vbl = 0;
                           }
                           putchar(p->buf[i]);
                           p->viscol += 1;
                 }                  }
                 p->viscol += vend - vis;                  vend += vbl;
                 vis = vend;                  vis = vend;
         }          }
   

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33