Subject: | [PATCH] fix O_CREAT without O_TRUNC in utf8_open.t |
Date: | Tue, 23 Jul 2013 22:28:29 -0500 |
To: | bug-autodie [...] rt.cpan.org |
From: | "Craig A. Berry" <craigberry [...] mac.com> |
The attached patch fixes a sysopen call in utf8_open.t that specifies O_CREAT without also specifying O_TRUNC. If you want the behavior you would get by creating a file, you have to specify O_TRUNC if the file already exists, which it definitely does in this case. See <http://pubs.opengroup.org/onlinepubs/009695399/functions/open.html>.
This fixes a test failure on VMS. Other platforms seem to be more forgiving. And here's the patch inline:
--- a/cpan/autodie/t/utf8_open.t
+++ b/cpan/autodie/t/utf8_open.t
@@ -96,7 +96,7 @@ else {
# open for writing only
{
- sysopen my $fh, $file, O_CREAT|O_WRONLY;
+ sysopen my $fh, $file, O_CREAT|O_TRUNC|O_WRONLY;
my @layers = PerlIO::get_layers($fh);
ok( (grep { $_ eq 'utf8' } @layers), "open write honors open pragma" ) or diag join ", ", @layers;
[end]
Show quoted text
________________________________________
Craig A. Berry
mailto:craigberry@mac.com
"... getting out of a sonnet is much more
difficult than getting in."
Brad Leithauser
Message body is not shown because sender requested not to inline it.