1
0
mirror of https://github.com/golang/go synced 2024-11-22 02:14:40 -07:00

5a/6a/8a/5c/6c/8c: remove fixed-size arrays for -I and -D options

R=rsc
CC=golang-dev
https://golang.org/cl/198044
This commit is contained in:
Dean Prichard 2010-02-05 01:40:58 -08:00 committed by Russ Cox
parent 04217ee54e
commit 0e47c75f60
9 changed files with 41 additions and 32 deletions

View File

@ -54,7 +54,6 @@ typedef struct Hist Hist;
#define NSYMB 8192
#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
#define EOF (-1)
#define IGN (-2)
@ -128,13 +127,13 @@ enum
EXTERN char debug[256];
EXTERN Sym* hash[NHASH];
EXTERN char* Dlist[30];
EXTERN char** Dlist;
EXTERN int nDlist;
EXTERN Hist* ehist;
EXTERN int newflag;
EXTERN Hist* hist;
EXTERN char* hunk;
EXTERN char* include[NINCLUDE];
EXTERN char** include;
EXTERN Io* iofree;
EXTERN Io* ionext;
EXTERN Io* iostack;

View File

@ -62,7 +62,7 @@ main(int argc, char *argv[])
memset(debug, 0, sizeof(debug));
cinit();
outfile = 0;
include[ninclude++] = ".";
setinclude(".");
ARGBEGIN {
default:
c = ARGC();
@ -76,8 +76,12 @@ main(int argc, char *argv[])
case 'D':
p = ARGF();
if(p)
if(p) {
if (nDlist%8 == 0)
Dlist = allocn(Dlist, nDlist*sizeof(char *),
8*sizeof(char *));
Dlist[nDlist++] = p;
}
break;
case 'I':

View File

@ -57,7 +57,6 @@ typedef struct Gen2 Gen2;
#define NSYMB 500
#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
#define EOF (-1)
#define IGN (-2)
@ -141,13 +140,13 @@ enum
EXTERN char debug[256];
EXTERN Sym* hash[NHASH];
EXTERN char* Dlist[30];
EXTERN char** Dlist;
EXTERN int nDlist;
EXTERN Hist* ehist;
EXTERN int newflag;
EXTERN Hist* hist;
EXTERN char* hunk;
EXTERN char* include[NINCLUDE];
EXTERN char** include;
EXTERN Io* iofree;
EXTERN Io* ionext;
EXTERN Io* iostack;

View File

@ -65,7 +65,7 @@ main(int argc, char *argv[])
memset(debug, 0, sizeof(debug));
cinit();
outfile = 0;
include[ninclude++] = ".";
setinclude(".");
ARGBEGIN {
default:
c = ARGC();
@ -79,8 +79,12 @@ main(int argc, char *argv[])
case 'D':
p = ARGF();
if(p)
if(p) {
if (nDlist%8 == 0)
Dlist = allocn(Dlist, nDlist*sizeof(char *),
8*sizeof(char *));
Dlist[nDlist++] = p;
}
break;
case 'I':

View File

@ -57,7 +57,6 @@ typedef struct Gen2 Gen2;
#define NSYMB 500
#define BUFSIZ 8192
#define HISTSZ 20
#define NINCLUDE 10
#define NHUNK 10000
#define EOF (-1)
#define IGN (-2)
@ -142,13 +141,13 @@ enum
EXTERN char debug[256];
EXTERN Sym* hash[NHASH];
EXTERN char* Dlist[30];
EXTERN char** Dlist;
EXTERN int nDlist;
EXTERN Hist* ehist;
EXTERN int newflag;
EXTERN Hist* hist;
EXTERN char* hunk;
EXTERN char* include[NINCLUDE];
EXTERN char** include;
EXTERN Io* iofree;
EXTERN Io* ionext;
EXTERN Io* iostack;

View File

@ -65,7 +65,7 @@ main(int argc, char *argv[])
memset(debug, 0, sizeof(debug));
cinit();
outfile = 0;
include[ninclude++] = ".";
setinclude(".");
ARGBEGIN {
default:
c = ARGC();
@ -79,8 +79,12 @@ main(int argc, char *argv[])
case 'D':
p = ARGF();
if(p)
if(p) {
if (nDlist%8 == 0)
Dlist = allocn(Dlist, nDlist*sizeof(char *),
8*sizeof(char *));
Dlist[nDlist++] = p;
}
break;
case 'I':

View File

@ -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;

View File

@ -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)
if(ninclude%8 == 0)
include = allocn(include, ninclude*sizeof(char *),
8*sizeof(char *));
include[ninclude++] = p;
if(ninclude > nelem(include)) {
diag(Z, "ninclude too small %d", nelem(include));
exits("ninclude");
}
}
}

View File

@ -150,10 +150,9 @@ setinclude(char *p)
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;
}