Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nettle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
5
Merge Requests
5
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Nettle
nettle
Commits
e9d6f612
Commit
e9d6f612
authored
Sep 28, 2002
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(sexp_iterator_assoc): Return 0 for missing or duplicate keys.
Rev: src/nettle/sexp.c:1.3
parent
2b7af82f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
sexp.c
sexp.c
+19
-2
No files found.
sexp.c
View file @
e9d6f612
...
...
@@ -192,9 +192,19 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
const
struct
sexp_assoc_key
*
keys
,
struct
sexp_iterator
*
values
)
{
int
*
found
;
unsigned
nfound
;
unsigned
i
;
if
(
!
sexp_iterator_enter_list
(
iterator
))
return
0
;
found
=
alloca
(
nkeys
*
sizeof
(
*
found
));
for
(
i
=
0
;
i
<
nkeys
;
i
++
)
found
[
i
]
=
0
;
nfound
=
0
;
for
(;;)
{
if
(
!
sexp_iterator_next
(
iterator
))
...
...
@@ -212,13 +222,19 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
&&
!
iterator
->
display
)
{
/* Compare to the given keys */
unsigned
i
;
for
(
i
=
0
;
i
<
nkeys
;
i
++
)
{
if
(
keys
[
i
].
length
==
iterator
->
atom_length
&&
!
memcmp
(
keys
[
i
].
name
,
iterator
->
atom
,
keys
[
i
].
length
))
{
if
(
found
[
i
])
/* We don't allow duplicates */
return
0
;
found
[
i
]
=
1
;
nfound
++
;
/* Record this position. */
values
[
i
]
=
*
iterator
;
...
...
@@ -234,7 +250,8 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
break
;
case
SEXP_END
:
return
sexp_iterator_exit_list
(
iterator
);
return
sexp_iterator_exit_list
(
iterator
)
&&
(
nfound
==
nkeys
);
default:
abort
();
...
...
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