encoding per sequence
diff --git a/asn1c/tests/check-126.-gen-PER.c b/asn1c/tests/check-126.-gen-PER.c
index 5df2c78..eac2793 100644
--- a/asn1c/tests/check-126.-gen-PER.c
+++ b/asn1c/tests/check-126.-gen-PER.c
@@ -224,8 +224,12 @@
fprintf(stderr, "Comparing PER output with [%s]\n", outName);
- f = fopen(outName, "r");
- if(f) {
+ if(getenv("REGENERATE")) {
+ f = fopen(outName, "w");
+ fwrite(buf, 1, size, f);
+ fclose(f);
+ } else {
+ f = fopen(outName, "r");
assert(f);
rd = fread(fbuf, 1, sizeof(fbuf), f);
assert(rd);
@@ -234,10 +238,6 @@
assert(rd == size);
assert(memcmp(fbuf, buf, rd) == 0);
fprintf(stderr, "XER->PER recoding .in->.out match.\n");
- } else if(getenv("REGENERATE")) {
- f = fopen(outName, "w");
- fwrite(buf, 1, size, f);
- fclose(f);
}
}
diff --git a/asn1c/tests/data-126/data-126-01.out b/asn1c/tests/data-126/data-126-01.out
new file mode 100644
index 0000000..0f23c82
--- /dev/null
+++ b/asn1c/tests/data-126/data-126-01.out
Binary files differ
diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c
index a6d12fa..9f870f7 100644
--- a/skeletons/constr_SEQUENCE.c
+++ b/skeletons/constr_SEQUENCE.c
@@ -1170,9 +1170,11 @@
void *buf;
ssize_t size;
+ ASN_DEBUG("Encoding as open type %s", td->name);
size = uper_encode_to_new_buffer(td, constraints, sptr, &buf);
if(size <= 0) return -1;
+ ASN_DEBUG("Putting %s of length %d", td->name, size);
while(size) {
ssize_t maySave = uper_put_length(po, size);
if(maySave < 0) break;
@@ -1194,7 +1196,8 @@
asn_per_outp_t *po1, asn_per_outp_t *po2) {
asn_SEQUENCE_specifics_t *specs
= (asn_SEQUENCE_specifics_t *)td->specifics;
- int num = 0;
+ int exts_present = 0;
+ int exts_count = 0;
int edx;
if(specs->ext_before < 0)
@@ -1207,8 +1210,10 @@
void **memb_ptr2; /* Pointer to that pointer */
int present;
- if(!IN_EXTENSION_GROUP(specs, edx))
+ if(!IN_EXTENSION_GROUP(specs, edx)) {
+ ASN_DEBUG("%d is not extension", edx);
continue;
+ }
/* Fetch the pointer to this member */
if(elm->flags & ATF_POINTER) {
@@ -1221,7 +1226,8 @@
}
ASN_DEBUG("checking ext %d is present => %d", edx, present);
- num += present;
+ exts_count++;
+ exts_present += present;
/* Encode as presence marker */
if(po1 && per_put_few_bits(po1, present, 1))
@@ -1233,7 +1239,7 @@
}
- return num;
+ return exts_present ? exts_count : 0;
}
asn_enc_rval_t