Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
6dcbc76f
Commit
6dcbc76f
authored
Aug 17, 2023
by
Dridi Boukelmoune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vte: Measure fields incrementally
parent
dddb171b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
vte.h
include/vte.h
+1
-0
vte.c
lib/libvarnish/vte.c
+71
-0
No files found.
include/vte.h
View file @
6dcbc76f
...
@@ -30,4 +30,5 @@
...
@@ -30,4 +30,5 @@
struct
vte
;
struct
vte
;
struct
vte
*
VTE_new
(
int
maxfields
,
int
width
);
struct
vte
*
VTE_new
(
int
maxfields
,
int
width
);
int
VTE_cat
(
struct
vte
*
,
const
char
*
);
void
VTE_destroy
(
struct
vte
**
);
void
VTE_destroy
(
struct
vte
**
);
lib/libvarnish/vte.c
View file @
6dcbc76f
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "config.h"
#include "config.h"
#include <errno.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <sys/types.h>
/* for MUSL (ssize_t) */
#include <sys/types.h>
/* for MUSL (ssize_t) */
...
@@ -91,6 +92,76 @@ VTE_destroy(struct vte **vtep)
...
@@ -91,6 +92,76 @@ VTE_destroy(struct vte **vtep)
FREE_OBJ
(
vte
);
FREE_OBJ
(
vte
);
}
}
static
int
vte_update
(
struct
vte
*
vte
)
{
const
char
*
p
,
*
q
;
int
len
,
fno
;
AZ
(
vte
->
o_sep
);
len
=
VSB_len
(
vte
->
vsb
);
assert
(
len
>=
vte
->
c_off
);
p
=
vte
->
vsb
->
s_buf
+
vte
->
c_off
;
q
=
vte
->
vsb
->
s_buf
+
len
;
for
(;
p
<
q
;
p
++
)
{
if
(
vte
->
f_off
<
0
)
{
while
(
p
<
q
&&
*
p
!=
'\n'
)
p
++
;
}
if
(
vte
->
l_sz
==
0
&&
*
p
==
' '
)
{
vte
->
f_off
=
-
1
;
continue
;
}
if
(
*
p
==
'\t'
||
*
p
==
'\n'
)
{
fno
=
vte
->
f_off
;
if
(
fno
>=
0
&&
vte
->
f_sz
>
vte
->
f_maxsz
[
fno
])
vte
->
f_maxsz
[
fno
]
=
vte
->
f_sz
;
fno
++
;
assert
(
fno
<=
vte
->
f_maxcnt
);
if
(
*
p
==
'\t'
&&
fno
==
vte
->
f_maxcnt
)
{
errno
=
EOVERFLOW
;
vte
->
o_sep
=
-
1
;
return
(
-
1
);
}
vte
->
f_off
=
fno
;
vte
->
f_sz
=
0
;
}
if
(
*
p
==
'\n'
)
{
vte
->
f_cnt
=
vmax
(
vte
->
f_cnt
,
vte
->
f_off
);
vte
->
l_maxsz
=
vmax
(
vte
->
l_maxsz
,
vte
->
l_sz
);
vte
->
f_off
=
0
;
vte
->
f_sz
=
0
;
vte
->
l_sz
=
0
;
}
else
{
vte
->
f_sz
++
;
vte
->
l_sz
++
;
}
}
vte
->
c_off
=
len
;
return
(
0
);
}
int
VTE_cat
(
struct
vte
*
vte
,
const
char
*
s
)
{
CHECK_OBJ_NOTNULL
(
vte
,
VTE_MAGIC
);
AN
(
s
);
if
(
vte
->
o_sep
!=
0
)
return
(
-
1
);
if
(
VSB_cat
(
vte
->
vsb
,
s
)
<
0
)
{
vte
->
o_sep
=
-
1
;
return
(
-
1
);
}
return
(
vte_update
(
vte
));
}
void
void
VCLI_VTE
(
struct
cli
*
cli
,
struct
vsb
**
src
,
int
width
)
VCLI_VTE
(
struct
cli
*
cli
,
struct
vsb
**
src
,
int
width
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment