[zypp-commit] r7822 - in /branches/SuSE-SLE-10-SP2-Branch/libzypp: package/libzypp.changes zypp/Date.cc
Author: mlandres Date: Thu Nov 15 09:54:41 2007 New Revision: 7822 URL: http://svn.opensuse.org/viewcvs/zypp?rev=7822&view=rev Log: fix without static strings Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/package/libzypp.changes branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Date.cc Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/package/libzypp.changes?rev=7822&r1=7821&r2=7822&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP2-Branch/libzypp/package/libzypp.changes (original) +++ branches/SuSE-SLE-10-SP2-Branch/libzypp/package/libzypp.changes Thu Nov 15 09:54:41 2007 @@ -1,9 +1,9 @@ ------------------------------------------------------------------- -Wed Nov 14 14:23:23 CET 2007 - ma@suse.de +Thu Nov 15 09:53:57 CET 2007 - ma@suse.de - Output date strings in UTF-8. (#339423) - version 2.30.3 -- revision 7808 +- revision 7822 ------------------------------------------------------------------- Tue Nov 6 14:43:54 CET 2007 - ma@suse.de Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Date.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Date.cc?rev=7822&r1=7821&r2=7822&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Date.cc (original) +++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Date.cc Thu Nov 15 09:54:41 2007 @@ -39,55 +39,41 @@ { static char buf[1024]; - static std::string lastLocale; - static std::string needLocale; const char * tmp = ::setlocale( LC_TIME, NULL ); std::string thisLocale( tmp ? tmp : "" ); - if ( thisLocale != lastLocale ) + if ( thisLocale.find( "UTF-8" ) == std::string::npos + && thisLocale.find( "utf-8" ) == std::string::npos + && thisLocale != "POSIX" + && thisLocale != "C" + && thisLocale != "" ) { - // locale changes since last call. compute new utf-8 locale - if ( thisLocale.find( "UTF-8" ) != std::string::npos - || thisLocale.find( "utf-8" ) != std::string::npos - || thisLocale == "POSIX" - || thisLocale == "C" - || thisLocale == "" ) + // language[_territory][.codeset][@modifier] + // add/exchange codeset with UTF-8 + std::string needLocale = ".UTF-8"; + std::string::size_type loc = thisLocale.find_first_of( ".@" ); + if ( loc != std::string::npos ) { - // is UTF-8 or C or POSIX - needLocale = thisLocale; - } - else - { - // language[_territory][.codeset][@modifier] - // add/exchange codeset with UTF-8 - needLocale = ".UTF-8"; - std::string::size_type loc = thisLocale.find_first_of( ".@" ); + // prepend language[_territory] + needLocale = thisLocale.substr( 0, loc ) + needLocale; + loc = thisLocale.find_last_of( "@" ); if ( loc != std::string::npos ) { - // prepend language[_territory] - needLocale = thisLocale.substr( 0, loc ) + needLocale; - loc = thisLocale.find_last_of( "@" ); - if ( loc != std::string::npos ) - { - // append [@modifier] - needLocale += thisLocale.substr( loc ); - } - } - else - { - // append ".UTF-8" - needLocale = thisLocale + needLocale; + // append [@modifier] + needLocale += thisLocale.substr( loc ); } } - lastLocale = thisLocale; + else + { + // append ".UTF-8" + needLocale = thisLocale + needLocale; + } + ::setlocale( LC_TIME, needLocale.c_str() ); } - if ( needLocale != lastLocale ) - ::setlocale( LC_TIME, needLocale.c_str() ); if ( ! strftime( buf, 1024, format_r.c_str(), localtime( &_date ) ) ) *buf = '\0'; - if ( needLocale != lastLocale ) - ::setlocale( LC_TIME, lastLocale.c_str() ); + return buf; } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
mlandres@svn.opensuse.org