mirror of
https://github.com/golang/go
synced 2024-11-22 02:04: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:
parent
04217ee54e
commit
0e47c75f60
@ -54,7 +54,6 @@ typedef struct Hist Hist;
|
|||||||
#define NSYMB 8192
|
#define NSYMB 8192
|
||||||
#define BUFSIZ 8192
|
#define BUFSIZ 8192
|
||||||
#define HISTSZ 20
|
#define HISTSZ 20
|
||||||
#define NINCLUDE 10
|
|
||||||
#define NHUNK 10000
|
#define NHUNK 10000
|
||||||
#define EOF (-1)
|
#define EOF (-1)
|
||||||
#define IGN (-2)
|
#define IGN (-2)
|
||||||
@ -128,13 +127,13 @@ enum
|
|||||||
|
|
||||||
EXTERN char debug[256];
|
EXTERN char debug[256];
|
||||||
EXTERN Sym* hash[NHASH];
|
EXTERN Sym* hash[NHASH];
|
||||||
EXTERN char* Dlist[30];
|
EXTERN char** Dlist;
|
||||||
EXTERN int nDlist;
|
EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
EXTERN char* hunk;
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char** include;
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
|
@ -62,7 +62,7 @@ main(int argc, char *argv[])
|
|||||||
memset(debug, 0, sizeof(debug));
|
memset(debug, 0, sizeof(debug));
|
||||||
cinit();
|
cinit();
|
||||||
outfile = 0;
|
outfile = 0;
|
||||||
include[ninclude++] = ".";
|
setinclude(".");
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
default:
|
default:
|
||||||
c = ARGC();
|
c = ARGC();
|
||||||
@ -76,8 +76,12 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
p = ARGF();
|
p = ARGF();
|
||||||
if(p)
|
if(p) {
|
||||||
|
if (nDlist%8 == 0)
|
||||||
|
Dlist = allocn(Dlist, nDlist*sizeof(char *),
|
||||||
|
8*sizeof(char *));
|
||||||
Dlist[nDlist++] = p;
|
Dlist[nDlist++] = p;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
|
@ -57,7 +57,6 @@ typedef struct Gen2 Gen2;
|
|||||||
#define NSYMB 500
|
#define NSYMB 500
|
||||||
#define BUFSIZ 8192
|
#define BUFSIZ 8192
|
||||||
#define HISTSZ 20
|
#define HISTSZ 20
|
||||||
#define NINCLUDE 10
|
|
||||||
#define NHUNK 10000
|
#define NHUNK 10000
|
||||||
#define EOF (-1)
|
#define EOF (-1)
|
||||||
#define IGN (-2)
|
#define IGN (-2)
|
||||||
@ -141,13 +140,13 @@ enum
|
|||||||
|
|
||||||
EXTERN char debug[256];
|
EXTERN char debug[256];
|
||||||
EXTERN Sym* hash[NHASH];
|
EXTERN Sym* hash[NHASH];
|
||||||
EXTERN char* Dlist[30];
|
EXTERN char** Dlist;
|
||||||
EXTERN int nDlist;
|
EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
EXTERN char* hunk;
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char** include;
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
|
@ -65,7 +65,7 @@ main(int argc, char *argv[])
|
|||||||
memset(debug, 0, sizeof(debug));
|
memset(debug, 0, sizeof(debug));
|
||||||
cinit();
|
cinit();
|
||||||
outfile = 0;
|
outfile = 0;
|
||||||
include[ninclude++] = ".";
|
setinclude(".");
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
default:
|
default:
|
||||||
c = ARGC();
|
c = ARGC();
|
||||||
@ -79,8 +79,12 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
p = ARGF();
|
p = ARGF();
|
||||||
if(p)
|
if(p) {
|
||||||
|
if (nDlist%8 == 0)
|
||||||
|
Dlist = allocn(Dlist, nDlist*sizeof(char *),
|
||||||
|
8*sizeof(char *));
|
||||||
Dlist[nDlist++] = p;
|
Dlist[nDlist++] = p;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
|
@ -57,7 +57,6 @@ typedef struct Gen2 Gen2;
|
|||||||
#define NSYMB 500
|
#define NSYMB 500
|
||||||
#define BUFSIZ 8192
|
#define BUFSIZ 8192
|
||||||
#define HISTSZ 20
|
#define HISTSZ 20
|
||||||
#define NINCLUDE 10
|
|
||||||
#define NHUNK 10000
|
#define NHUNK 10000
|
||||||
#define EOF (-1)
|
#define EOF (-1)
|
||||||
#define IGN (-2)
|
#define IGN (-2)
|
||||||
@ -142,13 +141,13 @@ enum
|
|||||||
|
|
||||||
EXTERN char debug[256];
|
EXTERN char debug[256];
|
||||||
EXTERN Sym* hash[NHASH];
|
EXTERN Sym* hash[NHASH];
|
||||||
EXTERN char* Dlist[30];
|
EXTERN char** Dlist;
|
||||||
EXTERN int nDlist;
|
EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
EXTERN char* hunk;
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char** include;
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
|
@ -65,7 +65,7 @@ main(int argc, char *argv[])
|
|||||||
memset(debug, 0, sizeof(debug));
|
memset(debug, 0, sizeof(debug));
|
||||||
cinit();
|
cinit();
|
||||||
outfile = 0;
|
outfile = 0;
|
||||||
include[ninclude++] = ".";
|
setinclude(".");
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
default:
|
default:
|
||||||
c = ARGC();
|
c = ARGC();
|
||||||
@ -79,8 +79,12 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
p = ARGF();
|
p = ARGF();
|
||||||
if(p)
|
if(p) {
|
||||||
|
if (nDlist%8 == 0)
|
||||||
|
Dlist = allocn(Dlist, nDlist*sizeof(char *),
|
||||||
|
8*sizeof(char *));
|
||||||
Dlist[nDlist++] = p;
|
Dlist[nDlist++] = p;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
|
@ -475,7 +475,7 @@ EXTERN Decl* firstdcl;
|
|||||||
EXTERN int fperror;
|
EXTERN int fperror;
|
||||||
EXTERN Sym* hash[NHASH];
|
EXTERN Sym* hash[NHASH];
|
||||||
EXTERN char* hunk;
|
EXTERN char* hunk;
|
||||||
EXTERN char* include[20];
|
EXTERN char** include;
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
|
@ -82,7 +82,7 @@ pathchar(void)
|
|||||||
void
|
void
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *defs[50], *p;
|
char **defs, *p;
|
||||||
int nproc, nout, i, c, ndef;
|
int nproc, nout, i, c, ndef;
|
||||||
|
|
||||||
ensuresymb(NSYMB);
|
ensuresymb(NSYMB);
|
||||||
@ -94,8 +94,9 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
tufield = simplet((1L<<tfield->etype) | BUNSIGNED);
|
tufield = simplet((1L<<tfield->etype) | BUNSIGNED);
|
||||||
ndef = 0;
|
ndef = 0;
|
||||||
|
defs = nil;
|
||||||
outfile = 0;
|
outfile = 0;
|
||||||
include[ninclude++] = ".";
|
setinclude(".");
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
default:
|
default:
|
||||||
c = ARGC();
|
c = ARGC();
|
||||||
@ -119,6 +120,9 @@ main(int argc, char *argv[])
|
|||||||
case 'D':
|
case 'D':
|
||||||
p = ARGF();
|
p = ARGF();
|
||||||
if(p) {
|
if(p) {
|
||||||
|
if(ndef%8 == 0)
|
||||||
|
defs = allocn(defs, ndef*sizeof(char *),
|
||||||
|
8*sizeof(char *));
|
||||||
defs[ndef++] = p;
|
defs[ndef++] = p;
|
||||||
dodefine(p);
|
dodefine(p);
|
||||||
}
|
}
|
||||||
@ -193,7 +197,7 @@ int
|
|||||||
compile(char *file, char **defs, int ndef)
|
compile(char *file, char **defs, int ndef)
|
||||||
{
|
{
|
||||||
char *ofile, incfile[20];
|
char *ofile, incfile[20];
|
||||||
char *p, *av[100], opt[256];
|
char *p, **av, opt[256];
|
||||||
int i, c, fd[2];
|
int i, c, fd[2];
|
||||||
static int first = 1;
|
static int first = 1;
|
||||||
|
|
||||||
@ -283,6 +287,7 @@ compile(char *file, char **defs, int ndef)
|
|||||||
close(fd[0]);
|
close(fd[0]);
|
||||||
dup(fd[1], 1);
|
dup(fd[1], 1);
|
||||||
close(fd[1]);
|
close(fd[1]);
|
||||||
|
av = alloc((ndef+ninclude+5)*sizeof(char *));
|
||||||
av[0] = CPP;
|
av[0] = CPP;
|
||||||
i = 1;
|
i = 1;
|
||||||
if(debug['.']){
|
if(debug['.']){
|
||||||
@ -1548,14 +1553,10 @@ setinclude(char *p)
|
|||||||
if(strcmp(p, include[i]) == 0)
|
if(strcmp(p, include[i]) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(i >= ninclude)
|
if(ninclude%8 == 0)
|
||||||
include[ninclude++] = p;
|
include = allocn(include, ninclude*sizeof(char *),
|
||||||
|
8*sizeof(char *));
|
||||||
if(ninclude > nelem(include)) {
|
include[ninclude++] = p;
|
||||||
diag(Z, "ninclude too small %d", nelem(include));
|
|
||||||
exits("ninclude");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,11 +149,10 @@ setinclude(char *p)
|
|||||||
for(i=1; i < ninclude; i++)
|
for(i=1; i < ninclude; i++)
|
||||||
if(strcmp(p, include[i]) == 0)
|
if(strcmp(p, include[i]) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(ninclude >= nelem(include)) {
|
if(ninclude%8 == 0)
|
||||||
yyerror("ninclude too small %d", nelem(include));
|
include = allocn(include, ninclude*sizeof(char *),
|
||||||
exits("ninclude");
|
8*sizeof(char *));
|
||||||
}
|
|
||||||
include[ninclude++] = p;
|
include[ninclude++] = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user