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

Diff for /mandoc/term.c between version 1.138 and 1.140

version 1.138, 2010/05/24 21:34:16 version 1.140, 2010/05/25 12:37:20
Line 138  term_flushln(struct termp *p)
Line 138  term_flushln(struct termp *p)
         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 */
         size_t           maxvis, mmax;          size_t           maxvis, mmax;
   
         /*          /*
Line 190  term_flushln(struct termp *p)
Line 191  term_flushln(struct termp *p)
                  */                   */
   
                 /* LINTED */                  /* LINTED */
                 for ( ; 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;
                         if (8 == p->buf[j])                          if (8 != p->buf[j]) {
                                 vend--;                                  if (vend > vis && vend < bp &&
                         else                                      ASCII_HYPH == p->buf[j])
                                           jhy = j;
                                 vend++;                                  vend++;
                           } else
                                   vend--;
                 }                  }
   
                 /*                  /*
                  * 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.                   * If so, break to the next line.
                  */                   */
                 if (vend > bp && vis > 0) {                  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) {
                                   p->viscol = p->rmargin;
                                 for (j = 0; j < (int)p->rmargin; j++)                                  for (j = 0; j < (int)p->rmargin; j++)
                                         putchar(' ');                                          putchar(' ');
                                 vend += p->rmargin - p->offset;                                  vend += p->rmargin - p->offset;
                         } else {                          } else {
                                   p->viscol = 0;
                                 vbl = p->offset;                                  vbl = p->offset;
                         }                          }
   
Line 229  term_flushln(struct termp *p)
Line 235  term_flushln(struct termp *p)
   
                 /* Write out the [remaining] word. */                  /* Write out the [remaining] word. */
                 for ( ; i < (int)p->col; i++) {                  for ( ; i < (int)p->col; i++) {
                           if (vend > bp && jhy > 0 && i > jhy)
                                   break;
                         if ('\t' == p->buf[i])                          if ('\t' == p->buf[i])
                                 break;                                  break;
                         if (' ' == p->buf[i]) {                          if (' ' == p->buf[i]) {
Line 251  term_flushln(struct termp *p)
Line 259  term_flushln(struct termp *p)
                         if (vbl) {                          if (vbl) {
                                 for (j = 0; j < (int)vbl; j++)                                  for (j = 0; j < (int)vbl; j++)
                                         putchar(' ');                                          putchar(' ');
                                   p->viscol += vbl;
                                 vbl = 0;                                  vbl = 0;
                         }                          }
                         putchar(p->buf[i]);  
                           if (ASCII_HYPH == p->buf[i])
                                   putchar('-');
                           else
                                   putchar(p->buf[i]);
   
                           p->viscol += 1;
                 }                  }
                 vend += vbl;                  vend += vbl;
                 vis = vend;                  vis = vend;
Line 263  term_flushln(struct termp *p)
Line 278  term_flushln(struct termp *p)
         p->overstep = 0;          p->overstep = 0;
   
         if ( ! (TERMP_NOBREAK & p->flags)) {          if ( ! (TERMP_NOBREAK & p->flags)) {
                   p->viscol = 0;
                 putchar('\n');                  putchar('\n');
                 return;                  return;
         }          }
Line 294  term_flushln(struct termp *p)
Line 310  term_flushln(struct termp *p)
   
         /* Right-pad. */          /* Right-pad. */
         if (maxvis > vis + /* LINTED */          if (maxvis > vis + /* LINTED */
                         ((TERMP_TWOSPACE & p->flags) ? 1 : 0))                          ((TERMP_TWOSPACE & p->flags) ? 1 : 0)) {
                   p->viscol += maxvis - vis;
                 for ( ; vis < maxvis; vis++)                  for ( ; vis < maxvis; vis++)
                         putchar(' ');                          putchar(' ');
         else {  /* ...or newline break. */          } else {        /* ...or newline break. */
                 putchar('\n');                  putchar('\n');
                   p->viscol = p->rmargin;
                 for (i = 0; i < (int)p->rmargin; i++)                  for (i = 0; i < (int)p->rmargin; i++)
                         putchar(' ');                          putchar(' ');
         }          }
Line 315  term_newln(struct termp *p)
Line 333  term_newln(struct termp *p)
 {  {
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         if (0 == p->col) {          if (0 == p->col && 0 == p->viscol) {
                 p->flags &= ~TERMP_NOLPAD;                  p->flags &= ~TERMP_NOLPAD;
                 return;                  return;
         }          }
Line 335  term_vspace(struct termp *p)
Line 353  term_vspace(struct termp *p)
 {  {
   
         term_newln(p);          term_newln(p);
           p->viscol = 0;
         putchar('\n');          putchar('\n');
 }  }
   

Legend:
Removed from v.1.138  
changed lines
  Added in v.1.140

CVSweb