[Aptitude-svn-commit] r3625 - in branches/aptitude-0.3/aptitude: . src/vscreen
Daniel Burrows
dburrows@costa.debian.org
Wed Jul 6 15:40:45 UTC 2005
Author: dburrows
Date: Wed Jul 6 15:40:43 2005
New Revision: 3625
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.h
Log:
Fix some cases where problems arose due to unprintable characters that
seemed to have negative width.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Wed Jul 6 15:40:43 2005
@@ -1,5 +1,10 @@
2005-07-06 Daniel Burrows <dburrows@debian.org>
+ * src/vscreen/vs_pager.cc:
+
+ Fix a number of corner cases involving negative widths and
+ unprintable characters. (Closes: #317115)
+
* src/cmdline/cmdline_show.cc:
Fix output of wide characters. (Closes: #317115)
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.cc Wed Jul 6 15:40:43 2005
@@ -78,12 +78,16 @@
while(loc<s.size() && s[loc]!=L'\n')
{
- if(s[loc]==L'\t')
+ wchar_t ch=s[loc];
+ bool printable=iswprint(ch);
+
+ if(ch==L'\t')
cur_width+=8;
- else
- cur_width+=wcwidth(s[loc]);
+ else if(printable)
+ cur_width+=wcwidth(ch);
- curline+=s[loc];
+ if(printable)
+ curline+=ch;
++loc;
}
@@ -193,24 +197,30 @@
for( ; i<lines.size(); ++i)
{
- col_count loc=lines[i].find(last_search);
+ wstring::size_type loc=lines[i].find(last_search);
if(loc!=wstring::npos)
{
+ int last_search_width=wcswidth(last_search.c_str(), last_search.size());
+ wstring &line=lines[i];
+ col_count foundcol=0;
+ for(wstring::size_type j=0; j<loc; ++j)
+ foundcol+=wcwidth(line[j]);
+
first_line=i;
do_line_signal();
- if(loc<first_column)
+ if(foundcol<first_column)
{
- first_column=loc;
+ first_column=foundcol;
do_column_signal();
}
- else if(loc+last_search.size()>=first_column+getmaxx())
+ else if(foundcol+last_search_width>=first_column+getmaxx())
{
- if(last_search.size()>(col_count) getmaxx())
- first_column=loc;
+ if(last_search_width>(col_count) getmaxx())
+ first_column=foundcol;
else
- first_column=loc+last_search.size()-getmaxx();
+ first_column=foundcol+last_search_width-getmaxx();
do_column_signal();
}
@@ -261,21 +271,29 @@
for(int y=0; y<height && first_line+y<lines.size(); ++y)
{
const wstring &s=lines[first_line+y];
- col_count x=0, curr=0;
+ col_count x=0;
+ wstring::size_type curr=0;
while(curr<s.size() && x<first_column+width)
{
if(s[curr]=='\t')
x+=8;
- else if(x>=first_column)
+ else
{
wchar_t ch=s[curr];
-
- mvadd_wch(y, x-first_column, ch);
- x+=wcwidth(ch);
+ // No nonprintables other than \t should appear
+ // (set_text screens them out)
+ assert(iswprint(ch));
+
+ if(x>=first_column)
+ {
+
+ mvadd_wch(y, x-first_column, ch);
+ x+=wcwidth(ch);
+ }
+ else
+ x+=wcwidth(ch);
}
- else
- ++x;
++curr;
}
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.h (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.h Wed Jul 6 15:40:43 2005
@@ -20,7 +20,7 @@
{
public:
typedef std::vector<std::wstring>::size_type line_count;
- typedef std::wstring::size_type col_count;
+ typedef int col_count;
private:
/** The lines of text being displayed: */
std::vector<std::wstring> lines;
More information about the Aptitude-svn-commit
mailing list