[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn_cmdline_printf and errors

From: Branko Čibej <brane_at_xbc.nu>
Date: 2004-05-16 22:52:44 CEST

Peter N. Lundblad wrote:

>On Sun, 16 May 2004, [UTF-8] Branko Ä^Libej wrote:
>
>
>
>> $ man printf
>> ...
>> int printf (const char *fmt, ...)
>> ...
>> returns the number of characters written...
>>
>>
>>I don't see any reason change that.
>>
>>
>>
>According to the man page for fputs, it returns the number of bytes
>written or EOF on error and according to the glibc manual, printf returns
>a negative numer on error.
>
>So you don't see a reason to change what?
>
>
I'd keep these functions as close to standard as makes sense. Here's
what the standard has to say:

    7.19.6.1p14: The fprintf function returns the number of characters
    transmitted, or a negative value if an output or encoding error
    occurred.

    7.19.6.3p2: The printf function is equivalent to fprintf with the
    argument stdout interposed before the arguments to printf.

    7.19.6.3p3: The printf function returns the number of characters
    transmitted, or a negative value if an output or encoding error
    occurred.

    7.19.7.4p3: The fputs function returns EOF if a write error occurs;
    otherwise it returns a nonnegative value.

    7.19.1p3: EOF which expands to an integer constant expression, with
    type int and a negative value, ...

So note that according to the standard, all three of these functions can
return EOF on error and the number of transmitted chars otherwise. Which
is what I propose they do. That will also satisfy the requirements for
the streaming output functions (if they call any of these), because they
only need to know that an output error occurred, not _which_ error
occurred. I'd hate to see us have to add SVN_ERR everywhere in the code.

-- Brane

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun May 16 22:55:07 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.