Fix the printfing nits pointed out by using gcc -Wall and
Jarkko Hietaniemi [Sat, 23 Oct 1999 16:04:02 +0000 (16:04 +0000)]
Configure -Duse64bits -Dccflags=-DDEBUGGING in Solaris,
plus few other warnings in Dumper.xs.

p4raw-id: //depot/cfgperl@4426

ext/Data/Dumper/Dumper.xs
ext/Devel/DProf/DProf.xs
ext/Devel/Peek/Peek.xs
regcomp.c
regexec.c
sv.c
util.c

index 054e0a9..886c317 100644 (file)
@@ -45,11 +45,12 @@ TOP:
     }
     if (isIDFIRST(*s)) {
        while (*++s)
-           if (!isALNUM(*s))
+           if (!isALNUM(*s)) {
                if (*s == ':')
                    goto TOP;
                else
                    return 1;
+           }
     }
     else 
        return 1;
@@ -384,7 +385,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
                
                ilen = inamelen;
                sv_setiv(ixsv, ix);
-                (void) sprintf(iname+ilen, "%ld", ix);
+                (void) sprintf(iname+ilen, "%"IVdf, (IV)ix);
                ilen = strlen(iname);
                iname[ilen++] = ']'; iname[ilen] = '\0';
                if (indent >= 3) {
@@ -705,7 +706,7 @@ Data_Dumper_Dumpxs(href, ...)
            SV **svp;
            SV *val, *name, *pad, *xpad, *apad, *sep, *tmp, *varname;
            SV *freezer, *toaster, *bless;
-           I32 purity, deepcopy, quotekeys, maxdepth;
+           I32 purity, deepcopy, quotekeys, maxdepth = 0;
            char tmpbuf[1024];
            I32 gimme = GIMME;
 
@@ -838,7 +839,7 @@ Data_Dumper_Dumpxs(href, ...)
                        STRLEN nchars = 0;
                        sv_setpvn(name, "$", 1);
                        sv_catsv(name, varname);
-                       (void) sprintf(tmpbuf, "%ld", i+1);
+                       (void) sprintf(tmpbuf, "%"IVdf, (IV)i+1);
                        nchars = strlen(tmpbuf);
                        sv_catpvn(name, tmpbuf, nchars);
                    }
index 533f94b..c751127 100644 (file)
@@ -163,13 +163,13 @@ static void
 prof_dumpa(opcode ptype, U32 id)
 {
     if(ptype == OP_LEAVESUB){
-       PerlIO_printf(fp,"- %lx\n", id );
+       PerlIO_printf(fp,"- %"UVxf"\n", (UV)id );
     } else if(ptype == OP_ENTERSUB) {
-       PerlIO_printf(fp,"+ %lx\n", id );
+       PerlIO_printf(fp,"+ %"UVxf"\n", (UV)id );
     } else if(ptype == OP_GOTO) {
-       PerlIO_printf(fp,"* %lx\n", id );
+       PerlIO_printf(fp,"* %"UVxf"\n", (UV)id );
     } else if(ptype == OP_DIE) {
-       PerlIO_printf(fp,"/ %lx\n", id );
+       PerlIO_printf(fp,"/ %"UVxf"\n", (UV)id );
     } else {
        PerlIO_printf(fp,"Profiler unknown prof code %d\n", ptype);
     }
@@ -178,7 +178,7 @@ prof_dumpa(opcode ptype, U32 id)
 static void
 prof_dumps(U32 id, char *pname, char *gname)
 {
-    PerlIO_printf(fp,"& %lx %s %s\n", id, pname, gname);
+    PerlIO_printf(fp,"& %"UVxf" %s %s\n", (UV)id, pname, gname);
 }   
 
 static clock_t otms_utime, otms_stime, orealtime;
@@ -477,7 +477,7 @@ prof_recordheader(void)
 
         /* fp is opened in the BOOT section */
         PerlIO_printf(fp, "#fOrTyTwO\n" );
-        PerlIO_printf(fp, "$hz=%d;\n", DPROF_HZ );
+        PerlIO_printf(fp, "$hz=%"IVdf";\n", (IV)DPROF_HZ );
         PerlIO_printf(fp, "$XS_VERSION='DProf %s';\n", XS_VERSION );
         PerlIO_printf(fp, "# All values are given in HZ\n" );
        test_time(&r, &u, &s);
@@ -516,7 +516,7 @@ prof_record(void)
                 prof_end.tms_utime - prof_start.tms_utime - wprof_u,
                 prof_end.tms_stime - prof_start.tms_stime - wprof_s,
                 rprof_end - rprof_start - wprof_r );
