[Aptitude-svn-commit] r3558 - in branches/aptitude-0.3/aptitude: . src
Daniel Burrows
dburrows@costa.debian.org
Sat, 02 Jul 2005 18:04:41 +0000
Author: dburrows
Date: Sat Jul 2 18:04:38 2005
New Revision: 3558
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/desc_parse.cc
branches/aptitude-0.3/aptitude/src/desc_parse.h
Log:
Update the description parser to take a wide string as input.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Sat Jul 2 18:04:38 2005
@@ -1,5 +1,9 @@
2005-07-02 Daniel Burrows <dburrows@debian.org>
+ * src/desc_parse.cc, src/desc_parse.h:
+
+ Update the description parser to take a wide string as input.
+
* src/mine/cmine.cc, src/mine/cmine.h:
Update cmine for the new prompt_string signature.
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 Sat Jul 2 18:04:38 2005
@@ -46,24 +46,24 @@
*
* \return the new fragment.
*/
-static fragment *make_level_fragment(string desc,
+static fragment *make_level_fragment(const wstring &desc,
unsigned int level,
- string::size_type indent,
- string::size_type &start)
+ wstring::size_type indent,
+ wstring::size_type &start)
{
vector<fragment*> fragments;
bool first=true;
while(start<desc.size())
{
- string::size_type loc=start;
+ wstring::size_type loc=start;
unsigned int nspaces;
if(!first)
{
nspaces=0;
- while(loc<desc.size() && desc[loc]==' ' && nspaces<indent)
+ while(loc<desc.size() && desc[loc]==L' ' && nspaces<indent)
{
++loc;
++nspaces;
@@ -80,7 +80,7 @@
switch(desc[loc])
{
- case ' ':
+ case L' ':
{
// Stores the number of spaces up to a bullet, if any.
unsigned int nspaces2=nspaces+1;
@@ -89,23 +89,23 @@
// Provisionally check if it's a bulletted line --
// *ignoring leading spaces*.
- string::size_type loc2=loc;
+ wstring::size_type loc2=loc;
- while(loc2<desc.size() && desc[loc2] == ' ')
+ while(loc2<desc.size() && desc[loc2] == L' ')
{
++loc2;
++nspaces2;
}
if(loc2<desc.size() &&
- (desc[loc2] == '+' ||
- desc[loc2] == '-' ||
- desc[loc2] == '*'))
+ (desc[loc2] == L'+' ||
+ desc[loc2] == L'-' ||
+ desc[loc2] == L'*'))
{
// Start a list item (i.e., an indented region).
- string bullet;
- bullet+=("*+-"[level%3]);
+ wstring bullet;
+ bullet+=(L"*+-"[level%3]);
start=loc2+2;
@@ -124,11 +124,11 @@
else
{
int amt=0;
- while(loc+amt<desc.size() && desc[loc+amt]!='\n')
+ while(loc+amt<desc.size() && desc[loc+amt]!=L'\n')
++amt;
// Hard-wrap AS REQUIRED BY POLICY.
- fragments.push_back(hardwrapbox(text_fragment(string(desc, loc, amt))));
+ fragments.push_back(hardwrapbox(text_fragment(wstring(desc, loc, amt))));
loc+=amt;
if(loc<desc.size())
@@ -139,12 +139,12 @@
}
break;
- case '.':
+ case L'.':
// Add a blank line (ignore the rest of the line)
{
fragments.push_back(newline_fragment());
- while(loc<desc.size() && desc[loc]!='\n')
+ while(loc<desc.size() && desc[loc]!=L'\n')
++loc;
if(loc<desc.size())
@@ -157,22 +157,22 @@
// It's a paragraph.
{
bool cont=true;
- string::size_type amt=0;
- string par="";
+ wstring::size_type amt=0;
+ wstring par=L"";
do {
amt=0;
- while(loc+amt<desc.size() && desc[loc+amt]!='\n')
+ while(loc+amt<desc.size() && desc[loc+amt]!=L'\n')
++amt;
- par=par+string(desc, loc, amt);
+ par=par+wstring(desc, loc, amt);
loc+=amt;
// If we hit a newline and didn't just output a whitespace
// character, insert one.
if(loc<desc.size() && par.size()>0 && par[par.size()-1]!=' ')
- par+=" ";
+ par+=L" ";
// Skip the newline
if(loc<desc.size())
@@ -183,7 +183,7 @@
// Find how much indentation this line has.
nspaces=0;
- while(loc<desc.size() && desc[loc]==' ')
+ while(loc<desc.size() && desc[loc]==L' ')
{
++loc;
++nspaces;
@@ -210,20 +210,20 @@
return sequence_fragment(fragments);
}
-fragment *make_desc_fragment(string desc)
+fragment *make_desc_fragment(const wstring &desc)
{
- string::size_type loc=0;
+ wstring::size_type loc=0;
vector<fragment*> fragments;
// Skip the short description
- while(loc<desc.size() && desc[loc]!='\n')
+ while(loc<desc.size() && desc[loc]!=L'\n')
++loc;
if(loc<desc.size()) // Skip the '\n'
++loc;
// Skip leading whitespace on the first line if there is any.
- if(loc<desc.size() && desc[loc] == ' ')
+ if(loc<desc.size() && desc[loc] == L' ')
++loc;
// Note that the starting amount of indentation is 1...
Modified: branches/aptitude-0.3/aptitude/src/desc_parse.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/desc_parse.h (original)
+++ branches/aptitude-0.3/aptitude/src/desc_parse.h Sat Jul 2 18:04:38 2005
@@ -15,6 +15,6 @@
* \param desc a Description tag to parse
* \return a fragment representing that description
*/
-fragment *make_desc_fragment(std::string desc);
+fragment *make_desc_fragment(const std::wstring &desc);
#endif