gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH]: gnokii_strsplit as in glib (was Re: [PATCH] gnokii gtk2 port)


From: Bastien Nocera
Subject: [PATCH]: gnokii_strsplit as in glib (was Re: [PATCH] gnokii gtk2 port)
Date: Thu, 04 Aug 2005 18:19:43 +0100

On Thu, 2005-08-04 at 17:52 +0100, Bastien Nocera wrote:
> On Tue, 2005-08-02 at 21:41 +0200, Pawel Kot wrote:
> <snip>
> > > configure detects wheter C99 compatible snprintf() and vsnprintf()
> > > implementation are available. gnokii will use a replacement function
> > > if these functions aren't available or they aren't C99 compatible.
> > > If there's no asprintf() or vasprintf() implementation, the snprintf
> > > code provides them (look into common/snprintf.c). I think asprintf()
> > > is the function you are looking for... :-)
> > 
> > Bastien, is it enough for you?
> 
> I misunderstood the paragraph above. asprintf would be good enough
> indeed for what I use it for. I'll modify gnokii_strsplit() to allow an
> undefined amount of tokens, and it should be good without glib.

And here's a testcase and a patch to implement an undefined number of
tokens. Pass "-1" as the number of tokens, and you shall receive the
smallest possible array, with the maximum number of tokens it could
create out of it. Should also be greedier than the current
gnokii_strsplit when it comes to allocating memory.

Cheers

---
Bastien Nocera <address@hidden> 

Attachment: gnokii-strplit-undefined-tokens.patch
Description: Text Data

Attachment: test-strsplit.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]