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

Diff for /mandoc/Attic/man_action.c between version 1.1 and 1.2

version 1.1, 2009/03/25 15:36:05 version 1.2, 2009/03/25 16:07:36
Line 33  struct actions {
Line 33  struct actions {
 };  };
   
   
   static  int       post_TH(struct man *);
   static time_t     man_atotime(const char *);
   
 const   struct actions man_actions[MAN_MAX] = {  const   struct actions man_actions[MAN_MAX] = {
         { NULL }, /* __ */          { NULL }, /* __ */
         { NULL }, /* TH */          { post_TH }, /* TH */
         { NULL }, /* SH */          { NULL }, /* SH */
         { NULL }, /* SS */          { NULL }, /* SS */
         { NULL }, /* TP */          { NULL }, /* TP */
Line 78  man_action_post(struct man *m)
Line 81  man_action_post(struct man *m)
         return(1);          return(1);
 }  }
   
 #if 0  
 static int  static int
 post_dt(POST_ARGS)  post_TH(struct man *m)
 {  {
         struct mdoc_node *n;          struct man_node *n;
         const char       *cp;          char            *ep;
         char             *ep;          long             lval;
         long              lval;  
   
         if (m->meta.title)          if (m->meta.title)
                 free(m->meta.title);                  free(m->meta.title);
         if (m->meta.vol)          if (m->meta.vol)
                 free(m->meta.vol);                  free(m->meta.vol);
         if (m->meta.arch)          if (m->meta.source)
                 free(m->meta.arch);                  free(m->meta.source);
   
         m->meta.title = m->meta.vol = m->meta.arch = NULL;          m->meta.title = m->meta.vol = m->meta.source = NULL;
         m->meta.msec = 0;          m->meta.msec = 0;
           m->meta.date = 0;
   
         /* Handles: `.Dt'          /* ->TITLE<- MSEC DATE SOURCE VOL */
          *   --> title = unknown, volume = local, msec = 0, arch = NULL  
          */  
   
         if (NULL == (n = m->last->child)) {          n = m->last->child;
                 m->meta.title = xstrdup("unknown");          assert(n);
                 m->meta.vol = xstrdup("local");  
                 return(post_prol(m));  
         }  
   
         /* Handles: `.Dt TITLE'          if (NULL == (m->meta.title = strdup(n->string)))
          *   --> title = TITLE, volume = local, msec = 0, arch = NULL                  return(man_verr(m, n->line, n->pos, "malloc"));
          */  
   
         m->meta.title = xstrdup(n->string);          /* TITLE ->MSEC<- DATE SOURCE VOL */
   
         if (NULL == (n = n->next)) {          n = n->next;
                 m->meta.vol = xstrdup("local");          assert(n);
                 return(post_prol(m));  
         }  
   
         /* Handles: `.Dt TITLE SEC'          errno = 0;
          *   --> title = TITLE, volume = SEC is msec ?          lval = strtol(n->string, &ep, 10);
          *           format(msec) : SEC,          if (n->string[0] != '\0' && *ep == '\0')
          *       msec = SEC is msec ? atoi(msec) : 0,                  m->meta.msec = (int)lval;
          *       arch = NULL          else if ( ! man_vwarn(m, n->line, n->pos, "invalid section"))
          */                  return(0);
   
         cp = mdoc_a2msec(n->string);          /* TITLE MSEC ->DATE<- SOURCE VOL */
         if (cp) {  
                 m->meta.vol = xstrdup(cp);  
                 errno = 0;  
                 lval = strtol(n->string, &ep, 10);  
                 if (n->string[0] != '\0' && *ep == '\0')  
                         m->meta.msec = (int)lval;  
         } else  
                 m->meta.vol = xstrdup(n->string);  
   
         if (NULL == (n = n->next))          if (NULL == (n = n->next)) {
                 return(post_prol(m));                  m->meta.date = time(NULL);
                   return(1);
           }
   
         /* Handles: `.Dt TITLE SEC VOL'          if (0 == (m->meta.date = man_atotime(n->string))) {
          *   --> title = TITLE, volume = VOL is vol ?                  if ( ! man_vwarn(m, n->line, n->pos, "invalid date"))
          *       format(VOL) :                          return(0);
          *           VOL is arch ? format(arch) :                  m->meta.date = time(NULL);
          *               VOL          }
          */  
   
         cp = mdoc_a2vol(n->string);          /* TITLE MSEC DATE ->SOURCE<- VOL */
         if (cp) {  
                 free(m->meta.vol);  
                 m->meta.vol = xstrdup(cp);  
                 n = n->next;  
         } else {  
                 cp = mdoc_a2arch(n->string);  
                 if (NULL == cp) {  
                         free(m->meta.vol);  
                         m->meta.vol = xstrdup(n->string);  
                 } else  
                         m->meta.arch = xstrdup(cp);  
         }  
   
         /* Ignore any subsequent parameters... */          if ((n = n->next))
                   if (NULL == (m->meta.source = strdup(n->string)))
                           return(man_verr(m, n->line, n->pos, "malloc"));
   
         return(post_prol(m));          /* TITLE MSEC DATE SOURCE ->VOL<- */
 }  
   
 static int          if ((n = n->next))
 post_prol(POST_ARGS)                  if (NULL == (m->meta.vol = strdup(n->string)))
 {                          return(man_verr(m, n->line, n->pos, "malloc"));
         struct mdoc_node *n;  
   
         /*          /*
          * The end document shouldn't have the prologue macros as part           * The end document shouldn't have the prologue macros as part
          * of the syntax tree (they encompass only meta-data).           * of the syntax tree (they encompass only meta-data).
          */           */
   
         if (m->last->parent->child == m->last)          assert(MAN_ROOT == m->last->parent->type);
                 m->last->parent->child = m->last->prev;          m->last->parent->child = NULL;
         if (m->last->prev)  
                 m->last->prev->next = NULL;  
   
         n = m->last;          n = m->last;
         assert(NULL == m->last->next);          m->last = m->last->parent;
           m->next = MAN_NEXT_CHILD;
           assert(m->last == m->first);
   
         if (m->last->prev) {          man_node_freelist(n);
                 m->last = m->last->prev;  
                 m->next = MDOC_NEXT_SIBLING;  
         } else {  
                 m->last = m->last->parent;  
                 m->next = MDOC_NEXT_CHILD;  
         }  
   
         mdoc_node_freelist(n);  
         return(1);          return(1);
 }  }
 #endif  
   
   static time_t
   man_atotime(const char *p)
   {
           struct tm        tm;
           char            *pp;
   
           (void)memset(&tm, 0, sizeof(struct tm));
   
           if ((pp = strptime(p, "%b %d %Y", &tm)) && 0 == *pp)
                   return(mktime(&tm));
           if ((pp = strptime(p, "%d %b %Y", &tm)) && 0 == *pp)
                   return(mktime(&tm));
           if ((pp = strptime(p, "%b %d, %Y", &tm)) && 0 == *pp)
                   return(mktime(&tm));
           if ((pp = strptime(p, "%b %Y", &tm)) && 0 == *pp)
                   return(mktime(&tm));
   
           return(0);
   }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

CVSweb