Author: aschnell Date: Mon Aug 4 20:26:43 2008 New Revision: 49658 URL: http://svn.opensuse.org/viewcvs/yast?rev=49658&view=rev Log: - moved function Modified: trunk/storage/storage/src/include/partition_defines.ycp Modified: trunk/storage/storage/src/include/partition_defines.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/partition_defines.ycp?rev=49658&r1=49657&r2=49658&view=diff ============================================================================== --- trunk/storage/storage/src/include/partition_defines.ycp (original) +++ trunk/storage/storage/src/include/partition_defines.ycp Mon Aug 4 20:26:43 2008 @@ -58,9 +58,78 @@ // // 8 is 8k // 16K == 16k == 16KB == 16kb +// TODO: remove define integer kmgt_str_to_byte( string input ) - ``{ - return( Storage::KmgtStrToByte( input )); +{ + integer number = 0; + integer pos = findfirstnotof( input, " +" ); + + if( pos != nil && pos>0 ) + { + input = substring( input, pos ); + } + + if( size(filterchars(input, "0123456789kKmMgGtTbBoO .")) != size(input)) + { + return(0); + } + + input = filterchars(input, "0123456789kKmMgGtTbBoO."); + + if( size(input)>0 && findfirstnotof( input, "0123456789.") != nil ) + { + // check whether the last char is in "kKmM" or "bB" + string last_char = substring( input, size(input)-1, 1); + + if( last_char == "b" || last_char == "B" || + last_char == "o" || last_char == "O" ) + { + input = substring( input, 0, size(input)-1); + // check whether the last char is in "kKmM" + last_char = substring( input, size(input)-1, 1); + } + + string number_str = substring(input, 0, size(input)-1); + + if( findfirstnotof( number_str, "0123456789.") == nil ) + { + if( last_char == "k" || last_char == "K" ) + { + number = tointeger(tofloat( number_str ) * 1024.0) ; + } + else if ( last_char == "m" || last_char == "M" ) + { + number = tointeger(tofloat( number_str ) * 1024.0 * 1024.0); + } + else if ( last_char == "g" || last_char == "G" ) + { + number = tointeger(tofloat( number_str ) * + 1024.0 * 1024.0 * 1024.0); + } + else if ( last_char == "t" || last_char == "T" ) + { + number = tointeger(tofloat( number_str ) * + 1024.0 * 1024.0 * 1024.0 * 1024.0); + } + else + { + number = 0; + } + } + else + { + number = 0; + } + } + else if( size(input)==0 ) + { + number = 0; + } + else + { + number = tointeger( input ); + } + return( number ); }; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org