# HG changeset patch # Parent 7da35bced88e6b100f448fe18fb7e11bd2bce419 Issue #4347: Fix dependencies between pgen, parsetok.c and graminit.h diff -r 7da35bced88e Makefile.pre.in --- a/Makefile.pre.in Mon Nov 21 00:21:39 2016 +0000 +++ b/Makefile.pre.in Mon Nov 21 04:57:37 2016 +0000 @@ -252,7 +252,6 @@ Parser/listnode.c \ Parser/node.c \ Parser/parser.c \ - Parser/parsetok.c \ Parser/bitset.c \ Parser/metagrammar.c \ Parser/firstsets.c \ @@ -265,14 +264,14 @@ Parser/listnode.o \ Parser/node.o \ Parser/parser.o \ - Parser/parsetok.o \ Parser/bitset.o \ Parser/metagrammar.o \ Parser/firstsets.o \ Parser/grammar.o \ Parser/pgen.o -PARSER_OBJS= $(POBJS) Parser/myreadline.o Parser/tokenizer.o +PARSER_OBJS= $(POBJS) \ + Parser/myreadline.o Parser/parsetok.o Parser/tokenizer.o PGSRCS= \ Objects/obmalloc.c \ @@ -280,6 +279,7 @@ Python/pyctype.c \ Parser/tokenizer_pgen.c \ Parser/printgrammar.c \ + Parser/parsetok_pgen.c \ Parser/pgenmain.c PGOBJS= \ @@ -288,6 +288,7 @@ Python/pyctype.o \ Parser/tokenizer_pgen.o \ Parser/printgrammar.o \ + Parser/parsetok_pgen.o \ Parser/pgenmain.o PARSER_HEADERS= \ @@ -694,6 +695,7 @@ Parser/metagrammar.o: $(srcdir)/Parser/metagrammar.c Parser/tokenizer_pgen.o: $(srcdir)/Parser/tokenizer.c +Parser/parsetok_pgen.o: $(srcdir)/Parser/parsetok.c Parser/pgenmain.o: $(srcdir)/Include/parsetok.h @@ -706,6 +708,7 @@ $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL) Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H) +Parser/parsetok.o: $(GRAMMAR_H) Python/getplatform.o: $(srcdir)/Python/getplatform.c $(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c diff -r 7da35bced88e Misc/NEWS --- a/Misc/NEWS Mon Nov 21 00:21:39 2016 +0000 +++ b/Misc/NEWS Mon Nov 21 04:57:37 2016 +0000 @@ -276,6 +276,8 @@ Build ----- +- Issue #4347: Fix dependencies between pgen, parsetok.c and graminit.h. + - Issue #10656: Fix out-of-tree building on AIX. Patch by Tristan Carel and Michael Haubenwallner. diff -r 7da35bced88e Parser/parsetok.c --- a/Parser/parsetok.c Mon Nov 21 00:21:39 2016 +0000 +++ b/Parser/parsetok.c Mon Nov 21 04:57:37 2016 +0000 @@ -8,7 +8,10 @@ #include "parser.h" #include "parsetok.h" #include "errcode.h" -#include "graminit.h" + +#ifndef PGEN +# include "graminit.h" +#endif int Py_TabcheckFlag; @@ -17,6 +20,7 @@ static node *parsetok(struct tok_state *, grammar *, int, perrdetail *, int *); static void initerr(perrdetail *err_ret, const char* filename); +#ifndef PGEN /* Parse input coming from a string. Return error code, print some errors. */ node * PyParser_ParseString(const char *s, grammar *g, int start, perrdetail *err_ret) @@ -65,6 +69,7 @@ return parsetok(tok, g, start, err_ret, flags); } +#endif /* Parse input coming from a file. Return error code, print some errors. */ @@ -241,7 +246,9 @@ } err_ret->text = text; } - } else if (tok->encoding != NULL) { + } +#ifndef PGEN + else if (tok->encoding != NULL) { /* 'nodes->n_str' uses PyObject_*, while 'tok->encoding' was * allocated using PyMem_ */ @@ -264,6 +271,7 @@ } done: +#endif PyTokenizer_Free(tok); return n; diff -r 7da35bced88e Parser/parsetok_pgen.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Parser/parsetok_pgen.c Mon Nov 21 04:57:37 2016 +0000 @@ -0,0 +1,2 @@ +#define PGEN +#include "parsetok.c"