-        PerlIO_printf(fp, "\n$total_marks=%ld;", total);
+        PerlIO_printf(fp, "\n$total_marks=%"IVdf, (IV)total);
        
         PerlIO_close( fp );
 }
index 4f34003..d2f66c4 100644 (file)
@@ -159,7 +159,7 @@ PPCODE:
     PL_dumpindent = 2;
 
     for (i=1; i<items; i++) {
-       PerlIO_printf(Perl_debug_log, "Elt No. %ld  0x%lx\n", i - 1, ST(i));
+       PerlIO_printf(Perl_debug_log, "Elt No. %ld  0x%"UVxf"\n", i - 1, PTR2UV(ST(i)));
        do_sv_dump(0, Perl_debug_log, ST(i), 0, lim, dumpop && SvTRUE(dumpop), pv_lim);
     }
     PL_dumpindent = save_dumpindent;
index 2a27b07..2b0e0c5 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -3239,21 +3239,23 @@ Perl_regdump(pTHX_ regexp *r)
 
     /* Header fields of interest. */
     if (r->anchored_substr)
-       PerlIO_printf(Perl_debug_log, "anchored `%s%.*s%s'%s at %d ", 
+       PerlIO_printf(Perl_debug_log,
+                     "anchored `%s%.*s%s'%s at %"IVdf" ", 
                      PL_colors[0],
-                     SvCUR(r->anchored_substr) - (SvTAIL(r->anchored_substr)!=0),
+                     (int)(SvCUR(r->anchored_substr) - (SvTAIL(r->anchored_substr)!=0)),
                      SvPVX(r->anchored_substr), 
                      PL_colors[1],
                      SvTAIL(r->anchored_substr) ? "$" : "",
-                     r->anchored_offset);
+                     (IV)r->anchored_offset);
     if (r->float_substr)
-       PerlIO_printf(Perl_debug_log, "floating `%s%.*s%s'%s at %d..%u ", 
+       PerlIO_printf(Perl_debug_log,
+                     "floating `%s%.*s%s'%s at %"IVdf"..%"UVuf" ", 
                      PL_colors[0],
-                     SvCUR(r->float_substr) - (SvTAIL(r->float_substr)!=0), 
+                     (int)(SvCUR(r->float_substr) - (SvTAIL(r->float_substr)!=0)), 
                      SvPVX(r->float_substr),
                      PL_colors[1],
                      SvTAIL(r->float_substr) ? "$" : "",
-                     r->float_min_offset, r->float_max_offset);
+                     (IV)r->float_min_offset, (UV)r->float_max_offset);
     if (r->check_substr)
        PerlIO_printf(Perl_debug_log, 
                      r->check_substr == r->float_substr 
index 65a3b90..f159f7a 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -424,7 +424,8 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                          (s ? "Found" : "Did not find"),
                          ((check == prog->anchored_substr) ? "anchored" : "floating"),
                          PL_colors[0],
-                         SvCUR(check) - (SvTAIL(check)!=0), SvPVX(check),
+                         (int)(SvCUR(check) - (SvTAIL(check)!=0)),
+                         SvPVX(check),
                          PL_colors[1], (SvTAIL(check) ? "$" : ""),
                          (s ? " at offset " : "...\n") ) );
 
