Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LSH
lsh
Commits
34a0d032
Commit
34a0d032
authored
Oct 17, 1998
by
Niels Möller
Browse files
Ignore zeros in the lists passed to %A.
Rev: src/format.c:1.15 Rev: src/format.h:1.12
parent
b5fc9824
Changes
2
Show whitespace changes
Inline
Side-by-side
src/format.c
View file @
34a0d032
...
...
@@ -148,16 +148,20 @@ UINT32 ssh_vformat_length(char *f, va_list args)
case
'A'
:
{
int
*
atom
=
va_arg
(
args
,
int
*
);
int
i
;
int
n
;
if
(
atom
[
0
])
{
/* Non empty */
for
(
i
=
0
;
atom
[
i
]
>
0
;
i
++
)
length
+=
get_atom_length
(
atom
[
i
])
+
1
;
/* One ','-character less than the number of atoms */
length
--
;
for
(
n
=
0
;
*
atom
>=
0
;
atom
++
)
{
if
(
*
atom
)
{
n
++
;
length
+=
get_atom_length
(
*
atom
);
}
}
if
(
n
)
/* One ','-character less than the number of atoms */
length
+=
(
n
-
1
);
if
(
!
literal
)
length
+=
4
;
f
++
;
...
...
@@ -333,23 +337,25 @@ UINT32 ssh_vformat(char *f, UINT8 *buffer, va_list args)
{
int
*
atom
=
va_arg
(
args
,
int
*
);
UINT8
*
start
=
buffer
;
/* Where to store the length */
int
i
;
int
n
;
if
(
!
literal
)
buffer
+=
4
;
if
(
atom
[
0
]
>
0
)
for
(
n
=
0
;
*
atom
>
=
0
;
atom
++
)
{
UINT32
length
=
get_atom_length
(
atom
[
0
]);
memcpy
(
buffer
,
get_atom_name
(
atom
[
0
]),
length
);
buffer
+=
length
;
for
(
i
=
1
;
atom
[
i
]
>
0
;
i
++
)
if
(
*
atom
)
{
UINT32
length
=
get_atom_length
(
*
atom
);
if
(
n
)
/* Not the first atom */
*
buffer
++
=
','
;
length
=
get_atom_length
(
atom
[
i
]);
memcpy
(
buffer
,
get_atom_name
(
atom
[
i
]),
length
);
memcpy
(
buffer
,
get_atom_name
(
atom
[
0
]),
length
);
buffer
+=
length
;
n
++
;
}
}
...
...
src/format.h
View file @
34a0d032
...
...
@@ -52,7 +52,7 @@
*
* %A Insert a string containing a list of atoms. The corresponding
* argument sublist should be a int* pointing to a list of atoms,
* terminated with -1.
* terminated with -1.
Zero elements are allowed and ignored.
*
* %X Insert a string containing a list of atoms. The corresponding
* argument sublist should be terminated with a zero. (Not used)
...
...
Write
Preview
Supports
Markdown
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