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

Diff for /mandoc/Attic/makewhatis.c between version 1.12 and 1.13

version 1.12, 2011/07/01 09:11:35 version 1.13, 2011/07/01 10:17:24
Line 75  struct buf {
Line 75  struct buf {
                           const struct mdoc_node *n, \                            const struct mdoc_node *n, \
                           const struct mdoc_meta *m                            const struct mdoc_meta *m
   
   static  void              buf_appendmdoc(struct buf *,
                                   const struct mdoc_node *);
 static  void              buf_append(struct buf *, const char *);  static  void              buf_append(struct buf *, const char *);
 static  void              buf_appendb(struct buf *,  static  void              buf_appendb(struct buf *,
                                 const void *, size_t);                                  const void *, size_t);
Line 524  buf_append(struct buf *buf, const char *cp)
Line 526  buf_append(struct buf *buf, const char *cp)
         buf_appendb(buf, cp, sz + 1);          buf_appendb(buf, cp, sz + 1);
 }  }
   
   /*
    * Recursively add all text from a given node.
    * This is optimised for general mdoc nodes in this context, which do
    * not consist of subexpressions and having a recursive call for n->next
    * would be wasteful.
    */
   static void
   buf_appendmdoc(struct buf *buf, const struct mdoc_node *n)
   {
   
           for ( ; n; n = n->next) {
                   if (n->child)
                           buf_appendmdoc(buf, n->child);
                   if (MDOC_TEXT == n->type)
                           buf_append(buf, n->string);
           }
   }
   
 /* ARGSUSED */  /* ARGSUSED */
 static void  static void
 pmdoc_An(MDOC_ARGS)  pmdoc_An(MDOC_ARGS)
Line 532  pmdoc_An(MDOC_ARGS)
Line 552  pmdoc_An(MDOC_ARGS)
         if (SEC_AUTHORS != n->sec)          if (SEC_AUTHORS != n->sec)
                 return;                  return;
   
         for (n = n->child; n; n = n->next)          buf_appendmdoc(buf, n->child);
                 if (MDOC_TEXT == n->type)  
                         buf_append(buf, n->string);  
   
         hash_put(hash, buf, TYPE_AUTHOR);          hash_put(hash, buf, TYPE_AUTHOR);
 }  }
   
Line 593  pmdoc_Cd(MDOC_ARGS)
Line 610  pmdoc_Cd(MDOC_ARGS)
         if (SEC_SYNOPSIS != n->sec)          if (SEC_SYNOPSIS != n->sec)
                 return;                  return;
   
         for (n = n->child; n; n = n->next)          buf_appendmdoc(buf, n->child);
                 if (MDOC_TEXT == n->type)  
                         buf_append(buf, n->string);  
   
         hash_put(hash, buf, TYPE_CONFIG);          hash_put(hash, buf, TYPE_CONFIG);
 }  }
   
Line 729  pmdoc_Fo(MDOC_ARGS)
Line 743  pmdoc_Fo(MDOC_ARGS)
 static void  static void
 pmdoc_Nd(MDOC_ARGS)  pmdoc_Nd(MDOC_ARGS)
 {  {
         int              first;  
         size_t           sz;          size_t           sz;
   
         for (first = 1, n = n->child; n; n = n->next) {  
                 if (MDOC_TEXT != n->type)  
                         continue;  
   
                 if (first) {          if (MDOC_BODY != n->type)
                         sz = strlen(n->string) + 1;                  return;
                         buf_appendb(dbuf, n->string, sz);          else if (NULL == (n = n->child))
                         buf_appendb(buf, n->string, sz);                  return;
                 } else {  
                         buf_append(dbuf, n->string);  
                         buf_append(buf, n->string);  
                 }  
   
                 first = 0;          /* FIXME: don't assume this. */
         }          assert(MDOC_TEXT == n->type);
   
           sz = strlen(n->string) + 1;
           buf_appendb(dbuf, n->string, sz);
           buf_appendb(buf, n->string, sz);
   
           buf_appendmdoc(dbuf, n->next);
           buf_appendmdoc(buf, n->next);
   
         hash_put(hash, buf, TYPE_DESC);          hash_put(hash, buf, TYPE_DESC);
 }  }
   
Line 759  pmdoc_Pa(MDOC_ARGS)
Line 771  pmdoc_Pa(MDOC_ARGS)
         if (SEC_FILES != n->sec)          if (SEC_FILES != n->sec)
                 return;                  return;
   
         for (n = n->child; n; n = n->next)          buf_appendmdoc(buf, n->child);
                 if (MDOC_TEXT == n->type)  
                         buf_append(buf, n->string);  
   
         hash_put(hash, buf, TYPE_PATH);          hash_put(hash, buf, TYPE_PATH);
 }  }
   
Line 772  pmdoc_Nm(MDOC_ARGS)
Line 781  pmdoc_Nm(MDOC_ARGS)
 {  {
   
         if (SEC_NAME == n->sec) {          if (SEC_NAME == n->sec) {
                 for (n = n->child; n; n = n->next)                  buf_appendmdoc(buf, n->child);
                         if (MDOC_TEXT == n->type)  
                                 buf_append(buf, n->string);  
                 hash_put(hash, buf, TYPE_NAME);                  hash_put(hash, buf, TYPE_NAME);
                 return;                  return;
         } else if (SEC_SYNOPSIS != n->sec || MDOC_HEAD != n->type)          } else if (SEC_SYNOPSIS != n->sec || MDOC_HEAD != n->type)
Line 783  pmdoc_Nm(MDOC_ARGS)
Line 790  pmdoc_Nm(MDOC_ARGS)
         if (NULL == n->child)          if (NULL == n->child)
                 buf_append(buf, m->name);                  buf_append(buf, m->name);
   
         for (n = n->child; n; n = n->next)          buf_appendmdoc(buf, n->child);
                 if (MDOC_TEXT == n->type)  
                         buf_append(buf, n->string);  
   
         hash_put(hash, buf, TYPE_UTILITY);          hash_put(hash, buf, TYPE_UTILITY);
 }  }
   

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

CVSweb