[Debtags-commits] [svn] r1568 - in tagcoll/trunk: . tagcoll tools

Enrico Zini enrico at costa.debian.org
Mon Feb 13 11:00:23 UTC 2006


Author: enrico
Date: Mon Feb 13 11:00:22 2006
New Revision: 1568

Modified:
   tagcoll/trunk/   (props changed)
   tagcoll/trunk/tagcoll/IntIndex.cc
   tagcoll/trunk/tools/tagidx.cc
Log:
 r7230 at viaza:  enrico | 2006-02-11 15:45:42 +0100
 Implemented "empty output" for tagidx for testing


Modified: tagcoll/trunk/tagcoll/IntIndex.cc
==============================================================================
--- tagcoll/trunk/tagcoll/IntIndex.cc	(original)
+++ tagcoll/trunk/tagcoll/IntIndex.cc	Mon Feb 13 11:00:22 2006
@@ -85,7 +85,7 @@
 		for (set<int>::const_iterator j = (*this)[i].begin(); j != (*this)[i].end(); j++)
 			buf[pos++] = *j;
 	}
-	buf[pos++] = size();
+	buf[pos] = size();
 }
 
 void IntIndexer::write(const std::string& filename)

Modified: tagcoll/trunk/tools/tagidx.cc
==============================================================================
--- tagcoll/trunk/tools/tagidx.cc	(original)
+++ tagcoll/trunk/tools/tagidx.cc	Mon Feb 13 11:00:22 2006
@@ -37,6 +37,7 @@
 #include "CommandlineParser.h"
 #include <tagcoll/BasicStringDiskIndex.h>
 #include <tagcoll/ItemGrouper.h>
+#include <tagcoll/Consumer.h>
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -456,6 +457,26 @@
 };
 #endif
 
+void output(CommandlineParserWithCommand& opts, ReadonlyCollection<string, string>& coll)
+{
+	if (opts.get("quiet").defined())
+	{
+		Sink<string, string> sink;
+		coll.output(sink);
+	} else {
+		TrivialConverter<string, string> conv;
+		TextFormat<string, string> writer(conv, conv, stdout);
+
+		if (opts.get("groupitems").defined())
+		{
+			ItemGrouper<string, string> grouper;
+			coll.output(grouper);
+			grouper.output(writer);
+		} else
+			coll.output(writer);
+	}
+}
+
 string indexdir(CommandlineParserWithCommand& opts)
 {
 	if (opts.get("index").defined())
@@ -526,6 +547,7 @@
 
 		opts.add("index", 'I', "index", "directory where the index files are stored", "dir");
 		opts.add("groupitems", 'g', "group-items", "group items with the same tagset in the output collection");
+		opts.add("quiet", 'q', "quiet", "produce no output");
 #if 0
 		opts.add("derived", 'e', "derived-tags-from", "use an external list of derived tags", "file");
 		opts.add("extimpl", 'i', "implications-from", "use an external list of implications", "file");
@@ -600,16 +622,7 @@
 				string dir = indexdir(opts);
 				BasicStringDiskIndex idx(dir);
 
-				TrivialConverter<string, string> conv;
-				TextFormat<string, string> writer(conv, conv, stdout);
-
-				if (opts.get("groupitems").defined())
-				{
-					ItemGrouper<string, string> grouper;
-					idx.output(grouper);
-					grouper.output(writer);
-				} else
-					idx.output(writer);
+				output(opts, idx);
 				break;
 			}
 #if 0



More information about the Debtags-commits mailing list