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

Diff for /docbook2mdoc/macro.c between version 1.10 and 1.13

version 1.10, 2019/04/12 08:48:16 version 1.13, 2019/04/14 23:59:11
Line 79  void
Line 79  void
 macro_addarg(struct format *f, const char *arg, int flags)  macro_addarg(struct format *f, const char *arg, int flags)
 {  {
         const char      *cp;          const char      *cp;
           int              quote_now;
   
         assert(f->linestate == LINE_MACRO);          assert(f->linestate == LINE_MACRO);
   
         /* Quote if requested and necessary. */          /* Quote if requested and necessary. */
   
           quote_now = 0;
         if ((flags & (ARG_SINGLE | ARG_QUOTED)) == ARG_SINGLE) {          if ((flags & (ARG_SINGLE | ARG_QUOTED)) == ARG_SINGLE) {
                 for (cp = arg; *cp != '\0'; cp++)                  for (cp = arg; *cp != '\0'; cp++)
                         if (isspace((unsigned char)*cp))                          if (isspace((unsigned char)*cp))
Line 95  macro_addarg(struct format *f, const char *arg, int fl
Line 97  macro_addarg(struct format *f, const char *arg, int fl
                         }                          }
                         putchar('"');                          putchar('"');
                         flags = ARG_QUOTED;                          flags = ARG_QUOTED;
                           quote_now = 1;
                 }                  }
         }          }
   
Line 112  macro_addarg(struct format *f, const char *arg, int fl
Line 115  macro_addarg(struct format *f, const char *arg, int fl
   
                 /* Escape us if we look like a macro. */                  /* Escape us if we look like a macro. */
   
                 if ((flags & ARG_QUOTED) == 0 &&                  if ((flags & (ARG_QUOTED | ARG_UPPER)) == 0 &&
                     (cp == arg || isspace((unsigned char)cp[-1])) &&                      (cp == arg || isspace((unsigned char)cp[-1])) &&
                     isupper((unsigned char)cp[0]) &&                      isupper((unsigned char)cp[0]) &&
                     islower((unsigned char)cp[1]) &&                      islower((unsigned char)cp[1]) &&
                     (cp[2] == '\0' || cp[2] == ' ' ||                      (cp[2] == '\0' || cp[2] == ' ' ||
                      (islower((unsigned char)cp[2]) &&                       ((cp[3] == '\0' || cp[3] == ' ') &&
                       (cp[3] == '\0' || cp[3] == ' '))))                        (strncmp(cp, "Brq", 3) == 0 ||
                          strncmp(cp, "Bro", 3) == 0 ||
                          strncmp(cp, "Brc", 3) == 0 ||
                          strncmp(cp, "Bsx", 3) == 0))))
                         fputs("\\&", stdout);                          fputs("\\&", stdout);
   
                 if (*cp == '"')                  if (*cp == '"')
Line 130  macro_addarg(struct format *f, const char *arg, int fl
Line 136  macro_addarg(struct format *f, const char *arg, int fl
                 if (*cp == '\\')                  if (*cp == '\\')
                         putchar('e');                          putchar('e');
         }          }
           if (quote_now)
                   putchar('"');
 }  }
   
 void  void
Line 216  print_text(struct format *f, const char *word, int fla
Line 224  print_text(struct format *f, const char *word, int fla
 {  {
         switch (f->linestate) {          switch (f->linestate) {
         case LINE_NEW:          case LINE_NEW:
                 if (*word == '.' || *word == '\'')  
                         fputs("\\&", stdout);  
                 break;                  break;
         case LINE_TEXT:          case LINE_TEXT:
                 if (flags & ARG_SPACE)                  if (flags & ARG_SPACE)
Line 227  print_text(struct format *f, const char *word, int fla
Line 233  print_text(struct format *f, const char *word, int fla
                 macro_close(f);                  macro_close(f);
                 break;                  break;
         }          }
           if (f->linestate == LINE_NEW && (*word == '.' || *word == '\''))
                   fputs("\\&", stdout);
         while (*word != '\0') {          while (*word != '\0') {
                 putchar(*word);                  putchar(*word);
                 if (*word++ == '\\')                  if (*word++ == '\\')

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.13

CVSweb