On 04/06/2012 01:46 AM, Dave Thompson wrote: >> AES_KEY actx, dctx; >> printf("\n keylen = %d; kebits= %d", KEYLEN, KEYBITS); >> > Get out of the habit of outputting 'partial' lines (not > terminated by \n) in C. Sometimes it works and sometimes > it doesn't. It appears in this case on your system it didn't. > The standard requires complete lines to work (up to possibly > a reasonable documented length limit) and if they don't (and > you didn't screw up something else) you can complain to your > implementor; incomplete lines are formally undefined behavior > which means the implementation can do anything it likes and > needn't even document it, although in practice implementors > try to do something reasonably sane if possible.
I've looked through my copy of the C99 standard and the C89 standard, because I could not believe I'd overlooked such a caveat on printf. Can you provide any links to any document which suggests that the behaviour of printf for output sequences not terminated with a newline leads to undefined behaviour? To the best of my knowledge there can be a restriction on the number of characters output in a single call to printf, but nowhere can I find any suggestion that a newline is required or even recommended. Building an output line in pieces with separate calls to printf to construct the pieces is a common programming practice. It can lead to cleaner and clearer code - you output things as soon as they are ready and at the point where you know the output type and the format appropriate to that particular datum, rather than saving the various pieces which will make up a line of output, their types and formatting details until you have a complete output line. It's my belief that any C standard library which doesn't handle partial lines of output is so severely broken as to make any use of that library a risky proposition. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org