On Wed, Sep 15, 2010 at 09:24:58PM +0100, Jeremy Henty wrote:
Johannes Hofmann wrote:
I don't have a solution yet, but I envision something, where e.g. Html_write_raw() or DilloHtml::write() works with a const buf and buflen (no null-termination required), but non-terminated buffers don't leak into lower-layer functions (like Html_process_space(), or Html_process_word()).
In that case, whenever a "high-layer" function like Html_write_raw() calls a lower-layer function it will have to either poke in a null byte (as Html_write_raw() does now) or copy a segment of its buffer into a new null-terminated buffer. If you want the original buffer to be const then it can't poke in a null, so it will have to copy. Unless there's a third way, but I can't see one.
As I said, I don't have any good idea either. So maybe what we currently have is a good compromise - I don't know. Also I won't invest much time as there are is no real need to change things.
Would you consider all the Html_tag_open_*() functions to be lower-layer too? If so then it would be natural (as I understand your suggestion) for them to lose their length arguments. Is that right? And presumably Html_get_{attr,attr2}() also? The more I think about this the more functions in html.cc I think it might affect. Maybe we could clone a new repository to experiment with?
I would leave them as they are but feel free to experiment. Having a cloned repo for experimenting is always a good idea. I have a clone for every non-trivial thing I do. Regards, Johannes