James Morrison <[EMAIL PROTECTED]> writes: |> Hello, |> I've noticed that on GNU/Hurd snprintf doesn't work if |> the expanded template exceeds the size given. |> |> eg |> char limited[5]; |> snprintf(limited,5,"12345"); |> |> On GNU/Linux with libio snprintf sets limited to "1234" and returns |> 5.
This is correct: 7.19.6.5 The snprintf function [#2] The snprintf function is equivalent to fprintf, except that the output is written into an array (specified by argument s) rather than to a stream. If n is zero, nothing is written, and s may be a null pointer. Otherwise, output characters beyond the n-1st are discarded rather than being written to the array, and a null character is written at the end of the characters actually written into the array. If copying takes place between objects that overlap, the behavior is undefined. Returns [#3] The snprintf function returns the number of characters that would have been written had n been sufficiently large, not counting the terminating null character, or a neg ative value if an encoding error occurred. Thus, the null-terminated output has been completely written if and only if the returned value is nonnegative and less than n. Andreas. -- Andreas Schwab "And now for something [EMAIL PROTECTED] completely different." SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 _______________________________________________ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd