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

Nathanael Nerode neroden-guest at costa.debian.org
Fri Sep 2 01:08:33 UTC 2005


Author: neroden-guest
Date: 2005-09-02 01:08:33 +0000 (Fri, 02 Sep 2005)
New Revision: 115

Modified:
   pinfo/branches/cxx/src/manual.cxx
Log:
Restore sorting code to manual.cxx.  Exposed some serious bugs in
link following.  :-P


Modified: pinfo/branches/cxx/src/manual.cxx
===================================================================
--- pinfo/branches/cxx/src/manual.cxx	2005-09-01 23:25:49 UTC (rev 114)
+++ pinfo/branches/cxx/src/manual.cxx	2005-09-02 01:08:33 UTC (rev 115)
@@ -324,6 +324,7 @@
 	do {
 		/* manualwork handles all actions when viewing man page */
 		return_value = manualwork();
+		/* Return value may specify link to follow */
 #ifdef getmaxyx
 		/* if ncurses, get maxx and maxy */
 		getmaxyx(stdscr, maxy, maxx);
@@ -524,6 +525,36 @@
 
 }
 
+bool
+compare_manuallink(manuallink a, manuallink b)
+{
+	/* Should a sort before b? */
+  return (a.col < b.col);
+}
+
+void
+sort_manuallinks_from_current_line(
+	vector<manuallink>::iterator startlink,
+	vector<manuallink>::iterator endlink)
+{
+	/* Bletchulous.  This breaks so often... */
+	for (vector<manuallink>::iterator ptr = manuallinks.begin();
+	     ptr < manuallinks.end(); ptr++) {
+		printf("%s (%s %d) at %d %d (%d) BEFORE\n\r", (ptr->name).c_str(),
+			(ptr->section).c_str(), ptr->section_mark,
+			ptr->line, ptr->col, ptr->carry);
+	}
+
+	std::sort(startlink, endlink, compare_manuallink);
+
+	for (vector<manuallink>::iterator ptr = manuallinks.begin();
+	     ptr < manuallinks.end(); ptr++) {
+		printf("%s (%s %d) at %d %d (%d) AFTER\n\r", (ptr->name).c_str(),
+			(ptr->section).c_str(), ptr->section_mark,
+			ptr->line, ptr->col, ptr->carry);
+	}
+}
+
 /* initializes hyperlinks in manual */
 void
 man_initializelinks(char *tmp, int carry)
@@ -537,6 +568,8 @@
 	 * handle url refrences                                                       *
 	 *****************************************************************************/
 	urlend = tmp;
+
+	vector<manuallink>::size_type initialManualLinks = manuallinks.size();
 	while ((urlstart = strstr(urlend, "http://")) != NULL)
 	{
 		/* always successfull */
@@ -709,6 +742,12 @@
 		}
 	} while (link != NULL);
 	/* do this loop until strchr() won't find a '(' in string */
+
+	if (manuallinks.size() > initialManualLinks) {
+		vector<manuallink>::iterator first_new_link
+			= manuallinks.end() - (manuallinks.size() - initialManualLinks); 
+		sort_manuallinks_from_current_line(first_new_link, manuallinks.end());
+	}
 }
 
 /* viewer function. Handles keyboard actions--main event loop */




More information about the Pinfo-devel mailing list