[Pinfo-devel] r176 - pinfo/branches/cxx/src

Nathanael Nerode neroden-guest at costa.debian.org
Tue Sep 6 12:35:34 UTC 2005


Author: neroden-guest
Date: 2005-09-06 12:35:34 +0000 (Tue, 06 Sep 2005)
New Revision: 176

Modified:
   pinfo/branches/cxx/src/mainfunction.cxx
   pinfo/branches/cxx/src/printinfo.cxx
Log:
Similarly convert (untested) printinfo to zero-based, fixing off-by-one
error in the process.


Modified: pinfo/branches/cxx/src/mainfunction.cxx
===================================================================
--- pinfo/branches/cxx/src/mainfunction.cxx	2005-09-06 12:30:52 UTC (rev 175)
+++ pinfo/branches/cxx/src/mainfunction.cxx	2005-09-06 12:35:34 UTC (rev 176)
@@ -211,13 +211,9 @@
 					/* Quick conversion to vector.  Temporary, FIXME. */
 					vector<string> my_message;
 					for (typeof(my_message.size()) x = 0; x < Lines; x++) {
-						if ((*message)[x] == NULL) {
-							my_message.push_back("");
-							/* Yaah, FIXME.  index 0 is funky. */
-						} else {
-							string foo = (*message)[x];
-							my_message.push_back(foo);
-						}
+						/* one-based to zero-based conversion, ick */
+						string foo = (*message)[x + 1];
+						my_message.push_back(foo);
 					}
 					printnode(my_message);
 				}

Modified: pinfo/branches/cxx/src/printinfo.cxx
===================================================================
--- pinfo/branches/cxx/src/printinfo.cxx	2005-09-06 12:30:52 UTC (rev 175)
+++ pinfo/branches/cxx/src/printinfo.cxx	2005-09-06 12:35:34 UTC (rev 176)
@@ -40,7 +40,7 @@
 	prnFD = popen(printutility.c_str(), "w");
 
 	/* scan through all lines */
-	for (int i = 1; i < message.size(); i++) {
+	for (int i = 0; i < message.size(); i++) {
 		/*
 		 * This says where the printer's head is right now,
 		 * offset in columns from the beginning of the line
@@ -50,7 +50,7 @@
 		 * Handle the highlights which belong to our (i'th) line.
 		 */
 		int highlight = 0; /* counter to track which highlights have been handled */
-		while (hyperobjects[highlight].line <= i) {
+		while (hyperobjects[highlight].line <= i + 1) {
 			string mynode;
 			/* build a complete highlighted text */
 			if (hyperobjects[highlight].file[0] == 0)
@@ -62,7 +62,7 @@
 				mynode += hyperobjects[highlight].node;
 			}
 			/* if it's a contiunuation of last's line highlight */
-			if (hyperobjects[highlight].line == i - 1) {
+			if (hyperobjects[highlight].line == i) {
 				int length = 1;
 				if (hyperobjects[highlight].breakpos == -1)
 					length = mynode.length() - hyperobjects[highlight].breakpos;
@@ -71,7 +71,7 @@
 				                        string::npos);
 				fputs(trimmed.c_str(), prnFD);
 				lineprinted += trimmed.length();
-			} else if (hyperobjects[highlight].line == i) {
+			} else if (hyperobjects[highlight].line == i + 1) {
 				for (int j = 0; j < hyperobjects[highlight].col - lineprinted; j++)
 					fputc(' ', prnFD);
 				fputs(mynode.c_str(), prnFD);




More information about the Pinfo-devel mailing list