[Aptitude-devel] r3026 - in branches/aptitude-0.3/aptitude: . src
Daniel Burrows
dburrows@costa.debian.org
Thu, 21 Apr 2005 03:32:44 +0000
Author: dburrows
Date: Thu Apr 21 03:32:41 2005
New Revision: 3026
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/desc_parse.cc
Log:
Detect bullets indented more than 3 spaces, and keep paragraphs
from consuming literal text that immediately follows them.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Thu Apr 21 03:32:41 2005
@@ -2,6 +2,12 @@
* src/desc_parse.cc:
+ Allow bulleted lists that are indented more than 2 spaces.
+ Don't mangle lists and literal lines that immediately follow a
+ paragraph.
+
+ * src/desc_parse.cc:
+
Fix a silly thinko in the generation of bullets that was causing
bullets to appear twice in the output.
Modified: branches/aptitude-0.3/aptitude/src/desc_parse.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/desc_parse.cc (original)
+++ branches/aptitude-0.3/aptitude/src/desc_parse.cc Thu Apr 21 03:32:41 2005
@@ -81,29 +81,42 @@
{
case ' ':
{
+ // Stores the number of spaces up to a bullet, if any.
+ unsigned int nspaces2=nspaces+1;
+
++loc;
- if(loc<desc.size() &&
- (desc[loc] == '+' ||
- desc[loc] == '-' ||
- desc[loc] == '*'))
+ // Provisionally check if it's a bulletted line --
+ // *ignoring leading spaces*.
+ string::size_type loc2=loc;
+
+ while(loc2<desc.size() && desc[loc2] == ' ')
+ {
+ ++loc2;
+ ++nspaces2;
+ }
+
+ if(loc2<desc.size() &&
+ (desc[loc2] == '+' ||
+ desc[loc2] == '-' ||
+ desc[loc2] == '*'))
{
// Start a list item (i.e., an indented region).
string bullet;
bullet+=("*+-"[level%3]);
- start=loc+1;
+ start=loc2+1;
fragment *item_contents=make_level_fragment(desc,
level+1,
- nspaces+3,
+ nspaces2+1,
start);
fragments.push_back(text_fragment(bullet,
get_color("Bullet")));
- fragments.push_back(indentbox(nspaces,
- nspaces+2,
+ fragments.push_back(indentbox(1,
+ nspaces2+1,
item_contents));
}
@@ -176,8 +189,11 @@
}
// Check if we should continue (if not, we back up and
- // start parsing again from "start")
- if(nspaces<indent)
+ // start parsing again from "start"). Note that *any*
+ // change in the indentation requires us to restart --
+ // more indentation is a literal line, while less means
+ // we should exit this indent level.
+ if(nspaces != indent)
cont=false;
else if(loc>=desc.size())
cont=false;