[sword-devel] NEED A HAND

Joachim Ansorg sword-devel@crosswire.org
Sat, 22 Feb 2003 13:14:52 +0100


Troy,
I tried to convert utf8bidireorder.cpp to the new SWBuf stuff. But it uses 
maxlen to call some of the ICU functions. I'm not sure what to do here.

And I'm not sure if it's ok to pass text.c_str() as parameter to some ICU 
convert functions, because I don't know how you did SWBuf.

I committed the changes I made, although bidireorder isn't working yet.

I'd be glad for some hints,

Joachim

> Hey guys.  I just added the new SWBuf class to the API and now need help
> integrating it throughout.
>
> CURRENT CVS IS BROKEN AND WON'T WORK TILL THIS IS DONE.
>
> I was going to do it all myself, but realized that we have nearly 50
> filters now!
>
> SO, if you have cvs write access, please post a note claiming a few
> filter that you are working on so we don't overlap our work.
>
>
> Here is the gist...
>
> SWBuf works pretty much like string, except that it can operate on
> buffers that aren't null terminated, as well.
>
> Have a look at tests/swbuftest.cpp and include/swbuf.h
>
> Up until yesterday there was a FILTER_PAD define that basically told us
> how much to guess at allocating a buffer to be sure we had enough space
> for filter to do their job.  The filters used to take a char *.
>
> Now, FILTER_PAD is gone (hurray!) and we're passing SWBuf & in place of
> char * to the filters.
>
> Headers have been changed to reflect the new sigs, but the .cpp files
> have not.
>
> swbasicfilter.cpp and gbfhtml.cpp are done.
>
> Quick help:
>
> -char Filter::ProcessText(char *text, int maxlen, const SWKey *key,
> -   const SWModule *module)
> +char Filter::processText(SWBuf &text, const SWKey *key,
> +   const SWModule *module)
>
>
> - pushString(buf, "whatever");
> + buf += "whatever";
>
>
> - *(*buf)++ = 'x';
> + buf += 'x';
>
>
> - pushString(buf, "%d %s", 4, "cows");
> + buf.appendFormatted("%d %s", 4, "cows");
>
>
> -        char *to, *from;
> -        len = strlen(text) + 1;
>
> -        // shift string to right of buffer
> -        if (len < maxlen) {
> -                memmove(&text[maxlen - len], text, len);
> -                from = (unsigned char *)&text[maxlen - len];
> -        }
> -        else    from = (unsigned char *)text;
> -        for (to = (unsigned char *)text; *from; from++) {
> +        const char *from;
> +        SWBuf orig = text;
> +        from = orig.c_str();
> +        for (text = ""; *from; from++) {
>
> _______________________________________
>
> Thanks for considering helping on this one!
>
> 	In His Grace,
> 		-Troy.
>
>
> _______________________________________________
> sword-devel mailing list
> sword-devel@crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel

-- 
Joachim Ansorg
www.bibletime.info
joachim.ansorgs.de