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.