From 4c0a0e6119c23818af524a94cff5eac202283ece Mon Sep 17 00:00:00 2001 From: dtrg Date: Tue, 18 Jul 2006 17:10:29 +0000 Subject: [PATCH] Rationalised use of #includes to be more standards-compliant. --- mach/arm/cv/cv.c | 1 + mach/i386/cv/cv.c | 2 +- mach/minixST/cv/cv.c | 2 +- mach/proto/as/comm0.h | 4 ++++ mach/proto/as/comm1.h | 8 -------- mach/proto/as/comm4.c | 2 +- mach/proto/cg/compute.c | 3 +++ mach/proto/cg/glosym.c | 2 ++ mach/proto/cg/salloc.c | 2 +- mach/proto/cg/subr.c | 1 + mach/proto/ncg/compute.c | 3 +++ mach/proto/ncg/glosym.c | 3 ++- mach/proto/ncg/salloc.c | 2 +- mach/proto/ncg/subr.c | 3 ++- mach/vax4/cv/cv.c | 3 +-- modules/src/assert/BadAssert.c | 1 + modules/src/em_code/em.c | 3 +++ modules/src/print/format.c | 1 + modules/src/read_em/mkcalls.c | 4 ++-- modules/src/read_em/read_em.c | 4 ++-- modules/src/read_em/reade.c | 1 + modules/src/system/access.c | 2 +- modules/src/system/break.c | 6 ++---- modules/src/system/chmode.c | 2 +- modules/src/system/close.c | 2 +- modules/src/system/create.c | 2 +- modules/src/system/filesize.c | 2 +- modules/src/system/lock.c | 2 +- modules/src/system/modtime.c | 3 +-- modules/src/system/open.c | 2 +- modules/src/system/read.c | 2 +- modules/src/system/remove.c | 2 +- modules/src/system/rename.c | 2 +- modules/src/system/seek.c | 2 +- modules/src/system/stop.c | 2 +- modules/src/system/system.c | 2 +- modules/src/system/system.h | 2 -- modules/src/system/time.c | 2 +- modules/src/system/unlock.c | 2 +- modules/src/system/write.c | 2 +- util/arch/archiver.c | 4 +++- util/ceg/as_parser/eval/eval.c | 1 + util/ceg/as_parser/help.c | 3 +++ util/ceg/as_parser/pars.g | 2 ++ util/cgg/bootgram.y | 22 ++++++++++++---------- util/cgg/main.c | 10 ++-------- util/cmisc/tabgen.c | 4 ++-- util/cpp/replace.c | 2 ++ 48 files changed, 80 insertions(+), 66 deletions(-) diff --git a/mach/arm/cv/cv.c b/mach/arm/cv/cv.c index 49e82f6f0..1d0276845 100644 --- a/mach/arm/cv/cv.c +++ b/mach/arm/cv/cv.c @@ -7,6 +7,7 @@ * V1.0, 08-Mar-89 AJM */ +#include #include #include "out.h" #include "arm.h" diff --git a/mach/i386/cv/cv.c b/mach/i386/cv/cv.c index 12f297bbf..7ad5b6d10 100644 --- a/mach/i386/cv/cv.c +++ b/mach/i386/cv/cv.c @@ -9,6 +9,7 @@ * It uses ~em/modules/lib/libobject.a. */ +#include #include struct xexec { @@ -351,7 +352,6 @@ emit_symtab() char *chars, *xname; struct outname *names; register char *xptr; - extern char *malloc(); long off = OFF_CHAR(outhead); register char *p; register struct outname *np; diff --git a/mach/minixST/cv/cv.c b/mach/minixST/cv/cv.c index 4ff5e0f4e..b102fac61 100644 --- a/mach/minixST/cv/cv.c +++ b/mach/minixST/cv/cv.c @@ -13,6 +13,7 @@ #include #include #include +#include struct outhead outhead; struct outsect outsect[S_MAX]; @@ -163,7 +164,6 @@ main(argc, argv) */ emits(section) struct outsect *section ; { char *p; - char *calloc(), *malloc(); long sz = section->os_flen; rd_outsect(section - outsect); diff --git a/mach/proto/as/comm0.h b/mach/proto/as/comm0.h index 86e05b66d..8f3d26c94 100644 --- a/mach/proto/as/comm0.h +++ b/mach/proto/as/comm0.h @@ -78,11 +78,15 @@ separate linker only possible if relocation info produced /* ========== Machine independent type declarations ========== */ #ifdef _include +_include _include +_include _include _include #else +#include #include +#include #include #include #endif diff --git a/mach/proto/as/comm1.h b/mach/proto/as/comm1.h index 14f4fc6cb..7e4620471 100644 --- a/mach/proto/as/comm1.h +++ b/mach/proto/as/comm1.h @@ -116,14 +116,6 @@ extern valu_t load(); extern FILE *ffcreat(); extern FILE *fftemp(); -/* some library functions used */ -extern char *mktemp(); -extern char *malloc(); -extern char *realloc(); -extern char *calloc(); -extern char *getenv(); -extern char *strncpy(); - /* ========== Machine dependent C declarations ========== */ #include "mach1.c" diff --git a/mach/proto/as/comm4.c b/mach/proto/as/comm4.c index 2b68b4038..9adff1ebf 100644 --- a/mach/proto/as/comm4.c +++ b/mach/proto/as/comm4.c @@ -20,7 +20,7 @@ extern YYSTYPE yylval; /* ========== Machine independent C routines ========== */ -stop() { +void stop() { #if DEBUG < 2 unlink(temppath); #ifdef LISTING diff --git a/mach/proto/cg/compute.c b/mach/proto/cg/compute.c index 07c290836..26570f49d 100644 --- a/mach/proto/cg/compute.c +++ b/mach/proto/cg/compute.c @@ -2,6 +2,9 @@ static char rcsid[] = "$Id$"; #endif +#include +#include +#include #include "assert.h" #include "param.h" #include "tables.h" diff --git a/mach/proto/cg/glosym.c b/mach/proto/cg/glosym.c index 72cbf51e1..4052c1bfe 100644 --- a/mach/proto/cg/glosym.c +++ b/mach/proto/cg/glosym.c @@ -2,6 +2,8 @@ static char rcsid[] = "$Id$"; #endif +#include +#include #include "param.h" #include "tables.h" #include "types.h" diff --git a/mach/proto/cg/salloc.c b/mach/proto/cg/salloc.c index 99347ce12..30554a471 100644 --- a/mach/proto/cg/salloc.c +++ b/mach/proto/cg/salloc.c @@ -2,6 +2,7 @@ static char rcsid[] = "$Id$"; #endif +#include #include "assert.h" #include "param.h" #include "tables.h" @@ -29,7 +30,6 @@ static char rcsid[] = "$Id$"; char *stab[MAXSTAB]; int nstab=0; -string malloc(); string myalloc(size) { register string p; diff --git a/mach/proto/cg/subr.c b/mach/proto/cg/subr.c index a4b303afc..325f54a2c 100644 --- a/mach/proto/cg/subr.c +++ b/mach/proto/cg/subr.c @@ -2,6 +2,7 @@ static char rcsid[] = "$Id$"; #endif +#include #include "assert.h" #include #include "param.h" diff --git a/mach/proto/ncg/compute.c b/mach/proto/ncg/compute.c index 347488ce5..f407aa8ae 100644 --- a/mach/proto/ncg/compute.c +++ b/mach/proto/ncg/compute.c @@ -2,6 +2,9 @@ static char rcsid[] = "$Id$"; #endif +#include +#include +#include #include "assert.h" #include "param.h" #include "tables.h" diff --git a/mach/proto/ncg/glosym.c b/mach/proto/ncg/glosym.c index 476261913..4052c1bfe 100644 --- a/mach/proto/ncg/glosym.c +++ b/mach/proto/ncg/glosym.c @@ -2,6 +2,8 @@ static char rcsid[] = "$Id$"; #endif +#include +#include #include "param.h" #include "tables.h" #include "types.h" @@ -15,7 +17,6 @@ static char rcsid[] = "$Id$"; */ extern string myalloc(); -extern char *strcpy(); glosym_p glolist= (glosym_p) 0; diff --git a/mach/proto/ncg/salloc.c b/mach/proto/ncg/salloc.c index 5337096f8..2bafb3fd0 100644 --- a/mach/proto/ncg/salloc.c +++ b/mach/proto/ncg/salloc.c @@ -2,6 +2,7 @@ static char rcsid[] = "$Id$"; #endif +#include #include "assert.h" #include "param.h" #include "tables.h" @@ -29,7 +30,6 @@ static char rcsid[] = "$Id$"; char *stab[MAXSTAB]; int nstab=0; -string malloc(); string myalloc(size) { register string p; diff --git a/mach/proto/ncg/subr.c b/mach/proto/ncg/subr.c index 67e802020..7d99ebcee 100644 --- a/mach/proto/ncg/subr.c +++ b/mach/proto/ncg/subr.c @@ -2,8 +2,9 @@ static char rcsid[] = "$Id$"; #endif -#include "assert.h" +#include #include +#include "assert.h" #include "param.h" #include "tables.h" #include "types.h" diff --git a/mach/vax4/cv/cv.c b/mach/vax4/cv/cv.c index 26769b694..0345426b3 100644 --- a/mach/vax4/cv/cv.c +++ b/mach/vax4/cv/cv.c @@ -13,6 +13,7 @@ #include #include #include +#include long lseek(); @@ -270,7 +271,6 @@ writef(addr,sz,cnt) */ emits(section) struct outsect *section ; { char *p; - char *calloc(), *malloc(); long sz = section->os_flen; rd_outsect(section - outsect); @@ -484,7 +484,6 @@ emit_symtab() register struct outname *A; struct sym *MACHnames; register struct sym *M; - extern char *malloc(), *calloc(); char *chars; long offX = OFF_CHAR(outhead) - 4; diff --git a/modules/src/assert/BadAssert.c b/modules/src/assert/BadAssert.c index cad0b3903..3584221fd 100644 --- a/modules/src/assert/BadAssert.c +++ b/modules/src/assert/BadAssert.c @@ -7,6 +7,7 @@ indicated by the parameters, and then give a core dump */ +#include #include static diff --git a/modules/src/em_code/em.c b/modules/src/em_code/em.c index a97216c59..e484a3ec9 100644 --- a/modules/src/em_code/em.c +++ b/modules/src/em_code/em.c @@ -8,6 +8,9 @@ /* I/O part of em_code module. Also contains C_open, C_close */ + +#include +#include #include #include #include "insert.h" diff --git a/modules/src/print/format.c b/modules/src/print/format.c index ec32ee1ef..e207eaa02 100644 --- a/modules/src/print/format.c +++ b/modules/src/print/format.c @@ -4,6 +4,7 @@ */ /* $Id$ */ +#include #include #include "print.h" diff --git a/modules/src/read_em/mkcalls.c b/modules/src/read_em/mkcalls.c index 2706ff588..f6dd3cb76 100644 --- a/modules/src/read_em/mkcalls.c +++ b/modules/src/read_em/mkcalls.c @@ -86,12 +86,12 @@ EM_doinstr(p) if (! checkarg(&(p->em_arg), cst_ptyp)) return; } else { -#include "C_mnem_narg" +#include "C_mnem_narg.h" return; } break; } -#include "C_mnem" +#include "C_mnem.h" } PRIVATE void diff --git a/modules/src/read_em/read_em.c b/modules/src/read_em/read_em.c index 7ec49b258..ccf9968c0 100644 --- a/modules/src/read_em/read_em.c +++ b/modules/src/read_em/read_em.c @@ -17,6 +17,8 @@ some routines from the system module. and the em_code module */ +#include +#include #include #include #include @@ -35,8 +37,6 @@ #define ungetbyte(uch) ((uch) >= 0 && (*--_ich = (uch))) #define init_input() (_fill(), _ich--) -#define EOF -1 - static File *fd; static char *_ich; diff --git a/modules/src/read_em/reade.c b/modules/src/read_em/reade.c index 88d582bbd..69acf2771 100644 --- a/modules/src/read_em/reade.c +++ b/modules/src/read_em/reade.c @@ -9,6 +9,7 @@ */ #include +#include /* #define XXX_YYY /* only for early debugging */ diff --git a/modules/src/system/access.c b/modules/src/system/access.c index 98389fac0..20773c7d0 100644 --- a/modules/src/system/access.c +++ b/modules/src/system/access.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" int sys_access(path, mode) diff --git a/modules/src/system/break.c b/modules/src/system/break.c index cbd115054..254ea0c9e 100644 --- a/modules/src/system/break.c +++ b/modules/src/system/break.c @@ -4,15 +4,13 @@ */ /* $Id$ */ -#include - -char *sbrk(); +#include "system.h" +#include char * sys_break(incr) int incr; { - char *sbrk(); register char *brk = sbrk(incr); if (brk == (char *) 0 || brk == (char *)-1) diff --git a/modules/src/system/chmode.c b/modules/src/system/chmode.c index faf07231f..0c0c1f59e 100644 --- a/modules/src/system/chmode.c +++ b/modules/src/system/chmode.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" int sys_chmode(path, mode) diff --git a/modules/src/system/close.c b/modules/src/system/close.c index 7fff58995..03aa767df 100644 --- a/modules/src/system/close.c +++ b/modules/src/system/close.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" void sys_close(fp) diff --git a/modules/src/system/create.c b/modules/src/system/create.c index 59bc9ec55..21203c41b 100644 --- a/modules/src/system/create.c +++ b/modules/src/system/create.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" extern File *_get_entry(); diff --git a/modules/src/system/filesize.c b/modules/src/system/filesize.c index 930ca62ee..c3a62e568 100644 --- a/modules/src/system/filesize.c +++ b/modules/src/system/filesize.c @@ -6,7 +6,7 @@ #include #include -#include +#include "system.h" long sys_filesize(path) diff --git a/modules/src/system/lock.c b/modules/src/system/lock.c index e3051ff0d..5203fcb6d 100644 --- a/modules/src/system/lock.c +++ b/modules/src/system/lock.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" int sys_lock(path) diff --git a/modules/src/system/modtime.c b/modules/src/system/modtime.c index af372b741..129c3bce3 100644 --- a/modules/src/system/modtime.c +++ b/modules/src/system/modtime.c @@ -6,8 +6,7 @@ #include #include - -#include +#include "system.h" long sys_modtime(path) diff --git a/modules/src/system/open.c b/modules/src/system/open.c index b99eb6647..cf24f3206 100644 --- a/modules/src/system/open.c +++ b/modules/src/system/open.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" extern File *_get_entry(); diff --git a/modules/src/system/read.c b/modules/src/system/read.c index 9bb64b890..850d68f35 100644 --- a/modules/src/system/read.c +++ b/modules/src/system/read.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" int sys_read(fp, bufptr, bufsiz, pnbytes) diff --git a/modules/src/system/remove.c b/modules/src/system/remove.c index ba26085b9..435d67b05 100644 --- a/modules/src/system/remove.c +++ b/modules/src/system/remove.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" int sys_remove(path) diff --git a/modules/src/system/rename.c b/modules/src/system/rename.c index 3876025d0..f65307764 100644 --- a/modules/src/system/rename.c +++ b/modules/src/system/rename.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" int sys_rename(path1, path2) diff --git a/modules/src/system/seek.c b/modules/src/system/seek.c index fbdb4ee49..e4d1f8580 100644 --- a/modules/src/system/seek.c +++ b/modules/src/system/seek.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" long lseek(); diff --git a/modules/src/system/stop.c b/modules/src/system/stop.c index d35c98da1..05986b162 100644 --- a/modules/src/system/stop.c +++ b/modules/src/system/stop.c @@ -5,7 +5,7 @@ /* $Id$ */ #include -#include +#include "system.h" void sys_stop(how) diff --git a/modules/src/system/system.c b/modules/src/system/system.c index 2c196be1d..1670c96c4 100644 --- a/modules/src/system/system.c +++ b/modules/src/system/system.c @@ -4,7 +4,7 @@ */ /* RCS: $Id$ */ -#include +#include "system.h" File _sys_ftab[SYS_NOPEN] = { { 0, OP_READ}, diff --git a/modules/src/system/system.h b/modules/src/system/system.h index 5b189a1ae..72cbd9772 100644 --- a/modules/src/system/system.h +++ b/modules/src/system/system.h @@ -62,6 +62,4 @@ _PROTOTYPE(long sys_modtime, (char *)); /* return value for sys_break */ #define ILL_BREAK ((char *)0) -/* system's idea of block */ -#define BUFSIZ 1024 #endif /* __SYSTEM_INCLUDED__ */ diff --git a/modules/src/system/time.c b/modules/src/system/time.c index 24dca1f57..e06a9fa00 100644 --- a/modules/src/system/time.c +++ b/modules/src/system/time.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" long time(); diff --git a/modules/src/system/unlock.c b/modules/src/system/unlock.c index dda75e62f..51ae6f591 100644 --- a/modules/src/system/unlock.c +++ b/modules/src/system/unlock.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" int sys_unlock(path) diff --git a/modules/src/system/write.c b/modules/src/system/write.c index 62ef98c2b..7423a59a8 100644 --- a/modules/src/system/write.c +++ b/modules/src/system/write.c @@ -4,7 +4,7 @@ */ /* $Id$ */ -#include +#include "system.h" int sys_write(fp, bufptr, nbytes) diff --git a/util/arch/archiver.c b/util/arch/archiver.c index 61bbb13dd..b627556df 100644 --- a/util/arch/archiver.c +++ b/util/arch/archiver.c @@ -25,6 +25,9 @@ static char RcsId[] = "$Id$"; #endif */ +#include +#include +#include #include #include #include @@ -38,7 +41,6 @@ struct ranlib *tab; unsigned int tnum = 0; char *tstrtab; unsigned int tssiz = 0; -char *malloc(), *realloc(), *strcpy(), *strncpy(); long time(); unsigned int tabsz, strtabsz; #else diff --git a/util/ceg/as_parser/eval/eval.c b/util/ceg/as_parser/eval/eval.c index 98d55e6d6..2a0bcbe8e 100644 --- a/util/ceg/as_parser/eval/eval.c +++ b/util/ceg/as_parser/eval/eval.c @@ -1,3 +1,4 @@ +#include #include #include #include "states.h" diff --git a/util/ceg/as_parser/help.c b/util/ceg/as_parser/help.c index 4f3575018..a72652f1f 100644 --- a/util/ceg/as_parser/help.c +++ b/util/ceg/as_parser/help.c @@ -1,3 +1,6 @@ +#include +#include + #if __STDC__ #include extern out(char *, ...); diff --git a/util/ceg/as_parser/pars.g b/util/ceg/as_parser/pars.g index 4b8fccd9f..ee0b49451 100644 --- a/util/ceg/as_parser/pars.g +++ b/util/ceg/as_parser/pars.g @@ -38,6 +38,8 @@ */ { +#include +#include #include "decl.h" extern int lineno, yyleng; diff --git a/util/cgg/bootgram.y b/util/cgg/bootgram.y index a3ed36a08..02d9a3d13 100644 --- a/util/cgg/bootgram.y +++ b/util/cgg/bootgram.y @@ -11,7 +11,9 @@ static char rcsid[]="$Id$"; * Author: Hans van Staveren */ +#include #include +#include #include #include #include @@ -37,8 +39,8 @@ static char rcsid[]="$Id$"; inst_t yy_instance; } -%type list1,structlistel -%type structlist,structdecl +%type list1 structlistel +%type structlist structdecl %type expr optexpr %type optcost cost optcommacost %type optboolexpr optnocoerc mnem emargno tokargno optprop @@ -48,8 +50,8 @@ static char rcsid[]="$Id$"; %type tokeninstance %type optformat %token IDENT TYPENAME -%token RIDENT,PIDENT,TIDENT,EIDENT -%token LSTRING,STRING +%token RIDENT PIDENT TIDENT EIDENT +%token LSTRING STRING %token NUMBER %token CIDENT %token REGISTERHEAD TOKENHEAD EXPRESSIONHEAD CODEHEAD MOVEHEAD TESTHEAD STACKHEAD @@ -63,12 +65,12 @@ static char rcsid[]="$Id$"; %left OR2 %left AND2 -%left CMPEQ,CMPNE -%left CMPLT,CMPLE,CMPGT,CMPGE -%left RSHIFT,LSHIFT -%left '+','-' -%left '*','/','%' -%nonassoc NOT,COMP,UMINUS +%left CMPEQ CMPNE +%left CMPLT CMPLE CMPGT CMPGE +%left RSHIFT LSHIFT +%left '+' '-' +%left '*' '/' '%' +%nonassoc NOT COMP UMINUS %nonassoc '$' %% machinespec diff --git a/util/cgg/main.c b/util/cgg/main.c index 449e79add..fba8e31b5 100644 --- a/util/cgg/main.c +++ b/util/cgg/main.c @@ -1,20 +1,14 @@ +#include #include #include #include +#include #include #include #include #include "booth.h" -extern char *strncpy(), *strcpy(); -extern char *malloc(); -#ifndef __STDC__ -extern char *sprintf(); -#else -/* sprintf should be declared in stdio.h, as returning an int */ -#endif - char * myalloc(n) { register char *p; diff --git a/util/cmisc/tabgen.c b/util/cmisc/tabgen.c index 4e8cf519d..777bda8d5 100644 --- a/util/cmisc/tabgen.c +++ b/util/cmisc/tabgen.c @@ -9,7 +9,9 @@ Many mods by Ceriel Jacobs */ +#include #include +#include #ifndef NORCSID static char *RcsId = "$Id$"; @@ -28,8 +30,6 @@ char *ProgCall; /* callname of this program */ int TabSize = 128; /* default size of generated table */ char *InitialValue; /* initial value of all table entries */ -extern char *malloc(), *strcpy(); - main(argc, argv) char *argv[]; { diff --git a/util/cpp/replace.c b/util/cpp/replace.c index 9143fe3c7..923b2c902 100644 --- a/util/cpp/replace.c +++ b/util/cpp/replace.c @@ -5,6 +5,8 @@ */ /* PREPROCESSOR: MACRO-TEXT REPLACEMENT ROUTINES */ +#include +#include #include "debug.h" /* UF */ #include "pathlength.h" /* UF */ #include "textsize.h" /* UF */