From: Nicholas Clark Date: Tue, 5 Apr 2005 14:52:05 +0000 (+0000) Subject: Down with C++ reserved names X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0723351e0aae3b4ed046fabd41bf188a3d6a77df;p=p5sagit%2Fp5-mst-13.2.git Down with C++ reserved names (and also function pointer declarations that rely on the C semantics of ()) p4raw-id: //depot/perl@24165 --- diff --git a/ext/Storable/Storable.xs b/ext/Storable/Storable.xs index c20011e..bba6369 100644 --- a/ext/Storable/Storable.xs +++ b/ext/Storable/Storable.xs @@ -289,6 +289,7 @@ typedef unsigned long stag_t; /* Used by pre-0.6 binary format */ * perl to remap such common words. -- RAM, 29/09/00 */ +struct stcxt; typedef struct stcxt { int entry; /* flags recursion */ int optype; /* type of traversal operation */ @@ -322,7 +323,7 @@ typedef struct stcxt { PerlIO *fio; /* where I/O are performed, NULL for memory */ int ver_major; /* major of version for retrieved object */ int ver_minor; /* minor of version for retrieved object */ - SV *(**retrieve_vtbl)(); /* retrieve dispatch table */ + SV *(**retrieve_vtbl)(pTHX_ struct stcxt *, char *); /* retrieve dispatch table */ SV *prev; /* contexts chained backwards in real recursion */ SV *my_sv; /* the blessed scalar who's SvPVX() I am */ } stcxt_t; @@ -2760,7 +2761,7 @@ static int store_hook( SV *hook) { I32 len; - char *class; + char *classname; STRLEN len2; SV *ref; AV *av; @@ -2777,7 +2778,7 @@ static int store_hook( char mtype = '\0'; /* for blessed ref to tied structures */ unsigned char eflags = '\0'; /* used when object type is SHT_EXTRA */ - TRACEME(("store_hook, class \"%s\", tagged #%d", HvNAME(pkg), cxt->tagnum)); + TRACEME(("store_hook, classname \"%s\", tagged #%d", HvNAME(pkg), cxt->tagnum)); /* * Determine object type on 2 bits. @@ -2828,8 +2829,8 @@ static int store_hook( } flags = SHF_NEED_RECURSE | obj_type; - class = HvNAME(pkg); - len = strlen(class); + classname = HvNAME(pkg); + len = strlen(classname); /* * To call the hook, we need to fake a call like: @@ -2844,7 +2845,7 @@ static int store_hook( * make the call on that reference. */ - TRACEME(("about to call STORABLE_freeze on class %s", class)); + TRACEME(("about to call STORABLE_freeze on class %s", classname)); ref = newRV_noinc(sv); /* Temporary reference */ av = array_call(aTHX_ ref, hook, clone); /* @a = $object->STORABLE_freeze($c) */ @@ -2868,14 +2869,14 @@ static int store_hook( * They must not change their mind in the middle of a serialization. */ - if (hv_fetch(cxt->hclass, class, len, FALSE)) + if (hv_fetch(cxt->hclass, classname, len, FALSE)) CROAK(("Too late to ignore hooks for %s class \"%s\"", - (cxt->optype & ST_CLONE) ? "cloning" : "storing", class)); + (cxt->optype & ST_CLONE) ? "cloning" : "storing", classname)); pkg_hide(aTHX_ cxt->hook, pkg, "STORABLE_freeze"); ASSERT(!pkg_can(aTHX_ cxt->hook, pkg, "STORABLE_freeze"), ("hook invisible")); - TRACEME(("ignoring STORABLE_freeze in class \"%s\"", class)); + TRACEME(("ignoring STORABLE_freeze in class \"%s\"", classname)); return store_blessed(aTHX_ cxt, sv, type, pkg); } @@ -2908,7 +2909,7 @@ static int store_hook( if (!SvROK(rsv)) CROAK(("Item #%d returned by STORABLE_freeze " - "for %s is not a reference", i, class)); + "for %s is not a reference", i, classname)); xsv = SvRV(rsv); /* Follow ref to know what to look for */ /* @@ -2946,7 +2947,7 @@ static int store_hook( svh = hv_fetch(cxt->hseen, (char *) &xsv, sizeof(xsv), FALSE); if (!svh) - CROAK(("Could not serialize item #%d from hook in %s", i, class)); + CROAK(("Could not serialize item #%d from hook in %s", i, classname)); /* * It was the first time we serialized `xsv'. @@ -2991,11 +2992,11 @@ static int store_hook( * proposed the right fix. -- RAM, 15/09/2000 */ - if (!known_class(aTHX_ cxt, class, len, &classnum)) { - TRACEME(("first time we see class %s, ID = %d", class, classnum)); + if (!known_class(aTHX_ cxt, classname, len, &classnum)) { + TRACEME(("first time we see class %s, ID = %d", classname, classnum)); classnum = -1; /* Mark: we must store classname */ } else { - TRACEME(("already seen class %s, ID = %d", class, classnum)); + TRACEME(("already seen class %s, ID = %d", classname, classnum)); } /* @@ -3051,7 +3052,7 @@ static int store_hook( unsigned char clen = (unsigned char) len; PUTMARK(clen); } - WRITE(class, len); /* Final \0 is omitted */ + WRITE(classname, len); /* Final \0 is omitted */ } /* */ @@ -3158,7 +3159,7 @@ static int store_blessed( { SV *hook; I32 len; - char *class; + char *classname; I32 classnum; TRACEME(("store_blessed, type %d, class \"%s\"", type, HvNAME(pkg))); @@ -3176,8 +3177,8 @@ static int store_blessed( * This is a blessed SV without any serialization hook. */ - class = HvNAME(pkg); - len = strlen(class); + classname = HvNAME(pkg); + len = strlen(classname); TRACEME(("blessed 0x%"UVxf" in %s, no hook: tagged #%d", PTR2UV(sv), class, cxt->tagnum)); @@ -3189,8 +3190,8 @@ static int store_blessed( * used). */ - if (known_class(aTHX_ cxt, class, len, &classnum)) { - TRACEME(("already seen class %s, ID = %d", class, classnum)); + if (known_class(aTHX_ cxt, classname, len, &classnum)) { + TRACEME(("already seen class %s, ID = %d", classname, classnum)); PUTMARK(SX_IX_BLESS); if (classnum <= LG_BLESS) { unsigned char cnum = (unsigned char) classnum; @@ -3201,7 +3202,7 @@ static int store_blessed( WLEN(classnum); } } else { - TRACEME(("first time we see class %s, ID = %d", class, classnum)); + TRACEME(("first time we see class %s, ID = %d", classname, classnum)); PUTMARK(SX_BLESS); if (len <= LG_BLESS) { unsigned char clen = (unsigned char) len; @@ -3211,7 +3212,7 @@ static int store_blessed( PUTMARK(flag); WLEN(len); /* Don't BER-encode, this should be rare */ } - WRITE(class, len); /* Final \0 is omitted */ + WRITE(classname, len); /* Final \0 is omitted */ } /* @@ -3776,7 +3777,7 @@ static SV *retrieve_other(pTHX_ stcxt_t *cxt, char *cname) static SV *retrieve_idx_blessed(pTHX_ stcxt_t *cxt, char *cname) { I32 idx; - char *class; + char *classname; SV **sva; SV *sv; @@ -3795,15 +3796,15 @@ static SV *retrieve_idx_blessed(pTHX_ stcxt_t *cxt, char *cname) if (!sva) CROAK(("Class name #%"IVdf" should have been seen already", (IV) idx)); - class = SvPVX(*sva); /* We know it's a PV, by construction */ + classname = SvPVX(*sva); /* We know it's a PV, by construction */ - TRACEME(("class ID %d => %s", idx, class)); + TRACEME(("class ID %d => %s", idx, classname)); /* * Retrieve object and bless it. */ - sv = retrieve(aTHX_ cxt, class); /* First SV which is SEEN will be blessed */ + sv = retrieve(aTHX_ cxt, classname); /* First SV which is SEEN will be blessed */ return sv; } @@ -3819,7 +3820,7 @@ static SV *retrieve_blessed(pTHX_ stcxt_t *cxt, char *cname) I32 len; SV *sv; char buf[LG_BLESS + 1]; /* Avoid malloc() if possible */ - char *class = buf; + char *classname = buf; TRACEME(("retrieve_blessed (#%d)", cxt->tagnum)); ASSERT(!cname, ("no bless-into class given here, got %s", cname)); @@ -3835,27 +3836,27 @@ static SV *retrieve_blessed(pTHX_ stcxt_t *cxt, char *cname) if (len & 0x80) { RLEN(len); TRACEME(("** allocating %d bytes for class name", len+1)); - New(10003, class, len+1, char); + New(10003, classname, len+1, char); } - READ(class, len); - class[len] = '\0'; /* Mark string end */ + READ(classname, len); + classname[len] = '\0'; /* Mark string end */ /* * It's a new classname, otherwise it would have been an SX_IX_BLESS. */ - TRACEME(("new class name \"%s\" will bear ID = %d", class, cxt->classnum)); + TRACEME(("new class name \"%s\" will bear ID = %d", classname, cxt->classnum)); - if (!av_store(cxt->aclass, cxt->classnum++, newSVpvn(class, len))) + if (!av_store(cxt->aclass, cxt->classnum++, newSVpvn(classname, len))) return (SV *) 0; /* * Retrieve object and bless it. */ - sv = retrieve(aTHX_ cxt, class); /* First SV which is SEEN will be blessed */ - if (class != buf) - Safefree(class); + sv = retrieve(aTHX_ cxt, classname); /* First SV which is SEEN will be blessed */ + if (classname != buf) + Safefree(classname); return sv; } @@ -3884,7 +3885,7 @@ static SV *retrieve_hook(pTHX_ stcxt_t *cxt, char *cname) { I32 len; char buf[LG_BLESS + 1]; /* Avoid malloc() if possible */ - char *class = buf; + char *classname = buf; unsigned int flags; I32 len2; SV *frozen; @@ -3995,8 +3996,8 @@ static SV *retrieve_hook(pTHX_ stcxt_t *cxt, char *cname) CROAK(("Class name #%"IVdf" should have been seen already", (IV) idx)); - class = SvPVX(*sva); /* We know it's a PV, by construction */ - TRACEME(("class ID %d => %s", idx, class)); + classname = SvPVX(*sva); /* We know it's a PV, by construction */ + TRACEME(("class ID %d => %s", idx, classname)); } else { /* @@ -4014,21 +4015,21 @@ static SV *retrieve_hook(pTHX_ stcxt_t *cxt, char *cname) if (len > LG_BLESS) { TRACEME(("** allocating %d bytes for class name", len+1)); - New(10003, class, len+1, char); + New(10003, classname, len+1, char); } - READ(class, len); - class[len] = '\0'; /* Mark string end */ + READ(classname, len); + classname[len] = '\0'; /* Mark string end */ /* * Record new classname. */ - if (!av_store(cxt->aclass, cxt->classnum++, newSVpvn(class, len))) + if (!av_store(cxt->aclass, cxt->classnum++, newSVpvn(classname, len))) return (SV *) 0; } - TRACEME(("class name: %s", class)); + TRACEME(("class name: %s", classname)); /* * Decode user-frozen string length and read it in an SV. @@ -4113,7 +4114,7 @@ static SV *retrieve_hook(pTHX_ stcxt_t *cxt, char *cname) * Bless the object and look up the STORABLE_thaw hook. */ - BLESS(sv, class); + BLESS(sv, classname); hook = pkg_can(aTHX_ cxt->hook, SvSTASH(sv), "STORABLE_thaw"); if (!hook) { /* @@ -4126,10 +4127,10 @@ static SV *retrieve_hook(pTHX_ stcxt_t *cxt, char *cname) */ SV *psv = newSVpvn("require ", 8); - sv_catpv(psv, class); + sv_catpv(psv, classname); - TRACEME(("No STORABLE_thaw defined for objects of class %s", class)); - TRACEME(("Going to require module '%s' with '%s'", class, SvPVX(psv))); + TRACEME(("No STORABLE_thaw defined for objects of class %s", classname)); + TRACEME(("Going to require module '%s' with '%s'", classname, SvPVX(psv))); perl_eval_sv(psv, G_DISCARD); sv_free(psv); @@ -4144,7 +4145,7 @@ static SV *retrieve_hook(pTHX_ stcxt_t *cxt, char *cname) if (!hook) CROAK(("No STORABLE_thaw defined for objects of class %s " - "(even after a \"require %s;\")", class, class)); + "(even after a \"require %s;\")", classname, classname)); } /* @@ -4175,7 +4176,7 @@ static SV *retrieve_hook(pTHX_ stcxt_t *cxt, char *cname) */ TRACEME(("calling STORABLE_thaw on %s at 0x%"UVxf" (%"IVdf" args)", - class, PTR2UV(sv), (IV) AvFILLp(av) + 1)); + classname, PTR2UV(sv), (IV) AvFILLp(av) + 1)); rv = newRV(sv); (void) scalar_call(aTHX_ rv, hook, clone, av, G_SCALAR|G_DISCARD); @@ -4188,8 +4189,8 @@ static SV *retrieve_hook(pTHX_ stcxt_t *cxt, char *cname) SvREFCNT_dec(frozen); av_undef(av); sv_free((SV *) av); - if (!(flags & SHF_IDX_CLASSNAME) && class != buf) - Safefree(class); + if (!(flags & SHF_IDX_CLASSNAME) && classname != buf) + Safefree(classname); /* * If we had an type, then the object was not as simple, and diff --git a/mg.c b/mg.c index f56812e..b07be11 100644 --- a/mg.c +++ b/mg.c @@ -146,7 +146,7 @@ Perl_mg_get(pTHX_ SV *sv) { const I32 mgs_ix = SSNEW(sizeof(MGS)); const bool was_temp = (bool)SvTEMP(sv); - int new = 0; + int have_new = 0; MAGIC *newmg, *head, *cur, *mg; /* guard against sv having being freed midway by holding a private reference. */ @@ -185,19 +185,19 @@ Perl_mg_get(pTHX_ SV *sv) mg = mg->mg_moremagic; - if (new) { + if (have_new) { /* Have we finished with the new entries we saw? Start again where we left off (unless there are more new entries). */ if (mg == head) { - new = 0; + have_new = 0; mg = cur; head = newmg; } } /* Were any new entries added? */ - if (!new && (newmg = SvMAGIC(sv)) != head) { - new = 1; + if (!have_new && (newmg = SvMAGIC(sv)) != head) { + have_new = 1; cur = mg; mg = newmg; } diff --git a/op.c b/op.c index 8421638..f675e72 100644 --- a/op.c +++ b/op.c @@ -6177,7 +6177,7 @@ Perl_ck_subr(pTHX_ OP *o) I32 contextclass = 0; char *e = 0; STRLEN n_a; - bool delete=0; + bool delete_op = 0; o->op_private |= OPpENTERSUB_HASTARG; for (cvop = o2; cvop->op_sibling; cvop = cvop->op_sibling) ; @@ -6202,7 +6202,7 @@ Perl_ck_subr(pTHX_ OP *o) o->op_private |= OPpENTERSUB_DB; } else { - delete=1; + delete_op = 1; if (ckWARN(WARN_ASSERTIONS) && !(PL_hints & HINT_ASSERTIONSSEEN)) { Perl_warner(aTHX_ packWARN(WARN_ASSERTIONS), "Impossible to activate assertion call"); @@ -6390,7 +6390,7 @@ Perl_ck_subr(pTHX_ OP *o) if (proto && !optional && (*proto && *proto != '@' && *proto != '%' && *proto != ';')) return too_few_arguments(o, gv_ename(namegv)); - if(delete) { + if(delete_op) { op_free(o); o=newSVOP(OP_CONST, 0, newSViv(0)); } diff --git a/perlio.c b/perlio.c index 46afce7..04677b8 100644 --- a/perlio.c +++ b/perlio.c @@ -2389,7 +2389,7 @@ IV PerlIOUnix_seek(pTHX_ PerlIO *f, Off_t offset, int whence) { int fd = PerlIOSelf(f, PerlIOUnix)->fd; - Off_t new; + Off_t new_loc; if (PerlIOBase(f)->flags & PERLIO_F_NOTREG) { #ifdef ESPIPE SETERRNO(ESPIPE, LIB_INVARG); @@ -2398,8 +2398,8 @@ PerlIOUnix_seek(pTHX_ PerlIO *f, Off_t offset, int whence) #endif return -1; } - new = PerlLIO_lseek(fd, offset, whence); - if (new == (Off_t) - 1) + new_loc = PerlLIO_lseek(fd, offset, whence); + if (new_loc == (Off_t) - 1) { return -1; } diff --git a/pp_sort.c b/pp_sort.c index 850b44b..1bd5719 100644 --- a/pp_sort.c +++ b/pp_sort.c @@ -1503,7 +1503,7 @@ PP(pp_sort) bool hasargs = FALSE; I32 is_xsub = 0; I32 sorting_av = 0; - U8 private = PL_op->op_private; + U8 priv = PL_op->op_private; U8 flags = PL_op->op_flags; void (*sortsvp)(pTHX_ SV **array, size_t nmemb, SVCOMPARE_t cmp) = Perl_sortsv; @@ -1566,7 +1566,7 @@ PP(pp_sort) /* optimiser converts "@a = sort @a" to "sort \@a"; * in case of tied @a, pessimise: push (@a) onto stack, then assign * result back to @a at the end of this function */ - if (private & OPpSORT_INPLACE) { + if (priv & OPpSORT_INPLACE) { assert( MARK+1 == SP && *SP && SvTYPE(*SP) == SVt_PVAV); (void)POPMARK; /* remove mark associated with ex-OP_AASSIGN */ av = (AV*)(*SP); @@ -1589,7 +1589,7 @@ PP(pp_sort) max = SP - MARK; } - if (private & OPpSORT_DESCEND) { + if (priv & OPpSORT_DESCEND) { sortsvp = S_sortsv_desc; } @@ -1668,8 +1668,8 @@ PP(pp_sort) MEXTEND(SP, 20); /* Can't afford stack realloc on signal. */ start = sorting_av ? AvARRAY(av) : ORIGMARK+1; sortsvp(aTHX_ start, max, - (private & OPpSORT_NUMERIC) - ? ( (private & OPpSORT_INTEGER) + (priv & OPpSORT_NUMERIC) + ? ( (priv & OPpSORT_INTEGER) ? ( overloading ? amagic_i_ncmp : sv_i_ncmp) : ( overloading ? amagic_ncmp : sv_ncmp)) : ( IN_LOCALE_RUNTIME @@ -1678,7 +1678,7 @@ PP(pp_sort) : sv_cmp_locale_static) : ( overloading ? amagic_cmp : sv_cmp_static))); } - if (private & OPpSORT_REVERSE) { + if (priv & OPpSORT_REVERSE) { SV **q = start+max-1; while (start < q) { SV *tmp = *start; diff --git a/universal.c b/universal.c index 149355f..a90ba5d 100644 --- a/universal.c +++ b/universal.c @@ -398,7 +398,7 @@ XS(XS_version_new) Perl_croak(aTHX_ "Usage: version::new(class, version)"); SP -= items; { - const char *class = SvPV_nolen(ST(0)); + const char *classname = SvPV_nolen(ST(0)); SV *vs = ST(1); SV *rv; if (items == 3 ) @@ -408,8 +408,8 @@ XS(XS_version_new) } rv = new_version(vs); - if ( strcmp(class,"version") != 0 ) /* inherited new() */ - sv_bless(rv, gv_stashpv(class,TRUE)); + if ( strcmp(classname,"version") != 0 ) /* inherited new() */ + sv_bless(rv, gv_stashpv(classname,TRUE)); PUSHs(sv_2mortal(rv)); PUTBACK;