source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Enable the integrated man(1) even when database support is
@ 2015-02-03 21:16 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-02-03 21:16 UTC (permalink / raw)
  To: source

Log Message:
-----------
Enable the integrated man(1) even when database support is disabled,
using the file system lookup fallback code, also reducing the number
of preprocessor conditional directives.
Hopefully, it will make some small Linux distros happy.

Modified Files:
--------------
    mdocml:
        Makefile
        configure.local.example
        main.c

Revision Data
-------------
Index: Makefile
===================================================================
RCS file: /home/cvs/mdocml/mdocml/Makefile,v
retrieving revision 1.453
retrieving revision 1.454
diff -LMakefile -LMakefile -u -p -r1.453 -r1.454
--- Makefile
+++ Makefile
@@ -211,6 +211,7 @@ BASE_OBJS	 = $(MANDOC_HTML_OBJS) \
 		   $(MANDOC_MAN_OBJS) \
 		   $(MANDOC_TERM_OBJS) \
 		   main.o \
+		   manpath.o \
 		   out.o \
 		   tree.o
 
@@ -218,8 +219,7 @@ MAIN_OBJS	 = $(BASE_OBJS)
 
 DB_OBJS		 = mandocdb.o \
 		   mansearch.o \
-		   mansearch_const.o \
-		   manpath.o
+		   mansearch_const.o
 
 CGI_OBJS	 = $(MANDOC_HTML_OBJS) \
 		   cgi.o \
