Author: aschnell Date: Tue Mar 24 13:18:00 2009 New Revision: 56368 URL: http://svn.opensuse.org/viewcvs/yast?rev=56368&view=rev Log: - cleanup Modified: trunk/storage/libstorage/src/AppUtil.cc trunk/storage/libstorage/src/AsciiFile.h trunk/storage/libstorage/src/EtcFstab.cc trunk/storage/libstorage/src/Storage.cc Modified: trunk/storage/libstorage/src/AppUtil.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.cc?rev=56368&r1=56367&r2=56368&view=diff ============================================================================== --- trunk/storage/libstorage/src/AppUtil.cc (original) +++ trunk/storage/libstorage/src/AppUtil.cc Tue Mar 24 13:18:00 2009 @@ -487,10 +487,11 @@ unsigned ret = 0; AsciiFile file("/proc/devices"); + const vector<string>& lines = file.lines(); Regex rx("^" + Regex::ws + "([0-9]+)" + Regex::ws + string(driver) + "$"); - if (file.find_if(regex_matches(rx)) >= 0) + if (find_if(lines.begin(), lines.end(), regex_matches(rx)) != lines.end()) rx.cap(1) >> ret; else y2err("did not find " << driver << " in /proc/devices"); Modified: trunk/storage/libstorage/src/AsciiFile.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AsciiFile.h?rev=56368&r1=56367&r2=56368&view=diff ============================================================================== --- trunk/storage/libstorage/src/AsciiFile.h (original) +++ trunk/storage/libstorage/src/AsciiFile.h Tue Mar 24 13:18:00 2009 @@ -40,7 +40,7 @@ string& operator []( unsigned int Index_iv ); template <class Pred> - int find_if(Pred pred) const + int find_if_idx(Pred pred) const { vector<string>::const_iterator it = std::find_if(Lines_C.begin(), Lines_C.end(), pred); if (it == Lines_C.end()) Modified: trunk/storage/libstorage/src/EtcFstab.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/EtcFstab.cc?rev=56368&r1=56367&r2=56368&view=diff ============================================================================== --- trunk/storage/libstorage/src/EtcFstab.cc (original) +++ trunk/storage/libstorage/src/EtcFstab.cc Tue Mar 24 13:18:00 2009 @@ -419,7 +419,7 @@ ret = fstab; reg = "^[ \t]*" + e.dentry + "[ \t]"; } - lineno = ret->find_if(regex_matches(reg)); + lineno = ret->find_if_idx(regex_matches(reg)); y2mil("fstab:" << fstab << " cryptotab:" << cryptotab << " lineno:" << lineno); return( ret ); } @@ -435,7 +435,7 @@ reg += "[ \t]+" + mount; if( mount.length()>0 && mount[mount.length()-1] != '/' ) reg += "/"; - int lineno = tab.find_if(regex_matches(reg)); + int lineno = tab.find_if_idx(regex_matches(reg)); y2mil("reg:" << reg << " lineno:" << lineno); return( lineno ); } @@ -445,11 +445,11 @@ { y2mil("dev:" << e.device); string reg = "^[ \t]*[^ \t]+[ \t]+" + e.device + "[ \t]"; - lineno = tab.find_if(regex_matches(reg)); + lineno = tab.find_if_idx(regex_matches(reg)); if( lineno<0 ) { reg = "^[ \t]*" + e.dentry + "[ \t]"; - lineno = tab.find_if(regex_matches(reg)); + lineno = tab.find_if_idx(regex_matches(reg)); } y2mil("reg:" << reg << " lineno:" << lineno); return( lineno>=0 ); @@ -460,7 +460,7 @@ { y2mil("dev:" << dev.c_str()); string reg = "^[ \t]*[^ \t]+[ \t]+" + dev + "[ \t]"; - lineno = tab.find_if(regex_matches(reg)); + lineno = tab.find_if_idx(regex_matches(reg)); y2mil("reg:" << reg << " lineno:" << lineno); return( lineno>=0 ); } Modified: trunk/storage/libstorage/src/Storage.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=56368&r1=56367&r2=56368&view=diff ============================================================================== --- trunk/storage/libstorage/src/Storage.cc (original) +++ trunk/storage/libstorage/src/Storage.cc Tue Mar 24 13:18:00 2009 @@ -135,8 +135,9 @@ if( access( "/etc/sysconfig/storage", R_OK )==0 ) { AsciiFile sc( "/etc/sysconfig/storage" ); + const vector<string>& lines = sc.lines(); Regex rx('^' + Regex::ws + "DEVICE_NAMES" + '=' + "(['\"]?)([^'\"]*)\\1" + Regex::ws + '$'); - if (sc.find_if(regex_matches(rx)) >= 0) + if (find_if(lines.begin(), lines.end(), regex_matches(rx)) != lines.end()) { string val = boost::to_lower_copy(rx.cap(2), locale::classic()); if( val == "id" ) @@ -339,7 +340,7 @@ if( proc_arch == "ppc" ) { AsciiFile cpu( "/proc/cpuinfo" ); - int l = cpu.find_if(string_starts_with("machine\t")); + int l = cpu.find_if_idx(string_starts_with("machine\t")); y2mil("line:" << l); if( l >= 0 ) { @@ -810,12 +811,14 @@ const VolIterator& end ) { AsciiFile vd( file ); + const vector<string>& lines = vd.lines(); + for( VolIterator i=begin; i!=end; ++i ) { - int pos = vd.find_if(string_starts_with(i->device() + " ")); - if (pos >= 0) + vector<string>::const_iterator pos = find_if(lines.begin(), lines.end(), string_starts_with(i->device() + " ")); + if (pos != lines.end()) { - i->getTestmodeData( vd[pos] ); + i->getTestmodeData(*pos); } i->getFstabData( *fstab ); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org