Problem in format

For the Compleat Fan
Locked
Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Problem in format

Post by Jeff »

There is a problem string formatting a % character after an actual %format character. For example:

Code: Select all

(format "%% %s %%" "hello world") ; *should* => "% hello world %"
...but, in actuality, does "% hello world %%".
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

This will be fixed in 9.1.8 (due this weekend). As a workaround use:

Code: Select all

(format "%c %s %c" 37 "hello" 37) => "% hello %"
Lutz

rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Post by rickyboy »

Looks like a bug. You'll have to use something like the following, as a work around.

Code: Select all

> (format "%% %s %%%s" "hello world" "")
"% hello world %"
P.S. -- Oops, Lutz beat me with another workaround. Lutz is Quick-Draw McGraw. :-)
(λx. x x) (λx. x x)

Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Post by Jeff »

Thanks guys!
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

Locked