summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am8
-rw-r--r--src/catman.c1
-rw-r--r--src/check_mandirs.c6
-rw-r--r--src/descriptions.h4
-rw-r--r--src/descriptions_store.c6
-rw-r--r--src/filenames.c155
-rw-r--r--src/filenames.h28
-rw-r--r--src/man.c8
-rw-r--r--src/mandb.c5
-rw-r--r--src/straycats.c1
-rw-r--r--src/whatis.c1
11 files changed, 21 insertions, 202 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index c92c852b..ce3c8dda 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -64,7 +64,7 @@ catman_LDADD = $(LIBMANDB) $(libpipeline_LIBS)
globbing_LDADD = $(LIBMAN)
lexgrog_LDADD = $(LIBMAN) $(LIBCOMPRESS) $(libpipeline_LIBS) $(LTLIBICONV)
man_LDADD = $(LIBMANDB) $(LIBCOMPRESS) $(libpipeline_LIBS) $(LTLIBICONV)
-man_recode_LDADD = $(LIBMANDB) $(LIBCOMPRESS) $(libpipeline_LIBS) $(LTLIBICONV)
+man_recode_LDADD = $(LIBMAN) $(LIBCOMPRESS) $(libpipeline_LIBS) $(LTLIBICONV)
manconv_LDADD = $(LIBMAN) $(LIBCOMPRESS) $(libpipeline_LIBS) $(LTLIBICONV)
mandb_LDADD = $(LIBMANDB) $(LIBCOMPRESS) $(libpipeline_LIBS) $(LTLIBICONV)
manpath_LDADD = $(LIBMAN)
@@ -90,8 +90,6 @@ lexgrog_SOURCES = \
decompress.h \
descriptions.c \
descriptions.h \
- filenames.c \
- filenames.h \
globbing.c \
globbing.h \
lexgrog.h \
@@ -108,8 +106,6 @@ lexgrog_SOURCES = \
man_SOURCES = \
decompress.c \
decompress.h \
- filenames.c \
- filenames.h \
globbing.c \
globbing.h \
man.c \
@@ -149,8 +145,6 @@ mandb_SOURCES = \
descriptions.c \
descriptions.h \
descriptions_store.c \
- filenames.c \
- filenames.h \
globbing.c \
globbing.h \
lexgrog.h \
diff --git a/src/catman.c b/src/catman.c
index a933d4fb..2da9d03d 100644
--- a/src/catman.c
+++ b/src/catman.c
@@ -78,6 +78,7 @@
#include "cleanup.h"
#include "debug.h"
#include "fatal.h"
+#include "filenames.h"
#include "glcontainers.h"
#include "pipeline.h"
#include "util.h"
diff --git a/src/check_mandirs.c b/src/check_mandirs.c
index 5ae5c00e..50027779 100644
--- a/src/check_mandirs.c
+++ b/src/check_mandirs.c
@@ -64,6 +64,7 @@
#include "appendstr.h"
#include "debug.h"
#include "fatal.h"
+#include "filenames.h"
#include "glcontainers.h"
#include "orderfiles.h"
#include "security.h"
@@ -73,7 +74,6 @@
#include "db_storage.h"
#include "descriptions.h"
-#include "filenames.h"
#include "globbing.h"
#include "lexgrog.h"
#include "manp.h"
@@ -170,7 +170,7 @@ void test_manfile (MYDBM_FILE dbf, const char *file, const char *path)
memset (&lg, 0, sizeof (struct lexgrog));
memset (&info, 0, sizeof (struct mandata));
- manpage = filename_info (file, &info, NULL);
+ manpage = filename_info (file, &info, NULL, quiet < 2);
if (!manpage)
return;
manpage_base = manpage + strlen (manpage) + 1;
@@ -787,7 +787,7 @@ static int count_glob_matches (const char *name, const char *ext,
continue;
}
- buf = filename_info (walk, &info, name);
+ buf = filename_info (walk, &info, name, quiet < 2);
if (buf) {
if (STREQ (ext, info.ext))
++count;
diff --git a/src/descriptions.h b/src/descriptions.h
index 38ae412a..0712b643 100644
--- a/src/descriptions.h
+++ b/src/descriptions.h
@@ -22,7 +22,9 @@
#include "gl_list.h"
-#include "db_storage.h"
+#include "filenames.h"
+
+#include "mydbm.h"
struct page_description {
char *name;
diff --git a/src/descriptions_store.c b/src/descriptions_store.c
index 621b8355..f019f0f9 100644
--- a/src/descriptions_store.c
+++ b/src/descriptions_store.c
@@ -44,11 +44,11 @@
#include "manconfig.h"
#include "debug.h"
+#include "filenames.h"
#include "glcontainers.h"
#include "db_storage.h"
-#include "filenames.h"
#include "ult_src.h"
#include "descriptions.h"
@@ -102,8 +102,8 @@ void store_descriptions (MYDBM_FILE dbf, gl_list_t descs, struct mandata *info,
struct mandata trace_info;
char *buf;
- buf = filename_info (trace_name,
- &trace_info, "");
+ buf = filename_info (trace_name, &trace_info,
+ "", quiet < 2);
if (trace_info.name &&
STREQ (trace_info.name, desc->name)) {
struct stat st;
diff --git a/src/filenames.c b/src/filenames.c
deleted file mode 100644
index 83e09069..00000000
--- a/src/filenames.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * filenames.c: compose and dissect man page file names
- *
- * Copyright (C) 1994, 1995 Graeme W. Wilford. (Wilf.)
- * Copyright (C) 2001, 2002 Colin Watson.
- *
- * This file is part of man-db.
- *
- * man-db is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * man-db is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with man-db; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "error.h"
-#include "xalloc.h"
-#include "xvasprintf.h"
-
-#include "gettext.h"
-#define _(String) gettext (String)
-
-#include "manconfig.h"
-
-#include "appendstr.h"
-#include "compression.h"
-#include "debug.h"
-
-#include "db_storage.h"
-
-#include "filenames.h"
-
-static void gripe_bogus_manpage (const char *manpage)
-{
- if (quiet < 2)
- error (0, 0, _("warning: %s: ignoring bogus filename"),
- manpage);
-}
-
-char *make_filename (const char *path, const char *name,
- struct mandata *in, const char *type)
-{
- static char *file;
-
- if (!name)
- name = in->name; /* comes from dblookup(), so non-NULL */
-
- file = xasprintf ("%s/%s%s/%s.%s", path, type, in->sec, name, in->ext);
-
- if (in->comp && *in->comp != '-') /* Is there an extension? */
- file = appendstr (file, ".", in->comp, (void *) 0);
-
- debug ("Checking physical location: %s\n", file);
- if (!CAN_ACCESS (file, R_OK)) {
- free (file);
- return NULL;
- }
-
- return file;
-}
-
-/* Fill in a mandata structure with information about a file name.
- * file is the name to examine. info points to the structure to be filled
- * in. req_name is the page name that was requested.
- *
- * Returns either a pointer to the buffer which the fields in info point
- * into, to be freed by the caller, or NULL on error. The buffer will
- * contain either three or four null-terminated strings: the directory name,
- * the base of the file name in that directory, the section extension, and
- * optionally the compression extension.
- *
- * Only the fields name, ext, sec, and comp are filled in by this function.
- * name is only set if it differs from req_name; otherwise it remains at
- * NULL.
- */
-char *filename_info (const char *file, struct mandata *info,
- const char *req_name)
-{
- char *manpage = xstrdup (file);
- char *slash = strrchr (manpage, '/');
- char *base_name;
- struct compression *comp;
-
- memset (info, 0, sizeof (struct mandata));
-
- if (slash) {
- *slash = '\0'; /* strip '/base_name' */
- base_name = slash + 1;
- } else
- base_name = manpage;
-
- /* Bogus files either have (i) no period, ie no extension, (ii)
- a compression extension, but no sectional extension, (iii)
- a missmatch between the section they are under and the
- sectional part of their extension. */
-
- comp = comp_info (base_name, 1);
- if (comp) {
- info->comp = comp->ext;
- *(base_name + strlen (comp->stem)) = '\0';
- free (comp->stem);
- } else
- info->comp = NULL;
-
- {
- char *ext = strrchr (base_name, '.');
- if (!ext) {
- /* no section extension */
- gripe_bogus_manpage (file);
- free (manpage);
- return NULL;
- }
- *ext++ = '\0'; /* set section ext */
- info->ext = ext;
- if (!*info->ext) {
- /* zero-length section extension */
- gripe_bogus_manpage (file);
- free (manpage);
- return NULL;
- }
- }
-
- info->sec = strrchr (manpage, '/') + 4; /* set section name */
-
- if (strlen (info->sec) >= 1 && strlen (info->ext) >= 1 &&
- info->sec[0] != info->ext[0]) {
- /* mismatch in section */
- gripe_bogus_manpage (file);
- free (manpage);
- return NULL;
- }
-
- if (req_name && !STREQ (base_name, req_name))
- info->name = xstrdup (base_name);
- else
- info->name = NULL;
-
- return manpage;
-}
diff --git a/src/filenames.h b/src/filenames.h
deleted file mode 100644
index d7fd8a13..00000000
--- a/src/filenames.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * filenames.h: Interface to composing and dissecting man page file names
- *
- * Copyright (C) 2001, 2002 Colin Watson.
- *
- * This file is part of man-db.
- *
- * man-db is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * man-db is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with man-db; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "db_storage.h"
-
-extern char *make_filename (const char *path, const char *name,
- struct mandata *in, const char *type);
-extern char *filename_info (const char *file, struct mandata *info,
- const char *req_name);
diff --git a/src/man.c b/src/man.c
index 456968dd..1ffad970 100644
--- a/src/man.c
+++ b/src/man.c
@@ -89,6 +89,7 @@
#include "compression.h"
#include "debug.h"
#include "fatal.h"
+#include "filenames.h"
#include "glcontainers.h"
#include "pipeline.h"
#include "pathsearch.h"
@@ -105,7 +106,6 @@
#include "mydbm.h"
#include "db_storage.h"
-#include "filenames.h"
#include "globbing.h"
#include "ult_src.h"
#include "manp.h"
@@ -3160,7 +3160,8 @@ static int try_section (const char *path, const char *sec, const char *name,
GL_LIST_FOREACH (names, found_name) {
struct mandata *info = XZALLOC (struct mandata);
- char *info_buffer = filename_info (found_name, info, name);
+ char *info_buffer = filename_info (found_name, info, name,
+ quiet < 2);
const char *ult;
int f;
@@ -3738,7 +3739,8 @@ static int do_global_apropos_section (const char *path, const char *sec,
continue;
info = XZALLOC (struct mandata);
- info_buffer = filename_info (found_name, info, NULL);
+ info_buffer = filename_info (found_name, info, NULL,
+ quiet < 2);
if (!info_buffer)
goto next;
info->addr = info_buffer;
diff --git a/src/mandb.c b/src/mandb.c
index 372eba6b..27cd4df2 100644
--- a/src/mandb.c
+++ b/src/mandb.c
@@ -69,16 +69,17 @@
#include "cleanup.h"
#include "debug.h"
+#include "filenames.h"
#include "glcontainers.h"
#include "pipeline.h"
#include "sandbox.h"
#include "security.h"
#include "util.h"
+#include "db_storage.h"
#include "mydbm.h"
#include "check_mandirs.h"
-#include "filenames.h"
#include "manp.h"
#include "straycats.h"
@@ -357,7 +358,7 @@ static int update_one_file (MYDBM_FILE dbf,
char *manpage;
memset (&info, 0, sizeof (struct mandata));
- manpage = filename_info (filename, &info, "");
+ manpage = filename_info (filename, &info, "", quiet < 2);
if (info.name) {
dbdelete (dbf, info.name, &info);
purge_pointers (dbf, info.name);
diff --git a/src/straycats.c b/src/straycats.c
index 75cacdd1..3b2b6d4c 100644
--- a/src/straycats.c
+++ b/src/straycats.c
@@ -55,6 +55,7 @@
#include "appendstr.h"
#include "compression.h"
#include "debug.h"
+#include "filenames.h"
#include "glcontainers.h"
#include "pipeline.h"
#include "decompress.h"
diff --git a/src/whatis.c b/src/whatis.c
index 05074aad..2f393fa8 100644
--- a/src/whatis.c
+++ b/src/whatis.c
@@ -70,6 +70,7 @@
#include "cleanup.h"
#include "debug.h"
#include "fatal.h"
+#include "filenames.h"
#include "glcontainers.h"
#include "pipeline.h"
#include "pathsearch.h"