Commit 5022d3f2 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Eliminate pointless code duplication



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5165 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 501fbc57
......@@ -5,23 +5,24 @@
#include "vcc_if.h"
const char *
vmod_toupper(struct sess *sp, const char *s, ...)
static const char *
vmod_updown(struct sess *sp, int up, const char *s, va_list ap)
{
va_list ap;
unsigned u;
char *b, *e;
const char *p;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
va_start(ap, s);
u = WS_Reserve(sp->wrk->ws, 0);
e = b = sp->wrk->ws->f;
e += u;
p = s;
while (p != vrt_magic_string_end && b < e) {
for (; b < e && *p != '\0'; p++)
if (up)
*b++ = toupper(*p);
else
*b++ = tolower(*p);
p = va_arg(ap, const char *);
}
if (b < e)
......@@ -39,34 +40,27 @@ vmod_toupper(struct sess *sp, const char *s, ...)
}
const char *
vmod_tolower(struct sess *sp, const char *s, ...)
vmod_toupper(struct sess *sp, const char *s, ...)
{
const char *p;
va_list ap;
unsigned u;
char *b, *e;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
va_start(ap, s);
p = vmod_updown(sp, 1, s, ap);
va_end(ap);
return (p);
}
const char *
vmod_tolower(struct sess *sp, const char *s, ...)
{
const char *p;
va_list ap;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
va_start(ap, s);
u = WS_Reserve(sp->wrk->ws, 0);
e = b = sp->wrk->ws->f;
e += u;
p = s;
while (p != vrt_magic_string_end && b < e) {
for (; b < e && *p != '\0'; p++)
*b++ = tolower(*p);
p = va_arg(ap, const char *);
}
if (b < e)
*b = '\0';
b++;
if (b > e) {
WS_Release(sp->wrk->ws, 0);
return (NULL);
} else {
e = b;
b = sp->wrk->ws->f;
WS_Release(sp->wrk->ws, e - b);
return (b);
}
p = vmod_updown(sp, 0, s, ap);
va_end(ap);
return (p);
}
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