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

Diff for /mandoc/Attic/apropos_db.c between version 1.32.2.8 and 1.33

version 1.32.2.8, 2014/08/14 04:13:30 version 1.33, 2012/06/08 10:47:17
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011, 2014 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 15 
Line 15 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
   #ifdef HAVE_CONFIG_H
 #include "config.h"  #include "config.h"
   #endif
   
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/types.h>  
   
 #include <assert.h>  #include <assert.h>
 #include <fcntl.h>  #include <fcntl.h>
Line 29 
Line 30 
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   
 #if defined(__APPLE__)  #if defined(__linux__)
 # include <libkern/OSByteOrder.h>  
 #elif defined(__linux__) || defined(__CYGWIN__)  
 # include <endian.h>  # include <endian.h>
 #elif defined(__sun)  
 # include <sys/byteorder.h>  
 #else  
 # include <sys/endian.h>  
 #endif  
   
 #if defined(__linux__) || defined(__CYGWIN__) || defined(__sun)  
 # include <db_185.h>  # include <db_185.h>
   #elif defined(__APPLE__)
   # include <libkern/OSByteOrder.h>
   # include <db.h>
 #else  #else
 # include <db.h>  # include <db.h>
 #endif  #endif
Line 48 
Line 43 
 #include "mandocdb.h"  #include "mandocdb.h"
 #include "apropos_db.h"  #include "apropos_db.h"
 #include "mandoc.h"  #include "mandoc.h"
 #include "mandoc_aux.h"  
   
 #define RESFREE(_x) \  #define RESFREE(_x) \
         do { \          do { \
Line 259  norm_string(const char *val, const struct mchars *mc, 
Line 253  norm_string(const char *val, const struct mchars *mc, 
         const char       *seq, *cpp;          const char       *seq, *cpp;
         int               len, u, pos;          int               len, u, pos;
         enum mandoc_esc   esc;          enum mandoc_esc   esc;
         static const char res[] = { '\\', '\t', ASCII_NBRSP,          static const char res[] = { '\\', '\t',
                         ASCII_HYPH, ASCII_BREAK, '\0' };                                  ASCII_NBRSP, ASCII_HYPH, '\0' };
   
         /* Pre-allocate by the length of the input */          /* Pre-allocate by the length of the input */
   
Line 280  norm_string(const char *val, const struct mchars *mc, 
Line 274  norm_string(const char *val, const struct mchars *mc, 
                         val += (int)sz;                          val += (int)sz;
                 }                  }
   
                 switch (*val) {                  if (ASCII_HYPH == *val) {
                 case (ASCII_HYPH):  
                         (*buf)[pos++] = '-';                          (*buf)[pos++] = '-';
                         val++;                          val++;
                         continue;                          continue;
                 case ('\t'):                  } else if ('\t' == *val || ASCII_NBRSP == *val) {
                         /* FALLTHROUGH */  
                 case (ASCII_NBRSP):  
                         (*buf)[pos++] = ' ';                          (*buf)[pos++] = ' ';
                         val++;                          val++;
                         /* FALLTHROUGH */  
                 case (ASCII_BREAK):  
                         continue;                          continue;
                 default:                  } else if ('\\' != *val)
                         break;                          break;
                 }  
                 if ('\\' != *val)  
                         break;  
   
                 /* Read past the slash. */                  /* Read past the slash. */
   
Line 427  apropos_search(int pathsz, char **paths, const struct 
Line 413  apropos_search(int pathsz, char **paths, const struct 
 {  {
         struct rectree   tree;          struct rectree   tree;
         struct mchars   *mc;          struct mchars   *mc;
         int              i;          int              i, rc;
   
         memset(&tree, 0, sizeof(struct rectree));          memset(&tree, 0, sizeof(struct rectree));
   
           rc = 0;
         mc = mchars_alloc();          mc = mchars_alloc();
         *sz = 0;          *sz = 0;
         *resp = NULL;          *resp = NULL;
Line 554  single_search(struct rectree *tree, const struct opts 
Line 541  single_search(struct rectree *tree, const struct opts 
                         if (strcasecmp(opts->arch, r.arch))                          if (strcasecmp(opts->arch, r.arch))
                                 continue;                                  continue;
   
                 tree->node = rs = mandoc_reallocarray(rs,                  tree->node = rs = mandoc_realloc
                     tree->len + 1, sizeof(struct res));                          (rs, (tree->len + 1) * sizeof(struct res));
   
                 memcpy(&rs[tree->len], &r, sizeof(struct res));                  memcpy(&rs[tree->len], &r, sizeof(struct res));
                 memset(&r, 0, sizeof(struct res));                  memset(&r, 0, sizeof(struct res));

Legend:
Removed from v.1.32.2.8  
changed lines
  Added in v.1.33

CVSweb