By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!Does it matter if PLUGININFO::pszFunctions ends with a comma?
Thanks.
> Does it matter if PLUGININFO::pszFunctions ends with a comma?
> On Sat, 03 Oct 2009 12:22:32 -0500, rconn <> wrote:
>
> |---Quote---
> |> Does it matter if PLUGININFO::pszFunctions ends with a comma?
> |---End Quote---
> |Leading or trailing commas are ignored.
> |
> |But why would you want to?
>
> I build the list dynamically. Without having to treat the first or last
> function name specially, I can do it with a simple loop.
>
> WCHAR *p = pluginfo.pszFunctions;
> for ( INT i=0; i<NUMBER_OF_ITEMS; i++ )
> p += Sprintf(p, L"%s,", item.Name);
> --
> - Vince
>
>
>
>
> You could do this instead:
> WCHAR *p = pluginfo.pszFunctions;
> for ( INT i=0; i<NUMBER_OF_ITEMS-1; i++ )
> p += Sprintf(p, L"%s,", item.Name);
> p += Sprintf(p, L"%s", item.Name);
>
> -Scott
>
> vefatica <> wrote on 10/03/2009 03:54:08 PM:
>
>
>
> ---Quote---
> > On Sat, 03 Oct 2009 12:22:32 -0500, rconn <> wrote:
> >
> > |---Quote---
> > |> Does it matter if PLUGININFO::pszFunctions ends with a comma?
> > |---End Quote---
> > |Leading or trailing commas are ignored.
> > |
> > |But why would you want to?
> >
> > I build the list dynamically. Without having to treat the first or
> > function name specially, I can do it with a simple loop.
> >
> > WCHAR *p = pluginfo.pszFunctions;
> > for ( INT i=0; i<NUMBER_OF_ITEMS; i++ )
> > p += Sprintf(p, L"%s,", item.Name);
> > --
> > - Vince
> >
> >
> >
> >
> ---End Quote---
>
>
>
> On Mon, 05 Oct 2009 10:59:34 -0500, samintz <> wrote:
>
> |You could do this instead:
> | * *WCHAR *p = pluginfo.pszFunctions;
> | * *for ( INT i=0; i<NUMBER_OF_ITEMS-1; i++ )
> | * * * p += Sprintf(p, L"%s,", item.Name);
> | * *p += Sprintf(p, L"%s", item.Name);
> |
>
> Or even,
>
> * *WCHAR *p = pluginfo.pszFunctions;
> * *for ( INT i=0; i<NUMBER_OF_ITEMS; i++ )
> * * * p += Sprintf(p, L"%s,", item.Name);
> * **(p-1) == 0;
>
> But not having to bother saves 16 bytes of code (in either case).
> --
> *- Vince
>
>
>
>
>
> Although it is more code than nothing, this hack might be what you
> want as well
>
> WCHAR *p = pluginfo.pszFunctions;
> for ( INT i=0; i<NUMBER_OF_ITEMS; i++ )
> p += Sprintf(p, L"%s%c", item.Name, i==NUMBER_OF_ITEMS-1 ?
> '\0', ',');
>
> Or, perhaps more gawdawful, assuming TRUE/FALSE are 1/0:
> WCHAR *p = pluginfo.pszFunctions;
> for ( INT i=0; i<NUMBER_OF_ITEMS; i++ )
> p += Sprintf(p, L"%s%c", item.Name, ","[i>=NUMBER_OF_ITEMS-1]);
>
>
> On Mon, Oct 5, 2009 at 10:08 AM, vefatica <> wrote:
>
>
> ---Quote---
> > On Mon, 05 Oct 2009 10:59:34 -0500, samintz <> wrote:
> >
> > |You could do this instead:
> > | * *WCHAR *p = pluginfo.pszFunctions;
> > | * *for ( INT i=0; i<NUMBER_OF_ITEMS-1; i++ )
> > | * * * p += Sprintf(p, L"%s,", item.Name);
> > | * *p += Sprintf(p, L"%s", item.Name);
> > |
> >
> > Or even,
> >
> > * *WCHAR *p = pluginfo.pszFunctions;
> > * *for ( INT i=0; i<NUMBER_OF_ITEMS; i++ )
> > * * * p += Sprintf(p, L"%s,", item.Name);
> > * **(p-1) == 0;
> >
> > But not having to bother saves 16 bytes of code (in either case).
> > --
> > *- Vince
> >
> >
> >
> >
> >
> ---End Quote---
>
>
> --
> Jim Cook
> 2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
> Next year they're Sunday.
>
>
>
>