Printf format problem

e$B!!e(Bprintf()e$B7O4X?t$N8F$S=P$7$K$*$$$F!“2?$,F~$C$F$$$k$+J,$+$i$J$$e(B
e$BJ8;zNs$r$=$N$^$^=q<0J8;zNs$H$7$FEO$7$F$$$k$H$3$m$,2?2U=j$b$”$ke(B
e$B$h$&$G$9!#e(B

e$B!!$?$H$($P!"<!$N$h$&$K$9$k$He(B core e$B$rEG$-$^$9!#e(B(c) akr

% ruby1.9 -w -e ‘/(?:(?:%s)?)?/’
-e:1: [BUG] Segmentation fault
ruby 1.9.0 (2006-10-13) [i686-linux]

e$B$"$k$$$O!"2=$1$?J8;zNse(B(e$B!Ve(B******e$B!WItJ,e(B)e$B$,=PNO$5$l$^$9!#e(B

% ./ruby -w -e ‘/(?:(?:%s)?)?/’
-e:1: warning: redundant nested repeat operator: /(?:(?:******?)?/
-e:1: warning: useless use of a literal in void context

e$B!!7Z$/e(Bgrep
e$B$7$F8+$D$+$C$?$b$N$rD>$9$HE:IU$N$h$&$J46$8$G$9$,!“e(B
e$B$[$+$K$b$”$k$+$b$7$l$^$;$s!#e(B

e$B!!$A$c$s$H%D!<%k$G<+F0%A%'%C%/$9$Y$-$G$9$,!“e(B PRINTF_ARGS()
e$B$Ge(B
e$B%1%”$7$F$$$k$N$Ke(B gcc -Wformat
e$B$G$O=P$F$-$F$/$l$J$$$_$?$$$G$9!#e(B
e$B$J$<$@$m$&!#e(B


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

“Different eyes see different things,
Different hearts beat on different strings –
But there are times for you and me when all such things agree”

Index: parse.y

RCS file: /src/ruby/parse.y,v
retrieving revision 1.465
diff -u -r1.465 parse.y
— parse.y 5 Oct 2006 22:31:59 -0000 1.465
+++ parse.y 13 Oct 2006 17:55:46 -0000
@@ -6911,7 +6911,7 @@
{
int line = ruby_sourceline;
ruby_sourceline = nd_line(node);

  • rb_warning(mesg);
  • rb_warning(“%s”, mesg);
    ruby_sourceline = line;
    }

@@ -6920,7 +6920,7 @@
{
int line = ruby_sourceline;
ruby_sourceline = nd_line(node);

  • rb_warn(mesg);
  • rb_warn(“%s”, mesg);
    ruby_sourceline = line;
    }

@@ -9277,7 +9277,7 @@
{
StringValue(msg);
if (obj == Qundef) {

  • rb_raise(rb_eArgError, RSTRING_PTR(msg));
  •    rb_raise(rb_eArgError, "%s", RSTRING_PTR(msg));
    
    }
    return Qnil;
    }
    Index: regparse.c
    ===================================================================
    RCS file: /src/ruby/regparse.c,v
    retrieving revision 1.28
    diff -u -r1.28 regparse.c
    — regparse.c 27 Aug 2006 12:58:22 -0000 1.28
    +++ regparse.c 13 Oct 2006 17:55:46 -0000
    @@ -64,13 +64,13 @@
    extern void
    onig_rb_warn(const char* s)
    {
  • rb_warn(s);
  • rb_warn(“%s”, s);
    }

extern void
onig_rb_warning(const char* s)
{

  • rb_warning(s);
  • rb_warning(“%s”, s);
    }
    #endif

Index: ext/bigdecimal/bigdecimal.c

RCS file: /src/ruby/ext/bigdecimal/bigdecimal.c,v
retrieving revision 1.52
diff -u -r1.52 bigdecimal.c
— ext/bigdecimal/bigdecimal.c 31 Aug 2006 10:30:22 -0000 1.52
+++ ext/bigdecimal/bigdecimal.c 13 Oct 2006 17:55:46 -0000
@@ -2206,8 +2206,8 @@
return 0; /* 0 Means VpException() raised no exception */

raise:

  • if(fatal) rb_fatal(str);
  • else rb_raise(exc,str);
  • if(fatal) rb_fatal(“%s”, str);
  • else rb_raise(exc, “%s”, str);
    return 0;
    }

Index: ext/dl/handle.c

RCS file: /src/ruby/ext/dl/handle.c,v
retrieving revision 1.19
diff -u -r1.19 handle.c
— ext/dl/handle.c 24 Sep 2005 00:17:42 -0000 1.19
+++ ext/dl/handle.c 13 Oct 2006 17:55:46 -0000
@@ -70,12 +70,12 @@
ptr = dlopen(clib, cflag);
#if defined(HAVE_DLERROR)
if( !ptr && (err = dlerror()) ){

  • rb_raise(rb_eDLError, err);
  • rb_raise(rb_eDLError, “%s”, err);
    }
    #else
    if( !ptr ){
    err = dlerror();
  • rb_raise(rb_eDLError, err);
  • rb_raise(rb_eDLError, “%s”, err);
    }
    #endif
    Data_Get_Struct(self, struct dl_handle, dlhandle);
    Index: ext/gdbm/gdbm.c
    ===================================================================
    RCS file: /src/ruby/ext/gdbm/gdbm.c,v
    retrieving revision 1.40
    diff -u -r1.40 gdbm.c
    — ext/gdbm/gdbm.c 20 Sep 2006 00:28:06 -0000 1.40
    +++ ext/gdbm/gdbm.c 13 Oct 2006 17:55:46 -0000
    @@ -81,7 +81,7 @@
    static void
    rb_gdbm_fatal(char *msg)
    {
  • rb_raise(rb_eGDBMFatalError, msg);
  • rb_raise(rb_eGDBMFatalError, “%s”, msg);
    }

struct dbmdata {

Akinori MUSHA wrote:

e$B$"$k$$$O!"2=$1$?J8;zNse(B(e$B!Ve(B******e$B!WItJ,e(B)e$B$,=PNO$5$l$^$9!#e(B

% ./ruby -w -e ‘/(?:(?:%s)?)?/’
-e:1: warning: redundant nested repeat operator: /(?:(?:******?)?/
-e:1: warning: useless use of a literal in void context

regparse.ce$B$NItJ,$K$D$$$F$O!"%3%_%C%H$7$FD:$$$F$be(B
e$B9=$o$J$$$H;W$$$^$9!#e(B

e$B2DJQD90z?t$N8D?t$,#0$+$I$&$+H=JL$9$kJ}K!$O!“e(B
e$B$J$$$N$G$7$g$&$+!)e(B
e$B$b$7$”$l$P!"e(Brb_warn()e$B$NCf$G$bBP1~$G$-$k$H;W$$$^$9$,!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:29667] Re: printf format problem”
on Sun, 15 Oct 2006 20:37:34 +0900, “K.Kosako” [email protected]
writes:

|regparse.ce$B$NItJ,$K$D$$$F$O!"%3%_%C%H$7$FD:$$$F$be(B
|e$B9=$o$J$$$H;W$$$^$9!#e(B

e$B%3%_%C%H$7$^$7$?!#e(B

|e$B2DJQD90z?t$N8D?t$,#0$+$I$&$+H=JL$9$kJ}K!$O!“e(B
|e$B$J$$$N$G$7$g$&$+!)e(B
|e$B$b$7$”$l$P!"e(Brb_warn()e$B$NCf$G$bBP1~$G$-$k$H;W$$$^$9$,!#e(B

e$B0?“@-$N$”$kJ}K!$O$J$+$C$?$h$&$K;W$$$^$9!#e(B