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

Nathanael Nerode neroden-guest at costa.debian.org
Fri Sep 2 07:31:26 UTC 2005


Author: neroden-guest
Date: 2005-09-02 07:31:26 +0000 (Fri, 02 Sep 2005)
New Revision: 140

Modified:
   pinfo/branches/cxx/src/filehandling_functions.cxx
   pinfo/branches/cxx/src/filehandling_functions.h
Log:
Convert internal algorithm in load_tag_table to std::string.


Modified: pinfo/branches/cxx/src/filehandling_functions.cxx
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.cxx	2005-09-02 06:58:03 UTC (rev 139)
+++ pinfo/branches/cxx/src/filehandling_functions.cxx	2005-09-02 07:31:26 UTC (rev 140)
@@ -358,7 +358,6 @@
 load_tag_table(char **message, long lines)
 {
 	long i;
-	char *wsk, *wsk1;
 	int is_indirect = 0;
 
 	/*
@@ -371,33 +370,33 @@
 
 	for (i = 1; i < lines - is_indirect; i++)
 	{
-		char *check;
-		wsk = message[i + is_indirect];
-		check = wsk + strlen(wsk);
-		while (!isspace(*(++wsk)))
-		{
-			if (wsk >= check)
-			{
-				wsk--;
+		string wsk_string = message[i + is_indirect];
+		/* Skip first character and nonwhitespace after it.
+		 * (Why first character? FIXME) 
+		 * plus one more (space) character */
+		string::size_type i;
+		for (i = 1; i < wsk_string.size(); i++) {
+			if (isspace(wsk_string[i])) {
+				i++;
 				break;
 			}
 		}
-		wsk++;
-		wsk1 = wsk;
-		check = wsk1 + strlen(wsk1);
-		while (*(++wsk1) != INDIRECT_TAG)
-		{
-			if (wsk1 >= check)
-				break;
+		string trimmed = wsk_string.substr(i); /* Might be "" */
+		if (trimmed == "") {
+			continue;
 		}
-		if (wsk1 < check)
-		{
-			TagTable my_tag;
-			my_tag.nodename.assign(wsk, wsk1 - wsk);
-			wsk1++;
-			my_tag.offset = atoi(wsk1);
-			tag_table.push_back(my_tag);
+
+		/* Find INDIRECT_TAG character, but skip at least one character
+		 * so the node name is nonempty */
+		string::size_type ind_tag_idx = trimmed.find(INDIRECT_TAG, 1);
+		if (ind_tag_idx == string::npos) {
+			continue;
 		}
+		TagTable my_tag;
+		my_tag.nodename.assign(trimmed, 0, ind_tag_idx);
+		string offset_string = trimmed.substr(ind_tag_idx + 1);
+		my_tag.offset = atoi(offset_string.c_str());
+		tag_table.push_back(my_tag);
 	}
 
 	/* info should ALWAYS start at the 'Top' node, not at the first

Modified: pinfo/branches/cxx/src/filehandling_functions.h
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.h	2005-09-02 06:58:03 UTC (rev 139)
+++ pinfo/branches/cxx/src/filehandling_functions.h	2005-09-02 07:31:26 UTC (rev 140)
@@ -31,8 +31,8 @@
 
 #include <string>
 
-#define INFO_TAG 0x1f
-#define INDIRECT_TAG 0x7f
+#define INFO_TAG (char)0x1f
+#define INDIRECT_TAG (char)0x7f
 
 void initpaths ();
 void addrawpath (const std::string filename);




More information about the Pinfo-devel mailing list