diff options
author | Dean Prichard <dean.prichard@gmail.com> | 2010-02-05 01:40:58 -0800 |
---|---|---|
committer | Dean Prichard <dean.prichard@gmail.com> | 2010-02-05 01:40:58 -0800 |
commit | d0f7b076cc58443eaa8ed7d9c388fe1cce58408e (patch) | |
tree | 4dfee9b69a77eba4e773915aa4baf3faa8f60cf1 /src/cmd/cc | |
parent | c944300b886a208142c41b5437f4ffc46cc721bd (diff) | |
download | go-d0f7b076cc58443eaa8ed7d9c388fe1cce58408e.tar.gz |
5a/6a/8a/5c/6c/8c: remove fixed-size arrays for -I and -D options
R=rsc
CC=golang-dev
http://codereview.appspot.com/198044
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd/cc')
-rw-r--r-- | src/cmd/cc/cc.h | 2 | ||||
-rw-r--r-- | src/cmd/cc/lex.c | 23 | ||||
-rw-r--r-- | src/cmd/cc/lexbody | 9 |
3 files changed, 17 insertions, 17 deletions
diff --git a/src/cmd/cc/cc.h b/src/cmd/cc/cc.h index 62a33ae5e..6098bc53a 100644 --- a/src/cmd/cc/cc.h +++ b/src/cmd/cc/cc.h @@ -475,7 +475,7 @@ EXTERN Decl* firstdcl; EXTERN int fperror; EXTERN Sym* hash[NHASH]; EXTERN char* hunk; -EXTERN char* include[20]; +EXTERN char** include; EXTERN Io* iofree; EXTERN Io* ionext; EXTERN Io* iostack; diff --git a/src/cmd/cc/lex.c b/src/cmd/cc/lex.c index b722ab15f..63916e2a1 100644 --- a/src/cmd/cc/lex.c +++ b/src/cmd/cc/lex.c @@ -82,7 +82,7 @@ pathchar(void) void main(int argc, char *argv[]) { - char *defs[50], *p; + char **defs, *p; int nproc, nout, i, c, ndef; ensuresymb(NSYMB); @@ -94,8 +94,9 @@ main(int argc, char *argv[]) tufield = simplet((1L<<tfield->etype) | BUNSIGNED); ndef = 0; + defs = nil; outfile = 0; - include[ninclude++] = "."; + setinclude("."); ARGBEGIN { default: c = ARGC(); @@ -119,6 +120,9 @@ main(int argc, char *argv[]) case 'D': p = ARGF(); if(p) { + if(ndef%8 == 0) + defs = allocn(defs, ndef*sizeof(char *), + 8*sizeof(char *)); defs[ndef++] = p; dodefine(p); } @@ -193,7 +197,7 @@ int compile(char *file, char **defs, int ndef) { char *ofile, incfile[20]; - char *p, *av[100], opt[256]; + char *p, **av, opt[256]; int i, c, fd[2]; static int first = 1; @@ -283,6 +287,7 @@ compile(char *file, char **defs, int ndef) close(fd[0]); dup(fd[1], 1); close(fd[1]); + av = alloc((ndef+ninclude+5)*sizeof(char *)); av[0] = CPP; i = 1; if(debug['.']){ @@ -1548,14 +1553,10 @@ setinclude(char *p) if(strcmp(p, include[i]) == 0) return; - if(i >= ninclude) - include[ninclude++] = p; - - if(ninclude > nelem(include)) { - diag(Z, "ninclude too small %d", nelem(include)); - exits("ninclude"); - } - + if(ninclude%8 == 0) + include = allocn(include, ninclude*sizeof(char *), + 8*sizeof(char *)); + include[ninclude++] = p; } } diff --git a/src/cmd/cc/lexbody b/src/cmd/cc/lexbody index 6be2bce92..c026a8d23 100644 --- a/src/cmd/cc/lexbody +++ b/src/cmd/cc/lexbody @@ -149,11 +149,10 @@ setinclude(char *p) for(i=1; i < ninclude; i++) if(strcmp(p, include[i]) == 0) return; - - if(ninclude >= nelem(include)) { - yyerror("ninclude too small %d", nelem(include)); - exits("ninclude"); - } + + if(ninclude%8 == 0) + include = allocn(include, ninclude*sizeof(char *), + 8*sizeof(char *)); include[ninclude++] = p; } |