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

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


Author: neroden-guest
Date: 2005-09-02 01:53:04 +0000 (Fri, 02 Sep 2005)
New Revision: 117

Modified:
   pinfo/branches/cxx/src/initializelinks.cxx
Log:
Restore sorting of hyperlinks.



Modified: pinfo/branches/cxx/src/initializelinks.cxx
===================================================================
--- pinfo/branches/cxx/src/initializelinks.cxx	2005-09-02 01:43:30 UTC (rev 116)
+++ pinfo/branches/cxx/src/initializelinks.cxx	2005-09-02 01:53:04 UTC (rev 117)
@@ -22,12 +22,31 @@
 #include "common_includes.h"
 #include <string>
 using std::string;
+#include <vector>
+using std::vector;
 
 RCSID("$Id$")
 
 #define MENU_DOT 0
 #define NOTE_DOT 1
 
+
+bool
+compare_hyperlink(HyperObject a, HyperObject b)
+{
+	/* Should a sort before b? */
+	return (a.col < b.col);
+}
+
+void
+sort_hyperlinks_from_current_line(
+	vector<HyperObject>::iterator startlink,
+	vector<HyperObject>::iterator endlink)
+{
+	std::sort(startlink, endlink, compare_hyperlink);
+}
+
+
 /*
  * Compares two strings, ignoring whitespaces(tabs, spaces)
  */
@@ -235,6 +254,8 @@
 	int changed;
 	int line1len = strlen(line1);
 
+	vector<HyperObject>::size_type initial_hyperobjects_size = hyperobjects.size();
+
 	strcpy(buf, line1);		/* copy two lines into one */
 	if (strlen(line1))
 		buf[strlen(line1) - 1] = ' ';	/* replace trailing '\n' with ' ' */
@@ -634,6 +655,11 @@
 		my_ho.tagtableoffset = -1;
 		hyperobjects.push_back(my_ho);
 	}
+	if (hyperobjects.size() > initial_hyperobjects_size) {
+		vector<HyperObject>::iterator first_new_link
+			= hyperobjects.end() - (hyperobjects.size() - initial_hyperobjects_size);
+		sort_hyperlinks_from_current_line(first_new_link, hyperobjects.end());
+	}
 	if (buf)
 	{
 		xfree(buf);




More information about the Pinfo-devel mailing list