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

Diff for /mandoc/Attic/strings.c between version 1.5 and 1.11

version 1.5, 2009/01/06 15:49:44 version 1.11, 2009/01/20 22:55:46
Line 21 
Line 21 
 #include <stdlib.h>  #include <stdlib.h>
 #include <stdio.h>  #include <stdio.h>
 #include <string.h>  #include <string.h>
 #ifdef __linux__  #ifndef __OpenBSD__
 #include <time.h>  #include <time.h>
 #endif  #endif
   
Line 36  mdoc_iscdelim(char p)
Line 36  mdoc_iscdelim(char p)
 {  {
   
         switch (p) {          switch (p) {
         case('{'):  
                 /* FALLTHROUGH */  
         case('.'):          case('.'):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case(','):          case(','):
Line 58  mdoc_iscdelim(char p)
Line 56  mdoc_iscdelim(char p)
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case(']'):          case(']'):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
           case('{'):
                   /* FALLTHROUGH */
         case('}'):          case('}'):
                 return(1);                  return(1);
         default:          default:
Line 81  mdoc_isdelim(const char *p)
Line 81  mdoc_isdelim(const char *p)
   
   
 enum mdoc_sec  enum mdoc_sec
 mdoc_atosec(size_t sz, const char **p)  mdoc_atosec(const char *p)
 {  {
   
         assert(sz > 0);          assert(p);
         if (sz > 2)          if (0 == strcmp(p, "NAME"))
                 return(SEC_CUSTOM);  
         if (sz == 2) {  
                 if (0 == strcmp(*p, "RETURN") &&  
                                 0 == strcmp(*(p + 1), "VALUES"))  
                         return(SEC_RETURN_VALUES);  
                 if (0 == strcmp(*p, "SEE") &&  
                                 0 == strcmp(*(p + 1), "ALSO"))  
                         return(SEC_SEE_ALSO);  
                 return(SEC_CUSTOM);  
         }  
   
         if (0 == strcmp(*p, "NAME"))  
                 return(SEC_NAME);                  return(SEC_NAME);
         else if (0 == strcmp(*p, "SYNOPSIS"))          else if (0 == strcmp(p, "RETURN VALUES"))
                   return(SEC_RETURN_VALUES);
           else if (0 == strcmp(p, "SEE ALSO"))
                   return(SEC_SEE_ALSO);
           else if (0 == strcmp(p, "SYNOPSIS"))
                 return(SEC_SYNOPSIS);                  return(SEC_SYNOPSIS);
         else if (0 == strcmp(*p, "DESCRIPTION"))          else if (0 == strcmp(p, "DESCRIPTION"))
                 return(SEC_DESCRIPTION);                  return(SEC_DESCRIPTION);
         else if (0 == strcmp(*p, "ENVIRONMENT"))          else if (0 == strcmp(p, "ENVIRONMENT"))
                 return(SEC_ENVIRONMENT);                  return(SEC_ENVIRONMENT);
         else if (0 == strcmp(*p, "FILES"))          else if (0 == strcmp(p, "FILES"))
                 return(SEC_FILES);                  return(SEC_FILES);
         else if (0 == strcmp(*p, "EXAMPLES"))          else if (0 == strcmp(p, "EXAMPLES"))
                 return(SEC_EXAMPLES);                  return(SEC_EXAMPLES);
         else if (0 == strcmp(*p, "DIAGNOSTICS"))          else if (0 == strcmp(p, "DIAGNOSTICS"))
                 return(SEC_DIAGNOSTICS);                  return(SEC_DIAGNOSTICS);
         else if (0 == strcmp(*p, "ERRORS"))          else if (0 == strcmp(p, "ERRORS"))
                 return(SEC_ERRORS);                  return(SEC_ERRORS);
         else if (0 == strcmp(*p, "STANDARDS"))          else if (0 == strcmp(p, "STANDARDS"))
                 return(SEC_STANDARDS);                  return(SEC_STANDARDS);
         else if (0 == strcmp(*p, "HISTORY"))          else if (0 == strcmp(p, "HISTORY"))
                 return(SEC_HISTORY);                  return(SEC_HISTORY);
         else if (0 == strcmp(*p, "AUTHORS"))          else if (0 == strcmp(p, "AUTHORS"))
                 return(SEC_AUTHORS);                  return(SEC_AUTHORS);
         else if (0 == strcmp(*p, "CAVEATS"))          else if (0 == strcmp(p, "CAVEATS"))
                 return(SEC_CAVEATS);                  return(SEC_CAVEATS);
         else if (0 == strcmp(*p, "BUGS"))          else if (0 == strcmp(p, "BUGS"))
                 return(SEC_BUGS);                  return(SEC_BUGS);
   
         return(SEC_CUSTOM);          return(SEC_CUSTOM);
Line 132  time_t
Line 124  time_t
 mdoc_atotime(const char *p)  mdoc_atotime(const char *p)
 {  {
         struct tm        tm;          struct tm        tm;
           char            *pp;
   
         (void)memset(&tm, 0, sizeof(struct tm));          (void)memset(&tm, 0, sizeof(struct tm));
   
         if (strptime(p, "%b %d %Y", &tm))          if (xstrcmp(p, "$Mdocdate$"))
                   return(time(NULL));
           if ((pp = strptime(p, "$Mdocdate$", &tm)) && 0 == *pp)
                 return(mktime(&tm));                  return(mktime(&tm));
         if (strptime(p, "%b %d, %Y", &tm))          /* XXX - this matches "June 1999", which is wrong. */
           if ((pp = strptime(p, "%b %d %Y", &tm)) && 0 == *pp)
                 return(mktime(&tm));                  return(mktime(&tm));
           if ((pp = strptime(p, "%b %d, %Y", &tm)) && 0 == *pp)
                   return(mktime(&tm));
   
         return(0);          return(0);
 }  }
Line 228  mdoc_atoarch(const char *p)
Line 226  mdoc_atoarch(const char *p)
                 return(ARCH_amiga);                  return(ARCH_amiga);
         else if (0 == strcmp(p, "arc"))          else if (0 == strcmp(p, "arc"))
                 return(ARCH_arc);                  return(ARCH_arc);
           else if (0 == strcmp(p, "arm"))
                   return(ARCH_arm);
         else if (0 == strcmp(p, "armish"))          else if (0 == strcmp(p, "armish"))
                 return(ARCH_armish);                  return(ARCH_armish);
         else if (0 == strcmp(p, "aviion"))          else if (0 == strcmp(p, "aviion"))
Line 306  mdoc_atoatt(const char *p)
Line 306  mdoc_atoatt(const char *p)
                 return(ATT_V4);                  return(ATT_V4);
   
         return(ATT_DEFAULT);          return(ATT_DEFAULT);
   }
   
   
   char *
   mdoc_type2a(enum mdoc_type type)
   {
           switch (type) {
           case (MDOC_ROOT):
                   return("root");
           case (MDOC_BLOCK):
                   return("block");
           case (MDOC_HEAD):
                   return("block-head");
           case (MDOC_BODY):
                   return("block-body");
           case (MDOC_TAIL):
                   return("block-tail");
           case (MDOC_ELEM):
                   return("elem");
           case (MDOC_TEXT):
                   return("text");
           default:
                   break;
           }
   
           abort();
           /* NOTREACHED */
 }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.11

CVSweb