Author: mlandres
Date: Wed Jul 18 14:38:02 2007
New Revision: 6063
URL: http://svn.opensuse.org/viewcvs/zypp?rev=6063&view=rev
Log: (empty)
Added:
trunk/libzypp/tests/parser/inifile/data/2.ini
Modified:
trunk/libzypp/devel/devel.ma/Main.cc
trunk/libzypp/tests/parser/inifile/iniparser_test.cc
trunk/libzypp/zypp/parser/IniParser.cc
Modified: trunk/libzypp/devel/devel.ma/Main.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Main.cc?rev=6063&r1=6062&r2=6063&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/Main.cc (original)
+++ trunk/libzypp/devel/devel.ma/Main.cc Wed Jul 18 14:38:02 2007
@@ -1,106 +1,13 @@
-#include "Tools.h"
-#include "FakePool.h"
+#include <iostream>
-#include "zypp/base/Exception.h"
+#include "zypp/base/Easy.h"
+#include "zypp/base/LogTools.h"
#include "zypp/base/InputStream.h"
-#include "zypp/base/DefaultIntegral.h"
-#include
-#include
-
-#include
-#include
-#include "zypp/ZYppCallbacks.h"
-
-#include "zypp/NVRAD.h"
-#include "zypp/ResFilters.h"
-#include "zypp/CapFilters.h"
-#include "zypp/PackageKeyword.h"
-#include "zypp/pool/GetResolvablesToInsDel.h"
-using namespace std;
-using namespace zypp;
-
-///////////////////////////////////////////////////////////////////
-
-struct SetTransactValue
-{
- SetTransactValue( ResStatus::TransactValue newVal_r, ResStatus::TransactByValue causer_r )
- : _newVal( newVal_r )
- , _causer( causer_r )
- {}
-
- ResStatus::TransactValue _newVal;
- ResStatus::TransactByValue _causer;
-
- bool operator()( const PoolItem & pi ) const
- {
- bool ret = pi.status().setTransactValue( _newVal, _causer );
- if ( ! ret )
- ERR << _newVal << _causer << " " << pi << endl;
- return ret;
- }
-};
-
-struct StatusReset : public SetTransactValue
-{
- StatusReset()
- : SetTransactValue( ResStatus::KEEP_STATE, ResStatus::USER )
- {}
-};
-
-struct StatusInstall : public SetTransactValue
-{
- StatusInstall()
- : SetTransactValue( ResStatus::TRANSACT, ResStatus::USER )
- {}
-};
+#include "zypp/parser/IniDict.h"
-inline bool selectForTransact( const NameKindProxy & nkp, Arch arch = Arch() )
-{
- if ( nkp.availableEmpty() )
- {
- ERR << "No Item to select: " << nkp << endl;
- return false;
- ZYPP_THROW( Exception("No Item to select") );
- }
-
- if ( arch != Arch() )
- {
- typeof( nkp.availableBegin() ) it = nkp.availableBegin();
- for ( ; it != nkp.availableEnd(); ++it )
- {
- if ( (*it)->arch() == arch )
- return (*it).status().setTransact( true, ResStatus::USER );
- }
- }
-
- return nkp.availableBegin()->status().setTransact( true, ResStatus::USER );
-}
-
-///////////////////////////////////////////////////////////////////
-
-bool solve( bool establish = false )
-{
- if ( establish )
- {
- bool eres = getZYpp()->resolver()->establishPool();
- if ( ! eres )
- {
- ERR << "establish " << eres << endl;
- return false;
- }
- MIL << "establish " << eres << endl;
- }
-
- bool rres = getZYpp()->resolver()->resolvePool();
- if ( ! rres )
- {
- ERR << "resolve " << rres << endl;
- return false;
- }
- MIL << "resolve " << rres << endl;
- return true;
-}
+using std::endl;
+using namespace zypp;
///////////////////////////////////////////////////////////////////
@@ -112,101 +19,24 @@
int main( int argc, char * argv[] )
{
INT << "===[START]==========================================" << endl;
- ///////////////////////////////////////////////////////////////////
- // define pool
- ///////////////////////////////////////////////////////////////////
- if ( 0 )
- {
- const char * data[] = {
- "@ package",
- "@ available",
- "- prodnew 1 1 x86_64",
- "@ fin",
- };
- debug::addPool( data, data + ( sizeof(data) / sizeof(const char *) ) );
- }
- else
- {
- debug::addPool( "TEST" );
- }
- ResPool pool( getZYpp()->pool() );
-
- vdumpPoolStats( USR << "Initial pool:" << endl,
- pool.begin(),
- pool.end() ) << endl;
-
- return 0;
+ Pathname file( "test.ini" );
+ InputStream is( file );
+ parser::IniDict dict( is );
- ///////////////////////////////////////////////////////////////////
- // define transaction
- ///////////////////////////////////////////////////////////////////
- if ( 0 )
- for_each( pool.byKindBegin<Product>(), pool.byKindEnd<Product>(), StatusInstall() );
-
-#define selt(K,N) selectForTransact( nameKindProxy<K>( pool, #N ) )
- selt( Package, bash );
- selt( Package, readline );
- selt( Package, fontcfg );
-#undef selt
-
- ///////////////////////////////////////////////////////////////////
- // solve
- ///////////////////////////////////////////////////////////////////
- if ( 1 )
+ SEC << endl;
+ for_( it, dict.sectionsBegin(), dict.sectionsEnd() )
{
- solve();
- }
-
- vdumpPoolStats( USR << "Transacting:"<< endl,
- make_filter_beginresfilter::ByTransact(pool),
- make_filter_endresfilter::ByTransact(pool) ) << endl;
-
- ///////////////////////////////////////////////////////////////////
- // install order
- ///////////////////////////////////////////////////////////////////
- pool::GetResolvablesToInsDel collect( pool, pool::GetResolvablesToInsDel::ORDER_BY_MEDIANR );
- MIL << "GetResolvablesToInsDel:" << endl << collect << endl;
+ MIL << (*it) << endl;
- if ( 1 )
- {
- // Collect until the 1st package from an unwanted media occurs.
- // Further collection could violate install order.
- bool hitUnwantedMedia = false;
- typedef pool::GetResolvablesToInsDel::PoolItemList PoolItemList;
- PoolItemList::iterator fst=collect._toInstall.end();
- for ( PoolItemList::iterator it = collect._toInstall.begin(); it != collect._toInstall.end(); ++it)
+ for_( ent, dict.entriesBegin(*it), dict.entriesEnd(*it) )
{
- ResObject::constPtr res( it->resolvable() );
-
- if ( hitUnwantedMedia
- || ( res->sourceMediaNr() && res->sourceMediaNr() != 1 ) )
- {
- if ( !hitUnwantedMedia )
- fst=it;
- hitUnwantedMedia = true;
- }
- else
- {
- }
+ DBG << "'" << (*ent).first << "'='" << (*ent).second << "'" << endl;
}
- dumpRange( WAR << "toInstall1: " << endl,
- collect._toInstall.begin(), fst ) << endl;
- dumpRange( WAR << "toInstall2: " << endl,
- fst, collect._toInstall.end() ) << endl;
- dumpRange( ERR << "toDelete: " << endl,
- collect._toDelete.begin(), collect._toDelete.end() ) << endl;
- }
- else
- {
- dumpRange( WAR << "toInstall: " << endl,
- collect._toInstall.begin(), collect._toInstall.end() ) << endl;
- dumpRange( ERR << "toDelete: " << endl,
- collect._toDelete.begin(), collect._toDelete.end() ) << endl;
}
+ SEC << endl;
INT << "===[END]============================================" << endl << endl;
- zypp::base::LogControl::instance().logNothing();
return 0;
}
Added: trunk/libzypp/tests/parser/inifile/data/2.ini
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/parser/inifile/data/2.ini?rev=6063&view=auto
==============================================================================
--- trunk/libzypp/tests/parser/inifile/data/2.ini (added)
+++ trunk/libzypp/tests/parser/inifile/data/2.ini Wed Jul 18 14:38:02 2007
@@ -0,0 +1,10 @@
+[base]
+name=foo
+name= foo
+name =foo
+name = foo
+[equal]
+name1==foo
+name1= =foo
+name2=f=oo
+name3=foo=
Modified: trunk/libzypp/tests/parser/inifile/iniparser_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/parser/inifile/iniparser_test.cc?rev=6063&r1=6062&r2=6063&view=diff
==============================================================================
--- trunk/libzypp/tests/parser/inifile/iniparser_test.cc (original)
+++ trunk/libzypp/tests/parser/inifile/iniparser_test.cc Wed Jul 18 14:38:02 2007
@@ -49,6 +49,20 @@
if ( key == "name" )
BOOST_CHECK_EQUAL( value, "foo" );
}
+ else if ( section == "equal" )
+ {
+ if ( key == "name1" )
+ BOOST_CHECK_EQUAL( value, "=foo" );
+ else if ( key == "name2" )
+ BOOST_CHECK_EQUAL( value, "f=oo" );
+ else if ( key == "name3" )
+ BOOST_CHECK_EQUAL( value, "foo=" );
+ else
+ {
+ cout << "'" << section << "'" << " | " << "'" << key << "'" << " | " << "'" << value << "'" << endl;
+ BOOST_CHECK_MESSAGE( false, "Unhandled key" );
+ }
+ }
}
};
@@ -82,9 +96,9 @@
{
datadir = argv[1];
}
-
+
test_suite* test= BOOST_TEST_SUITE("ini_file");
-
+
std::string const params[] = { datadir };
test->add(BOOST_PARAM_TEST_CASE(&ini_read_test,
(std::string const*)params, params+1));
Modified: trunk/libzypp/zypp/parser/IniParser.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/IniParser.cc?rev=6063&r1=6062&r2=6063&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/IniParser.cc (original)
+++ trunk/libzypp/zypp/parser/IniParser.cc Wed Jul 18 14:38:02 2007
@@ -69,8 +69,8 @@
void IniParser::parse( const InputStream & input_r, const ProgressData::ReceiverFnc & progress )
{
boost::regex rxSection("^\\[(.+)\\]$");
- boost::regex rxKeyValue("^(.*[^[:space:]])[ [:space:]]*=[[:space:]]*(.+)$");
-
+ boost::regex rxKeyValue("^([^=]*[^=[:space:]])[[:space:]]*=[[:space:]]*(.+)$");
+
MIL << "Start parsing " << input_r << endl;
_inputname = input_r.name();
beginParse();
@@ -109,7 +109,7 @@
}
}
}
-
+
// set progress and allow cancel
if ( ! ticks.set( input_r.stream().tellg() ) )
ZYPP_THROW(AbortRequestException());
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org