Updating asn1c to latest git version.
This commit is contained in:
Vendored
+26
-20
@@ -13,11 +13,11 @@ per_data_string(asn_per_data_t *pd) {
|
||||
static int n;
|
||||
n = (n+1) % 2;
|
||||
snprintf(buf[n], sizeof(buf),
|
||||
"{m=%d span %+d[%d..%d] (%d)}",
|
||||
pd->moved,
|
||||
"{m=%ld span %+d[%d..%d] (%d)}",
|
||||
(long)pd->moved,
|
||||
(((int)pd->buffer) & 0xf),
|
||||
pd->nboff, pd->nbits,
|
||||
pd->nbits - pd->nboff);
|
||||
(int)pd->nboff, (int)pd->nbits,
|
||||
(int)(pd->nbits - pd->nboff));
|
||||
return buf[n];
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ per_get_few_bits(asn_per_data_t *pd, int nbits) {
|
||||
int32_t tailv, vhead;
|
||||
if(!pd->refill || nbits > 31) return -1;
|
||||
/* Accumulate unused bytes before refill */
|
||||
ASN_DEBUG("Obtain the rest %d bits (want %d)", nleft, nbits);
|
||||
ASN_DEBUG("Obtain the rest %d bits (want %d)",
|
||||
(int)nleft, (int)nbits);
|
||||
tailv = per_get_few_bits(pd, nleft);
|
||||
if(tailv < 0) return -1;
|
||||
/* Refill (replace pd contents with new data) */
|
||||
@@ -104,12 +105,12 @@ per_get_few_bits(asn_per_data_t *pd, int nbits) {
|
||||
accum &= (((uint32_t)1 << nbits) - 1);
|
||||
|
||||
ASN_DEBUG(" [PER got %2d<=%2d bits => span %d %+d[%d..%d]:%02x (%d) => 0x%x]",
|
||||
nbits, nleft,
|
||||
pd->moved,
|
||||
(int)nbits, (int)nleft,
|
||||
(int)pd->moved,
|
||||
(((int)pd->buffer) & 0xf),
|
||||
pd->nboff, pd->nbits,
|
||||
(int)pd->nboff, (int)pd->nbits,
|
||||
pd->buffer[0],
|
||||
pd->nbits - pd->nboff,
|
||||
(int)(pd->nbits - pd->nboff),
|
||||
(int)accum);
|
||||
|
||||
return accum;
|
||||
@@ -200,7 +201,7 @@ uper_get_nslength(asn_per_data_t *pd) {
|
||||
if(per_get_few_bits(pd, 1) == 0) {
|
||||
length = per_get_few_bits(pd, 6) + 1;
|
||||
if(length <= 0) return -1;
|
||||
ASN_DEBUG("l=%d", length);
|
||||
ASN_DEBUG("l=%d", (int)length);
|
||||
return length;
|
||||
} else {
|
||||
int repeat;
|
||||
@@ -275,7 +276,7 @@ per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) {
|
||||
if(obits <= 0 || obits >= 32) return obits ? -1 : 0;
|
||||
|
||||
ASN_DEBUG("[PER put %d bits %x to %p+%d bits]",
|
||||
obits, (int)bits, po->buffer, po->nboff);
|
||||
obits, (int)bits, po->buffer, (int)po->nboff);
|
||||
|
||||
/*
|
||||
* Normalize position indicator.
|
||||
@@ -291,8 +292,8 @@ per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) {
|
||||
*/
|
||||
if(po->nboff + obits > po->nbits) {
|
||||
int complete_bytes = (po->buffer - po->tmpspace);
|
||||
ASN_DEBUG("[PER output %d complete + %d]",
|
||||
complete_bytes, po->flushed_bytes);
|
||||
ASN_DEBUG("[PER output %ld complete + %ld]",
|
||||
(long)complete_bytes, (long)po->flushed_bytes);
|
||||
if(po->outper(po->tmpspace, complete_bytes, po->op_key) < 0)
|
||||
return -1;
|
||||
if(po->nboff)
|
||||
@@ -307,42 +308,47 @@ per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) {
|
||||
*/
|
||||
buf = po->buffer;
|
||||
omsk = ~((1 << (8 - po->nboff)) - 1);
|
||||
off = (po->nboff += obits);
|
||||
off = (po->nboff + obits);
|
||||
|
||||
/* Clear data of debris before meaningful bits */
|
||||
bits &= (((uint32_t)1 << obits) - 1);
|
||||
|
||||
ASN_DEBUG("[PER out %d %u/%x (t=%d,o=%d) %x&%x=%x]", obits,
|
||||
(int)bits, (int)bits,
|
||||
po->nboff - obits, off, buf[0], omsk&0xff, buf[0] & omsk);
|
||||
(int)po->nboff, (int)off,
|
||||
buf[0], (int)(omsk&0xff),
|
||||
(int)(buf[0] & omsk));
|
||||
|
||||
if(off <= 8) /* Completely within 1 byte */
|
||||
po->nboff = off,
|
||||
bits <<= (8 - off),
|
||||
buf[0] = (buf[0] & omsk) | bits;
|
||||
else if(off <= 16)
|
||||
po->nboff = off,
|
||||
bits <<= (16 - off),
|
||||
buf[0] = (buf[0] & omsk) | (bits >> 8),
|
||||
buf[1] = bits;
|
||||
else if(off <= 24)
|
||||
po->nboff = off,
|
||||
bits <<= (24 - off),
|
||||
buf[0] = (buf[0] & omsk) | (bits >> 16),
|
||||
buf[1] = bits >> 8,
|
||||
buf[2] = bits;
|
||||
else if(off <= 31)
|
||||
po->nboff = off,
|
||||
bits <<= (32 - off),
|
||||
buf[0] = (buf[0] & omsk) | (bits >> 24),
|
||||
buf[1] = bits >> 16,
|
||||
buf[2] = bits >> 8,
|
||||
buf[3] = bits;
|
||||
else {
|
||||
ASN_DEBUG("->[PER out split %d]", obits);
|
||||
per_put_few_bits(po, bits >> 8, 24);
|
||||
per_put_few_bits(po, bits >> (obits - 24), 24);
|
||||
per_put_few_bits(po, bits, obits - 24);
|
||||
ASN_DEBUG("<-[PER out split %d]", obits);
|
||||
}
|
||||
|
||||
ASN_DEBUG("[PER out %u/%x => %02x buf+%d]",
|
||||
(int)bits, (int)bits, buf[0], po->buffer - po->tmpspace);
|
||||
ASN_DEBUG("[PER out %u/%x => %02x buf+%ld]",
|
||||
(int)bits, (int)bits, buf[0],
|
||||
(long)(po->buffer - po->tmpspace));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user