From d3612178b71b5c7d66252933c3e5a5980887c4ca Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Wed, 17 Sep 2003 00:22:26 +0000 Subject: Patch by Junio C Hamano to workaround a gcc compiler bug. The construct certain vintages of GCC (the one I have trouble with is 3.2.3) have trouble with looks like the following: static struct st a; static struct st *p = &a; struct st { int foo; }; static void init(void) { a.foo = 0; } The problem disappears if we move the struct declaration up to let the compiler know the shape of the struct before the first definition uses it, like this: struct st { int foo; }; /* this has been moved up */ static struct st a; static struct st *p = &a; static void init(void) { a.foo = 0; } --- shell/ash.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 0cdfd2b1c..8adf581b6 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -550,6 +550,29 @@ static int parselleft; /* copy of parsefile->lleft */ /* next character in input buffer */ static char *parsenextc; /* copy of parsefile->nextc */ + +struct strpush { + struct strpush *prev; /* preceding string on stack */ + char *prevstring; + int prevnleft; +#ifdef CONFIG_ASH_ALIAS + struct alias *ap; /* if push was associated with an alias */ +#endif + char *string; /* remember the string since it may change */ +}; + +struct parsefile { + struct parsefile *prev; /* preceding file on stack */ + int linno; /* current line */ + int fd; /* file descriptor (or -1 if string) */ + int nleft; /* number of chars left in this line */ + int lleft; /* number of chars left in this buffer */ + char *nextc; /* next char in buffer */ + char *buf; /* input buffer */ + struct strpush *strpush; /* for pushing strings at this level */ + struct strpush basestrpush; /* so pushing one is fast */ +}; + static struct parsefile basepf; /* top level input file */ static char basebuf[IBUFSIZ]; /* buffer for top level input file */ static struct parsefile *parsefile = &basepf; /* current input file */ @@ -1573,28 +1596,6 @@ static inline int varequal(const char *a, const char *b) { static int loopnest; /* current loop nesting level */ -struct strpush { - struct strpush *prev; /* preceding string on stack */ - char *prevstring; - int prevnleft; -#ifdef CONFIG_ASH_ALIAS - struct alias *ap; /* if push was associated with an alias */ -#endif - char *string; /* remember the string since it may change */ -}; - -struct parsefile { - struct parsefile *prev; /* preceding file on stack */ - int linno; /* current line */ - int fd; /* file descriptor (or -1 if string) */ - int nleft; /* number of chars left in this line */ - int lleft; /* number of chars left in this buffer */ - char *nextc; /* next char in buffer */ - char *buf; /* input buffer */ - struct strpush *strpush; /* for pushing strings at this level */ - struct strpush basestrpush; /* so pushing one is fast */ -}; - /* * The parsefile structure pointed to by the global variable parsefile * contains information about the current file being read. -- cgit v1.2.3