diff --git a/include/QF/cbuf.h b/include/QF/cbuf.h index 192dc82ef..8eb433197 100644 --- a/include/QF/cbuf.h +++ b/include/QF/cbuf.h @@ -73,7 +73,7 @@ cbuf_t * Cbuf_New ( void (*construct) (struct cbuf_s *cbuf), void (*destruct) (struct cbuf_s *cbuf) ); -void CBuf_Delete (cbuf_t *cbuf); +void Cbuf_Delete (cbuf_t *cbuf); void Cbuf_AddText (cbuf_t *cbuf, const char *text); void Cbuf_InsertText (cbuf_t *cbuf, const char *text); void Cbuf_Execute (cbuf_t *cbuf); diff --git a/libs/util/cbuf.c b/libs/util/cbuf.c index 2f69cdc88..d2fedd138 100644 --- a/libs/util/cbuf.c +++ b/libs/util/cbuf.c @@ -111,7 +111,7 @@ Cbuf_New ( } void -CBuf_Delete (cbuf_t *cbuf) +Cbuf_Delete (cbuf_t *cbuf) { if (!cbuf) return; @@ -142,6 +142,7 @@ Cbuf_Execute (cbuf_t *cbuf) cbuf_args_t *args = cbuf->args; cbuf_active = cbuf; + cbuf->state = CBUF_STATE_NORMAL; while (cbuf->buf->str[0]) { cbuf->extract_line (cbuf); if (cbuf->state) @@ -157,6 +158,32 @@ Cbuf_Execute (cbuf_t *cbuf) } } +void +Cbuf_Execute_Stack (cbuf_t *cbuf) +{ + cbuf_t *sp; + + for (sp = cbuf; sp->down; sp = sp->down); + while (sp) { + Cbuf_Execute (sp); + if (sp->state) { + if (sp->state == CBUF_STATE_STACK) { + sp = sp->down; + continue; + } else if (sp->state == CBUF_STATE_ERROR) + break; + else + return; + } + sp = sp->up; + } + dstring_clearstr (cbuf->buf); + for (cbuf = cbuf->down; cbuf; cbuf = sp) { // Reduce, reuse, recycle + sp = cbuf->down; + Cbuf_Delete (cbuf); + } +} + void Cbuf_Execute_Sets (cbuf_t *cbuf) {