version 1.8, 2011/12/24 22:37:16 |
version 1.16, 2014/08/10 23:54:41 |
|
|
* 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/types.h> |
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
#include "mandoc.h" |
#include "mandoc_aux.h" |
#include "manpath.h" |
#include "manpath.h" |
|
|
#define MAN_CONF_FILE "/etc/man.conf" |
#define MAN_CONF_FILE "/etc/man.conf" |
Line 42 manpath_parse(struct manpaths *dirs, const char *file, |
|
Line 40 manpath_parse(struct manpaths *dirs, const char *file, |
|
char *defp, char *auxp) |
char *defp, char *auxp) |
{ |
{ |
#ifdef USE_MANPATH |
#ifdef USE_MANPATH |
char cmd[(MAXPATHLEN * 3) + 20]; |
char cmd[(PATH_MAX * 3) + 20]; |
FILE *stream; |
FILE *stream; |
char *buf; |
char *buf; |
size_t sz, bsz; |
size_t sz, bsz; |
Line 74 manpath_parse(struct manpaths *dirs, const char *file, |
|
Line 72 manpath_parse(struct manpaths *dirs, const char *file, |
|
|
|
do { |
do { |
buf = mandoc_realloc(buf, bsz + 1024); |
buf = mandoc_realloc(buf, bsz + 1024); |
sz = fread(buf + (int)bsz, 1, 1024, stream); |
sz = fread(buf + bsz, 1, 1024, stream); |
bsz += sz; |
bsz += sz; |
} while (sz > 0); |
} while (sz > 0); |
|
|
Line 90 manpath_parse(struct manpaths *dirs, const char *file, |
|
Line 88 manpath_parse(struct manpaths *dirs, const char *file, |
|
char *insert; |
char *insert; |
|
|
/* Always prepend -m. */ |
/* Always prepend -m. */ |
manpath_parseline(dirs, auxp); |
manpath_parseline(dirs, auxp); |
|
|
/* If -M is given, it overrides everything else. */ |
/* If -M is given, it overrides everything else. */ |
if (NULL != defp) { |
if (NULL != defp) { |
manpath_parseline(dirs, defp); |
manpath_parseline(dirs, defp); |
Line 117 manpath_parse(struct manpaths *dirs, const char *file, |
|
Line 115 manpath_parse(struct manpaths *dirs, const char *file, |
|
} |
} |
|
|
/* Append man.conf(5) to MANPATH. */ |
/* Append man.conf(5) to MANPATH. */ |
if (':' == defp[(int)strlen(defp) - 1]) { |
if (':' == defp[strlen(defp) - 1]) { |
manpath_parseline(dirs, defp); |
manpath_parseline(dirs, defp); |
manpath_manconf(dirs, file); |
manpath_manconf(dirs, file); |
return; |
return; |
Line 162 manpath_add(struct manpaths *dirs, const char *dir) |
|
Line 160 manpath_add(struct manpaths *dirs, const char *dir) |
|
{ |
{ |
char buf[PATH_MAX]; |
char buf[PATH_MAX]; |
char *cp; |
char *cp; |
int i; |
size_t i; |
|
|
if (NULL == (cp = realpath(dir, buf))) |
if (NULL == (cp = realpath(dir, buf))) |
return; |
return; |
Line 171 manpath_add(struct manpaths *dirs, const char *dir) |
|
Line 169 manpath_add(struct manpaths *dirs, const char *dir) |
|
if (0 == strcmp(dirs->paths[i], dir)) |
if (0 == strcmp(dirs->paths[i], dir)) |
return; |
return; |
|
|
dirs->paths = mandoc_realloc |
dirs->paths = mandoc_reallocarray(dirs->paths, |
(dirs->paths, |
dirs->sz + 1, sizeof(char *)); |
((size_t)dirs->sz + 1) * sizeof(char *)); |
|
|
|
dirs->paths[dirs->sz++] = mandoc_strdup(cp); |
dirs->paths[dirs->sz++] = mandoc_strdup(cp); |
} |
} |
Line 181 manpath_add(struct manpaths *dirs, const char *dir) |
|
Line 178 manpath_add(struct manpaths *dirs, const char *dir) |
|
void |
void |
manpath_free(struct manpaths *p) |
manpath_free(struct manpaths *p) |
{ |
{ |
int i; |
size_t i; |
|
|
for (i = 0; i < p->sz; i++) |
for (i = 0; i < p->sz; i++) |
free(p->paths[i]); |
free(p->paths[i]); |
Line 211 manpath_manconf(struct manpaths *dirs, const char *fil |
|
Line 208 manpath_manconf(struct manpaths *dirs, const char *fil |
|
if (strncmp(MAN_CONF_KEY, p, keysz)) |
if (strncmp(MAN_CONF_KEY, p, keysz)) |
continue; |
continue; |
p += keysz; |
p += keysz; |
while (isspace(*p)) |
while (isspace((unsigned char)*p)) |
p++; |
p++; |
if ('\0' == *p) |
if ('\0' == *p) |
continue; |
continue; |