From: Andy Lester Date: Fri, 30 Dec 2005 23:05:58 +0000 (-0600) Subject: Making 0 pointers to NULLs X-Git-Tag: perl-5.9.3~267 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/cbbf89328f29f925842d180c1410e324b297744d Making 0 pointers to NULLs Message-ID: <20051231050558.GA29093@petdance.com> p4raw-id: //depot/perl@26558 --- diff --git a/doio.c b/doio.c index a956af0..fea7c5d 100644 --- a/doio.c +++ b/doio.c @@ -1053,7 +1053,7 @@ Perl_do_eof(pTHX_ GV *gv) Off_t Perl_do_tell(pTHX_ GV *gv) { - register IO *io = 0; + register IO *io = NULL; register PerlIO *fp; if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) { @@ -1072,7 +1072,7 @@ Perl_do_tell(pTHX_ GV *gv) bool Perl_do_seek(pTHX_ GV *gv, Off_t pos, int whence) { - register IO *io = 0; + register IO *io = NULL; register PerlIO *fp; if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) { @@ -1091,7 +1091,7 @@ Perl_do_seek(pTHX_ GV *gv, Off_t pos, int whence) Off_t Perl_do_sysseek(pTHX_ GV *gv, Off_t pos, int whence) { - register IO *io = 0; + register IO *io = NULL; register PerlIO *fp; if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) diff --git a/doop.c b/doop.c index 75cbd3e..c163182 100644 --- a/doop.c +++ b/doop.c @@ -399,7 +399,8 @@ STATIC I32 S_do_trans_count_utf8(pTHX_ SV *sv) { const U8 *s; - const U8 *start = 0, *send; + const U8 *start = NULL; + const U8 *send; I32 matches = 0; STRLEN len; diff --git a/hv.c b/hv.c index 918404c..a2e9443 100644 --- a/hv.c +++ b/hv.c @@ -2257,7 +2257,7 @@ S_unshare_hek_or_pvn(pTHX_ const HEK *hek, const char *str, I32 len, U32 hash) bool is_utf8 = FALSE; int k_flags = 0; const char * const save = str; - struct shared_he *he = 0; + struct shared_he *he = NULL; if (hek) { /* Find the shared he which is just before us in memory. */ diff --git a/mg.c b/mg.c index 44e48d2..a5ee470 100644 --- a/mg.c +++ b/mg.c @@ -1206,7 +1206,7 @@ Perl_magic_clearsig(pTHX_ SV *sv, MAGIC *mg) register const char * const s = MgPV_nolen_const(mg); PERL_UNUSED_ARG(sv); if (*s == '_') { - SV** svp = 0; + SV** svp = NULL; if (strEQ(s,"__DIE__")) svp = &PL_diehook; else if (strEQ(s,"__WARN__")) @@ -1215,7 +1215,7 @@ Perl_magic_clearsig(pTHX_ SV *sv, MAGIC *mg) Perl_croak(aTHX_ "No such hook: %s", s); if (svp && *svp) { SV * const to_dec = *svp; - *svp = 0; + *svp = NULL; SvREFCNT_dec(to_dec); } } @@ -1345,12 +1345,12 @@ Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg) { dVAR; I32 i; - SV** svp = 0; + SV** svp = NULL; /* Need to be careful with SvREFCNT_dec(), because that can have side * effects (due to closures). We must make sure that the new disposition * is in place before it is called. */ - SV* to_dec = 0; + SV* to_dec = NULL; STRLEN len; #ifdef HAS_SIGPROCMASK sigset_t set, save; @@ -1368,7 +1368,7 @@ Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg) i = 0; if (*svp) { to_dec = *svp; - *svp = 0; + *svp = NULL; } } else { diff --git a/pp.c b/pp.c index d679f6a..1ebbf49 100644 --- a/pp.c +++ b/pp.c @@ -2918,7 +2918,7 @@ PP(pp_substr) const char *tmps; const I32 arybase = PL_curcop->cop_arybase; SV *repl_sv = NULL; - const char *repl = 0; + const char *repl = NULL; STRLEN repl_len; const int num_args = PL_op->op_private & 7; bool repl_need_utf8_upgrade = FALSE; @@ -4018,7 +4018,7 @@ PP(pp_splice) I32 newlen; I32 after; I32 diff; - SV **tmparyval = 0; + SV **tmparyval = NULL; const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied); if (mg) { diff --git a/pp_ctl.c b/pp_ctl.c index 12f3f04..f1c468e 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -407,7 +407,7 @@ PP(pp_formline) bool item_is_utf8 = FALSE; bool targ_is_utf8 = FALSE; SV * nsv = NULL; - OP * parseres = 0; + OP * parseres = NULL; const char *fmt; bool oneline; @@ -2250,12 +2250,12 @@ S_dofindlabel(pTHX_ OP *o, const char *label, OP **opstack, OP **oplimit) PP(pp_goto) { dVAR; dSP; - OP *retop = 0; + OP *retop = NULL; I32 ix; register PERL_CONTEXT *cx; #define GOTO_DEPTH 64 OP *enterops[GOTO_DEPTH]; - const char *label = 0; + const char *label = NULL; const bool do_dump = (PL_op->op_type == OP_DUMP); static const char must_have_label[] = "goto must have label"; @@ -2488,10 +2488,10 @@ PP(pp_goto) label = cPVOP->op_pv; if (label && *label) { - OP *gotoprobe = 0; + OP *gotoprobe = NULL; bool leaving_eval = FALSE; bool in_block = FALSE; - PERL_CONTEXT *last_eval_cx = 0; + PERL_CONTEXT *last_eval_cx = NULL; /* find label */ @@ -4275,7 +4275,7 @@ S_doparseform(pTHX_ SV *sv) bool postspace = FALSE; U32 *fops; register U32 *fpc; - U32 *linepc = 0; + U32 *linepc = NULL; register I32 arg; bool ischop; bool unchopnum = FALSE; diff --git a/pp_hot.c b/pp_hot.c index b999b23..a222290 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1036,7 +1036,7 @@ PP(pp_aassign) I32 i; int magic; int duplicates = 0; - SV **firsthashrelem = 0; /* "= 0" keeps gcc 2.95 quiet */ + SV **firsthashrelem = NULL; /* "= 0" keeps gcc 2.95 quiet */ PL_delaymagic = DM_DELAY; /* catch simultaneous items */ @@ -1419,9 +1419,11 @@ play_it_again: } else { if (global) { - MAGIC* mg = 0; + MAGIC* mg; if (SvTYPE(TARG) >= SVt_PVMG && SvMAGIC(TARG)) mg = mg_find(TARG, PERL_MAGIC_regex_global); + else + mg = NULL; if (!mg) { sv_magic(TARG, (SV*)0, PERL_MAGIC_regex_global, Nullch, 0); mg = mg_find(TARG, PERL_MAGIC_regex_global); diff --git a/pp_sort.c b/pp_sort.c index 1be5dce..c5855ff 100644 --- a/pp_sort.c +++ b/pp_sort.c @@ -1464,7 +1464,7 @@ PP(pp_sort) AV* av = NULL; HV *stash; GV *gv; - CV *cv = 0; + CV *cv = NULL; I32 gimme = GIMME; OP* const nextop = PL_op->op_next; I32 overloading = 0; diff --git a/regcomp.c b/regcomp.c index 3dcc152..74e55f9 100644 --- a/regcomp.c +++ b/regcomp.c @@ -3215,18 +3215,21 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp) register regnode *ret; /* Will be the head of the group. */ register regnode *br; register regnode *lastbr; - register regnode *ender = 0; + register regnode *ender = NULL; register I32 parno = 0; - I32 flags, oregflags = RExC_flags, have_branch = 0, open = 0; + I32 flags; + const I32 oregflags = RExC_flags; + I32 have_branch = 0; + I32 open = 0; /* for (?g), (?gc), and (?o) warnings; warning about (?c) will warn about (?g) -- japhy */ - I32 wastedflags = 0x00, - wasted_o = 0x01, - wasted_g = 0x02, - wasted_gc = 0x02 | 0x04, - wasted_c = 0x04; + I32 wastedflags = 0x00; + const I32 wasted_o = 0x01; + const I32 wasted_g = 0x02; + const I32 wasted_gc = 0x02 | 0x04; + const I32 wasted_c = 0x04; char * parse_start = RExC_parse; /* MJD */ char * const oregcomp_parse = RExC_parse; @@ -3868,7 +3871,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp) STATIC regnode * S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp) { - register regnode *ret = 0; + register regnode *ret = NULL; I32 flags; char *parse_start = RExC_parse; @@ -4650,13 +4653,13 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state) register regnode *ret; STRLEN numlen; IV namedclass; - char *rangebegin = 0; + char *rangebegin = NULL; bool need_class = 0; SV *listsv = NULL; register char *e; UV n; bool optimize_invert = TRUE; - AV* unicode_alternate = 0; + AV* unicode_alternate = NULL; #ifdef EBCDIC UV literal_endpoint = 0; #endif diff --git a/regexec.c b/regexec.c index 13cc68b..17ddf11 100644 --- a/regexec.c +++ b/regexec.c @@ -879,7 +879,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos, s = find_byclass(prog, prog->regstclass, s, endpos, 1); if (!s) { #ifdef DEBUGGING - const char *what = 0; + const char *what = NULL; #endif if (endpos == strend) { DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log, @@ -2400,8 +2400,8 @@ S_regmatch(pTHX_ regnode *prog) I32 unwind = 0; /* used by the trie code */ - SV *sv_accept_buff = 0; /* accepting states we have traversed */ - reg_trie_accepted *accept_buff = 0; /* "" */ + SV *sv_accept_buff = NULL; /* accepting states we have traversed */ + reg_trie_accepted *accept_buff = NULL; /* "" */ reg_trie_data *trie; /* what trie are we using right now */ U32 accepted = 0; /* how many accepting states we have seen*/ diff --git a/sv.c b/sv.c index b707a73..cb3e193 100644 --- a/sv.c +++ b/sv.c @@ -3085,7 +3085,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags) if (dtype >= SVt_PV) { if (dtype == SVt_PVGV) { SV * const sref = SvREFCNT_inc(SvRV(sstr)); - SV *dref = 0; + SV *dref = NULL; const int intro = GvINTRO(dstr); #ifdef GV_UNIQUE_CHECK @@ -5197,15 +5197,13 @@ Perl_sv_pos_u2b(pTHX_ register SV *sv, I32* offsetp, I32* lenp) start = (U8*)SvPV_const(sv, len); if (len) { STRLEN boffset = 0; - STRLEN *cache = 0; + STRLEN *cache = NULL; const U8 *s = start; I32 uoffset = *offsetp; const U8 * const send = s + len; - MAGIC *mg = 0; - bool found = FALSE; + MAGIC *mg = NULL; + bool found = utf8_mg_pos(sv, &mg, &cache, 0, offsetp, *offsetp, &s, start, send); - if (utf8_mg_pos(sv, &mg, &cache, 0, offsetp, *offsetp, &s, start, send)) - found = TRUE; if (!found && uoffset > 0) { while (s < send && uoffset--) s += UTF8SKIP(s); @@ -5955,7 +5953,7 @@ thats_really_all_folks: { /*The big, slow, and stupid way. */ #ifdef USE_HEAP_INSTEAD_OF_STACK /* Even slower way. */ - STDCHAR *buf = 0; + STDCHAR *buf = NULL; Newx(buf, 8192, STDCHAR); assert(buf); #else @@ -9528,7 +9526,7 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param) break; case SVt_PVHV: { - HEK *hvname = 0; + HEK *hvname = NULL; if (HvARRAY((HV*)sstr)) { STRLEN i = 0; diff --git a/toke.c b/toke.c index b8f3c71..c9a5b75 100644 --- a/toke.c +++ b/toke.c @@ -4116,8 +4116,8 @@ Perl_yylex(pTHX) keylookup: { I32 tmp; I32 orig_keyword = 0; - GV *gv = Nullgv; - GV **gvp = 0; + GV *gv = NULL; + GV **gvp = NULL; PL_bufptr = s; s = scan_word(s, PL_tokenbuf, sizeof PL_tokenbuf, FALSE, &len); @@ -4159,8 +4159,8 @@ Perl_yylex(pTHX) } if (tmp < 0) { /* second-class keyword? */ - GV *ogv = Nullgv; /* override (winner) */ - GV *hgv = Nullgv; /* hidden (loser) */ + GV *ogv = NULL; /* override (winner) */ + GV *hgv = NULL; /* hidden (loser) */ if (PL_expect != XOPERATOR && (*s != ':' || s[1] != ':')) { CV *cv; if ((gv = gv_fetchpv(PL_tokenbuf, 0, SVt_PVCV)) && @@ -10412,7 +10412,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) NV nv; /* number read, as a double */ SV *sv = Nullsv; /* place to put the converted number */ bool floatit; /* boolean: int or float? */ - const char *lastub = 0; /* position of last underbar */ + const char *lastub = NULL; /* position of last underbar */ static char const number_too_long[] = "Number too long"; /* We use the first character to decide what type of number this is */ diff --git a/utf8.c b/utf8.c index 2356255..3d9f00f 100644 --- a/utf8.c +++ b/utf8.c @@ -2235,9 +2235,12 @@ Perl_ibcmp_utf8(pTHX_ const char *s1, char **pe1, register UV l1, bool u1, const { register const U8 *p1 = (const U8*)s1; register const U8 *p2 = (const U8*)s2; - register const U8 *f1 = 0, *f2 = 0; - register U8 *e1 = 0, *q1 = 0; - register U8 *e2 = 0, *q2 = 0; + register const U8 *f1 = NULL; + register U8 *f2 = NULL; + register U8 *e1 = NULL; + register U8 *q1 = NULL; + register U8 *e2 = NULL; + register U8 *q2 = NULL; STRLEN n1 = 0, n2 = 0; U8 foldbuf1[UTF8_MAXBYTES_CASE+1]; U8 foldbuf2[UTF8_MAXBYTES_CASE+1]; diff --git a/util.c b/util.c index c4fddee..020663f 100644 --- a/util.c +++ b/util.c @@ -139,7 +139,6 @@ Perl_safesysrealloc(Malloc_t where,MEM_SIZE size) where = (Malloc_t)((char*)where-sTHX); size += sTHX; if (((struct perl_memory_debug_header *)where)->interpreter != aTHX) { - /* int *nowhere = NULL; *nowhere = 0; */ Perl_croak_nocontext("panic: realloc from wrong pool"); } # ifdef PERL_POISON @@ -190,7 +189,6 @@ Perl_safesysfree(Malloc_t where) #ifdef PERL_TRACK_MEMPOOL where = (Malloc_t)((char*)where-sTHX); if (((struct perl_memory_debug_header *)where)->interpreter != aTHX) { - /* int *nowhere = NULL; *nowhere = 0; */ Perl_croak_nocontext("panic: free from wrong pool"); } # ifdef PERL_POISON