Author: aschnell Date: Wed Aug 13 15:35:31 2008 New Revision: 50023 URL: http://svn.opensuse.org/viewcvs/yast?rev=50023&view=rev Log: - added tohexstring builtin with width parameter Modified: trunk/core/VERSION trunk/core/libycp/src/YCPBuiltinString.cc trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.err trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.out trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.ycp trunk/core/package/yast2-core.changes Modified: trunk/core/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/VERSION?rev=50023&r1=50022&r2=50023&view=diff ============================================================================== --- trunk/core/VERSION (original) +++ trunk/core/VERSION Wed Aug 13 15:35:31 2008 @@ -1 +1 @@ -2.17.7 +2.17.8 Modified: trunk/core/libycp/src/YCPBuiltinString.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPBuiltinString.cc?rev=50023&r1=50022&r2=50023&view=diff ============================================================================== --- trunk/core/libycp/src/YCPBuiltinString.cc (original) +++ trunk/core/libycp/src/YCPBuiltinString.cc Wed Aug 13 15:35:31 2008 @@ -202,24 +202,51 @@ static YCPValue -s_tohexstring (const YCPInteger &i) +s_tohexstring1 (const YCPInteger &i) { /** * @builtin tohexstring + * @id tohexstring-1 * @short Converts an integer to a hexadecimal string. * @param integer number Number * @return string number in Hex * * @description - * + * * @usage tohexstring (31) -> "0x1f" */ if (i.isNull ()) return YCPNull (); - char buffer[66]; - snprintf (buffer, 66, "0x%x", int (i->value ())); + char buffer[64 + 3]; + snprintf (buffer, 64 + 3, "0x%llx", i->value ()); + return YCPString (buffer); +} + + +static YCPValue +s_tohexstring2 (const YCPInteger &i, const YCPInteger &w) +{ + /** + * @builtin tohexstring + * @id tohexstring-2 + * @short Converts an integer to a hexadecimal string. + * @param integer number Number + * @param integer width Width + * @return string number in Hex + * + * @description + * + * @usage tohexstring (31, 1) -> "0x1f" + * @usage tohexstring (31, 4) -> "0x001f" + */ + + if (i.isNull () || w.isNull()) + return YCPNull (); + + char buffer[64 + 3]; + snprintf (buffer, 64 + 3, "0x%0*llx", (int) w->value(), i->value ()); return YCPString (buffer); } @@ -1351,7 +1378,8 @@ { "+", "string (string, symbol)", (void *)s_plus4 }, { "issubstring", "boolean (string, string)", (void *)s_issubstring }, { "tostring", "string (any)", (void *)s_tostring }, - { "tohexstring", "string (integer)", (void *)s_tohexstring }, + { "tohexstring", "string (integer)", (void *)s_tohexstring1 }, + { "tohexstring", "string (integer, integer)", (void *)s_tohexstring2 }, { "size", "integer (string)", (void *)s_size }, { "find", "integer (string, string)", (void *)s_find, DECL_DEPRECATED }, { "search", "integer (string, string)", (void *)s_search }, Modified: trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.err URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.err?rev=50023&r1=50022&r2=50023&view=diff ============================================================================== --- trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.err (original) +++ trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.err Wed Aug 13 15:35:31 2008 @@ -180,3 +180,7 @@ ---------------------------------------------------------------------- tohexstring (31) ---------------------------------------------------------------------- +Parsed: +---------------------------------------------------------------------- +tohexstring (31, 4) +---------------------------------------------------------------------- Modified: trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.out URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.out?rev=50023&r1=50022&r2=50023&view=diff ============================================================================== --- trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.out (original) +++ trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.out Wed Aug 13 15:35:31 2008 @@ -43,3 +43,4 @@ ("63.0000") ("0.1235") ("0x1f") +("0x001f") Modified: trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.ycp?rev=50023&r1=50022&r2=50023&view=diff ============================================================================== --- trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.ycp (original) +++ trunk/core/libycp/testsuite/tests/builtin/Builtin-String1.ycp Wed Aug 13 15:35:31 2008 @@ -82,4 +82,5 @@ (tostring (tofloat (63), 4)) (tostring (0.12345, 4)) (tohexstring (31)) +(tohexstring (31, 4)) Modified: trunk/core/package/yast2-core.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/package/yast2-core.changes?rev=50023&r1=50022&r2=50023&view=diff ============================================================================== --- trunk/core/package/yast2-core.changes (original) +++ trunk/core/package/yast2-core.changes Wed Aug 13 15:35:31 2008 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Wed Aug 13 15:10:50 CEST 2008 - aschnell@suse.de + +- added tohexstring builtin with width parameter +- 2.17.8 + +------------------------------------------------------------------- Fri Aug 8 14:56:07 CEST 2008 - locilka@suse.cz - Re-added support to build libycp documentation in separate files -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org