@@ -308,10 +308,12 @@ base-install: base-build
 	mkdir -p $(DESTDIR)$(MANDIR)/man3
 	mkdir -p $(DESTDIR)$(MANDIR)/man7
 	$(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
+	ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
 	$(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
 	$(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h \
 		$(DESTDIR)$(INCLUDEDIR)
 	$(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
+	$(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
 	$(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
 		mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
 	$(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
@@ -330,12 +332,10 @@ db-install: base-build
 	mkdir -p $(DESTDIR)$(MANDIR)/man5
 	mkdir -p $(DESTDIR)$(MANDIR)/man8
 	ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
-	ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
 	ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
 	ln -f $(DESTDIR)$(BINDIR)/mandoc \
 		$(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
 	$(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
-	$(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
 	ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
 		$(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
 	$(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
Index: configure.local.example
===================================================================
RCS file: /home/cvs/mdocml/mdocml/configure.local.example,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lconfigure.local.example -Lconfigure.local.example -u -p -r1.4 -r1.5
--- configure.local.example
+++ configure.local.example
@@ -74,6 +74,21 @@ LIBDIR="${PREFIX}/lib/mandoc"
 MANDIR="${PREFIX}/man"
 EXAMPLEDIR="${PREFIX}/share/examples/mandoc"
 
+# The man(1) utility needs to know where the manuals reside.
+# We know of two ways to tell it: via manpath(1) or man.conf(5).
+# The latter is used by OpenBSD and NetBSD, the former by most
+# other systems.
+
+# Force usage of manpath(1).
+# If it is not installed or not operational,
+# man(1), makewhatis(8), and apropos(1) will not work properly.
+HAVE_MANPATH=1
+
+# Force usage of man.conf(5).
+# If it does not exist or contains no valid configuration,
+# man(1), makewhatis(8), and apropos(1) will not work properly.
+HAVE_MANPATH=0
+
 # Some distributions may want to avoid naming conflicts among manuals.
 # If you want to change the names of installed section 7 manual pages,
 # the following alternative names are suggested.
@@ -87,6 +102,15 @@ MANM_ROFF="mandoc_roff"		# default is "r
 MANM_EQN="mandoc_eqn"		# default is "eqn"
 MANM_TBL="mandoc_tbl"		# default is "tbl"
 
+# Some distributions may want to avoid naming conflicts
+# with another man(1) utility.
+# If you want to change the name of the binary program,
+# the following alternative name is suggested.
+# Using a different name is possible as well.
+# This changes the name of the installed section 1 manual page as well.
+
+BINM_MAN=mman			# default is "man"
+
 # It is possible to change the utility program used for installation
 # and the modes files are installed with.  The defaults are:
 
@@ -121,35 +145,17 @@ DBLIB="-L/usr/local/lib -lsqlite3"
 
 CFLAGS="${CFLAGS} -I/usr/local/include"
 
-# The man(1) utility needs to know where the manuals reside.
-# We know of two ways to tell it: via manpath(1) or man.conf(5).
-# The latter is used by OpenBSD and NetBSD, the former by most
-# other systems.
-
-# Force usage of manpath(1).
-# If it is not installed or not operational,
-# makewhatis(8) and apropos(1) will not work properly.
-
-HAVE_MANPATH=1
-
-# Force usage of man.conf(5).
-# If it does not exist or contains no valid configuration,
-# makewhatis(8) and apropos(1) will not work properly.
-
-HAVE_MANPATH=0
-
 # Some distributions may want to avoid naming conflicts
-# with groff, man-db, or other tools.
-# If you want to change the names of binary programs,
+# with another implementation of apropos(1) and makewhatis(8).
+# If you want to change the names of the binary programs,
 # the following alternative names are suggested.
 # Using other names is possible as well.
 # This changes the names of the installed section 1 and section 8
 # manual pages as well.
-# It is possible to set only one or a few of these variables,
+# It is possible to set only one or two of these variables,
 # there is no need to copy the whole block.
 
 BINM_APROPOS=mapropos		# default is "apropos"
-BINM_MAN=mman			# default is "man"
 BINM_WHATIS=mwhatis		# default is "whatis"
 BINM_MAKEWHATIS=mandocdb	# default is "makewhatis"
 
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.217
retrieving revision 1.218
diff -Lmain.c -Lmain.c -u -p -r1.217 -r1.218
--- main.c
+++ main.c
@@ -83,7 +83,6 @@ struct	curparse {
 	char		  outopts[BUFSIZ]; /* buf of output opts */
 };
 
-#if HAVE_SQLITE3
 static	int		  fs_lookup(const struct manpaths *,
 				size_t ipath, const char *,
 				const char *, const char *,
@@ -91,7 +90,6 @@ static	int		  fs_lookup(const struct man
 static	void		  fs_search(const struct mansearch *,
 				const struct manpaths *, int, char**,
 				struct manpage **, size_t *);
-#endif
 static	int		  koptions(int *, char *);
 #if HAVE_SQLITE3
 int			  mandocdb(int, char**);
@@ -101,9 +99,7 @@ static	void		  mmsg(enum mandocerr, enum
 				const char *, int, int, const char *);
 static	void		  parse(struct curparse *, int,
 				const char *, enum mandoclevel *);
-#if HAVE_SQLITE3
 static	enum mandoclevel  passthrough(const char *, int, int);
-#endif
 static	void		  spawn_pager(void);
 static	int		  toptions(struct curparse *, char *);
 static	void		  usage(enum argmode) __attribute__((noreturn));
@@ -125,13 +121,11 @@ main(int argc, char *argv[])
 	char		*auxpaths;
 	char		*defos;
 	unsigned char	*uc;
-#if HAVE_SQLITE3
 	struct manpage	*res, *resp;
 	char		*conf_file, *defpaths;
 	size_t		 isec, i, sz;
 	int		 prio, best_prio, synopsis_only;
 	char		 sec;
-#endif
 	enum mandoclevel rc, rctmp;
 	enum outmode	 outmode;
 	int		 fd;
@@ -154,9 +148,7 @@ main(int argc, char *argv[])
 	/* Search options. */
 
 	memset(&paths, 0, sizeof(struct manpaths));
-#if HAVE_SQLITE3
 	conf_file = defpaths = NULL;
-#endif
 	auxpaths = NULL;
 
 	memset(&search, 0, sizeof(struct mansearch));
@@ -183,9 +175,7 @@ main(int argc, char *argv[])
 
 	use_pager = 1;
 	show_usage = 0;
-#if HAVE_SQLITE3
 	synopsis_only = 0;
-#endif
 	outmode = OUTMODE_DEF;
 
 	while (-1 != (c = getopt(argc, argv,
@@ -195,9 +185,7 @@ main(int argc, char *argv[])
 			outmode = OUTMODE_ALL;
 			break;
 		case 'C':
-#if HAVE_SQLITE3
 			conf_file = optarg;
-#endif
 			break;
 		case 'c':
 			use_pager = 0;
@@ -207,9 +195,7 @@ main(int argc, char *argv[])
 			break;
 		case 'h':
 			(void)strlcat(curp.outopts, "synopsis,", BUFSIZ);
-#if HAVE_SQLITE3
 			synopsis_only = 1;
-#endif
 			use_pager = 0;
 			outmode = OUTMODE_ALL;
 			break;
@@ -243,9 +229,7 @@ main(int argc, char *argv[])
 			outmode = OUTMODE_ALL;
 			break;
 		case 'M':
-#if HAVE_SQLITE3
 			defpaths = optarg;
-#endif
 			break;
 		case 'm':
 			auxpaths = optarg;
@@ -305,9 +289,7 @@ main(int argc, char *argv[])
 
 	argc -= optind;
 	argv += optind;
-#if HAVE_SQLITE3
 	resp = NULL;
-#endif
 
 	/*
 	 * Quirks for help(1)
@@ -340,7 +322,6 @@ main(int argc, char *argv[])
 	/* man(1), whatis(1), apropos(1) */
 
 	if (search.argmode != ARG_FILE) {
-#if HAVE_SQLITE3
 		if (argc == 0)
 			usage(search.argmode);
 
@@ -351,9 +332,18 @@ main(int argc, char *argv[])
 		/* Access the mandoc database. */
 
 		manpath_parse(&paths, conf_file, defpaths, auxpaths);
+#if HAVE_SQLITE3
 		mansearch_setup(1);
 		if( ! mansearch(&search, &paths, argc, argv, &res, &sz))
 			usage(search.argmode);
+#else
+		if (search.argmode != ARG_NAME) {
+			fputs("mandoc: database support not compiled in\n",
+			    stderr);
+			return((int)MANDOCLEVEL_BADARG);
+		}
+		sz = 0;
+#endif
 
 		if (sz == 0 && search.argmode == ARG_NAME)
 			fs_search(&search, &paths, argc, argv, &res, &sz);
@@ -407,11 +397,6 @@ main(int argc, char *argv[])
 
 		if (outmode == OUTMODE_FLN || outmode == OUTMODE_LST)
 			goto out;
-#else
-		fputs("mandoc: database support not compiled in\n",
-		    stderr);
-		return((int)MANDOCLEVEL_BADARG);
-#endif
 	}
 
 	/* mandoc(1) */
@@ -437,10 +422,7 @@ main(int argc, char *argv[])
 
 	while (argc) {
 		rctmp = mparse_open(curp.mp, &fd,
-#if HAVE_SQLITE3
-		    resp != NULL ? resp->file :
-#endif
-		    *argv);
+		    resp != NULL ? resp->file : *argv);
 		if (rc < rctmp)
 			rc = rctmp;
 
@@ -449,11 +431,8 @@ main(int argc, char *argv[])
 				spawn_pager();
 			use_pager = 0;
 
-#if HAVE_SQLITE3
 			if (resp == NULL)
-#endif
 				parse(&curp, fd, *argv, &rc);
-#if HAVE_SQLITE3
 			else if (resp->form & FORM_SRC) {
 				/* For .so only; ignore failure. */
 				chdir(paths.paths[resp->ipath]);
@@ -464,7 +443,6 @@ main(int argc, char *argv[])
 				if (rc < rctmp)
 					rc = rctmp;
 			}
-#endif
 
 			rctmp = mparse_wait(curp.mp);
 			if (rc < rctmp)
@@ -477,11 +455,9 @@ main(int argc, char *argv[])
 		if (MANDOCLEVEL_OK != rc && curp.wstop)
 			break;
 
-#if HAVE_SQLITE3
 		if (resp != NULL)
 			resp++;
 		else
-#endif
 			argv++;
 		if (--argc)
 			mparse_reset(curp.mp);
@@ -492,14 +468,14 @@ main(int argc, char *argv[])
 	mparse_free(curp.mp);
 	mchars_free(curp.mchars);
 
-#if HAVE_SQLITE3
 out:
 	if (search.argmode != ARG_FILE) {
 		manpath_free(&paths);
+#if HAVE_SQLITE3
 		mansearch_free(res, sz);
 		mansearch_setup(0);
-	}
 #endif
+	}
 
 	free(defos);
 
@@ -545,7 +521,6 @@ usage(enum argmode argmode)
 	exit((int)MANDOCLEVEL_BADARG);
 }
 
-#if HAVE_SQLITE3
 static int
 fs_lookup(const struct manpaths *paths, size_t ipath,
 	const char *sec, const char *arch, const char *name,
@@ -583,9 +558,11 @@ fs_lookup(const struct manpaths *paths, 
 	return(0);
 
 found:
+#if HAVE_SQLITE3
 	fprintf(stderr, "%s: outdated mandoc.db lacks %s(%s) entry,\n"
 	    "     consider running  # makewhatis %s\n",
 	    progname, name, sec, paths->paths[ipath]);
+#endif
 	
 	*res = mandoc_reallocarray(*res, ++*ressz, sizeof(struct manpage));
 	page = *res + (*ressz - 1);
@@ -635,7 +612,6 @@ fs_search(const struct mansearch *cfg, c
 		argc--;
 	}
 }
-#endif
 
 static void
 parse(struct curparse *curp, int fd, const char *file,
@@ -742,7 +718,6 @@ cleanup:
 		*level = rc;
 }
 
-#if HAVE_SQLITE3
 static enum mandoclevel
 passthrough(const char *file, int fd, int synopsis_only)
 {
@@ -808,7 +783,6 @@ fail:
 	    progname, file, syscall, strerror(errno));
 	return(MANDOCLEVEL_SYSERR);
 }
-#endif
 
 static int
 koptions(int *options, char *arg)
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-02-03 21:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-03 21:16 mdocml: Enable the integrated man(1) even when database support is schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).