[esnacc-dev] [PATCH v2] c-lib: Remove unneeded config.h references

Uri Blumenthal uri at mit.edu
Sun Nov 13 16:23:56 UTC 2016


Thank you - your patch appears to work. I guess it can be merged.

Downside - on my system (after “make clean && make all && make test && sudo make install”) it did not refresh $PREFIX/c-lib/inc/snacc.h, so I had to replace it manually.

> On Nov 13, 2016, at 3:31 , Aaron Conole <aconole at bytheb.org> wrote:
> 
> It appears that the config.h file is being included, which makes using
> the distributed version of esnacc unusable.
> 
> After this change, we rely on standardized C99.  Since it's 17 years old,
> at this point, I think it's likely safe to rely on, and the patch
> statistics look good.
> 
> Signed-off-by: Aaron Conole <aconole at bytheb.org>
> Reported-by: Uri Blumenthal <uri at mit.edu>
> Reported-at: https://github.com/esnacc/esnacc-ng/issues/39
> ---
> This is for backporting to the stable 1.8 branch
> 
> c-lib/src/asn-bits.c             | 5 ++++-
> c-lib/src/asn-octs.c             | 3 ++-
> compiler/back-ends/c++-gen/kwd.c | 1 +
> compiler/back-ends/c-gen/kwd.c   | 1 +
> compiler/core/lex-asn1.l         | 1 +
> snacc.h                          | 20 +-------------------
> c-lib/inc/asn-config.h           | 1 -
> 7 files changed, 10 insertions(+), 22 deletions(-)
> 
> diff --git a/c-lib/src/asn-bits.c b/c-lib/src/asn-bits.c
> index 369c347..457388e 100644
> --- a/c-lib/src/asn-bits.c
> +++ b/c-lib/src/asn-bits.c
> @@ -349,7 +349,10 @@ AsnBitsEquiv PARAMS ((b1, b2),
>        unusedBits = 8 - unusedBits;
> 
>     /* trailing bits may not be significant  */
> -    return b1->bitLen == b2->bitLen && !memcmpeq (b1->bits, b2->bits, octetsLessOne) && ((b1->bits[octetsLessOne] & (0xFF << unusedBits)) == (b1->bits[octetsLessOne] & (0xFF << unusedBits)));
> +    return b1->bitLen == b2->bitLen &&
> +        !memcmp(b1->bits, b2->bits, octetsLessOne) &&
> +        ((b1->bits[octetsLessOne] & (0xFF << unusedBits)) ==
> +         (b1->bits[octetsLessOne] & (0xFF << unusedBits)));
> 
> } /* AsnBitsEquiv */
> 
> diff --git a/c-lib/src/asn-octs.c b/c-lib/src/asn-octs.c
> index 30a647a..b34b8b7 100644
> --- a/c-lib/src/asn-octs.c
> +++ b/c-lib/src/asn-octs.c
> @@ -355,7 +355,8 @@ AsnOctsEquiv PARAMS ((o1, o2),
>     AsnOcts *o1 _AND_
>     AsnOcts *o2)
> {
> -    return o1->octetLen == o2->octetLen && !memcmpeq (o1->octs, o2->octs, o1->octetLen);
> +    return o1->octetLen == o2->octetLen &&
> +        !memcmp(o1->octs, o2->octs, o1->octetLen);
> } /* AsnOctsEquiv */
> 
> 
> diff --git a/compiler/back-ends/c++-gen/kwd.c b/compiler/back-ends/c++-gen/kwd.c
> index 5b5c3af..79b3918 100644
> --- a/compiler/back-ends/c++-gen/kwd.c
> +++ b/compiler/back-ends/c++-gen/kwd.c
> @@ -51,6 +51,7 @@
>  *
>  */
> 
> +#include "config.h"
> #include "snacc.h"
> 
> #if STDC_HEADERS || HAVE_STRING_H
> diff --git a/compiler/back-ends/c-gen/kwd.c b/compiler/back-ends/c-gen/kwd.c
> index e1b75a9..1c10f53 100644
> --- a/compiler/back-ends/c-gen/kwd.c
> +++ b/compiler/back-ends/c-gen/kwd.c
> @@ -35,6 +35,7 @@
>  *
>  */
> 
> +#include "config.h"
> #include "snacc.h"
> 
> #if STDC_HEADERS || HAVE_STRING_H
> diff --git a/compiler/core/lex-asn1.l b/compiler/core/lex-asn1.l
> index 585c427..165de52 100644
> --- a/compiler/core/lex-asn1.l
> +++ b/compiler/core/lex-asn1.l
> @@ -27,6 +27,7 @@
> 
> %{
> 
> +#include "config.h"
> #include <string.h>
> #include <errno.h>
> #include "asn-incl.h"
> diff --git a/snacc.h b/snacc.h
> index deb871b..d9732b0 100644
> --- a/snacc.h
> +++ b/snacc.h
> @@ -72,25 +72,7 @@
> #define GLASS	1
> #define KHO	1
> 
> -#include "config.h"
> -
> -#ifndef NULL
> -#define NULL	0
> -#endif
> -
> -#if HAVE_MEMCMP /* memcmp(3) returns <0, 0 and 0, bcmp(3) returns only 0 and !0 */
> -#define memcmpeq( a, b, len)	memcmp (a, b, len)
> -#else
> -#define memcmpeq( a, b, len)	bcmp (a, b, len)
> -#endif
> -#if HAVE_MEMSET
> -#define memzero( p, len)	memset (p, 0, len)
> -#else
> -#define memzero( p, len)	bzero (p, len)
> -#endif
> -#if !HAVE_MEMCPY
> -#define memcpy( dst, src, len)	bcopy (src, dst, len)
> -#endif
> +#define memzero(p, len)   memset(p, 0, len)
> 
> #ifdef __cplusplus
> 
> diff --git a/c-lib/inc/asn-config.h b/c-lib/inc/asn-config.h
> index ca7b8c4..9a31d6e 100644
> --- a/c-lib/inc/asn-config.h
> +++ b/c-lib/inc/asn-config.h
> @@ -102,7 +102,6 @@
> /* for pow() used in asn_real.c - must include to avoid casting err on pow */
> /* #include <math.h> */
> 
> -#include "config.h"
> #include "snacc.h"
> 
> 
> --
> 2.7.0

--
Uri Blumenthal
uri at mit.edu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1838 bytes
Desc: not available
URL: <http://mail.esnacc.org/pipermail/dev/attachments/20161113/6349a9ba/attachment-0002.p7s>


More information about the dev mailing list