@@ -480,8 +481,8 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                DEBUG_r(PerlIO_printf(Perl_debug_log, "%s anchored substr `%s%.*s%s'%s",
                        (s ? "Found" : "Contradicts"),
                        PL_colors[0],
-                         SvCUR(prog->anchored_substr)
-                         - (SvTAIL(prog->anchored_substr)!=0),
+                         (int)(SvCUR(prog->anchored_substr)
+                         - (SvTAIL(prog->anchored_substr)!=0)),
                          SvPVX(prog->anchored_substr),
                          PL_colors[1], (SvTAIL(prog->anchored_substr) ? "$" : "")));
                if (!s) {
@@ -532,8 +533,8 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                DEBUG_r(PerlIO_printf(Perl_debug_log, "%s floating substr `%s%.*s%s'%s",
                        (s ? "Found" : "Contradicts"),
                        PL_colors[0],
-                         SvCUR(prog->float_substr)
-                         - (SvTAIL(prog->float_substr)!=0),
+                         (int)(SvCUR(prog->float_substr)
+                         - (SvTAIL(prog->float_substr)!=0)),
                          SvPVX(prog->float_substr),
                          PL_colors[1], (SvTAIL(prog->float_substr) ? "$" : "")));
                if (!s) {
@@ -2141,7 +2142,7 @@ S_regmatch(pTHX_ regnode *prog)
            
            n = ARG(scan);
            PL_op = (OP_4tree*)PL_regdata->data[n];
-           DEBUG_r( PerlIO_printf(Perl_debug_log, "  re_eval 0x%x\n", PL_op) );
+           DEBUG_r( PerlIO_printf(Perl_debug_log, "  re_eval 0x%"UVxf"\n", (UV)PL_op) );
            PL_curpad = AvARRAY((AV*)PL_regdata->data[n + 2]);
            PL_regendp[0] = PL_reg_magic->mg_len = locinput - PL_bostr;
 
@@ -2704,8 +2705,9 @@ S_regmatch(pTHX_ regnode *prog)
                locinput = PL_reginput;
                DEBUG_r(
                    PerlIO_printf(Perl_debug_log,
-                                 "%*s  matched %ld times, len=%ld...\n",
-                                 REPORT_CODE_OFF+PL_regindent*2, "", n, l)
+                                 "%*s  matched %d times, len=%"IVdf"...\n",
+                                 (int)(REPORT_CODE_OFF+PL_regindent*2), "",
+                                 n, (IV)l)
                    );
                if (n >= ln) {
                    if (PL_regkind[(U8)OP(next)] == EXACT) {
@@ -2729,8 +2731,8 @@ S_regmatch(pTHX_ regnode *prog)
                    {
                        DEBUG_r(
                                PerlIO_printf(Perl_debug_log,
-                                             "%*s  trying tail with n=%ld...\n",
-                                             REPORT_CODE_OFF+PL_regindent*2, "", n)
+                                             "%*s  trying tail with n=%"IVdf"...\n",
+                                             (int)(REPORT_CODE_OFF+PL_regindent*2), "", (IV)n)
                            );
                        if (paren) {
                            if (n) {
@@ -3306,8 +3308,8 @@ S_regrepeat(pTHX_ regnode *p, I32 max)
 
                regprop(prop, p);
                PerlIO_printf(Perl_debug_log, 
-                             "%*s  %s can match %ld times out of %ld...\n", 
-                             REPORT_CODE_OFF+1, "", SvPVX(prop),c,max);
+                             "%*s  %s can match %"IVdf" times out of %"IVdf"...\n", 
+                             REPORT_CODE_OFF+1, "", SvPVX(prop),(IV)c,(IV)max);
        });
     
     return(c);
diff --git a/sv.c b/sv.c
index cb83771..967a34c 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -1699,8 +1699,8 @@ Perl_sv_2uv(pTHX_ register SV *sv)
        return 0;
     }
 
-    DEBUG_c(PerlIO_printf(Perl_debug_log, "0x%lx 2uv(%lu)\n",
-       (unsigned long)sv,SvUVX(sv)));
+    DEBUG_c(PerlIO_printf(Perl_debug_log, "0x%"UVxf" 2uv(%"UVuf")\n",
+       (UV)sv,SvUVX(sv)));
     return SvIsUV(sv) ? SvUVX(sv) : (UV)SvIVX(sv);
 }
 
