summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-10-20 14:25:37 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-10-20 14:25:37 +0000
commit06c7082d6226d352105bade1a7e185ff0a49e896 (patch)
tree39eedf1073fc64f1b55d2314cbb1ba0b0ab85691 /doio.c
parented1c0269a31901e89fe8c0090d5c6cb7881eeb2f (diff)
downloadperl-06c7082d6226d352105bade1a7e185ff0a49e896.tar.gz
Extract doio.c's open(2) mode to string conversion as PerlIO_intmod2str()
Use for non-PERLIO fdupopen(). p4raw-id: //depot/perlio@12532
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c42
1 files changed, 2 insertions, 40 deletions
diff --git a/doio.c b/doio.c
index ebcd07194f..462c8841b8 100644
--- a/doio.c
+++ b/doio.c
@@ -158,45 +158,7 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
rawmode |= O_LARGEFILE; /* Transparently largefiley. */
#endif
-#ifndef O_ACCMODE
-#define O_ACCMODE 3 /* Assume traditional implementation */
-#endif
-
- switch (result = rawmode & O_ACCMODE) {
- case O_RDONLY:
- IoTYPE(io) = IoTYPE_RDONLY;
- break;
- case O_WRONLY:
- IoTYPE(io) = IoTYPE_WRONLY;
- break;
- case O_RDWR:
- default:
- IoTYPE(io) = IoTYPE_RDWR;
- break;
- }
- writing = (result != O_RDONLY);
-
- if (result == O_RDONLY) {
- mode[ix++] = 'r';
- }
-#ifdef O_APPEND
- else if (rawmode & O_APPEND) {
- mode[ix++] = 'a';
- if (result != O_WRONLY)
- mode[ix++] = '+';
- }
-#endif
- else {
- if (result == O_WRONLY)
- mode[ix++] = 'w';
- else {
- mode[ix++] = 'r';
- mode[ix++] = '+';
- }
- }
- if (rawmode & O_BINARY)
- mode[ix++] = 'b';
- mode[ix] = '\0';
+ IoTYPE(io) = PerlIO_intmode2str(rawmode, &mode[ix], &writing);
namesv = sv_2mortal(newSVpvn(name,strlen(name)));
num_svs = 1;
@@ -1693,7 +1655,7 @@ nothing in the core.
if ( accessed == &PL_sv_undef && modified == &PL_sv_undef )
utbufp = NULL;
-
+
Zero(&utbuf, sizeof utbuf, char);
#ifdef BIG_TIME
utbuf.actime = (Time_t)SvNVx(accessed); /* time accessed */