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

View File

@ -5,6 +5,8 @@ USING: kernel printf tools.test ;
[ "%s" printf ] must-infer [ "%s" printf ] must-infer
[ "%s" sprintf ] must-infer
[ t ] [ "10" 10 "%d" sprintf = ] unit-test [ t ] [ "10" 10 "%d" sprintf = ] unit-test
[ 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 -- ) MACRO: printf ( format-string -- )
parse-format-string [ length ] keep compose-all '[ _ <vector> @ reverse [ write ] each ] ; parse-format-string [ length ] keep compose-all '[ _ <vector> @ reverse [ write ] each ] ;
: sprintf ( format-string -- ) : sprintf ( format-string -- result )
[ printf ] with-string-writer ; [ printf ] with-string-writer ; inline