Re: [PATCH v3 3/5] config: make parsing stack struct independent from actual data source
- From
Jeff King <peff@peff.net>
- Date
- May 9, 2013, 22:21 UTC
- Message-ID
- <20130509222158.GA30774@sigill.intra.peff.net>
- In-Reply-To
- <20130509161932.GE3526@book-mint>
On Thu, May 09, 2013 at 06:19:32PM +0200, Heiko Voigt wrote:
Show 16 quoted lines
> diff --git a/config.c b/config.c
> index 046642b..2390458 100644
> --- a/config.c
> +++ b/config.c
> @@ -10,20 +10,41 @@
> #include "strbuf.h"
> #include "quote.h"
>
> -typedef struct config_file {
> - struct config_file *prev;
> - FILE *f;
> +struct config_source {
> + struct config_source *prev;
> + union {
> + FILE *file;
> + };Anonymous unions like this are a C11-ism (I don't know when gcc learned about them, but I am sure that many of the older compilers we support would not be happy). You have to do:
union {
FILE *file;
} u;and access the file as "cf->u.file".
-Peff