summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorAaron Crane <arc@cpan.org>2017-10-13 18:16:16 +0200
committerAaron Crane <arc@cpan.org>2017-10-21 16:53:08 +0100
commitfaf558915f633171b621a29f5da0fcddd829a571 (patch)
tree5f3d0452864690870df54e29b82b3277e709f347 /perlio.c
parentda5fdda8009e6ea2085865e59ddbe437fa6ffd46 (diff)
downloadperl-faf558915f633171b621a29f5da0fcddd829a571.tar.gz
perlio.c: simplify cpp conditionals
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/perlio.c b/perlio.c
index 521c274766..054f210e37 100644
--- a/perlio.c
+++ b/perlio.c
@@ -243,22 +243,21 @@ PerlIO_fdupopen(pTHX_ PerlIO *f, CLONE_PARAMS *param, int flags)
{
#if defined(PERL_MICRO) || defined(__SYMBIAN32__)
return NULL;
-#else
-#ifdef PERL_IMPLICIT_SYS
+#elif defined(PERL_IMPLICIT_SYS)
return PerlSIO_fdupopen(f);
#else
-#ifdef WIN32
+# ifdef WIN32
return win32_fdupopen(f);
-#else
+# else
if (f) {
const int fd = PerlLIO_dup(PerlIO_fileno(f));
if (fd >= 0) {
char mode[8];
-#ifdef DJGPP
+# ifdef DJGPP
const int omode = djgpp_get_stream_mode(f);
-#else
+# else
const int omode = fcntl(fd, F_GETFL);
-#endif
+# endif
PerlIO_intmode2str(omode,mode,NULL);
/* the r+ is a hack */
return PerlIO_fdopen(fd, mode);
@@ -268,10 +267,9 @@ PerlIO_fdupopen(pTHX_ PerlIO *f, CLONE_PARAMS *param, int flags)
else {
SETERRNO(EBADF, SS_IVCHAN);
}
-#endif
+# endif
return NULL;
#endif
-#endif
}
@@ -3607,14 +3605,12 @@ PerlIOStdio_set_ptrcnt(pTHX_ PerlIO *f, STDCHAR * ptr, SSize_t cnt)
*/
#ifdef STDIO_CNT_LVALUE
PerlSIO_set_cnt(stdio, cnt);
-#else /* STDIO_CNT_LVALUE */
-#if (defined(STDIO_PTR_LVALUE) && defined(STDIO_PTR_LVAL_SETS_CNT))
+#elif (defined(STDIO_PTR_LVALUE) && defined(STDIO_PTR_LVAL_SETS_CNT))
PerlSIO_set_ptr(stdio,
PerlSIO_get_ptr(stdio) + (PerlSIO_get_cnt(stdio) -
cnt));
#else /* STDIO_PTR_LVAL_SETS_CNT */
PerlProc_abort();
-#endif /* STDIO_PTR_LVAL_SETS_CNT */
#endif /* STDIO_CNT_LVALUE */
}
@@ -5038,8 +5034,7 @@ PerlIO_tmpfile(void)
const int fd = win32_tmpfd();
if (fd >= 0)
f = PerlIO_fdopen(fd, "w+b");
-#else /* WIN32 */
-# if defined(HAS_MKSTEMP) && ! defined(VMS) && ! defined(OS2)
+#elif defined(HAS_MKSTEMP) && ! defined(VMS) && ! defined(OS2)
int fd = -1;
char tempname[] = "/tmp/PerlIO_XXXXXX";
const char * const tmpdir = TAINTING_get ? NULL : PerlEnv_getenv("TMPDIR");
@@ -5074,13 +5069,12 @@ PerlIO_tmpfile(void)
PerlLIO_unlink(sv ? SvPVX_const(sv) : tempname);
}
SvREFCNT_dec(sv);
-# else /* !HAS_MKSTEMP, fallback to stdio tmpfile(). */
+#else /* !HAS_MKSTEMP, fallback to stdio tmpfile(). */
FILE * const stdio = PerlSIO_tmpfile();
if (stdio)
f = PerlIO_fdopen(fileno(stdio), "w+");
-# endif /* else HAS_MKSTEMP */
#endif /* else WIN32 */
return f;
}