Hello community, here is the log from the commit of package yast2-ncurses for openSUSE:Factory checked in at 2012-02-15 16:18:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-ncurses (Old) and /work/SRC/openSUSE:Factory/.yast2-ncurses.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-ncurses", Maintainer is "g...@suse.com" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-ncurses/yast2-ncurses.changes 2012-01-19 09:45:09.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-ncurses.new/yast2-ncurses.changes 2012-02-15 16:19:36.000000000 +0100 @@ -1,0 +2,7 @@ +Mon Feb 13 13:09:45 CET 2012 - g...@suse.de + +- NCRichText: interpret html tags inside <pre> </pre> + (bnc #724119, bnc #737752) +- V 2.22.1 + +------------------------------------------------------------------- Old: ---- yast2-ncurses-2.22.0.tar.bz2 New: ---- yast2-ncurses-2.22.1.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-ncurses.spec ++++++ --- /var/tmp/diff_new_pack.5Ha20n/_old 2012-02-15 16:19:37.000000000 +0100 +++ /var/tmp/diff_new_pack.5Ha20n/_new 2012-02-15 16:19:37.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package yast2-ncurses # -# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,17 +18,16 @@ Name: yast2-ncurses -Version: 2.22.0 +Version: 2.22.1 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build Source0: yast2-ncurses-%{version}.tar.bz2 - Group: System/YaST License: GPL-2.0 -BuildRequires: doxygen dejagnu gcc-c++ yast2-devtools libtool -BuildRequires: libxcrypt-devel blocxx-devel ncurses-devel +BuildRequires: dejagnu doxygen gcc-c++ libtool yast2-devtools +BuildRequires: blocxx-devel libxcrypt-devel ncurses-devel Summary: YaST2 - Character Based User Interface Provides: yast2_ui @@ -36,6 +35,7 @@ BuildRequires: yast2-libyui-devel >= 2.21.1 Requires: yast2-libyui >= 2.21.1 Recommends: yast2-ncurses-pkg + %description This package contains the character based (ncurses) user interface component for YaST2. ++++++ yast2-ncurses-2.22.0.tar.bz2 -> yast2-ncurses-2.22.1.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ncurses-2.22.0/VERSION new/yast2-ncurses-2.22.1/VERSION --- old/yast2-ncurses-2.22.0/VERSION 2011-12-21 12:24:37.000000000 +0100 +++ new/yast2-ncurses-2.22.1/VERSION 2012-02-09 12:40:41.000000000 +0100 @@ -1 +1 @@ -2.22.0 +2.22.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ncurses-2.22.0/configure new/yast2-ncurses-2.22.1/configure --- old/yast2-ncurses-2.22.0/configure 2012-01-17 12:16:08.000000000 +0100 +++ new/yast2-ncurses-2.22.1/configure 2012-02-13 13:16:02.000000000 +0100 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for yast2-ncurses 2.22.0. +# Generated by GNU Autoconf 2.68 for yast2-ncurses 2.22.1. # # Report bugs to <http://bugs.opensuse.org/>. # @@ -709,8 +709,8 @@ # Identity of this package. PACKAGE_NAME='yast2-ncurses' PACKAGE_TARNAME='yast2-ncurses' -PACKAGE_VERSION='2.22.0' -PACKAGE_STRING='yast2-ncurses 2.22.0' +PACKAGE_VERSION='2.22.1' +PACKAGE_STRING='yast2-ncurses 2.22.1' PACKAGE_BUGREPORT='http://bugs.opensuse.org/' PACKAGE_URL='' @@ -1488,7 +1488,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures yast2-ncurses 2.22.0 to adapt to many kinds of systems. +\`configure' configures yast2-ncurses 2.22.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1559,7 +1559,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of yast2-ncurses 2.22.0:";; + short | recursive ) echo "Configuration of yast2-ncurses 2.22.1:";; esac cat <<\_ACEOF @@ -1673,7 +1673,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -yast2-ncurses configure 2.22.0 +yast2-ncurses configure 2.22.1 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2308,7 +2308,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by yast2-ncurses $as_me 2.22.0, which was +It was created by yast2-ncurses $as_me 2.22.1, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -3238,7 +3238,7 @@ # Define the identity of the package. PACKAGE='yast2-ncurses' - VERSION='2.22.0' + VERSION='2.22.1' cat >>confdefs.h <<_ACEOF @@ -3360,7 +3360,7 @@ -VERSION="2.22.0" +VERSION="2.22.1" RPMNAME="yast2-ncurses" MAINTAINER="Gabriele Mohr <g...@suse.de>" @@ -16101,7 +16101,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by yast2-ncurses $as_me 2.22.0, which was +This file was extended by yast2-ncurses $as_me 2.22.1, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16167,7 +16167,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -yast2-ncurses config.status 2.22.0 +yast2-ncurses config.status 2.22.1 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ncurses-2.22.0/configure.in new/yast2-ncurses-2.22.1/configure.in --- old/yast2-ncurses-2.22.0/configure.in 2012-01-17 12:15:59.000000000 +0100 +++ new/yast2-ncurses-2.22.1/configure.in 2012-02-13 13:15:53.000000000 +0100 @@ -3,7 +3,7 @@ dnl -- This file is generated by y2autoconf 2.21.2 - DO NOT EDIT! -- dnl (edit configure.in.in instead) -AC_INIT(yast2-ncurses, 2.22.0, http://bugs.opensuse.org/, yast2-ncurses) +AC_INIT(yast2-ncurses, 2.22.1, http://bugs.opensuse.org/, yast2-ncurses) dnl Check for presence of file 'RPMNAME' AC_CONFIG_SRCDIR([RPMNAME]) @@ -18,7 +18,7 @@ AM_INIT_AUTOMAKE(tar-ustar -Wno-portability) dnl Important YaST2 variables -VERSION="2.22.0" +VERSION="2.22.1" RPMNAME="yast2-ncurses" MAINTAINER="Gabriele Mohr <g...@suse.de>" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ncurses-2.22.0/src/NCAskForFile.cc new/yast2-ncurses-2.22.1/src/NCAskForFile.cc --- old/yast2-ncurses-2.22.0/src/NCAskForFile.cc 2011-12-21 13:18:49.000000000 +0100 +++ new/yast2-ncurses-2.22.1/src/NCAskForFile.cc 2012-02-09 14:09:13.000000000 +0100 @@ -238,6 +238,10 @@ dirName->addItem( dirList->getCurrentDir(), true ); // selected + if ( iniFileName == "" ) + // show the currently selected file + fileName->setValue( fileList->getCurrentFile() ); + // event loop do { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ncurses-2.22.0/src/NCFileSelection.cc new/yast2-ncurses-2.22.1/src/NCFileSelection.cc --- old/yast2-ncurses-2.22.0/src/NCFileSelection.cc 2011-12-21 13:20:13.000000000 +0100 +++ new/yast2-ncurses-2.22.1/src/NCFileSelection.cc 2012-02-09 14:30:33.000000000 +0100 @@ -409,6 +409,7 @@ const string & filter, const string & iniDir ) : NCFileSelection( parent, tableHeader, type, iniDir ) + , currentFile("") { //fillHeader(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ncurses-2.22.0/src/NCRichText.cc new/yast2-ncurses-2.22.1/src/NCRichText.cc --- old/yast2-ncurses-2.22.0/src/NCRichText.cc 2011-12-21 13:22:55.000000000 +0100 +++ new/yast2-ncurses-2.22.1/src/NCRichText.cc 2012-02-13 11:10:38.000000000 +0100 @@ -45,6 +45,7 @@ #include "stringutil.h" #include "stdutil.h" #include <sstream> +#include <boost/algorithm/string.hpp> #include "YMenuItem.h" #include "YApplication.h" @@ -344,36 +345,23 @@ } } - -void NCRichText::PadPlainTXT( const wchar_t * osch, const unsigned olen ) +void NCRichText::PadPreTXT( const wchar_t * osch, const unsigned olen ) { wstring wtxt( osch, olen ); + // resolve the entities even in PRE (#71718) wtxt = filterEntities( wtxt ); - + NCstring nctxt( wtxt ); NCtext ftext( nctxt ); - if ( ftext.Columns() > textwidth ) - textwidth = ftext.Columns(); - - AdjustPad( wsze( cl + ftext.Lines(), textwidth ) ); - // insert the text const wchar_t * sch = wtxt.data(); while ( *sch ) { - if ( *sch != L'\r' ) // skip carriage return - { - myPad()->addwstr( sch, 1 ); // add one wide chararacter - cc += wcwidth( *sch ); + myPad()->addwstr( sch, 1 ); // add one wide chararacter - if ( *sch == L'\n' ) - { - PadNL(); // add a new line - } - } ++sch; } } @@ -420,21 +408,87 @@ while ( *wch && WDtoken.find( *wch ) == wstring::npos ); } +static wstring PREtoken( L"<\n\v\r" ); // line manipulations + TokenStart '<' + inline void SkipPreTXT( const wchar_t *& wch ) { + do + { + ++wch; + } + while ( *wch && PREtoken.find( *wch ) == wstring::npos ); +} + + +// +// Calculate longest line of text in <pre> </pre> tags +// and adjust the pad accordingly +// +void NCRichText::AdjustPrePad( const wchar_t *osch ) +{ + const wchar_t * wch = osch; wstring wstr( wch, 6 ); + size_t llen = 0; // longest line + size_t tmp_len = 0; // width of current line + + list<NCstring>::const_iterator line; // iterator for list <NCstring> mtext + std::wstring::const_iterator wstr_it; // iterator for wstring + do { - ++wch; + ++wch; wstr.assign( wch, 6 ); } while ( *wch && wstr != L"</pre>" ); -} + wstring wtxt( osch, wch - osch ); + + // resolve the entities to get correct length for calculation of longest line + wtxt = filterEntities( wtxt ); + + // replace <br> by \n to get appropriate lines in NCtext + boost::replace_all( wtxt, L"<br>", L"\n" ); + + yuiDebug() << "Text: " << wtxt << " initial length: " << wch - osch << endl; + + NCstring nctxt( wtxt ); + NCtext ftext( nctxt ); + + // iterate through NCtext + for ( line = ftext.Text().begin(); line != ftext.Text().end(); ++line ) + { + tmp_len = 0; + for ( wstr_it = ( *line ).str().begin(); wstr_it != ( *line ).str().end() ; ++wstr_it ) + { + // skip html tags + if ( *wstr_it == '<' ) + { + wstr_it = find(wstr_it, (*line).str().end(), L'>'); + } + else if ( *wstr_it == '\t' ) + { + tmp_len += myPad()->tabsize(); + } + else + { + tmp_len += wcwidth( *wstr_it ); + } + } + if ( tmp_len > llen ) + llen = tmp_len; + } + + if ( llen > textwidth ) + { + textwidth = llen; + AdjustPad( wsze( cl + ftext.Lines(), llen ) ); // adjust pad to longest line + } + +} void NCRichText::DrawHTMLPad() { @@ -470,12 +524,19 @@ } else { - if ( *wch != L'\r' ) // skip carriage return + switch ( *wch ) { - myPad()->addwstr( wch, 1 ); // add the wide chararacter - cc += wcwidth( *wch ); - if ( *wch == '\n' ) - PadNL(); + case L' ': // add white space + case L'\t': + myPad()->addwstr( wch, 1 ); + break; + + case L'\n': + PadNL(); // add new line + break; + + default: + yuiDebug() << "Ignoring " << *wch << endl; } ++wch; } @@ -483,16 +544,14 @@ break; case L'<': - if ( !preTag ) - { - swch = wch; - SkipToken( wch ); + swch = wch; + SkipToken( wch ); + + if ( PadTOKEN( swch, wch ) ) + break; // strip token + else + wch = swch; // reset and fall through - if ( PadTOKEN( swch, wch ) ) - break; // strip token - else - wch = swch; // reset and fall through - } default: swch = wch; @@ -504,9 +563,7 @@ else { SkipPreTXT( wch ); - PadPlainTXT( swch, wch - swch ); - preTag = false; - PadNL(); // add new line after pre is closed + PadPreTXT( swch, wch - swch ); } break; @@ -515,6 +572,7 @@ PadBOL(); AdjustPad( wsze( cl, textwidth ) ); + yuiDebug() << "Anchors: " << anchors.size() << endl; for ( unsigned i = 0; i < anchors.size(); ++i ) @@ -597,7 +655,8 @@ /** * Get the number of columns needed to print a 'wstring'. Only printable characters - * are taken into account because others would return -1 (e.g. '\n'). + * are taken into account because otherwise 'wcwidth' would return -1 (e.g. for '\n'). + * Tabs are calculated with tabsize(). * Attention: only use textWidth() to calculate space, not for iterating through a text * or to get the length of a text (real text length includes new lines). */ @@ -610,7 +669,13 @@ { // check whether char is printable if ( iswprint( *wstr_it ) ) - len += wcwidth( *wstr_it ); + { + len += wcwidth( *wstr_it ); + } + else if ( *wstr_it == '\t' ) + { + len += myPad()->tabsize(); + } } return len; @@ -981,11 +1046,13 @@ if ( !endtag ) { - preTag = true; // display plain text + preTag = true; // display text preserving newlines and spaces + AdjustPrePad( ech ); } else { preTag = false; + PadNL(); // add new line (text may continue after </pre>) } break; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ncurses-2.22.0/src/NCRichText.h new/yast2-ncurses-2.22.1/src/NCRichText.h --- old/yast2-ncurses-2.22.0/src/NCRichText.h 2011-12-21 13:38:10.000000000 +0100 +++ new/yast2-ncurses-2.22.1/src/NCRichText.h 2012-02-07 10:33:44.000000000 +0100 @@ -91,8 +91,7 @@ unsigned cindent; bool atbol; - bool preTag; // default is false; set true - // if <pre> tag is found + bool preTag; // <pre> tag unsigned Tattr; @@ -212,7 +211,8 @@ void PadBOL(); void PadWS( const bool tab = false ); void PadTXT( const wchar_t * sch, const unsigned len ); - void PadPlainTXT( const wchar_t * sch, const unsigned len ); + void PadPreTXT( const wchar_t * sch, const unsigned len ); + void AdjustPrePad( const wchar_t * sch ); bool PadTOKEN( const wchar_t * sch, const wchar_t *& ech ); protected: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ncurses-2.22.0/src/NCtext.cc new/yast2-ncurses-2.22.1/src/NCtext.cc --- old/yast2-ncurses-2.22.0/src/NCtext.cc 2011-12-21 13:23:56.000000000 +0100 +++ new/yast2-ncurses-2.22.1/src/NCtext.cc 2012-02-13 13:52:41.000000000 +0100 @@ -46,6 +46,7 @@ #include <wchar.h> // wcwidth #include <langinfo.h> +#include <boost/algorithm/string.hpp> const NCstring NCtext::emptyStr; @@ -81,7 +82,7 @@ if ( ntext.str().empty() ) return; - const wstring & text( ntext.str() ); + wstring text( ntext.str() ); wstring::size_type spos = 0; @@ -89,6 +90,9 @@ bool sawnl = false; // saw new line + // handle DOS text + boost::erase_all( text, L"\r" ); + while (( cpos = text.find( L'\n', spos ) ) != wstring::npos ) { if ( sawnl ) @@ -119,8 +123,11 @@ if ( ntext.str().empty() ) return; - const wstring & text( ntext.str() ); + wstring text( ntext.str() ); + // handle DOS text + boost::erase_all( text, L"\r" ); + wstring::size_type spos = 0; wstring::size_type cpos = wstring::npos; @@ -194,7 +201,10 @@ for ( wstr_it = ( *line ).str().begin(); wstr_it != ( *line ).str().end() ; ++wstr_it ) { - tmp_len += wcwidth( *wstr_it ); + if ( iswprint( *wstr_it ) ) + tmp_len += wcwidth( *wstr_it ); + else if ( *wstr_it == L'\t' ) + tmp_len += NCurses::tabsize(); } if ( tmp_len > llen ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ncurses-2.22.0/src/NCurses.h new/yast2-ncurses-2.22.1/src/NCurses.h --- old/yast2-ncurses-2.22.0/src/NCurses.h 2011-12-21 13:41:15.000000000 +0100 +++ new/yast2-ncurses-2.22.1/src/NCurses.h 2012-02-08 13:31:06.000000000 +0100 @@ -207,6 +207,8 @@ static int lines() { return ::LINES; } + static int tabsize() { return ::TABSIZE; } + void run(); public: -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org