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

Diff for /pod2mdoc/pod2mdoc.c between version 1.53 and 1.54

version 1.53, 2015/02/19 13:50:45 version 1.54, 2015/02/19 15:26:45
Line 185  outbuf_flush(struct state *st)
Line 185  outbuf_flush(struct state *st)
         if (OUST_TXT == st->oust && st->wantws)          if (OUST_TXT == st->oust && st->wantws)
                 putchar(' ');                  putchar(' ');
   
         fputs(st->outbuf, stdout);          if (OUST_MAC == st->oust && '"' == *st->outbuf)
                   printf("\\(dq%s", st->outbuf + 1);
           else
                   fputs(st->outbuf, stdout);
   
         *st->outbuf = '\0';          *st->outbuf = '\0';
         st->outbuflen = 0;          st->outbuflen = 0;
   
Line 480  formatcode(struct state *st, const char *buf, size_t *
Line 484  formatcode(struct state *st, const char *buf, size_t *
 {  {
         size_t           i, j, dsz;          size_t           i, j, dsz;
         enum fmt         fmt;          enum fmt         fmt;
         int              wantws;  
         unsigned char    uc;          unsigned char    uc;
   
         assert(*start + 1 < end);          assert(*start + 1 < end);
Line 559  formatcode(struct state *st, const char *buf, size_t *
Line 562  formatcode(struct state *st, const char *buf, size_t *
         if (FMT__MAX != fmt && !nomacro) {          if (FMT__MAX != fmt && !nomacro) {
   
                 /*                  /*
                  * We may already have wantws if there was whitespace  
                  * before the code ("text B<text"), but initial  
                  * whitespace inside our scope ("textB< text")  
                  * allows to break at this point as well.  
                  */  
   
                 wantws = ' ' == buf[*start] ||  
                     (OUST_MAC == st->oust ? st->wantws : ! st->outbuflen);  
   
                 /*  
                  * If we are on a text line and there is no                   * If we are on a text line and there is no
                  * whitespace before our content, we have to make                   * whitespace before our content, we have to make
                  * the previous word a prefix to the macro line.                   * the previous word a prefix to the macro line.
                  * In the following, mdoc_newln() must not be used  
                  * lest we clobber out output state.  
                  */                   */
   
                 if (OUST_MAC != st->oust && ! wantws) {                  if (OUST_MAC != st->oust && ' ' != buf[*start] &&
                       st->outbuflen) {
                         if (OUST_NL != st->oust)                          if (OUST_NL != st->oust)
                                 putchar('\n');                                  mdoc_newln(st);
                         printf(".Pf ");                          printf(".Pf ");
                         st->wantws = 0;                          st->oust = OUST_MAC;
                           st->wantws = 1;
                 }                  }
   
                 outbuf_flush(st);                  outbuf_flush(st);
   
                 /* Whitespace is easier to suppress on macro lines. */                  /*
                    * Whitespace is easier to suppress on macro lines.
                    * We may already have wantws if there was whitespace
                    * before the code ("text B<text"), or there may be
                    * whitespace inside our scope ("textB< text").
                    */
   
                 if (OUST_MAC == st->oust && ! wantws)                  if (OUST_MAC == st->oust && ' ' != buf[*start] &&
                         printf(" Ns ");                      ! st->wantws)
                           printf(" Ns");
   
                 /* Unless we are on a macro line, start one. */                  /* Unless we are on a macro line, start one. */
   
                 if (OUST_MAC != st->oust && wantws) {                  if (OUST_MAC != st->oust) {
                         if (OUST_NL != st->oust)                          if (OUST_NL != st->oust)
                                 putchar('\n');                                  mdoc_newln(st);
                         putchar('.');                          putchar('.');
                           st->oust = OUST_MAC;
                 } else                  } else
                         putchar(' ');                          putchar(' ');
                   st->wantws = 1;
   
                 /*                  /*
                  * Print the macro corresponding to this format code,                   * Print the macro corresponding to this format code,
Line 657  formatcode(struct state *st, const char *buf, size_t *
Line 658  formatcode(struct state *st, const char *buf, size_t *
                 default:                  default:
                         abort();                          abort();
                 }                  }
                 st->oust = OUST_MAC;  
                 st->wantws = 1;  
         } else          } else
                 outbuf_flush(st);                  outbuf_flush(st);
   

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54

CVSweb