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

Diff for /mandoc/Attic/makewhatis.c between version 1.10 and 1.16

version 1.10, 2011/06/22 10:36:36 version 1.16, 2011/07/01 13:46:39
Line 54 
Line 54 
 #define TYPE_AUTHOR       0x40  #define TYPE_AUTHOR       0x40
 #define TYPE_CONFIG       0x80  #define TYPE_CONFIG       0x80
 #define TYPE_DESC         0x100  #define TYPE_DESC         0x100
   #define TYPE_XREF         0x200
   #define TYPE_PATH         0x400
   #define TYPE_ENV          0x800
   #define TYPE_ERR          0x1000
   
 /* Buffer for storing growable data. */  /* Buffer for storing growable data. */
   
Line 73  struct buf {
Line 77  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 *, int);
 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 82  static int    pman_node(MAN_ARGS);
Line 88  static int    pman_node(MAN_ARGS);
 static  void              pmdoc_node(MDOC_ARGS);  static  void              pmdoc_node(MDOC_ARGS);
 static  void              pmdoc_An(MDOC_ARGS);  static  void              pmdoc_An(MDOC_ARGS);
 static  void              pmdoc_Cd(MDOC_ARGS);  static  void              pmdoc_Cd(MDOC_ARGS);
   static  void              pmdoc_Er(MDOC_ARGS);
   static  void              pmdoc_Ev(MDOC_ARGS);
 static  void              pmdoc_Fd(MDOC_ARGS);  static  void              pmdoc_Fd(MDOC_ARGS);
 static  void              pmdoc_In(MDOC_ARGS);  static  void              pmdoc_In(MDOC_ARGS);
 static  void              pmdoc_Fn(MDOC_ARGS);  static  void              pmdoc_Fn(MDOC_ARGS);
 static  void              pmdoc_Fo(MDOC_ARGS);  static  void              pmdoc_Fo(MDOC_ARGS);
 static  void              pmdoc_Nd(MDOC_ARGS);  static  void              pmdoc_Nd(MDOC_ARGS);
 static  void              pmdoc_Nm(MDOC_ARGS);  static  void              pmdoc_Nm(MDOC_ARGS);
   static  void              pmdoc_Pa(MDOC_ARGS);
 static  void              pmdoc_St(MDOC_ARGS);  static  void              pmdoc_St(MDOC_ARGS);
 static  void              pmdoc_Vt(MDOC_ARGS);  static  void              pmdoc_Vt(MDOC_ARGS);
   static  void              pmdoc_Xr(MDOC_ARGS);
 static  void              usage(void);  static  void              usage(void);
   
 typedef void            (*pmdoc_nf)(MDOC_ARGS);  typedef void            (*pmdoc_nf)(MDOC_ARGS);
Line 115  static const pmdoc_nf   mdocs[MDOC_MAX] = {
Line 125  static const pmdoc_nf   mdocs[MDOC_MAX] = {
         pmdoc_Cd, /* Cd */          pmdoc_Cd, /* Cd */
         NULL, /* Cm */          NULL, /* Cm */
         NULL, /* Dv */          NULL, /* Dv */
         NULL, /* Er */          pmdoc_Er, /* Er */
         NULL, /* Ev */          pmdoc_Ev, /* Ev */
         NULL, /* Ex */          NULL, /* Ex */
         NULL, /* Fa */          NULL, /* Fa */
         pmdoc_Fd, /* Fd */          pmdoc_Fd, /* Fd */
Line 130  static const pmdoc_nf   mdocs[MDOC_MAX] = {
Line 140  static const pmdoc_nf   mdocs[MDOC_MAX] = {
         pmdoc_Nm, /* Nm */          pmdoc_Nm, /* Nm */
         NULL, /* Op */          NULL, /* Op */
         NULL, /* Ot */          NULL, /* Ot */
         NULL, /* Pa */          pmdoc_Pa, /* Pa */
         NULL, /* Rv */          NULL, /* Rv */
         pmdoc_St, /* St */          pmdoc_St, /* St */
         pmdoc_Vt, /* Va */          pmdoc_Vt, /* Va */
         pmdoc_Vt, /* Vt */          pmdoc_Vt, /* Vt */
         NULL, /* Xr */          pmdoc_Xr, /* Xr */
         NULL, /* %A */          NULL, /* %A */
         NULL, /* %B */          NULL, /* %B */
         NULL, /* %D */          NULL, /* %D */
Line 520  buf_append(struct buf *buf, const char *cp)
Line 530  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.
    * The "f" variable should be 0 unless called from pmdoc_Nd for the
    * description buffer, which does not start at the beginning of the
    * buffer.
    */
   static void
   buf_appendmdoc(struct buf *buf, const struct mdoc_node *n, int f)
   {
   
           for ( ; n; n = n->next) {
                   if (n->child)
                           buf_appendmdoc(buf, n->child, f);
   
                   if (MDOC_TEXT == n->type && f) {
                           f = 0;
                           buf_appendb(buf, n->string,
                                           strlen(n->string) + 1);
                   } else 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 528  pmdoc_An(MDOC_ARGS)
Line 565  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, 0);
                 if (MDOC_TEXT == n->type)  
                         buf_append(buf, n->string);  
   
         hash_put(hash, buf, TYPE_AUTHOR);          hash_put(hash, buf, TYPE_AUTHOR);
 }  }
   
Line 589  pmdoc_Cd(MDOC_ARGS)
Line 623  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, 0);
                 if (MDOC_TEXT == n->type)  
                         buf_append(buf, n->string);  
   
         hash_put(hash, buf, TYPE_CONFIG);          hash_put(hash, buf, TYPE_CONFIG);
 }  }
   
