source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Reimplement the global command line options -a and -v as static
@ 2011-11-27 23:27 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2011-11-27 23:27 UTC (permalink / raw)
  To: source

Log Message:
-----------
Reimplement the global command line options -a and -v
as static global variables, reducing the maze of arguments
passed around among various static functions.
Suggested by kristaps@.

Modified Files:
--------------
    mdocml:
        mandocdb.c

Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.15 -r1.16
--- mandocdb.c
+++ mandocdb.c
@@ -97,18 +97,15 @@ static	void		  dbt_put(DB *, const char 
 static	void		  hash_put(DB *, const struct buf *, uint64_t);
 static	void		  hash_reset(DB **);
 static	void		  index_merge(const struct of *, struct mparse *,
-				struct buf *, struct buf *,
-				DB *, DB *, const char *, 
-				DB *, const char *, int, int,
+				struct buf *, struct buf *, DB *,
+				DB *, const char *, DB *, const char *,
 				recno_t, const recno_t *, size_t);
 static	void		  index_prune(const struct of *, DB *, 
 				const char *, DB *, const char *, 
-				int, recno_t *, recno_t **, size_t *);
-static	void		  ofile_argbuild(char *[], int, int, int,
-				struct of **);
+				recno_t *, recno_t **, size_t *);
+static	void		  ofile_argbuild(int, char *[], struct of **);
 static	int		  ofile_dirbuild(const char *, const char *,
-				const char *, int, int, int,
-				struct of **);
+				const char *, int, struct of **);
 static	void		  ofile_free(struct of *);
 static	void		  pformatted(DB *, struct buf *, struct buf *,
 				const struct of *);
@@ -258,6 +255,8 @@ static	const pmdoc_nf	  mdocs[MDOC_MAX] 
 };
 
 static	const char	 *progname;
+static	int		  use_all;  /* Use all directories and files. */
+static	int		  verb;  /* Output verbosity level. */
 
 int
 main(int argc, char *argv[])
@@ -268,9 +267,7 @@ main(int argc, char *argv[])
 	const char	*dir;
 	char		 ibuf[MAXPATHLEN], /* index fname */
 			 fbuf[MAXPATHLEN];  /* btree fname */
-	int		 verb, /* output verbosity */
-			 use_all, /* use all directories and files */
-			 ch, i, flags;
+	int		 ch, i, flags;
 	DB		*idx, /* index database */
 			*db, /* keyword database */
 			*hash; /* temporary keyword hashtable */
@@ -377,19 +374,19 @@ main(int argc, char *argv[])
 			printf("%s: Opened\n", ibuf);
 		}
 
-		ofile_argbuild(argv, argc, use_all, verb, &of);
+		ofile_argbuild(argc, argv, &of);
 		if (NULL == of)
 			goto out;
 
 		of = of->first;
 
-		index_prune(of, db, fbuf, idx, ibuf, verb,
+		index_prune(of, db, fbuf, idx, ibuf,
 				&maxrec, &recs, &recsz);
 
 		if (OP_UPDATE == op)
 			index_merge(of, mp, &dbuf, &buf, hash,
-					db, fbuf, idx, ibuf, use_all,
-					verb, maxrec, recs, reccur);
+					db, fbuf, idx, ibuf,
+					maxrec, recs, reccur);
 
 		goto out;
 	}
@@ -450,7 +447,7 @@ main(int argc, char *argv[])
 		of = NULL;
 
 		if ( ! ofile_dirbuild(dirs.paths[i], NULL, NULL,
-				0, use_all, verb, &of)) 
+					0, &of)) 
 			exit((int)MANDOCLEVEL_SYSERR);
 
 		if (NULL == of)
@@ -459,8 +456,7 @@ main(int argc, char *argv[])
 		of = of->first;
 
 		index_merge(of, mp, &dbuf, &buf, hash, db, fbuf,
-				idx, ibuf, use_all, verb,
-				maxrec, recs, reccur);
+				idx, ibuf, maxrec, recs, reccur);
 	}
 
 out:
@@ -484,9 +480,8 @@ out:
 
 void
 index_merge(const struct of *of, struct mparse *mp,
-		struct buf *dbuf, struct buf *buf,
-		DB *hash, DB *db, const char *dbf,
-		DB *idx, const char *idxf, int use_all, int verb,
+		struct buf *dbuf, struct buf *buf, DB *hash,
+		DB *db, const char *dbf, DB *idx, const char *idxf,
 		recno_t maxrec, const recno_t *recs, size_t reccur)
 {
 	recno_t		 rec;
@@ -662,7 +657,7 @@ index_merge(const struct of *of, struct 
  */
 static void
 index_prune(const struct of *ofile, DB *db, const char *dbf, 
-		DB *idx, const char *idxf, int verb,
+		DB *idx, const char *idxf,
 		recno_t *maxrec, recno_t **recs, size_t *recsz)
 {
 	const struct of	*of;
@@ -1336,8 +1331,7 @@ pformatted(DB *hash, struct buf *buf, st
 }
 
 static void
-ofile_argbuild(char *argv[], int argc, int use_all, int verb,
-		struct of **of)
+ofile_argbuild(int argc, char *argv[], struct of **of)
 {
 	char		 buf[MAXPATHLEN];
 	char		*sec, *arch, *title, *p;
@@ -1429,7 +1423,7 @@ ofile_argbuild(char *argv[], int argc, i
  */
 static int
 ofile_dirbuild(const char *dir, const char* psec, const char *parch,
-		int p_src_form, int use_all, int verb, struct of **of)
+		int p_src_form, struct of **of)
 {
 	char		 buf[MAXPATHLEN];
 	struct stat	 sb;
@@ -1495,7 +1489,7 @@ ofile_dirbuild(const char *dir, const ch
 				printf("%s: Scanning\n", buf);
 
 			if ( ! ofile_dirbuild(buf, sec, arch,
-					src_form, use_all, verb, of))
+					src_form, of))
 				return(0);
 		}
 		if (DT_REG != dp->d_type ||
--
 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:[~2011-11-27 23:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-27 23:27 mdocml: Reimplement the global command line options -a and -v as static 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).