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

Nathanael Nerode neroden-guest at costa.debian.org
Thu Sep 8 09:13:26 UTC 2005


Author: neroden-guest
Date: 2005-09-08 09:13:25 +0000 (Thu, 08 Sep 2005)
New Revision: 204

Modified:
   pinfo/branches/cxx/src/manual.cxx
   pinfo/branches/cxx/src/video.cxx
Log:
Properly reset regexp on new manual page.  Fix off-by-ones in regexp
highlighting code.


Modified: pinfo/branches/cxx/src/manual.cxx
===================================================================
--- pinfo/branches/cxx/src/manual.cxx	2005-09-07 08:35:24 UTC (rev 203)
+++ pinfo/branches/cxx/src/manual.cxx	2005-09-08 09:13:25 UTC (rev 204)
@@ -327,7 +327,12 @@
 		getmaxyx(stdscr, maxy, maxx);
 		check_manwidth();
 
-		manual_aftersearch = 0;
+		if (manual_aftersearch) {
+			/* Clear regexp from prior page */
+			h_regexp.pop_back();
+			manual_aftersearch = 0;
+		}
+
 		/* -1 is quit key */
 		if (return_value != -1)
 		{
@@ -1404,8 +1409,7 @@
 mvaddstr_manual(int y, int x, string my_str)
 {
 	static string strippedline_string;
-	if ((h_regexp.size() > 0) ||(manual_aftersearch))
-	{
+	if (h_regexp.size() > 0) {
 		strippedline_string = my_str;
 		strip_manual(strippedline_string);
 	}
@@ -1463,19 +1467,15 @@
 #endif
 	attrset(normal);
 #ifndef ___DONT_USE_REGEXP_SEARCH___
-	if ((h_regexp.size() > 0) ||(manual_aftersearch))
-	{
+	if (h_regexp.size() > 0) {
 		regmatch_t pmatch[1];
-		int maxregexp = manual_aftersearch ? h_regexp.size() + 1 : h_regexp.size();
 
 		/* if it is after search, then we have user defined regexps+
 		   a searched regexp to highlight */
-		for (int j = 0; j < maxregexp; j++)
-		{
+		for (int j = 0; j < h_regexp.size(); j++) {
 			const char* strippedline = strippedline_string.c_str();
 			const char* tmpstr = strippedline;
-			while (!regexec(&h_regexp[j], tmpstr, 1, pmatch, 0))
-			{
+			while (!regexec(&h_regexp[j], tmpstr, 1, pmatch, 0)) {
 				int n = pmatch[0].rm_eo - pmatch[0].rm_so;
 				int rx = pmatch[0].rm_so + tmpstr - strippedline;
 				int curY, curX;

Modified: pinfo/branches/cxx/src/video.cxx
===================================================================
--- pinfo/branches/cxx/src/video.cxx	2005-09-07 08:35:24 UTC (rev 203)
+++ pinfo/branches/cxx/src/video.cxx	2005-09-08 09:13:25 UTC (rev 204)
@@ -207,18 +207,16 @@
 	}
 
 #ifndef ___DONT_USE_REGEXP_SEARCH___
-	if ((h_regexp.size() > 0) ||(aftersearch))
+	if (h_regexp.size() > 0)
 	{
 		regmatch_t pmatch[1];
 		for (int i = pos - 1; 
-		     (i < message.size()) && (i + 1 < pos + (maxy - 2)); i++)
-		{
-			int maxregexp = aftersearch ? h_regexp.size() + 1 : h_regexp.size();
+		     (i < message.size()) && (i + 1 < pos + (maxy - 2)); i++) {
 			/*
 			 * if it is after search, then we have user defined regexps+
 			 * a searched regexp to highlight
 			 */
-			for (int j = 0; j < maxregexp; j++)
+			for (int j = 0; j < h_regexp.size(); j++)
 			{
 				const char * message_i = message[i].c_str();
 				const char *rest_of_str = message_i;




More information about the Pinfo-devel mailing list