r2297 - alfs-POC/src

jhuntwork at linuxfromscratch.org jhuntwork at linuxfromscratch.org
Thu Mar 2 12:15:14 PST 2006


Author: jhuntwork
Date: 2006-03-02 13:15:13 -0700 (Thu, 02 Mar 2006)
New Revision: 2297

Modified:
   alfs-POC/src/parser.cpp
Log:
Fix how the parent string is set

Modified: alfs-POC/src/parser.cpp
===================================================================
--- alfs-POC/src/parser.cpp	2006-03-02 19:28:36 UTC (rev 2296)
+++ alfs-POC/src/parser.cpp	2006-03-02 20:15:13 UTC (rev 2297)
@@ -25,7 +25,7 @@
 int parse_file(string filename){
 
   int loc, len;
-  string fn, parent, curline;
+  string fn, parent, curline, path;
   const char *dir, *file;
   char wd[512];
   ifstream fp;
@@ -36,10 +36,8 @@
   if ((loc = filename.find_last_of("/")) == -1)
     fn = filename;  
   else {
-    string path(filename, 0, loc);
+    path = string(filename, 0, loc);
     fn = string(filename, loc+1, len-loc);
-    if ((loc = path.find_last_of("/")) != -1)
-       parent = string(path, 0, loc);
     dir = path.c_str();
     if ((chdir(dir)) == -1)
 	cerr << "Cannot change directories to " << path << endl;
@@ -56,6 +54,9 @@
      and so we can get the name of the parent directory for
      the file we're parsing */
   getcwd(wd, 256);
+  path = string(wd);
+  if ((loc = path.find_last_of("/")) != -1)
+      parent = string(path, 0, loc);
 
   /* Read one line at a time from the opened file
      until the end of the file is reached */




More information about the alfs-log mailing list