On C<sysopen(..., O_APPEND)>, call C<fopen(..., "a")>
Chip Salzenberg [Sun, 9 Feb 1997 23:36:54 +0000 (11:36 +1200)]
doio.c

diff --git a/doio.c b/doio.c
index 31c9a35..ec3181e 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -118,9 +118,16 @@ PerlIO *supplied_fp;
        if (fd == -1)
            fp = NULL;
        else {
-           fp = PerlIO_fdopen(fd, ((result == 0) ? "r"
-                            : (result == 1) ? "w"
-                            : "r+"));
+           char *fpmode;
+           if (result == 0)
+               fpmode = "r";
+#ifdef O_APPEND
+           else if (rawmode & O_APPEND)
+               fpmode = (result == 1) ? "a" : "a+";
+#endif
+           else
+               fpmode = (result == 1) ? "w" : "r+";
+           fp = PerlIO_fdopen(fd, fpmode);
            if (!fp)
                close(fd);
        }