Commit 611baec6 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

STRING_LIST is no more.

parent 656aa24b
......@@ -748,15 +748,6 @@ VSLb_ts_busyobj(struct busyobj *bo, const char *event, vtim_real now)
/* cache_vcl.c */
const char *VCL_Name(const struct vcl *);
/* cache_vrt.c */
/*
* These prototypes go here, because we do not want to pollute vrt.h
* with va_list. VCC never generates direct calls to them.
* XXX: We should deprecate these (ref: STRANDS)
*/
const char *VRT_String(struct ws *ws, const char *h, const char *p, va_list ap);
char *VRT_StringList(char *d, unsigned dl, const char *p, va_list ap);
/* cache_wrk.c */
typedef void *bgthread_t(struct worker *, void *priv);
......
......@@ -54,7 +54,6 @@
#include "common/vsmw.h"
#include "proxy/cache_proxy.h"
const void * const vrt_magic_string_end = &vrt_magic_string_end;
const struct strands *vrt_null_strands = &(struct strands){
.n = 0,
.p = (const char *[1]){NULL}
......@@ -395,126 +394,6 @@ VRT_HashStrands32(VCL_STRANDS s)
return (vle32dec(sha256 + VSHA256_LEN - 4));
}
/*--------------------------------------------------------------------
* Collapse a STRING_LIST in the space provided, or return NULL
*/
char *
VRT_StringList(char *d, unsigned dl, const char *p, va_list ap)
{
char *b, *e;
unsigned x;
b = d;
e = b + dl;
while (p != vrt_magic_string_end && b < e) {
if (p != NULL && *p != '\0') {
x = strlen(p);
if (b + x < e)
memcpy(b, p, x);
b += x;
}
p = va_arg(ap, const char *);
}
if (b >= e)
return (NULL);
*b++ = '\0';
return (b);
}
/*--------------------------------------------------------------------
* Copy and merge a STRING_LIST into a workspace.
*/
const char *
VRT_String(struct ws *ws, const char *h, const char *p, va_list ap)
{
char *b, *e;
const char *q;
unsigned u, x;
va_list aq;
u = WS_ReserveAll(ws);
e = b = WS_Reservation(ws);
e += u;
va_copy(aq, ap);
do
q = va_arg(aq, const char *);
while (q == NULL || (q != vrt_magic_string_end && *q == '\0'));
if (h != NULL && p == NULL && q == vrt_magic_string_end &&
WS_Allocated(ws, h, -1)) {
va_end(aq);
WS_Release(ws, 0);
return (h);
}
if (h == NULL && p != NULL && q == vrt_magic_string_end &&
WS_Allocated(ws, p, -1)) {
va_end(aq);
WS_Release(ws, 0);
return (p);
}
if (h == NULL && p == NULL) {
if (q == vrt_magic_string_end) {
va_end(aq);
WS_Release(ws, 0);
return ("");
}
do
p = va_arg(aq, const char *);
while (p == NULL || (p != vrt_magic_string_end && *p == '\0'));
if (p == vrt_magic_string_end && WS_Allocated(ws, q, -1)) {
va_end(aq);
WS_Release(ws, 0);
return (q);
}
p = NULL;
va_end(aq);
}
if (h != NULL) {
x = strlen(h);
if (b + x < e)
memcpy(b, h, x);
b += x;
if (b < e)
*b = ' ';
b++;
}
b = VRT_StringList(b, e > b ? e - b : 0, p, ap);
if (b == NULL || b == e) {
WS_MarkOverflow(ws);
WS_Release(ws, 0);
return (NULL);
}
e = b;
b = WS_Reservation(ws);
WS_Release(ws, e - b);
return (b);
}
/*--------------------------------------------------------------------
* Copy and merge a STRING_LIST on the current workspace
*/
VCL_STRING
VRT_CollectString(VRT_CTX, const char *p, ...)
{
va_list ap;
const char *b;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
va_start(ap, p);
b = VRT_String(ctx->ws, NULL, p, ap);
va_end(ap);
if (b == NULL)
VRT_fail(ctx, "Workspace overflow");
return (b);
}
/*--------------------------------------------------------------------
* Collapse STRANDS into the space provided, or return NULL
......
......@@ -54,6 +54,8 @@
* binary/load-time compatible, increment MAJOR version
*
* NEXT (2021-09-15)
* VCL_STRINGLIST, vrt_magic_string_end removed
* VRT_String(), VRT_StringList(), VRT_CollectString() removed
* VRT_CollectStrands() renamed to VRT_STRANDS_string()
* VRT_l_{beresp|resp}_body() changed to takes STRANDS argument
* VRT_SetHdr() changed to take `const char*` & `STRANDS` arguments.
......@@ -714,5 +716,4 @@ void VRT_VCL_Allow_Discard(struct vclref **);
*/
VCL_VOID VRT_synth_page(VRT_CTX, VCL_STRANDS);
extern const void * const vrt_magic_string_end;
int VRT_Stv(const char *nm);
......@@ -327,7 +327,6 @@ class vcltype(object):
vcltype("STRINGS", "void", True)
vcltype("STRING_LIST", "void*", True)
vcltype("SUB", "void*", True)
fi = open(join(srcroot, "include/vrt.h"))
......
......@@ -48,7 +48,7 @@ struct expr {
uint8_t constant;
#define EXPR_VAR (1<<0)
#define EXPR_CONST (1<<1)
#define EXPR_STR_CONST (1<<2) // Last STRING_LIST elem is "..."
#define EXPR_STR_CONST (1<<2) // Last string elem is "..."
struct token *t1, *t2;
struct symbol *instance;
int nstr;
......@@ -176,13 +176,18 @@ vcc_expr_edit(struct vcc *tl, vcc_type_t fmt, const char *p, struct expr *e1,
e3 = (*p == 'S' ? e1 : e2);
AN(e3);
assert(e1->fmt == STRINGS);
if (e3->nstr > 1)
if (e3->nstr > 1) {
VSB_cat(e->vsb,
"\nVRT_CollectString(ctx,\v+\n");
VSB_cat(e->vsb, VSB_data(e3->vsb));
if (e3->nstr > 1)
"\nVRT_STRANDS_string(ctx,\v+\n");
VSB_printf(e->vsb,
"&(struct strands){.n = %d, .p = "
"(const char *[%d]){\n%s\n}}",
e3->nstr, e3->nstr, VSB_data(e3->vsb));
VSB_cat(e->vsb,
",\nvrt_magic_string_end)\v-\n");
"\v-\n)\n");
} else {
VSB_cat(e->vsb, VSB_data(e3->vsb));
}
break;
case 'T':
case 't':
......@@ -1396,9 +1401,7 @@ vcc_expr0(struct vcc *tl, struct expr **e, vcc_type_t fmt)
}
if ((*e)->fmt == STRINGS && fmt->stringform) {
if (fmt == STRING_LIST)
(*e)->fmt = STRING_LIST;
else if (fmt == STRING)
if (fmt == STRING)
*e = vcc_expr_edit(tl, STRING, "\vS", *e, NULL);
else if (fmt == STRANDS)
*e = vcc_expr_edit(tl, STRANDS, "\vT", (*e), NULL);
......@@ -1406,10 +1409,6 @@ vcc_expr0(struct vcc *tl, struct expr **e, vcc_type_t fmt)
WRONG("Unhandled stringform");
}
if ((*e)->fmt == STRING_LIST)
*e = vcc_expr_edit(tl, STRING_LIST,
"\n\v1,\nvrt_magic_string_end", *e, NULL);
if (fmt == BOOL) {
vcc_expr_tobool(tl, e);
ERRCHK(tl);
......
......@@ -202,12 +202,6 @@ const struct type STRINGS[1] = {{
.tostring = "",
}};
const struct type STRING_LIST[1] = {{
.magic = TYPE_MAGIC,
.name = "STRING_LIST",
.stringform = 1,
}};
const struct type SUB[1] = {{
.magic = TYPE_MAGIC,
.name = "SUB",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment