=================================================================== RCS file: /cvs/mandoc/main.c,v retrieving revision 1.221 retrieving revision 1.222 diff -u -p -r1.221 -r1.222 --- mandoc/main.c 2015/02/16 16:23:54 1.221 +++ mandoc/main.c 2015/02/27 16:02:10 1.222 @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.221 2015/02/16 16:23:54 schwarze Exp $ */ +/* $Id: main.c,v 1.222 2015/02/27 16:02:10 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -517,16 +518,16 @@ fs_lookup(const struct manpaths *paths, size_t ipath, const char *sec, const char *arch, const char *name, struct manpage **res, size_t *ressz) { + glob_t globinfo; struct manpage *page; char *file; - int form; + int form, globres; + form = FORM_SRC; mandoc_asprintf(&file, "%s/man%s/%s.%s", paths->paths[ipath], sec, name, sec); - if (access(file, R_OK) != -1) { - form = FORM_SRC; + if (access(file, R_OK) != -1) goto found; - } free(file); mandoc_asprintf(&file, "%s/cat%s/%s.0", @@ -540,13 +541,23 @@ fs_lookup(const struct manpaths *paths, size_t ipath, if (arch != NULL) { mandoc_asprintf(&file, "%s/man%s/%s/%s.%s", paths->paths[ipath], sec, arch, name, sec); - if (access(file, R_OK) != -1) { - form = FORM_SRC; + if (access(file, R_OK) != -1) goto found; - } free(file); } - return(0); + + mandoc_asprintf(&file, "%s/man%s/%s.*", + paths->paths[ipath], sec, name); + globres = glob(file, 0, NULL, &globinfo); + if (globres != 0 && globres != GLOB_NOMATCH) + fprintf(stderr, "%s: %s: glob: %s\n", + progname, file, strerror(errno)); + free(file); + if (globres == 0) + file = mandoc_strdup(*globinfo.gl_pathv); + globfree(&globinfo); + if (globres != 0) + return(0); found: #if HAVE_SQLITE3