Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asn1c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
qwebaby3
asn1c
Commits
e14480fa
Commit
e14480fa
authored
11 years ago
by
Lev Walkin
Browse files
Options
Downloads
Patches
Plain Diff
fix
https://sourceforge.net/p/asn1c/bugs/51/
parent
f01946ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
asn1c/tests/check-132.-fnative-types.-gen-PER.c
+63
-0
63 additions, 0 deletions
asn1c/tests/check-132.-fnative-types.-gen-PER.c
skeletons/constr_CHOICE.c
+10
-7
10 additions, 7 deletions
skeletons/constr_CHOICE.c
tests/132-per-choice-OK.asn1
+21
-0
21 additions, 0 deletions
tests/132-per-choice-OK.asn1
with
94 additions
and
7 deletions
asn1c/tests/check-132.-fnative-types.-gen-PER.c
0 → 100644
+
63
−
0
View file @
e14480fa
#undef NDEBUG
#include
<stdio.h>
#include
<stdlib.h>
#include
<sys/types.h>
#include
<string.h>
#include
<assert.h>
#include
<ctype.h>
#include
<errno.h>
#include
<T.h>
static
void
verify
(
int
testNo
,
T_t
*
ti
)
{
asn_enc_rval_t
er
;
asn_dec_rval_t
rv
;
unsigned
char
buf
[
2
];
T_t
*
to
=
0
;
er
=
uper_encode_to_buffer
(
&
asn_DEF_T
,
ti
,
buf
,
sizeof
buf
);
fprintf
(
stderr
,
"%d IN: %d => %d
\n
"
,
testNo
,
ti
->
present
,
(
int
)
er
.
encoded
);
assert
(
er
.
encoded
>=
1
&&
er
.
encoded
<=
8
*
sizeof
(
buf
));
rv
=
uper_decode
(
0
,
&
asn_DEF_T
,
(
void
*
)
&
to
,
buf
,
sizeof
buf
,
0
,
0
);
assert
(
rv
.
code
==
RC_OK
);
fprintf
(
stderr
,
"%d ENC: %2x%2x
\n
"
,
testNo
,
buf
[
0
],
buf
[
1
]);
fprintf
(
stderr
,
"%d OUT: %d
\n
"
,
testNo
,
ti
->
present
);
assert
(
ti
->
present
==
to
->
present
);
if
(
ti
->
present
==
T_PR_second
)
{
assert
(
ti
->
choice
.
second
==
to
->
choice
.
second
);
}
else
{
assert
(
ti
->
choice
.
first
.
present
==
to
->
choice
.
first
.
present
);
assert
(
ti
->
choice
.
first
.
choice
.
nothing
==
to
->
choice
.
first
.
choice
.
nothing
);
}
xer_fprint
(
stderr
,
&
asn_DEF_T
,
ti
);
xer_fprint
(
stderr
,
&
asn_DEF_T
,
to
);
}
int
main
()
{
T_t
t
;
memset
(
&
t
,
0
,
sizeof
(
t
));
t
.
present
=
T_PR_first
;
t
.
choice
.
first
.
present
=
first_PR_nothing
;
t
.
choice
.
first
.
choice
.
nothing
=
5
;
verify
(
0
,
&
t
);
memset
(
&
t
,
0
,
sizeof
(
t
));
t
.
present
=
T_PR_first
;
t
.
choice
.
first
.
present
=
first_PR_nothing
;
t
.
choice
.
first
.
choice
.
nothing
=
6
;
verify
(
1
,
&
t
);
memset
(
&
t
,
0
,
sizeof
(
t
));
t
.
present
=
T_PR_second
;
t
.
choice
.
second
=
7
;
verify
(
2
,
&
t
);
return
0
;
}
This diff is collapsed.
Click to expand it.
skeletons/constr_CHOICE.c
+
10
−
7
View file @
e14480fa
...
...
@@ -913,6 +913,7 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
asn_per_constraint_t
*
ct
;
void
*
memb_ptr
;
int
present
;
int
present_enc
;
if
(
!
sptr
)
_ASN_ENCODE_FAILED
;
...
...
@@ -934,15 +935,17 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
else
present
--
;
ASN_DEBUG
(
"Encoding %s CHOICE element %d"
,
td
->
name
,
present
);
/* Adjust if canonical order is different from natural order */
if
(
specs
->
canonical_order
)
present
=
specs
->
canonical_order
[
present
];
ASN_DEBUG
(
"Encoding %s CHOICE element %d"
,
td
->
name
,
present
)
;
present
_enc
=
specs
->
canonical_order
[
present
];
else
present_enc
=
present
;
if
(
ct
&&
ct
->
range_bits
>=
0
)
{
if
(
present
<
ct
->
lower_bound
||
present
>
ct
->
upper_bound
)
{
if
(
present
_enc
<
ct
->
lower_bound
||
present
_enc
>
ct
->
upper_bound
)
{
if
(
ct
->
flags
&
APC_EXTENSIBLE
)
{
if
(
per_put_few_bits
(
po
,
1
,
1
))
_ASN_ENCODE_FAILED
;
...
...
@@ -966,7 +969,7 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
}
if
(
ct
&&
ct
->
range_bits
>=
0
)
{
if
(
per_put_few_bits
(
po
,
present
,
ct
->
range_bits
))
if
(
per_put_few_bits
(
po
,
present
_enc
,
ct
->
range_bits
))
_ASN_ENCODE_FAILED
;
return
elm
->
type
->
uper_encoder
(
elm
->
type
,
elm
->
per_constraints
,
...
...
@@ -975,7 +978,7 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
asn_enc_rval_t
rval
;
if
(
specs
->
ext_start
==
-
1
)
_ASN_ENCODE_FAILED
;
if
(
uper_put_nsnnwn
(
po
,
present
-
specs
->
ext_start
))
if
(
uper_put_nsnnwn
(
po
,
present
_enc
-
specs
->
ext_start
))
_ASN_ENCODE_FAILED
;
if
(
uper_open_type_put
(
elm
->
type
,
elm
->
per_constraints
,
memb_ptr
,
po
))
...
...
This diff is collapsed.
Click to expand it.
tests/132-per-choice-OK.asn1
0 → 100644
+
21
−
0
View file @
e14480fa
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .132
ModulePERChoice
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 132 }
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
T ::= CHOICE {
first [1] CHOICE {
nothing INTEGER (5..10)
},
second [0] INTEGER (-10..10)
}
END
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