Commit 80bb8a10 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Split vcc_Coord() function out from vcc_ErrWhere(), to give a set

of source coordinates in human readable form in a vsb.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3235 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e05f9b6e
...@@ -203,6 +203,7 @@ int vcc_StringVal(struct tokenlist *tl); ...@@ -203,6 +203,7 @@ int vcc_StringVal(struct tokenlist *tl);
void vcc_ExpectedStringval(struct tokenlist *tl); void vcc_ExpectedStringval(struct tokenlist *tl);
/* vcc_token.c */ /* vcc_token.c */
void vcc_Coord(const struct tokenlist *tl, struct vsb *vsb, const struct token *t);
void vcc_ErrToken(const struct tokenlist *tl, const struct token *t); void vcc_ErrToken(const struct tokenlist *tl, const struct token *t);
void vcc_ErrWhere(struct tokenlist *tl, const struct token *t); void vcc_ErrWhere(struct tokenlist *tl, const struct token *t);
void vcc__Expect(struct tokenlist *tl, unsigned tok, int line); void vcc__Expect(struct tokenlist *tl, unsigned tok, int line);
......
...@@ -68,32 +68,52 @@ vcc__ErrInternal(struct tokenlist *tl, const char *func, unsigned line) ...@@ -68,32 +68,52 @@ vcc__ErrInternal(struct tokenlist *tl, const char *func, unsigned line)
tl->err = 1; tl->err = 1;
} }
void static void
vcc_ErrWhere(struct tokenlist *tl, const struct token *t) vcc_icoord(struct vsb *vsb, const struct token *t, const char **ll)
{ {
unsigned lin, pos, x, y; unsigned lin, pos;
const char *p, *l, *f, *b, *e; const char *p, *b;
struct source *sp; struct source *sp;
lin = 1; lin = 1;
pos = 0; pos = 0;
sp = t->src; sp = t->src;
f = sp->name;
b = sp->b; b = sp->b;
e = sp->e; for (p = b; p < t->b; p++) {
for (l = p = b; p < t->b; p++) {
if (*p == '\n') { if (*p == '\n') {
lin++; lin++;
pos = 0; pos = 0;
l = p + 1; if (ll != NULL)
*ll = p + 1;
} else if (*p == '\t') { } else if (*p == '\t') {
pos &= ~7; pos &= ~7;
pos += 8; pos += 8;
} else } else
pos++; pos++;
} }
vsb_printf(tl->sb, "(%s Line %d Pos %d)\n", f, lin, pos + 1); vsb_printf(vsb, "(%s Line %d Pos %d)", sp->name, lin, pos + 1);
}
void
vcc_Coord(const struct tokenlist *tl, struct vsb *vsb, const struct token *t)
{
if (t == NULL)
t = tl->t;
vcc_icoord(vsb, t, NULL);
}
void
vcc_ErrWhere(struct tokenlist *tl, const struct token *t)
{
unsigned x, y;
const char *p, *l, *e;
vcc_icoord(tl->sb, t, &l);
vsb_printf(tl->sb, "\n");
x = y = 0; x = y = 0;
e = t->src->e;
for (p = l; p < e && *p != '\n'; p++) { for (p = l; p < e && *p != '\n'; p++) {
if (*p == '\t') { if (*p == '\t') {
y &= ~7; y &= ~7;
......
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