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