bin/varnishd/cache/cache_vrt.c
VCL_STRING
VRT_StrandsWS(struct ws *ws, const char *h, VCL_STRANDS s)
{
	const char *q = NULL;
	struct vsb vsb[1];
	int i;

	WS_Assert(ws);
	AN(s);

	for (i = 0; i < s->n; i++) {
		if (s->p[i] != NULL && *s->p[i] != '\0') {
			q = s->p[i];
			break;
		}
	}

	if (q == NULL) {
		if (h == NULL)
			return ("");
		if (WS_Allocated(ws, h, -1))
			return (h);
	} else if (h == NULL && WS_Allocated(ws, q, -1)) {
		for (i++; i < s->n; i++)
			if (s->p[i] != NULL && *s->p[i] != '\0')
				break;
		if (i == s->n)
			return (q);
	}

	WS_VSB_new(vsb, ws);
	if (h != NULL)
		VSB_cat(vsb, h);
	for (i = 0; i < s->n; i++) {
		if (s->p[i] != NULL && *s->p[i] != '\0')
			VSB_cat(vsb, s->p[i]);
	}
	return (WS_VSB_finish(vsb, ws, NULL));
}
/*--------------------------------------------------------------------
 * Copy and merge STRANDS into a workspace.
 */
Copy and merge STRANDS into a workspace.
Copy and merge STRANDS into a workspace .
VCL_STRING
VRT_StrandsWS(struct ws *ws, const char *h, VCL_STRANDS s)
{
	const char *q = NULL;
	struct vsb vsb[1];
	int i;
	WS_Assert(ws);
	AN(s);
	for (i = 0; i < s->n; i++) {
		if (s->p[i] != NULL && *s->p[i] != '\0') {
			q = s->p[i];
			break;
		}
	}
	if (q == NULL) {
		if (h == NULL)
			return ("");
		if (WS_Allocated(ws, h, -1))
			return (h);
	} else if (h == NULL && WS_Allocated(ws, q, -1)) {
		for (i++; i < s->n; i++)
			if (s->p[i] != NULL && *s->p[i] != '\0')
				break;
		if (i == s->n)
			return (q);
	}
	WS_VSB_new(vsb, ws);
	if (h != NULL)
		VSB_cat(vsb, h);
	for (i = 0; i < s->n; i++) {
		if (s->p[i] != NULL && *s->p[i] != '\0')
			VSB_cat(vsb, s->p[i]);
	}
	return (WS_VSB_finish(vsb, ws, NULL));
}
VCL_STRING VRT_StrandsWS ( struct ws * ws , const char * h , VCL_STRANDS s ) { const char * q = NULL ; struct vsb vsb [ 1 ] ; int i ; WS_Assert ( ws ) ; AN ( s ) ; for ( i = 0 ; i < s -> n ; i ++ ) { if ( s -> p [ i ] != NULL && * s -> p [ i ] != ' \0 ' ) { q = s -> p [ i ] ; break ; } } if ( q == NULL ) { if ( h == NULL ) return ( " " ) ; if ( WS_Allocated ( ws , h , -1 ) ) return ( h ) ; } else if ( h == NULL && WS_Allocated ( ws , q , -1 ) ) { for ( i ++ ; i < s -> n ; i ++ ) if ( s -> p [ i ] != NULL && * s -> p [ i ] != ' \0 ' ) break ; if ( i == s -> n ) return ( q ) ; } WS_VSB_new ( vsb , ws ) ; if ( h != NULL ) VSB_cat ( vsb , h ) ; for ( i = 0 ; i < s -> n ; i ++ ) { if ( s -> p [ i ] != NULL && * s -> p [ i ] != ' \0 ' ) VSB_cat ( vsb , s -> p [ i ] ) ; } return ( WS_VSB_finish ( vsb , ws , NULL ) ) ; }
Copy and merge STRANDS into a workspace.
Copy and merge STRANDS into a workspace .