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

Nathanael Nerode neroden-guest at costa.debian.org
Wed Sep 7 01:22:51 UTC 2005


Author: neroden-guest
Date: 2005-09-07 01:22:51 +0000 (Wed, 07 Sep 2005)
New Revision: 182

Modified:
   pinfo/branches/cxx/src/filehandling_functions.cxx
Log:
Use the first partial match, not the last (bringing in from trunk 178:179);
also various cosmetic cleanups.



Modified: pinfo/branches/cxx/src/filehandling_functions.cxx
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.cxx	2005-09-07 01:13:17 UTC (rev 181)
+++ pinfo/branches/cxx/src/filehandling_functions.cxx	2005-09-07 01:22:51 UTC (rev 182)
@@ -219,11 +219,8 @@
 		     && ( (filestart = this_line.find('(', nameend + 1)) != string::npos )
 		     && ( (fileend = this_line.find(')', filestart)) != string::npos )
 		     && ( (dot = this_line.find('.', fileend)) != string::npos )
-		     && (strcasecmp(wanted_name.c_str(),
-		                    this_line.substr(2, wanted_name.length()).c_str())
-             == 0) /* Right file */
 		   ) {
-			; /* Matches the pattern we want, with the right name */
+			; /* Matches the pattern we want */
 		} else {
 			continue;
 		}
@@ -233,6 +230,19 @@
 		string file(this_line, filestart + 1, fileend - filestart - 2);
 		string node(this_line, fileend + 1, dot - fileend - 2);
 
+		if (strcasecmp(wanted_name.c_str(),
+		               name.substr(0, wanted_name.length()).c_str())
+        != 0) { 
+			/* Wrong name -- wanted_name must begin the name */
+			continue;
+		}
+
+		if ( goodHit && (name.length() != wanted_name.length()) ) {
+			/* skip this hit if we have already found a previous partial match,
+		   * and this hit is not a perfect match */
+			continue;
+		}
+
 		if (node != "") {
 			string::size_type idx = 0;
 			while (isspace(node[idx]))
@@ -752,8 +762,10 @@
 			mybuf = infopaths[i];
 			/* Modify mybuf in place by suffixing filename -- eeewww */
 			int result = matchfile(mybuf, filename);
-			if (result == 1)	/* no match found in this directory */
+			if (result == 1) {
+				/* no match found in this directory */
 				continue;
+			}
 		}
 		for (int j = 0; j < SuffixesNumber; j++) { /* go through all suffixes */
 			string buf_with_suffix = mybuf;
@@ -778,7 +790,7 @@
 				}
 			}
 		}
-		if ((i == -1) && ( !filenameprefix.empty() ))
+		if ((i == -1) && ( !filenameprefix.empty() )) {
 			/* if we have a nonzero filename prefix,
 				 that is we view a set of infopages,
 				 we don't want to search for a page
@@ -786,6 +798,7 @@
 				 the prefix directory. Therefore
 				 break here. */
 			break;
+		}
 	}
 	return 0;
 }




More information about the Pinfo-devel mailing list