Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Brian Smith
nettle
Commits
e9d6f612
Commit
e9d6f612
authored
22 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
(sexp_iterator_assoc): Return 0 for missing or duplicate keys.
Rev: src/nettle/sexp.c:1.3
parent
2b7af82f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sexp.c
+19
-2
19 additions, 2 deletions
sexp.c
with
19 additions
and
2 deletions
sexp.c
+
19
−
2
View file @
e9d6f612
...
@@ -192,9 +192,19 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
...
@@ -192,9 +192,19 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
const
struct
sexp_assoc_key
*
keys
,
const
struct
sexp_assoc_key
*
keys
,
struct
sexp_iterator
*
values
)
struct
sexp_iterator
*
values
)
{
{
int
*
found
;
unsigned
nfound
;
unsigned
i
;
if
(
!
sexp_iterator_enter_list
(
iterator
))
if
(
!
sexp_iterator_enter_list
(
iterator
))
return
0
;
return
0
;
found
=
alloca
(
nkeys
*
sizeof
(
*
found
));
for
(
i
=
0
;
i
<
nkeys
;
i
++
)
found
[
i
]
=
0
;
nfound
=
0
;
for
(;;)
for
(;;)
{
{
if
(
!
sexp_iterator_next
(
iterator
))
if
(
!
sexp_iterator_next
(
iterator
))
...
@@ -212,13 +222,19 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
...
@@ -212,13 +222,19 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
&&
!
iterator
->
display
)
&&
!
iterator
->
display
)
{
{
/* Compare to the given keys */
/* Compare to the given keys */
unsigned
i
;
for
(
i
=
0
;
i
<
nkeys
;
i
++
)
for
(
i
=
0
;
i
<
nkeys
;
i
++
)
{
{
if
(
keys
[
i
].
length
==
iterator
->
atom_length
if
(
keys
[
i
].
length
==
iterator
->
atom_length
&&
!
memcmp
(
keys
[
i
].
name
,
iterator
->
atom
,
&&
!
memcmp
(
keys
[
i
].
name
,
iterator
->
atom
,
keys
[
i
].
length
))
keys
[
i
].
length
))
{
{
if
(
found
[
i
])
/* We don't allow duplicates */
return
0
;
found
[
i
]
=
1
;
nfound
++
;
/* Record this position. */
/* Record this position. */
values
[
i
]
=
*
iterator
;
values
[
i
]
=
*
iterator
;
...
@@ -234,7 +250,8 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
...
@@ -234,7 +250,8 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
break
;
break
;
case
SEXP_END
:
case
SEXP_END
:
return
sexp_iterator_exit_list
(
iterator
);
return
sexp_iterator_exit_list
(
iterator
)
&&
(
nfound
==
nkeys
);
default:
default:
abort
();
abort
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment