# Printf format problem

**URL:** <https://www.ruby-forum.com/t/printf-format-problem/72044>\
**Category:** Development\
**Created:** [October 13, 2006, 9:08pm UTC](https://www.ruby-forum.com/t/printf-format-problem/72044 "2006-10-13T21:08:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akinori\_MUSHA](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b782af/32.png) [@Akinori\_MUSHA](https://www.ruby-forum.com/u/Akinori_MUSHA)\
**Post date:** [October 13, 2006, 9:08pm UTC](https://www.ruby-forum.com/t/printf-format-problem/72044/1 "2006-10-13T21:08:35Z")

</div>

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](http://Akinori.org) / [MUSHA.org](http://MUSHA.org)  
/ ) ) ) ) / [FreeBSD.org](http://FreeBSD.org) / [Ruby-lang.org](http://Ruby-lang.org)  
Akinori MUSHA aka / (\_ / ( (\_\_( @ [iDaemons.org](http://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 {

---

<div class="post-metadata">

**Author:** ![Akinori\_MUSHA](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b782af/32.png) [@Akinori\_MUSHA](https://www.ruby-forum.com/u/Akinori_MUSHA)\
**Post date:** [October 15, 2006, 1:40pm UTC](https://www.ruby-forum.com/t/printf-format-problem/72044/2 "2006-10-15T13:40:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Akinori\_MUSHA](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b782af/32.png) [@Akinori\_MUSHA](https://www.ruby-forum.com/u/Akinori_MUSHA)\
**Post date:** [October 15, 2006, 1:54pm UTC](https://www.ruby-forum.com/t/printf-format-problem/72044/3 "2006-10-15T13:54:05Z")

</div>

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” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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
