On Fri, 21 May 2004, [UTF-8] Branko Ä^Libej wrote:
> Peter N. Lundblad wrote:
>
> >On Thu, 20 May 2004 lundblad@tigris.org wrote:
> >
> >>Modified: trunk/subversion/libsvn_subr/cmdline.c
> >>==============================================================================
> >>--- trunk/subversion/libsvn_subr/cmdline.c (original)
> >>+++ trunk/subversion/libsvn_subr/cmdline.c Thu May 20 18:30:05 2004
> >>@@ -268,7 +268,21 @@
> >> out = svn_cmdline_cstring_from_utf8_fuzzy (string, pool);
> >> }
> >>
> >>- fputs (out, stream);
> >>+ /* On POSIX systems, errno will be set on an error in fputs, but this might
> >>+ not be the case on other platforms. We reset the OS error and only
> >>+ use it if it was set by the below fputs call. Else, we just return
> >>+ a generic error. */
> >>+ apr_set_os_error (APR_SUCCESS);
> >>
> >>
> This is not guaranteed to work. I also believe it is unnecessary, since
> you only check errno if fputs failed, in which case it should always
> have the correct value -- *if* the system sets it, which the C standard
> does not require. POSIX might, though.
>
The idea was to support non-POSIX systems by setting the os_error to 0
before the fputs call. Then, if fputs returns failure *and* os_error was
changed, then use it as the error. You are saying that on a non-POSIX
system, something could change the os_error in the fputs call, still it
would be some internal error or something?
> >>+ if (fputs (out, stream) == EOF)
> >>+ {
> >>+ apr_status_t status = apr_get_os_error ();
> >>
> >>
> >
> >This obviously works on my Linux box. Anyone who knows if this is correct
> >on platforms such as Win32?
> >
> >
> No, because apr_get_os_error() doesn't use errno on Win32.
>
So it uses GetLastError() then? Wouldn't a failed fputs on Windows also
set GetLastError()? But that might be relying on the implementation
internals?
Maybe it would be better to use plain errno? But I'd like not to use
strerror directly.
What I'd like is something more than the generic write error, but if it is
difficult on non-POSIX systems, I'll just return the generic one and go
on.
Thanks,
//Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri May 21 21:56:13 2004