[Aptitude-svn-commit] r4370 - in branches/aptitude-0.3/aptitude: . src

Daniel Burrows dburrows at costa.debian.org
Fri Sep 30 17:19:42 UTC 2005


Author: dburrows
Date: Fri Sep 30 17:19:39 2005
New Revision: 4370

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/changelog_parse.cc
Log:
Don't use the description parser to parse changelog text; the
bullet and wrapping logic are not accurate enough for changelogs.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Fri Sep 30 17:19:39 2005
@@ -1,5 +1,11 @@
 2005-09-30  Daniel Burrows  <dburrows at debian.org>
 
+	* src/changelog_parse.cc:
+
+	  Instead of using the description parser to generate formatted
+	  changelogs, just parse them by hand; the bulletting conventions
+	  are not, unfortunately, as well-defined as for descriptions.
+
 	* src/menu_text_layout.cc, src/menu_text_layout.h:
 
 	  Make the search keystrokes active in the menu_text_layout

Modified: branches/aptitude-0.3/aptitude/src/changelog_parse.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/changelog_parse.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/changelog_parse.cc	Fri Sep 30 17:19:39 2005
@@ -36,6 +36,42 @@
 #include <vscreen/transcode.h>
 
 static
+fragment *change_text_fragment(const std::string &s)
+{
+  std::vector<fragment *> lines;
+
+  std::string::size_type start = 0;
+  std::string::size_type next_nl;
+
+  do
+    {
+      next_nl = s.find('\n', start);
+
+      if(s[start] == ' ')
+	++start;
+
+      if(next_nl == start + 1 && s[start] == '.')
+	{
+	  lines.push_back(newline_fragment());
+	  start = next_nl + 1;
+	  continue;
+	}
+
+      std::string this_line;
+      if(next_nl != std::string::npos)
+	this_line.assign(s, start, next_nl - start);
+      else
+	this_line.assign(s, start, std::string::npos);
+
+      lines.push_back(hardwrapbox(fragf("%s%n", this_line.c_str())));
+
+      start = next_nl + 1;
+    } while(next_nl != std::string::npos);
+
+  return sequence_fragment(lines);
+}
+
+static
 fragment *parse_predigested_changelog(const temp::name &digest,
 				      const std::string &curver)
 {
@@ -56,13 +92,12 @@
       while(tagfile.Step(sec))
 	{
 	  std::string version(sec.FindS("Version"));
-	  std::string changes = "\n";
-	  changes.append(sec.FindS("Changes"));
+	  std::string changes(sec.FindS("Changes"));
 	  std::string maintainer(sec.FindS("Maintainer"));
 	  std::string date(sec.FindS("Date"));
 
 	  fragment *f = fragf(first ? "%F%F" : "%n%F%F",
-			      make_desc_fragment(transcode(changes)),
+			      change_text_fragment(changes),
 			      hardwrapbox(fragf("%n -- %s  %s",
 						maintainer.c_str(),
 						date.c_str())));



More information about the Aptitude-svn-commit mailing list