On Wed, 5 Dec 2012 11:19:41 +0900 Carsten Haitzler (The Rasterman)
<[email protected]> wrote:

> On Wed, 5 Dec 2012 00:10:57 -0200 "Eduardo Lima (Etrunko)"
> <[email protected]> said:
> 
> > On Tue, Dec 4, 2012 at 11:39 PM, Gustavo Sverzut Barbieri
> > <[email protected]> wrote:
> > > On Tuesday, December 4, 2012, David Seikel wrote:
> > >
> > >> On Tue, 4 Dec 2012 19:22:58 -0200 Gustavo Sverzut Barbieri
> > >> <[email protected] <javascript:;>> wrote:
> > >>
> > >> > On Tue, Dec 4, 2012 at 6:30 PM, Eduardo Lima (Etrunko)
> > >> > <[email protected] <javascript:;>> wrote:
> > >> > > On Tue, Dec 4, 2012 at 6:21 PM, Enlightenment SVN
> > >> > > <[email protected] <javascript:;>> wrote:
> > >> > >> Log:
> > >> > >> New embryo function: get_program_id
> > >> > >>
> > >> > >>   It is now you can run programs with names generated
> > >> > >> dinamically. Say that you have 10 programs indexed somehow.
> > >> > >> You can now call them using the following snippet:
> > >> > >>
> > >> > >>   script {
> > >> > >>      new program_id[15], i;
> > >> > >>      for (i = 0; i < 10; i++) {
> > >> > >>         snprintf(program_id, 15, "my_program_%d", i+1);
> > >> > >>         run_program(get_program_id(program_id));
> > >> > >>      }
> > >> > >>   }
> > >> > >>
> > >> > >
> > >> > > By the way, I noticed a bug in Embryo's snprintf. I can
> > >> > > specify something like "my_program_%02d" as format string
> > >> > > and it will generate as result "my_program_01",
> > >> > > "my_program_02", and so on. It will use '0' to the left of
> > >> > > the number if it is less than 2 chars long. See test code
> > >> > > attached.
> > >> >
> > >> > sorry if that bite you, but it's a "known issue". If you look
> > >> > at some e17 themes or even outside people doing clocks (hint:
> > >> > canola2) there are snippets:
> > >> >
> > >> >  if (x < 10)
> > >> >     snprintf(buf, sizeof(buf), "0%d", x);
> > >> > else
> > >> >     snprintf(buf, sizeof(buf), "%d", x);
> > >> >
> > >> > :-/
> > >>
> > >> Er, isn't that the way it's supposed to work?  From man 3
> > >> snprintf -
> > >>
> > >> "The value should be zero padded.  For d, i, o, u, x, X, a, A, e,
> > >> E, f, F, g, and G conversions, the converted value is padded on
> > >> the left with zeros rather than blanks."
> > >>
> > >> so "%02d" means print a number into a space two characters wide,
> > >> padded on the left with 0s.  Which is what you are getting.
> > >
> > >
> > > Embryo doesn't use libc sprintf. It's implemented inependently
> > > because embryo strings are made of int, not char.
> > >
> > 
> > Yeah, the program shows the desired behavior. WIth embryo I only get
> > something like "my_program_2d" or something similar.
> 
> yeah. i consider this a limitation, not a "bug" since it literally
> implements a simple printf of its own with all the format parsing etc.

So basically it calls itself snprintf, thus I'd expect it to act like
every one else's snprintf, even if it's a cut down version that outputs
something a little different, though the output makes sense coz it's
still considered a string in this particular language.  So I'd say the
originally reported behaviour is "works as designed", and you'll have to
code some other way if you want different results.

In other words, if it wasn't meant to be very similar to regular
snprintf, it would have been called something different.  Using the
"printf" family of names infers it acts like printf and friends every
where else.

'tis a feature, not a bug.  B-)

-- 
A big old stinking pile of genius that no one wants
coz there are too many silver coated monkeys in the world.

Attachment: signature.asc
Description: PGP signature

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to