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

Nathanael Nerode neroden-guest at costa.debian.org
Mon Aug 29 02:48:02 UTC 2005


Author: neroden-guest
Date: 2005-08-29 02:48:02 +0000 (Mon, 29 Aug 2005)
New Revision: 64

Modified:
   pinfo/branches/cxx/src/filehandling_functions.cxx
   pinfo/branches/cxx/src/filehandling_functions.h
   pinfo/branches/cxx/src/mainfunction.cxx
   pinfo/branches/cxx/src/pinfo.cxx
Log:
And convert the openinfo interface.


Modified: pinfo/branches/cxx/src/filehandling_functions.cxx
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.cxx	2005-08-29 02:35:19 UTC (rev 63)
+++ pinfo/branches/cxx/src/filehandling_functions.cxx	2005-08-29 02:48:02 UTC (rev 64)
@@ -193,7 +193,8 @@
 									id = 0;
 									if (!strstr(file, ".info"))
 										strcat(file, ".info");
-									id = openinfo(file, 0);
+									string tmpstr = file;
+									id = openinfo(tmpstr, 0);
 									goodHit = 1;
 									if ((nameend - Message[i]) - 2 == filenamelen)	/* the name matches perfectly to the query */
 										perfectHit = 1;	/* stop searching for another matches, and use this one */
@@ -645,12 +646,12 @@
  * filenameprefix and then in the rest of userdefined paths.
  */
 FILE *
-openinfo(const char *filename, int number)
+openinfo(const string filename, int number)
 {
 	FILE *id = NULL;
 	char *tmpfilename;
 
-	if (strncmp(filename, "dir", 3) == 0)
+	if (filename == "dir")
 	{
 		return opendirfile(number);
 	}
@@ -678,7 +679,6 @@
 
 	for (int i = -1; i < infopathcount; i++) { /* go through all paths */
 		string mybuf;
-		string filename_string = filename;
 		if (i == -1) {
 			/*
 			 * no filenameprefix, we don't navigate around any specific
@@ -690,13 +690,13 @@
 				mybuf = filenameprefix;
 				mybuf += "/";
 				string basename_string;
-				basename(filename_string, basename_string);
+				basename(filename, basename_string);
 				mybuf += basename_string;
 			}
 		} else {
 			mybuf = infopaths[i];
 			/* Modify mybuf in place by suffixing filename -- eeewww */
-			int result = matchfile(mybuf, filename_string);
+			int result = matchfile(mybuf, filename);
 			if (result == 1)	/* no match found in this directory */
 				continue;
 		}
@@ -971,7 +971,8 @@
 	int i, j, initial;
 	for (i = 1; i <= IndirectEntries; i++)
 	{
-		id = openinfo(indirect[i].filename, 1);
+		string tmpstr = indirect[i].filename;
+		id = openinfo(tmpstr, 1);
 		initial = TagTableEntries + 1;
 		if (id)
 		{
@@ -1079,7 +1080,8 @@
 			{
 				long off = tag_table[tag_table_pos].offset - indirect[i].offset + FirstNodeOffset - 4;
 				fclose(id);
-				id = openinfo(indirect[i].filename, 0);
+				string tmpstr = indirect[i].filename;
+				id = openinfo(tmpstr, 0);
 				if (id == NULL)
 				{
 					closeprogram();

Modified: pinfo/branches/cxx/src/filehandling_functions.h
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.h	2005-08-29 02:35:19 UTC (rev 63)
+++ pinfo/branches/cxx/src/filehandling_functions.h	2005-08-29 02:48:02 UTC (rev 64)
@@ -63,7 +63,7 @@
 /* loads tag table (as above) */
 void load_tag_table (char **message, long lines);
 /* opens info file */
-FILE *openinfo (const char *filename, int number);
+FILE *openinfo (const std::string filename, int number);
 /* opens dir info file */
 FILE *opendirfile (int number);
 

Modified: pinfo/branches/cxx/src/mainfunction.cxx
===================================================================
--- pinfo/branches/cxx/src/mainfunction.cxx	2005-08-29 02:35:19 UTC (rev 63)
+++ pinfo/branches/cxx/src/mainfunction.cxx	2005-08-29 02:48:02 UTC (rev 64)
@@ -20,7 +20,8 @@
  ***************************************************************************/
 #include "common_includes.h"
 #include "printinfo.h"
-
+#include <string>
+using std::string;
 RCSID("$Id$")
 
 #include <ctype.h>
@@ -337,8 +338,8 @@
 					long filelen;
 					for (j = indirectstart; j <= IndirectEntries; j++)
 					{
-						fd = openinfo(indirect[j].filename, 1);	/* get file
-																	 * length. */
+						string tmpstr = indirect[j].filename;
+						fd = openinfo(tmpstr, 1);	/* get file length. */
 						fseek(fd, 0, SEEK_END);
 						filelen = ftell(fd);
 

Modified: pinfo/branches/cxx/src/pinfo.cxx
===================================================================
--- pinfo/branches/cxx/src/pinfo.cxx	2005-08-29 02:35:19 UTC (rev 63)
+++ pinfo/branches/cxx/src/pinfo.cxx	2005-08-29 02:48:02 UTC (rev 64)
@@ -159,7 +159,7 @@
 					/* Get basename, and pass to openinfo */
 					string basename_string;
 					basename(filename_string, basename_string);
-					(*id) = openinfo(basename_string.c_str(), 0);
+					(*id) = openinfo(basename_string, 0);
 				}
 				break;
 			case 'a':
@@ -309,8 +309,10 @@
 	}
 
 	/* no rawpath has been opened */
-	if (id == NULL)
-		id = openinfo(filename, 0);
+	if (id == NULL) {
+		string tmpstr = filename;
+		id = openinfo(tmpstr, 0);
+	}
 
 	/* try to lookup the name in dir file */
 	if (id == NULL)
@@ -421,15 +423,14 @@
 				}
 				else /* open new info file */
 				{
-					char *tmp;
 					fclose(id);
-					tmp = strdup(work_return_value.file);
-
+					string tmpstr;
+					tmpstr = work_return_value.file;
 					/* Reset global filenameprefix */
 					filenameprefix.clear();
-					id = openinfo(tmp, 0);
-					xfree(tmp);
-					tmp = 0;
+					id = openinfo(tmpstr, 0);
+
+					char *tmp = NULL;
 					/* if the file doesn't exist */
 					if (id == NULL)
 					{
@@ -447,10 +448,9 @@
 						}
 						/* open back the old file */
 						strip_file_from_info_suffix(curfile);
-						tmp = strdup(curfile);
-						id = openinfo(tmp, 0);
-						xfree(tmp);
-						tmp = 0;
+						string tmpstr = curfile;
+						id = openinfo(tmpstr, 0);
+						tmp = NULL;
 						if (id == NULL)
 						{
 							closeprogram();




More information about the Pinfo-devel mailing list