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

Diff for /mandoc/out.c between version 1.9 and 1.10

version 1.9, 2009/11/07 14:14:15 version 1.10, 2009/11/08 09:23:35
Line 25 
Line 25 
   
 #include "out.h"  #include "out.h"
   
   /* See a2roffdeco(). */
   #define C2LIM(c, l) do { \
           (l) = 1; \
           if ('[' == (c) || '\'' == (c)) \
                   (l) = 0; \
           else if ('(' == (c)) \
                   (l) = 2; } \
           while (/* CONSTCOND */ 0)
   
   /* See a2roffdeco(). */
   #define C2TERM(c, t) do { \
           (t) = 0; \
           if ('\'' == (c)) \
                   (t) = 1; \
           else if ('[' == (c)) \
                   (t) = 2; \
           else if ('(' == (c)) \
                   (t) = 3; } \
           while (/* CONSTCOND */ 0)
   
 #ifdef __linux__  #ifdef __linux__
 extern  size_t    strlcat(char *, const char *, size_t);  extern  size_t    strlcat(char *, const char *, size_t);
 #endif  #endif
Line 167  time2a(time_t t, char *dst, size_t sz)
Line 187  time2a(time_t t, char *dst, size_t sz)
 }  }
   
   
 /* Returns length of parsed string. */  /*
    * Returns length of parsed string (the leading "\" should NOT be
    * included).  This can be zero if the current character is the nil
    * terminator.  "d" is set to the type of parsed decorator, which may
    * have an adjoining "word" of size "sz" (e.g., "(ab" -> "ab", 2).
    */
 int  int
 a2roffdeco(enum roffdeco *d,  a2roffdeco(enum roffdeco *d,
                 const char **word, size_t *sz)                  const char **word, size_t *sz)
 {  {
         int              j, type, sv, t, lim;          int              j, type, term, lim;
         const char      *wp;          const char      *wp, *sp;
   
         *d = DECO_NONE;          *d = DECO_NONE;
         wp = *word;          wp = *word;
Line 184  a2roffdeco(enum roffdeco *d,
Line 209  a2roffdeco(enum roffdeco *d,
                 return(0);                  return(0);
   
         case ('('):          case ('('):
                 wp++;                  if ('\0' == *(++wp))
                 if ('\0' == *wp)  
                         return(1);                          return(1);
                 if ('\0' == *(wp + 1))                  if ('\0' == *(wp + 1))
                         return(2);                          return(2);
Line 196  a2roffdeco(enum roffdeco *d,
Line 220  a2roffdeco(enum roffdeco *d,
                 return(3);                  return(3);
   
         case ('*'):          case ('*'):
                 wp++;                  switch (*(++wp)) {
   
                 switch (*wp) {  
                 case ('\0'):                  case ('\0'):
                         return(1);                          return(1);
   
                 case ('('):                  case ('('):
                         wp++;                          if ('\0' == *(++wp))
                         if ('\0' == *wp)  
                                 return(2);                                  return(2);
                         if ('\0' == *(wp + 1))                          if ('\0' == *(wp + 1))
                                 return(3);                                  return(3);
Line 226  a2roffdeco(enum roffdeco *d,
Line 247  a2roffdeco(enum roffdeco *d,
                 }                  }
                 break;                  break;
   
 #if 0  
         case ('s'):          case ('s'):
                 wp++;                  sp = wp;
                   if ('\0' == *(++wp))
                 /* This closely follows mandoc_special(). */  
                 if ('\0' == *wp)  
                         return(1);                          return(1);
   
                 t = 0;                  C2LIM(*wp, lim);
                 lim = 1;                  C2TERM(*wp, term);
   
                 if (*wp == '\'') {                  if (term)
                         lim = 0;                          wp++;
                         t = 1;  
                         ++wp;  
                 } else if (*wp == '[') {  
                         lim = 0;  
                         t = 2;  
                         ++wp;  
                 } else if (*wp == '(') {  
                         lim = 2;  
                         t = 3;  
                         ++wp;  
                 }  
   
                   *word = wp;
   
                 if (*wp == '+' || *wp == '-')                  if (*wp == '+' || *wp == '-')
                         ++wp;                          ++wp;
   
                 if (*wp == '\'') {                  switch (*wp) {
                         if (t) {                  case ('\''):
                                 *word = wp;                          /* FALLTHROUGH */
                                 return;                  case ('['):
                         }                          /* FALLTHROUGH */
                         lim = 0;                  case ('('):
                         t = 1;                          if (term)
                         ++wp;                                  return((int)(wp - sp));
                 } else if (*wp == '[') {  
                         if (t) {  
                                 *word = wp;  
                                 return;  
                         }  
                         lim = 0;  
                         t = 2;  
                         ++wp;  
                 } else if (*wp == '(') {  
                         if (t) {  
                                 *word = wp;  
                                 return;  
                         }  
                         lim = 2;  
                         t = 3;  
                         ++wp;  
                 }  
   
                 if ( ! isdigit((u_char)*wp)) {                          C2LIM(*wp, lim);
                         *word = --wp;                          C2TERM(*wp, term);
                         return;                          wp++;
                           break;
                   default:
                           break;
                 }                  }
   
                   if ( ! isdigit((u_char)*wp))
                           return((int)(wp - sp));
   
                 for (j = 0; isdigit((u_char)*wp); j++) {                  for (j = 0; isdigit((u_char)*wp); j++) {
                         if (lim && j >= lim)                          if (lim && j >= lim)
                                 break;                                  break;
                         ++wp;                          ++wp;
                 }                  }
   
                 if (t && t < 3) {                  if (term && term < 3) {
                         if (1 == t && *wp != '\'') {                          if (1 == term && *wp != '\'')
                                 *word = --wp;                                  return((int)(wp - sp));
                                 return;                          if (2 == term && *wp != ']')
                         }                                  return((int)(wp - sp));
                         if (2 == t && *wp != ']') {  
                                 *word = --wp;  
                                 return;  
                         }  
                         ++wp;                          ++wp;
                 }                  }
                 *word = --wp;  
                 return;  
 #endif  
   
         case ('f'):                  *d = DECO_SIZE;
                 wp++;                  return((int)(wp - sp));
   
                 switch (*wp) {          case ('f'):
                   switch (*(++wp)) {
                 case ('\0'):                  case ('\0'):
                         return(1);                          return(1);
                 case ('3'):                  case ('3'):
Line 354  a2roffdeco(enum roffdeco *d,
Line 346  a2roffdeco(enum roffdeco *d,
                 return(j + 1);                  return(j + 1);
   
         *d = type ? DECO_SPECIAL : DECO_RESERVED;          *d = type ? DECO_SPECIAL : DECO_RESERVED;
         *sz = j;          *sz = (size_t)j;
         return (j + 2);          return (j + 2);
 }  }

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

CVSweb