Olaf Dabrunz wrote:
> to reproduce this in vim:
>
> :echo system('md5sum', '')
> E677: Error writing temp file
>
> With the patch below, there is no error and the result is as expected:
>
> :echo system('md5sum', '')
> d41d8cd98f00b204e9800998ecf8427e -
>
> Tested against vim 7.4.000 on Ubuntu 12.04. The patch below is against
> the current hg repo.
>
>
> diff -r 7af530381fec src/eval.c
> --- a/src/eval.c Sun Aug 17 17:24:07 2014 +0200
> +++ b/src/eval.c Tue Aug 19 21:13:14 2014 +0200
> @@ -18575,13 +18575,16 @@
> }
> else
> {
> + size_t len;
> +
> p = get_tv_string_buf_chk(&argvars[1], buf);
> if (p == NULL)
> {
> fclose(fd);
> goto errret; /* type error; errmsg already given */
> }
> - if (fwrite(p, STRLEN(p), 1, fd) != 1)
> + len = STRLEN(p);
> + if (len && fwrite(p, len, 1, fd) != 1)
> err = TRUE;
> }
> if (fclose(fd) != 0)
>
>
> This avoids checking for the case where fwrite() returns 0 because
> legitimately 0 bytes were written, and handles this as a non-error
> upfront.
>
> My fwrite(3) man page on Linux does not mention this non-error reason
> for returning 0, there are only error cases. But the POSIX-derived
> fwrite(3posix) does:
>
> RETURN VALUE
> The fwrite() function shall return the number of elements
> successfully written, which may be less than nitems if a write
> error is encountered. If size or nitems is 0, fwrite() shall
> return 0 and the state of the stream remains unchanged.
> Otherwise, if a write error occurs, the error indicator for the
> stream shall be set, and errno shall be set to indicate the
> error.
>
> This makes me believe that the fix should work with all POSIX-compliant
> fwrite()s.
>
> There is only one instace of fwrite() in eval.c, so maybe no other fixes
> needed.
>
>
> BTW, systemlist() uses putc(). I do not have systemlist() in my vim yet,
> but looking at the source, it should not have problems with an empty
> list.
Thanks for looking into this and providing a patch.
--
Just remember...if the world didn't suck, we'd all fall off.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.