Line 652  pmdoc_St(MDOC_ARGS)
Line 683  pmdoc_St(MDOC_ARGS)
   
 /* ARGSUSED */  /* ARGSUSED */
 static void  static void
   pmdoc_Xr(MDOC_ARGS)
   {
   
           if (NULL == (n = n->child))
                   return;
   
           buf_appendb(buf, n->string, strlen(n->string));
   
           if (NULL != (n = n->next)) {
                   buf_appendb(buf, ".", 1);
                   buf_appendb(buf, n->string, strlen(n->string) + 1);
           } else
                   buf_appendb(buf, ".", 2);
   
           hash_put(hash, buf, TYPE_XREF);
   }
   
   /* ARGSUSED */
   static void
 pmdoc_Vt(MDOC_ARGS)  pmdoc_Vt(MDOC_ARGS)
 {  {
         const char      *start;          const char      *start;
Line 706  pmdoc_Fo(MDOC_ARGS)
Line 756  pmdoc_Fo(MDOC_ARGS)
 static void  static void
 pmdoc_Nd(MDOC_ARGS)  pmdoc_Nd(MDOC_ARGS)
 {  {
         int              first;  
         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);  
                         buf_appendb(buf, n->string, sz);  
                 } else {  
                         buf_append(dbuf, n->string);  
                         buf_append(buf, n->string);  
                 }  
   
                 first = 0;          buf_appendmdoc(dbuf, n->child, 1);
         }          buf_appendmdoc(buf, n->child, 0);
   
         hash_put(hash, buf, TYPE_DESC);          hash_put(hash, buf, TYPE_DESC);
 }  }
   
 /* ARGSUSED */  /* ARGSUSED */
 static void  static void
   pmdoc_Er(MDOC_ARGS)
   {
   
           if (SEC_ERRORS != n->sec)
                   return;
   
           buf_appendmdoc(buf, n->child, 0);
           hash_put(hash, buf, TYPE_ERR);
   }
   
   /* ARGSUSED */
   static void
   pmdoc_Ev(MDOC_ARGS)
   {
   
           if (SEC_ENVIRONMENT != n->sec)
                   return;
   
           buf_appendmdoc(buf, n->child, 0);
           hash_put(hash, buf, TYPE_ENV);
   }
   
   /* ARGSUSED */
   static void
   pmdoc_Pa(MDOC_ARGS)
   {
   
           if (SEC_FILES != n->sec)
                   return;
   
           buf_appendmdoc(buf, n->child, 0);
           hash_put(hash, buf, TYPE_PATH);
   }
   
   /* ARGSUSED */
   static void
 pmdoc_Nm(MDOC_ARGS)  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, 0);
                         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 745  pmdoc_Nm(MDOC_ARGS)
Line 817  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, 0);
                 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.10  
changed lines
  Added in v.1.16

CVSweb