On Sat, Apr 12, 2008 at 10:27:40AM -0700, Chris Elving wrote:
> Basant Kukreja wrote:
>> +static void sed_write(sed_eval_t *eval, char *buf, int sz)
>> +{
>> +    if (eval->curoutbuf + sz >= eval->outbend) {
>> +        // flush current buffer
>> +        sed_flush_output_buffer(eval, buf, sz);
>> +    }
>> +    else {
>> +        memcpy(eval->curoutbuf, buf, sz);
>> +        eval->curoutbuf += sz;
>> +    }
>
> sed is an inherently line-oriented editor. It seems wrong to buffer 
> multiple lines within libsed. Consider, for example, how adding such 
> multi-line buffering to libsed would complicate implementing an interactive 
> sed like sed(1).
>
> Instead, it seems like such buffering should occur in mod_sed. mod_sed is 
> what couples libsed to the bucket brigade, and mod_sed knows that such such 
> buffering is appropriate.
sed_eval_buffer and sed_finalize_eval flush the output before returning. If
somebody want to implement interactive sed then one can send line vise line
data to sed_eval_buffer (but that seems like poor assumption). So it is still
possible to implement interactive sed code using these APIs. 

But still it makes more sense to me to move buffering code outside the libsed.
I will work towards moving buffering code outside the libsed to mod_sed filter
code.

Regards,
Basant.

Reply via email to