[Pinfo-devel] r58 - pinfo/branches/cxx/src
Nathanael Nerode
neroden-guest at costa.debian.org
Mon Aug 29 00:25:16 UTC 2005
Author: neroden-guest
Date: 2005-08-29 00:25:15 +0000 (Mon, 29 Aug 2005)
New Revision: 58
Modified:
pinfo/branches/cxx/src/filehandling_functions.cxx
Log:
More cleanup of matchfile.
Modified: pinfo/branches/cxx/src/filehandling_functions.cxx
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.cxx 2005-08-29 00:16:54 UTC (rev 57)
+++ pinfo/branches/cxx/src/filehandling_functions.cxx 2005-08-29 00:25:15 UTC (rev 58)
@@ -94,30 +94,29 @@
* Leaves the matching name in buf.
*/
int
-matchfile(char **buf, const string name_string)
+matchfile(string& buf, const string name_string)
{
string basename_string;
string dirname_string;
basename_and_dirname(name_string, basename_string, dirname_string);
- if ((*buf)[strlen((*buf))-1]!='/')
- strcat((*buf),"/");
- strcat((*buf),dirname_string.c_str());
+ if (buf[buf.length()-1]!='/')
+ buf += "/";
+ buf += dirname_string;
DIR *dir;
- dir = opendir((*buf)); /* here we always have '/' at end */
+ dir = opendir(buf.c_str()); /* here we always have '/' at end */
if (dir == NULL)
return 1;
struct dirent *dp;
- while ((dp = readdir(dir)) != NULL) {
+ while (dp = readdir(dir)) { /* Ends loop when NULL is returned */
string test_filename = dp->d_name;
strip_compression_suffix(test_filename); /* Strip in place */
if (test_filename == basename_string) {
/* Matched. Clean up and return from function. */
- string toattach = "/";
- toattach += test_filename;
- strcat((*buf), toattach.c_str());
+ buf += "/";
+ buf += test_filename;
closedir(dir);
return 0;
}
@@ -710,10 +709,13 @@
}
else
{
- strcpy(buf, infopaths[i]); /* build a filename */
+ string fullpathname = infopaths[i];
string filename_string = filename;
- if (matchfile(&buf, filename_string) == 1) /* no match found in this directory */
+ /* Modify fullpathname in place by suffixing filename -- eeewww */
+ int result = matchfile(fullpathname, filename_string);
+ if (result == 1) /* no match found in this directory */
continue;
+ strcpy(buf, fullpathname.c_str());
}
bufend = buf;
/*
More information about the Pinfo-devel
mailing list