From: Jarkko Hietaniemi Date: Sat, 30 Aug 2003 18:47:02 +0000 (+0000) Subject: Fewer naked char constants. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3b6c1aba8481917ec21730e293e339a1c561e02c;p=p5sagit%2Fp5-mst-13.2.git Fewer naked char constants. p4raw-id: //depot/perl@20957 --- diff --git a/doio.c b/doio.c index 18d5254..da9cd80 100644 --- a/doio.c +++ b/doio.c @@ -179,7 +179,7 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw, (ismodifying & (O_CREAT|appendtrunc))) TAINT_PROPER("sysopen"); } - mode[ix++] = '#'; /* Marker to openn to use numeric "sysopen" */ + mode[ix++] = IoTYPE_NUMERIC; /* Marker to openn to use numeric "sysopen" */ #if defined(USE_64_BIT_RAWIO) && defined(O_LARGEFILE) rawmode |= O_LARGEFILE; /* Transparently largefiley. */ @@ -674,8 +674,8 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw, if (IoTYPE(io) == IoTYPE_SOCKET || (IoTYPE(io) == IoTYPE_WRONLY && fd >= 0 && S_ISCHR(PL_statbuf.st_mode)) ) { char *s = mode; - if (*s == 'I' || *s == '#') - s++; + if (*s == IoTYPE_IMPLICIT || *s == IoTYPE_NUMERIC) + s++; *s = 'w'; if (!(IoOFP(io) = PerlIO_openn(aTHX_ type,s,fd,0,0,NULL,0,svp))) { PerlIO_close(fp); diff --git a/perlio.c b/perlio.c index 84c1f79..91b7781 100644 --- a/perlio.c +++ b/perlio.c @@ -288,7 +288,7 @@ PerlIO_openn(pTHX_ const char *layers, const char *mode, int fd, return PerlIO_tmpfile(); else { char *name = SvPV_nolen(*args); - if (*mode == '#') { + if (*mode == IoTYPE_NUMERIC) { fd = PerlLIO_open3(name, imode, perm); if (fd >= 0) return PerlIO_fdopen(fd, (char *) mode + 1); @@ -1960,7 +1960,7 @@ PerlIOBase_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab) if (tab->Set_ptrcnt != NULL) l->flags |= PERLIO_F_FASTGETS; if (mode) { - if (*mode == '#' || *mode == 'I') + if (*mode == IoTYPE_NUMERIC || *mode == IoTYPE_IMPLICIT) mode++; switch (*mode++) { case 'r': @@ -2276,7 +2276,7 @@ int PerlIOUnix_oflags(const char *mode) { int oflags = -1; - if (*mode == 'I' || *mode == '#') + if (*mode == IoTYPE_IMPLICIT || *mode == IoTYPE_NUMERIC) mode++; switch (*mode) { case 'r': @@ -2408,7 +2408,7 @@ PerlIOUnix_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, } if (narg > 0) { char *path = SvPV_nolen(*args); - if (*mode == '#') + if (*mode == IoTYPE_NUMERIC) mode++; else { imode = PerlIOUnix_oflags(mode); @@ -2419,7 +2419,7 @@ PerlIOUnix_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, } } if (fd >= 0) { - if (*mode == 'I') + if (*mode == IoTYPE_IMPLICIT) mode++; if (!f) { f = PerlIO_allocate(aTHX); @@ -2707,7 +2707,7 @@ PerlIOStdio_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, else { if (narg > 0) { char *path = SvPV_nolen(*args); - if (*mode == '#') { + if (*mode == IoTYPE_NUMERIC) { mode++; fd = PerlLIO_open3(path, imode, perm); } @@ -2743,7 +2743,7 @@ PerlIOStdio_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, if (fd >= 0) { FILE *stdio = NULL; int init = 0; - if (*mode == 'I') { + if (*mode == IoTYPE_IMPLICIT) { init = 1; mode++; } @@ -3433,7 +3433,7 @@ PerlIOBuf_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, else { PerlIO_funcs *tab = PerlIO_layer_fetch(aTHX_ layers, n - 1, PerlIO_default_btm()); int init = 0; - if (*mode == 'I') { + if (*mode == IoTYPE_IMPLICIT) { init = 1; /* * mode++; diff --git a/sv.h b/sv.h index ebdb2dd..d2113ae 100644 --- a/sv.h +++ b/sv.h @@ -788,14 +788,16 @@ and leaves the UTF8 status as it was. #define IoFLAGS(sv) ((XPVIO*) SvANY(sv))->xio_flags /* IoTYPE(sv) is a single character telling the type of I/O connection. */ -#define IoTYPE_RDONLY '<' -#define IoTYPE_WRONLY '>' -#define IoTYPE_RDWR '+' -#define IoTYPE_APPEND 'a' -#define IoTYPE_PIPE '|' -#define IoTYPE_STD '-' /* stdin or stdout */ -#define IoTYPE_SOCKET 's' -#define IoTYPE_CLOSED ' ' +#define IoTYPE_RDONLY '<' +#define IoTYPE_WRONLY '>' +#define IoTYPE_RDWR '+' +#define IoTYPE_APPEND 'a' +#define IoTYPE_PIPE '|' +#define IoTYPE_STD '-' /* stdin or stdout */ +#define IoTYPE_SOCKET 's' +#define IoTYPE_CLOSED ' ' +#define IoTYPE_IMPLICIT 'I' /* stdin or stdout or stderr */ +#define IoTYPE_NUMERIC '#' /* fdopen */ /* =for apidoc Am|bool|SvTAINTED|SV* sv