@@ -5652,7 +5652,7 @@ do_clean_named_objs(pTHXo_ SV *sv)
 static void
 do_clean_all(pTHXo_ SV *sv)
 {
-    DEBUG_D((PerlIO_printf(Perl_debug_log, "Cleaning loops: SV at 0x%lx\n", sv) );)
+    DEBUG_D((PerlIO_printf(Perl_debug_log, "Cleaning loops: SV at 0x%"UVxf"\n", PTR2UV(sv)) );)
     SvFLAGS(sv) |= SVf_BREAK;
     SvREFCNT_dec(sv);
 }
diff --git a/util.c b/util.c
index f4af3e9..f78ad04 100644 (file)
--- a/util.c
+++ b/util.c
@@ -95,7 +95,7 @@ Perl_safesysmalloc(MEM_SIZE size)
        Perl_croak_nocontext("panic: malloc");
 #endif
     ptr = PerlMem_malloc(size?size:1); /* malloc(0) is NASTY on our system */
-    DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%lx: (%05d) malloc %ld bytes\n",ptr,PL_an++,(long)size));
+    DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05d) malloc %ld bytes\n",PTR2UV(ptr),PL_an++,(long)size));
     if (ptr != Nullch)
        return ptr;
     else if (PL_nomemok)
@@ -139,8 +139,8 @@ Perl_safesysrealloc(Malloc_t where,MEM_SIZE size)
 #endif
     ptr = PerlMem_realloc(where,size);
 
-    DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%lx: (%05d) rfree\n",where,PL_an++));
-    DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%lx: (%05d) realloc %ld bytes\n",ptr,PL_an++,(long)size));
+    DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05d) rfree\n",PTR2UV(where),PL_an++));
+    DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05d) realloc %ld bytes\n",PTR2UV(ptr),PL_an++,(long)size));
 
     if (ptr != Nullch)
        return ptr;
@@ -160,7 +160,7 @@ Free_t
 Perl_safesysfree(Malloc_t where)
 {
     dTHX;
-    DEBUG_m( PerlIO_printf(Perl_debug_log, "0x%lx: (%05d) free\n",(char *) where,PL_an++));
+    DEBUG_m( PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05d) free\n",PTR2UV(where),PL_an++));
     if (where) {
        /*SUPPRESS 701*/
        PerlMem_free(where);
@@ -188,7 +188,7 @@ Perl_safesyscalloc(MEM_SIZE count, MEM_SIZE size)
 #endif
     size *= count;
     ptr = PerlMem_malloc(size?size:1); /* malloc(0) is NASTY on our system */
-    DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%lx: (%05d) calloc %ld x %ld bytes\n",ptr,PL_an++,(long)count,(long)size));
+    DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05d) calloc %ld x %ld bytes\n",PTR2UV(ptr),PL_an++,(long)count,(long)size));
     if (ptr != Nullch) {
        memset((void*)ptr, 0, size);
        return ptr;
@@ -2581,7 +2581,7 @@ Perl_wait4pid(pTHX_ Pid_t pid, int *statusp, int flags)
     if (!pid)
        return -1;
     if (pid > 0) {
-       sprintf(spid, "%d", pid);
+       sprintf(spid, "%"IVdf, (IV)pid);
        svp = hv_fetch(PL_pidstatus,spid,strlen(spid),FALSE);
        if (svp && *svp != &PL_sv_undef) {
            *statusp = SvIVX(*svp);
@@ -2597,7 +2597,7 @@ Perl_wait4pid(pTHX_ Pid_t pid, int *statusp, int flags)
            pid = atoi(hv_iterkey(entry,(I32*)statusp));
            sv = hv_iterval(PL_pidstatus,entry);
            *statusp = SvIVX(sv);
-           sprintf(spid, "%d", pid);
+           sprintf(spid, "%"IVdf, (IV)pid);
            (void)hv_delete(PL_pidstatus,spid,strlen(spid),G_DISCARD);
            return pid;
        }
@@ -2637,7 +2637,7 @@ Perl_pidgone(pTHX_ Pid_t pid, int status)
     register SV *sv;
     char spid[TYPE_CHARS(int)];
 
-    sprintf(spid, "%d", pid);
+    sprintf(spid, "%"IVdf, (IV)pid);
     sv = *hv_fetch(PL_pidstatus,spid,strlen(spid),TRUE);
     (void)SvUPGRADE(sv,SVt_IV);
     SvIVX(sv) = status;