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
1a43a0e1
Commit
1a43a0e1
authored
Aug 22, 2023
by
Dridi Boukelmoune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vte: Add support for left-justified fields
parent
4957292f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
8 deletions
+32
-8
vte.h
include/vte.h
+4
-2
vte.c
lib/libvarnish/vte.c
+28
-6
No files found.
include/vte.h
View file @
1a43a0e1
...
...
@@ -30,9 +30,11 @@
*
* Align and print fields in a line-based output. Fields are delimited
* with a horizontal tab HT and lines starting with a space SP are kept
* verbatim. Lines are delimited with a single new line LF character.
* verbatim. Lines are delimited with a single new line LF character. A
* field starting with a vertical tab VT is justified to the left.
*
* Using non-ASCII or non-printable ASCII character is undefined behavior.
* Using non-ASCII or non-printable ASCII characters besides delimiters
* and modifiers for fields and lines is undefined behavior.
*/
struct
vte
;
...
...
lib/libvarnish/vte.c
View file @
1a43a0e1
...
...
@@ -116,6 +116,8 @@ vte_update(struct vte *vte)
vte
->
f_off
=
-
1
;
continue
;
}
if
(
vte
->
f_off
>=
0
&&
vte
->
f_sz
==
0
&&
*
p
==
'\v'
)
p
++
;
if
(
*
p
==
'\t'
||
*
p
==
'\n'
)
{
fno
=
vte
->
f_off
;
if
(
fno
>=
0
&&
vte
->
f_sz
>
vte
->
f_maxsz
[
fno
])
...
...
@@ -240,8 +242,8 @@ VTE_finish(struct vte *vte)
int
VTE_format
(
const
struct
vte
*
vte
,
VTE_format_f
*
func
,
void
*
priv
)
{
int
fno
,
fsz
,
nsp
;
const
char
*
p
,
*
q
;
int
fno
,
fsz
,
nsp
,
just_left
;
const
char
*
p
,
*
q
,
*
sep
;
CHECK_OBJ_NOTNULL
(
vte
,
VTE_MAGIC
);
AN
(
func
);
...
...
@@ -255,22 +257,42 @@ VTE_format(const struct vte *vte, VTE_format_f *func, void *priv)
q
=
p
;
fno
=
0
;
sep
=
""
;
just_left
=
0
;
while
(
*
p
!=
0
)
{
if
(
fno
==
0
&&
*
p
==
' '
)
if
(
*
p
==
'\v'
)
{
if
(
p
-
1
>
q
)
{
/* exclude previous separator */
VTE_FORMAT
(
func
,
priv
,
"%.*s%s"
,
(
int
)(
p
-
1
-
q
),
q
,
sep
);
}
q
=
++
p
;
just_left
=
1
;
}
if
(
!
just_left
&&
fno
==
0
&&
*
p
==
' '
)
fsz
=
strcspn
(
p
,
"
\n
"
);
else
fsz
=
strcspn
(
p
,
"
\t\n
"
);
p
+=
fsz
;
if
(
*
p
==
'\t'
)
{
assert
(
vte
->
f_maxsz
[
fno
]
+
nsp
>
fsz
);
VTE_FORMAT
(
func
,
priv
,
"%.*s%*s"
,
(
int
)(
p
-
q
),
q
,
vte
->
f_maxsz
[
fno
]
+
nsp
-
fsz
,
""
);
if
(
just_left
)
{
VTE_FORMAT
(
func
,
priv
,
"%*s%.*s%*s"
,
vte
->
f_maxsz
[
fno
]
-
fsz
,
""
,
(
int
)(
p
-
q
),
q
,
nsp
,
""
);
just_left
=
0
;
}
else
{
VTE_FORMAT
(
func
,
priv
,
"%.*s%*s"
,
(
int
)(
p
-
q
),
q
,
vte
->
f_maxsz
[
fno
]
+
nsp
-
fsz
,
""
);
}
fno
++
;
q
=
++
p
;
sep
=
""
;
}
else
if
(
*
p
==
'\n'
)
{
fno
=
0
;
p
++
;
sep
=
"
\n
"
;
}
}
...
...
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