diff --git a/util/cmisc/GCIPM.c b/util/cmisc/GCIPM.c index 3d579e79a..78b3a9d7e 100644 --- a/util/cmisc/GCIPM.c +++ b/util/cmisc/GCIPM.c @@ -10,17 +10,30 @@ #include -extern CheckId(); -extern DoOption(); -extern BeginOfProgram(), EndOfProgram(); +extern void BeginOfProgram(void); +extern void EndOfProgram(void); +extern void DoOption(char*); +extern void CheckId(char *, int); + #define MAX_ID_LEN 256 char *ProgName; int GCcopy; -main(argc, argv) - char *argv[]; + +void DoFile(FILE *); +void SkipString(FILE *, int); +void SkipComment(FILE *); +void DoIdent(FILE *, int); +int StartId(int); +int InId(int); +int StartNum(int); +void DoNum(register FILE *, int); + + + +int main(int argc, char *argv[]) { char **nargv; int nargc = 0; @@ -55,13 +68,12 @@ main(argc, argv) DoFile(stdin); } EndOfProgram(); - exit(0); + return 0; } -DoFile(fp) - FILE *fp; +void DoFile(FILE *fp) { - register c; + register int c; while ((c = getc(fp)) != EOF) { switch (c) { @@ -98,10 +110,9 @@ DoFile(fp) fclose(fp); } -SkipString(fp, stopc) - FILE *fp; +void SkipString(FILE *fp, int stopc) { - register c; + register int c; while ((c = getc(fp)) != EOF) { if (GCcopy) putchar(c); @@ -116,10 +127,9 @@ SkipString(fp, stopc) } } -SkipComment(fp) - FILE *fp; +void SkipComment(FILE *fp) { - register c; + register int c; while ((c = getc(fp)) != EOF) { if (GCcopy) putchar(c); @@ -133,12 +143,11 @@ SkipComment(fp) } } -DoIdent(fp, s) - FILE *fp; +void DoIdent(FILE *fp, int s) { char id_buf[MAX_ID_LEN]; - register cnt = 1; - register c; + register int cnt = 1; + register int c; id_buf[0] = s; @@ -155,7 +164,7 @@ DoIdent(fp, s) } } -StartId(c) +int StartId(int c) { switch (c) { @@ -179,7 +188,7 @@ StartId(c) } } -InId(c) +int InId(int c) { switch (c) { @@ -205,7 +214,7 @@ InId(c) } } -StartNum(c) +int StartNum(int c) { switch(c) { case '0': case '1': case '2': case '3': case '4': @@ -223,8 +232,7 @@ StartNum(c) #define getoct(c, fp) do { c = getc((fp)); if (GCcopy) putchar(c);} while (isoct(c)) #define gethex(c, fp) do { c = getc((fp)); if (GCcopy) putchar(c);} while (ishex(c)) -DoNum(fp, c) - register FILE *fp; +void DoNum(register FILE *fp, int c) { if (c != '0') { getdec(c, fp); diff --git a/util/cmisc/cclash.c b/util/cmisc/cclash.c index 1bc8c68b3..9221c1df9 100644 --- a/util/cmisc/cclash.c +++ b/util/cmisc/cclash.c @@ -30,6 +30,7 @@ */ #include +#include #include #define DEF_LENGTH 8 @@ -84,20 +85,32 @@ char * keywords[] = { 0 }; + +void InsertId(char *,int); +char *Malloc(unsigned int); +char *Salloc(char *); +int EnHash(char*); +void EndOfProgram(void); +void DoOption(char*); +void CheckId(char *, int); +void saveline(register struct idf *); +void mapline(char *); + + + struct idf *maplist = 0; -DefineKeys() +void DefineKeys(void) { register char **pkey = &keywords[0]; register char *id; - while (id = *pkey++) + while ((id = *pkey++)) if (strlen(id) >= maxlen) InsertId(id, 1); } -DoOption(str) - char *str; +void DoOption(char *str) { switch (str[1]) { @@ -129,8 +142,7 @@ struct idf *hash_tab[HASHSIZE]; char *Malloc(), *Salloc(); -InsertId(id, key) - char *id; +void InsertId(char *id, int key) { int hash_val = EnHash(id); register struct idf *idp = hash_tab[hash_val]; @@ -168,11 +180,9 @@ InsertId(id, key) p->id_key = key; } -char * -Malloc(n) - unsigned n; +char *Malloc(unsigned n) { - char *mem, *malloc(); + char *mem; if ((mem = malloc(n)) == 0) { fprintf(stderr, "%s: out of memory\n", ProgName); @@ -181,9 +191,7 @@ Malloc(n) return mem; } -char * -Salloc(str) - char *str; +char *Salloc(char *str) { if (str == 0) str = ""; @@ -191,11 +199,10 @@ Salloc(str) return strcpy(Malloc((unsigned)strlen(str) + 1), str); } -EnHash(id) - char *id; +int EnHash(char *id) { register unsigned hash_val = 0; - register n = maxlen; + register int n = maxlen; while (n-- && *id) hash_val = 31 * hash_val + *id++; @@ -203,9 +210,9 @@ EnHash(id) return hash_val % (unsigned) HASHSIZE; } -BeginOfProgram() { DefineKeys(); } +void BeginOfProgram(void) { DefineKeys(); } -EndOfProgram() +void EndOfProgram(void) { register int i; register struct idf *idp, *p; @@ -216,12 +223,12 @@ EndOfProgram() continue; switch (action) { - register n; + register int n; case ACT_LISTONLY: n = 0; if (idp->id_key == 0) { - printf(idp->id_name); + printf("%s",idp->id_name); n++; } for (p = idp->id_same; p; p = p->id_same) @@ -260,8 +267,7 @@ EndOfProgram() } } -saveline(p) - register struct idf *p; +void saveline(register struct idf *p) { register struct idf *idp = maplist, *idp1 = 0; @@ -278,10 +284,9 @@ saveline(p) } } -mapline(nm) - char *nm; +void mapline(char *nm) { - static map_count = 0; + static int map_count = 0; switch (action) { @@ -295,8 +300,7 @@ mapline(nm) } } -CheckId(id, s) - char *id; +void CheckId(char *id, int s) { if (s >= maxlen) InsertId(id, 0); diff --git a/util/cmisc/cid.c b/util/cmisc/cid.c index b09136e33..96e20df09 100644 --- a/util/cmisc/cid.c +++ b/util/cmisc/cid.c @@ -15,6 +15,7 @@ #include #include +#include #ifndef DEF_LENGTH #define DEF_LENGTH 8 @@ -32,13 +33,22 @@ struct idf { struct idf *hash_tab[HASHSIZE]; -char *Malloc(), *Salloc(); -struct idf *FindId(); +char *Malloc(unsigned int); +char *Salloc(char *); +int EnHash(char*); +void EndOfProgram(void); +void DoOption(char*); +void CheckId(char *, int); +void DoMacro(char *); +void GetMacros(char *); +void InsertMacro(char *, char *); +struct idf *FindId(char *); + + extern char *ProgName; -DoOption(str) - char *str; +void DoOption(char* str) { switch (str[1]) { @@ -57,8 +67,7 @@ DoOption(str) } /*ARGSUSED*/ -CheckId(id, len) - char *id; +void CheckId(char *id, int len) { struct idf *idp = FindId(id); @@ -70,8 +79,7 @@ CheckId(id, len) } } -DoMacro(str) - char *str; +void DoMacro(char *str) { char *id, *text; @@ -92,11 +100,10 @@ DoMacro(str) InsertMacro(id, text); } -GetMacros(fn) - char *fn; +void GetMacros(char *fn) { FILE *fp; - register c; + register int c; char buf[LINE_LEN]; char *bufp = &buf[0]; @@ -118,8 +125,7 @@ GetMacros(fn) fclose(fp); } -InsertMacro(id, text) - char *id, *text; +void InsertMacro(char *id, char *text) { int hash_val = EnHash(id); struct idf *idp = hash_tab[hash_val]; @@ -143,11 +149,9 @@ InsertMacro(id, text) hash_tab[hash_val] = idp; } -char * -Malloc(n) - unsigned n; +char *Malloc(unsigned int n) { - char *mem, *malloc(); + char *mem; if ((mem = malloc(n)) == 0) { fprintf(stderr, "%s: out of memory\n", ProgName); @@ -156,9 +160,7 @@ Malloc(n) return mem; } -char * -Salloc(str) - char *str; +char *Salloc(char *str) { if (str == 0) { str = ""; @@ -166,11 +168,9 @@ Salloc(str) return strcpy(Malloc((unsigned)strlen(str) + 1), str); } -struct idf * -FindId(id) - char *id; +struct idf *FindId(char *id) { - register hash_val = EnHash(id); + register int hash_val = EnHash(id); register struct idf *idp = hash_tab[hash_val]; while (idp) { @@ -182,8 +182,7 @@ FindId(id) return 0; } -EnHash(id) - char *id; +int EnHash(char *id) { register unsigned hash_val = 0; @@ -196,11 +195,11 @@ EnHash(id) extern int GCcopy; -BeginOfProgram() +void BeginOfProgram(void) { GCcopy = 1; } -EndOfProgram() +void EndOfProgram(void) { } diff --git a/util/cmisc/mkdep.c b/util/cmisc/mkdep.c index 065678929..1e2749c07 100644 --- a/util/cmisc/mkdep.c +++ b/util/cmisc/mkdep.c @@ -5,19 +5,21 @@ */ /* make dependencies; Date: jan 07, 1986; Author: Erik Baalbergen */ /* Log: - [Thu Oct 6 09:56:30 MET 1988; erikb] - Added option '-d' which suppresses "file.c :" be printed + [Thu Oct 6 09:56:30 MET 1988; erikb] + Added option '-d' which suppresses "file.c :" be printed */ #include -#incoude +#include +#include #define BSIZ 1024 char *prog; -int dflag = 0; /* suppress "file.c :" */ +int dflag = 0; /* suppress "file.c :" */ -struct namelist { +struct namelist +{ struct namelist *next; char *name; }; @@ -26,13 +28,19 @@ struct namelist *freelist; struct namelist *new_namelist(); struct namelist *nl = 0; +char *Malloc(unsigned int); + +char *include_line(char *); +int dofile(char *); + char *Malloc(u) unsigned u; { - char *sp, *malloc(); + char *sp; - if ((sp = malloc(u)) == 0) { - fprintf(stderr, "%s: out of space\n"); + if ((sp = malloc(u)) == 0) + { + fprintf(stderr, "%s:", " out of space\n"); exit(1); } return sp; @@ -43,7 +51,8 @@ new_namelist() { register struct namelist *nlp = freelist; - if (nlp) { + if (nlp) + { freelist = nlp->next; return nlp; } @@ -51,48 +60,50 @@ new_namelist() return (struct namelist *) Malloc(sizeof(struct namelist)); } -free_namelist(nlp) - struct namelist *nlp; +void free_namelist(struct namelist *nlp) { - if (nlp) { + if (nlp) + { free_namelist(nlp->next); nlp->next = freelist; freelist = nlp; } } -add_name(nm) - char *nm; +void add_name(char *nm) { struct namelist *nlp = nl, *lnlp = 0, *nnlp; - while (nlp) { - register i = strcmp(nm, nlp->name); + while (nlp) + { + register int i = strcmp(nm, nlp->name); if (i < 0) break; - if (i == 0) /* already present */ + if (i == 0) /* already present */ return; lnlp = nlp; nlp = nlp->next; } - (nnlp = new_namelist())->name = strcpy(Malloc((unsigned)strlen(nm) + 1), nm); + (nnlp = new_namelist())->name = strcpy(Malloc((unsigned) strlen(nm) + 1), + nm); - if (lnlp) { + if (lnlp) + { nnlp->next = lnlp->next; lnlp->next = nnlp; } - else { + else + { nnlp->next = nl; nl = nnlp; } } -print_namelist(nm, nlp) - char *nm; - struct namelist *nlp; +void print_namelist(char *nm, struct namelist *nlp) { - while (nlp) { + while (nlp) + { if (!dflag) printf("%s: ", nm); printf("%s\n", nlp->name); @@ -101,23 +112,25 @@ print_namelist(nm, nlp) } /*ARGSUSED*/ -main(argc, argv) - char *argv[]; +int main(int argc, char *argv[]) { int err = 0; prog = *argv++; - if (*argv && **argv == '-') { + if (*argv && **argv == '-') + { char *opt = &(*argv++)[1]; - if (*opt++ != 'd' || *opt) { + if (*opt++ != 'd' || *opt) + { fprintf(stderr, "use: %s [-d] [file ...]\n", prog); exit(1); } dflag = 1; } - while (*argv) { + while (*argv) + { free_namelist(nl); nl = 0; if (dofile(*argv) == 0) @@ -127,67 +140,63 @@ main(argc, argv) exit(err ? 1 : 0); } -int -contains_slash(s) - register char *s; +int contains_slash(register char *s) { while (*s) - if (*s++ == '/') return 1; + if (*s++ == '/') + return 1; return 0; } -extern char *fgets(); - -dofile(fn) - char *fn; +int dofile(char *fn) { char buf[BSIZ]; FILE *fp; - char *nm, *include_line(); + char *nm; - if ((fp = fopen(fn, "r")) == 0) { + if ((fp = fopen(fn, "r")) == 0) + { fprintf(stderr, "%s: cannot read %s\n", prog, fn); return 0; } - if (contains_slash(fn)) { - fprintf(stderr, "%s: (warning) %s not in current directory; not checked\n", prog, fn); + if (contains_slash(fn)) + { + fprintf(stderr, + "%s: (warning) %s not in current directory; not checked\n", + prog, fn); fclose(fp); return 1; } while (fgets(buf, BSIZ, fp) != NULL) - if (nm = include_line(buf)) { + if ((nm = include_line(buf))) + { add_name(nm); - if (dofile(nm)) ; + if (dofile(nm)) + ; } fclose(fp); return 1; } -char * -include_line(s) - char *s; +char *include_line(char *s) { while ((*s == '\t') || (*s == ' ')) s++; - - if (*s++ == '#') { + + if (*s++ == '#') + { while ((*s == '\t') || (*s == ' ')) s++; - if ( - (*s++ == 'i') && - (*s++ == 'n') && - (*s++ == 'c') && - (*s++ == 'l') && - (*s++ == 'u') && - (*s++ == 'd') && - (*s++ == 'e') - ) { + if ((*s++ == 'i') && (*s++ == 'n') && (*s++ == 'c') && (*s++ == 'l') + && (*s++ == 'u') && (*s++ == 'd') && (*s++ == 'e')) + { while ((*s == '\t') || (*s == ' ')) s++; - if (*s++ == '"') { + if (*s++ == '"') + { char *nm = s; while (*s != 0 && *s != '"')