r2303 - alfs-POC/src

jhuntwork at linuxfromscratch.org jhuntwork at linuxfromscratch.org
Mon Mar 6 10:17:39 PST 2006


Author: jhuntwork
Date: 2006-03-06 11:17:39 -0700 (Mon, 06 Mar 2006)
New Revision: 2303

Modified:
   alfs-POC/src/parser.cpp
Log:
Adjusted parsing of comments to track comments that may appear on the same line as un-commented code

Modified: alfs-POC/src/parser.cpp
===================================================================
--- alfs-POC/src/parser.cpp	2006-03-06 17:06:07 UTC (rev 2302)
+++ alfs-POC/src/parser.cpp	2006-03-06 18:17:39 UTC (rev 2303)
@@ -67,17 +67,12 @@
       continue;
 
     if (comment == 1) {
-	if ((curline.find("-->", 0)) == string::npos)
- 	  continue;
-	comment = 0;
-	continue;
+      if ((curline.find("-->", 0)) == string::npos)
+        continue;
+      comment = 0;
+      continue;
     }
 
-    if ((curline.find("<!--", 0)) != string::npos) {
-	comment = 1;
-	continue;
-    }
-
     for (buf = string(curline); !buf.empty(); i = 0) {
 	if (multi != 1)
 	  i = buf.find_first_of("<");
@@ -93,32 +88,42 @@
 	    break;
 
 	  case 0 :
+	    if ((buf.find("<!--", 0)) == 0) {
+	      if ((buf.find("-->", 0)) == string::npos) {
+		comment = 1;
+	      }
+	      buf.erase();
+	    }
 	  // '<' found as the first character of the string
-	    if (multi == 1) {
+	    else {
+	      if (multi == 1) {
 		multibuf.append(buf);
 		buf = string(multibuf);
+	      }
+	      i = buf.find_first_of(">");
+	      if (i != -1) {
+	        // Analyze tag
+	        parsebuf = string(buf, 0, i+1);
+	        parsebuf = string(parsebuf, parsebuf.find_first_not_of("<"), (parsebuf.find_last_not_of(">")-parsebuf.find_first_not_of("<"))+1);
+	        cout << "Parsed tag is: " << parsebuf << endl;
+	        // cout << (string(buf, 0, i+1)) << endl;
+	        buf = string(buf, i+1, buf.length()-i);
+	        multi = 0;
+	      } else {
+	        // FIXME: append to previous line.
+	        multibuf = string(buf);
+	        multi = 1;
+	        buf.erase();
+	      }
 	    }
-	    i = buf.find_first_of(">");
-	    if (i != -1) {
-	      // Analyze tag
-	      parsebuf = string(buf, 0, i+1);
-	      parsebuf = string(parsebuf, parsebuf.find_first_not_of("<"), (parsebuf.find_last_not_of(">")-parsebuf.find_first_not_of("<"))+1);
-	      cout << "Parsed tag is: " << parsebuf << endl;
-	     // cout << (string(buf, 0, i+1)) << endl;
-	      buf = string(buf, i+1, buf.length()-i);
-	      multi = 0;
-	    } else {
-	      // FIXME: append to previous line.
-	      multibuf = string(buf);
-	      multi = 1;
-	      buf.erase();
-	    }
 	    break;
 
 	  default :
 	  // '<' found, but not the first character in the string.
-	    cout << (string(buf, 0, i)) << endl;
+	    if ((string(buf,0,i).find_first_not_of(" ")) != string::npos)
+	      cout << (string(buf, 0, i)) << endl;
 	    buf = string(buf, i, buf.length()-i);
+
 	    
 	}
 	




More information about the alfs-log mailing list