Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
e14480fa
Commit
e14480fa
authored
Mar 24, 2013
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
https://sourceforge.net/p/asn1c/bugs/51/
parent
f01946ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
7 deletions
+94
-7
asn1c/tests/check-132.-fnative-types.-gen-PER.c
asn1c/tests/check-132.-fnative-types.-gen-PER.c
+63
-0
skeletons/constr_CHOICE.c
skeletons/constr_CHOICE.c
+10
-7
tests/132-per-choice-OK.asn1
tests/132-per-choice-OK.asn1
+21
-0
No files found.
asn1c/tests/check-132.-fnative-types.-gen-PER.c
0 → 100644
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
;
}
skeletons/constr_CHOICE.c
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
))
...
...
tests/132-per-choice-OK.asn1
0 → 100644
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
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