summaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorGlenn L McGrath2003-09-17 00:22:26 +0000
committerGlenn L McGrath2003-09-17 00:22:26 +0000
commitd3612178b71b5c7d66252933c3e5a5980887c4ca (patch)
treeed281183851ef7f437520fe212efc54dea2faa80 /shell/ash.c
parent2570b43e829ccfc0f199fe61aafc24b1bd3fc7b1 (diff)
downloadbusybox-d3612178b71b5c7d66252933c3e5a5980887c4ca.zip
busybox-d3612178b71b5c7d66252933c3e5a5980887c4ca.tar.gz
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; }
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 0cdfd2b..8adf581 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.