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

Diff for /docbook2mdoc/macro.c between version 1.8 and 1.9

version 1.8, 2019/04/10 14:22:37 version 1.9, 2019/04/11 04:23:22
Line 31  void
Line 31  void
 macro_open(struct format *f, const char *name)  macro_open(struct format *f, const char *name)
 {  {
         switch (f->linestate) {          switch (f->linestate) {
           case LINE_MACRO:
                   if (f->flags & FMT_NOSPC) {
                           fputs(" Ns ", stdout);
                           break;
                   }
                   if (f->flags & (FMT_CHILD | FMT_IMPL)) {
                           putchar(' ');
                           break;
                   }
                   /* FALLTHROUGH */
         case LINE_TEXT:          case LINE_TEXT:
                 putchar('\n');                  putchar('\n');
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case LINE_NEW:          case LINE_NEW:
                 putchar('.');                  putchar('.');
                 f->linestate = LINE_MACRO;                  f->linestate = LINE_MACRO;
                   f->flags = 0;
                 break;                  break;
         case LINE_MACRO:  
                 putchar(' ');  
                 if (f->spc == 0)  
                         fputs("Ns ", stdout);  
                 break;  
         }          }
         fputs(name, stdout);          fputs(name, stdout);
           f->flags &= FMT_IMPL;
           f->flags |= FMT_ARG;
 }  }
   
 void  void
 macro_close(struct format *f)  macro_close(struct format *f)
 {  {
         if (f->linestate == LINE_NEW)          if (f->linestate != LINE_NEW)
                 return;                  putchar('\n');
         putchar('\n');  
         f->linestate = LINE_NEW;          f->linestate = LINE_NEW;
           f->flags = 0;
 }  }
   
 void  void
Line 65  macro_line(struct format *f, const char *name)
Line 73  macro_line(struct format *f, const char *name)
 }  }
   
 /*  /*
  * At the end of a macro, decide whether the line needs to remain open  
  * because the next node follows without intervening whitespace;  
  * otherwise, close the line.  
  */  
 void  
 macro_closepunct(struct format *f, struct pnode *pn)  
 {  
         char            *cp;  
   
         if ((pn = TAILQ_NEXT(pn, child)) != NULL && pn->spc == 0) {  
   
                 /*  
                  * If a non-text node follows without intervening  
                  * whitespace, the handler of that node will decide  
                  * whether and how to suppress whitespace.  To allow  
                  * that, the macro line needs to remain open.  
                  */  
   
                 if (pn->node != NODE_TEXT && pn->node != NODE_ESCAPE)  
                         return;  
   
                 /*  
                  * Give closing punctuation  
                  * in the form of trailing macro arguments.  
                  */  
   
                 while (*pn->b != '\0' &&  
                     strchr("!),.:;?]", *pn->b) != NULL) {  
                         putchar(' ');  
                         putchar(*pn->b);  
                         pn->b++;  
                         pn->bsz--;  
                 }  
   
                 /*  
                  * Text follows without intervening whitespace.  
                  * Append the first word with .Ns.  
                  */  
   
                 if (*pn->b != '\0' && isspace((unsigned char)*pn->b) == 0) {  
                         fputs(" Ns", stdout);  
                         for (cp = pn->b; *cp != '\0'; cp++)  
                                 if (isspace((unsigned char)*cp))  
                                         break;  
                         *cp = '\0';  
                         macro_addarg(f, pn->b, ARG_SPACE);  
                         pn->bsz -= cp - pn->b;  
                         pn->b = cp;  
                         if (pn->bsz > 0) {  
                                 pn->b++;  
                                 pn->bsz--;  
                                 pn->spc = 1;  
                         }  
                 }  
   
                 /* Skip whitespace after the first word. */  
   
                 while (isspace((unsigned char)*pn->b)) {  
                         pn->b++;  
                         pn->bsz--;  
                         pn->spc = 1;  
                 }  
         }  
         macro_close(f);  
 }  
   
 /*  
  * Print an argument string on a macro line, collapsing whitespace.   * Print an argument string on a macro line, collapsing whitespace.
  */   */
 void  void
Line 285  print_text(struct format *f, const char *word, int fla
Line 226  print_text(struct format *f, const char *word, int fla
         }          }
         fputs(word, stdout);          fputs(word, stdout);
         f->linestate = LINE_TEXT;          f->linestate = LINE_TEXT;
           f->flags = 0;
 }  }
   
 /*  /*

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

CVSweb