Some fixes to printf for help-lint warnings.

db4
John Benediktsson 2008-09-20 22:22:12 -07:00
parent 37c8d6c7f5
commit 7cbbd3e0e6
3 changed files with 8 additions and 6 deletions

View File

@ -6,7 +6,7 @@ IN: printf
HELP: printf
{ $values { "format-string" string } }
{ $description
"Writes the arguments formatted according to the format string.\n"
"Writes the arguments (specified on the stack) formatted according to the format string.\n"
{ $table
{ "%%" "Single %" "" }
{ "%P.Ds" "String format" "string" }
@ -45,7 +45,7 @@ HELP: printf
"00123" }
{ $example
"USING: printf ;"
"HEX: ff \"04X\" printf"
"HEX: ff \"%04X\" printf"
"00FF" }
{ $example
"USING: printf ;"
@ -66,7 +66,7 @@ HELP: printf
} ;
HELP: sprintf
{ $values { "params" sequence } { "format-string" string } { "result" string } }
{ $description "Returns the arguments formatted according to the format string as a result string." }
{ $values { "format-string" string } { "result" string } }
{ $description "Returns the arguments (specified on the stack) formatted according to the format string as a result string." }
{ $see-also printf } ;

View File

@ -5,6 +5,8 @@ USING: kernel printf tools.test ;
[ "%s" printf ] must-infer
[ "%s" sprintf ] must-infer
[ t ] [ "10" 10 "%d" sprintf = ] unit-test
[ t ] [ "+10" 10 "%+d" sprintf = ] unit-test

View File

@ -98,7 +98,7 @@ PRIVATE>
MACRO: printf ( format-string -- )
parse-format-string [ length ] keep compose-all '[ _ <vector> @ reverse [ write ] each ] ;
: sprintf ( format-string -- )
[ printf ] with-string-writer ;
: sprintf ( format-string -- result )
[ printf ] with-string-writer ; inline