From 49b77c7492f9fbdec4dc02d7a96c8163557dac9a Mon Sep 17 00:00:00 2001 From: Harald van Dijk Date: Thu, 27 Jun 2019 20:52:32 +0100 Subject: [PATCH] Various portability fixes. Compiler portability: - Do not use gcc's -include option. * Include "config.h" in each source file. * Update generators to emit #include "config.h" too. - Do not use gcc's -x option. * Use $(CPP) - instead, reading input from stdin. - Do not hard-code gcc's -Wall option. * Use autoconf-archive's AX_CFLAGS_WARN_ALL instead. - Do not include unused host headers in build utilities. Standard library compatibility: - Do not include traditional but non-standard headers , . * Change MAXPATHLEN to PATH_MAX. - Check header files for missing #includes that may be implicitly included by other headers. * As this causes some header files to be included multiple times, add missing header guards to all files. Make compatibility: - Do not use $(patsubst), $< and $^, and static pattern rules in Makefiles. --- configure.ac | 9 +++++++-- src/Makefile.am | 34 ++++++++++++++++++---------------- src/alias.c | 2 ++ src/alias.h | 5 +++++ src/arith_yacc.c | 3 +++ src/arith_yacc.h | 7 +++++++ src/arith_yylex.c | 2 ++ src/bltin/printf.c | 2 ++ src/bltin/test.c | 2 ++ src/bltin/times.c | 2 ++ src/builtins.def.in | 2 ++ src/cd.c | 2 ++ src/cd.h | 5 +++++ src/error.c | 2 ++ src/error.h | 5 +++++ src/eval.c | 2 ++ src/eval.h | 5 +++++ src/exec.c | 2 ++ src/exec.h | 7 +++++++ src/expand.c | 2 ++ src/expand.h | 5 +++++ src/histedit.c | 5 +++-- src/init.h | 5 +++++ src/input.c | 2 ++ src/input.h | 9 +++++++++ src/jobs.c | 4 ++-- src/jobs.h | 7 +++++++ src/machdep.h | 5 +++++ src/mail.c | 2 ++ src/mail.h | 5 +++++ src/main.c | 2 ++ src/main.h | 5 +++++ src/memalloc.c | 2 ++ src/memalloc.h | 8 ++++++++ src/miscbltin.c | 3 ++- src/miscbltin.h | 5 +++++ src/mkbuiltins | 2 ++ src/mkinit.c | 4 ++++ src/mknodes.c | 2 ++ src/mksyntax.c | 9 ++++++--- src/myhistedit.h | 4 ++++ src/mylocale.c | 2 ++ src/mylocale.h | 7 +++++++ src/mystring.c | 2 ++ src/mystring.h | 5 +++++ src/nodes.c.pat | 2 ++ src/options.c | 2 ++ src/options.h | 5 +++++ src/output.c | 4 ++-- src/output.h | 4 ++-- src/parser.c | 2 ++ src/parser.h | 5 +++++ src/redir.c | 3 ++- src/redir.h | 4 ++++ src/shell.h | 5 ++++- src/show.c | 2 ++ src/show.h | 7 ++++++- src/signames.c | 2 ++ src/system.c | 2 ++ src/system.h | 7 +++++++ src/trap.c | 2 ++ src/trap.h | 5 +++++ src/var.c | 5 +++++ src/var.h | 7 ++++++- 64 files changed, 254 insertions(+), 34 deletions(-) diff --git a/configure.ac b/configure.ac index 6df89cb..fe3a40f 100644 --- a/configure.ac +++ b/configure.ac @@ -11,6 +11,7 @@ dnl Checks for programs. AC_PROG_CC AX_PROG_CC_FOR_BUILD AC_USE_SYSTEM_EXTENSIONS +AX_CFLAGS_WARN_ALL AC_SYS_LARGEFILE AC_PROG_YACC @@ -167,8 +168,12 @@ if test "$enable_locale" != "no"; then [AS_HELP_STRING([--disable-parser-locale], [Disable use of fixed locale during parsing.])]) if test "$enable_parser_locale" != "no"; then - AC_DEFINE([WITH_PARSER_LOCALE], [1], - [Define if you want parsing to ignore LC_CTYPE changes after the shell starts.]) + AC_CHECK_FUNC([uselocale], + [AC_DEFINE([WITH_PARSER_LOCALE], [1], + [Define if you want parsing to ignore LC_CTYPE changes after the shell starts.])], + [if test "$enable_parser_locale" = "yes"; then + AC_MSG_ERROR([--enable-parser-locale requires the uselocale() function.]) + fi]) fi fi AC_CONFIG_FILES([Makefile src/Makefile]) diff --git a/src/Makefile.am b/src/Makefile.am index 5492127..1896863 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,12 +1,8 @@ AM_YFLAGS = -d -COMMON_CFLAGS = -Wall -COMMON_CPPFLAGS = \ - -DBSD=1 -DSHELL +COMMON_CPPFLAGS = -DBSD -DSHELL -AM_CFLAGS = $(COMMON_CFLAGS) -AM_CPPFLAGS = -include $(top_builddir)/config.h $(COMMON_CPPFLAGS) -AM_CFLAGS_FOR_BUILD = -g -O2 $(COMMON_CFLAGS) +AM_CPPFLAGS = $(COMMON_CPPFLAGS) AM_CPPFLAGS_FOR_BUILD = $(COMMON_CPPFLAGS) COMPILE_FOR_BUILD = \ @@ -34,8 +30,8 @@ HELPERS = mkinit mksyntax mknodes BUILT_SOURCES = builtins.h nodes.h syntax.h token.h token_vars.h CLEANFILES = \ - $(BUILT_SOURCES) $(patsubst %.o,%.c,$(gwsh_LDADD)) \ - $(HELPERS) builtins.def + builtins.def builtins.c builtins.h init.c nodes.c nodes.h \ + syntax.c syntax.h token.h token_vars.h $(HELPERS) man_MANS = gwsh.1 EXTRA_DIST = \ @@ -44,24 +40,30 @@ EXTRA_DIST = \ mknodes.c nodetypes nodes.c.pat mksyntax.c token.h token_vars.h: mktokens - $(AM_V_GEN)$(SHELL) $^ + $(AM_V_GEN)$(SHELL) $(srcdir)/mktokens builtins.def: builtins.def.in $(top_builddir)/config.h - $(AM_V_CC)$(COMPILE) -E -x c -o $@ $< + $(AM_V_CC)$(CPP) $(DEFAULT_INCLUDES) - < $(srcdir)/builtins.def.in > $@.tmp && mv $@.tmp $@ builtins.c builtins.h: mkbuiltins builtins.def - $(AM_V_GEN)$(SHELL) $^ + $(AM_V_GEN)$(SHELL) $(srcdir)/mkbuiltins builtins.def init.c: mkinit $(gwsh_CFILES) - $(AM_V_GEN)./$^ + $(AM_V_GEN)./mkinit `echo " $(gwsh_CFILES)" | sed -e 's: : $(srcdir)/:g'` nodes.c nodes.h: mknodes nodetypes nodes.c.pat - $(AM_V_GEN)./$^ + $(AM_V_GEN)./mknodes $(srcdir)/nodetypes $(srcdir)/nodes.c.pat syntax.c syntax.h: mksyntax - $(AM_V_GEN)./$^ + $(AM_V_GEN)./mksyntax mksyntax: token.h -$(HELPERS): %: %.c - $(AM_V_CC)$(COMPILE_FOR_BUILD) -o $@ $< +CCBUILD = $(AM_V_CC)$(COMPILE_FOR_BUILD) -o $@ + +mkinit: mkinit.c + $(CCBUILD) $(srcdir)/mkinit.c +mknodes: mknodes.c + $(CCBUILD) $(srcdir)/mknodes.c +mksyntax: mksyntax.c + $(CCBUILD) $(srcdir)/mksyntax.c diff --git a/src/alias.c b/src/alias.c index cca5293..55852a3 100644 --- a/src/alias.c +++ b/src/alias.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include "shell.h" #include "input.h" diff --git a/src/alias.h b/src/alias.h index 7aa942e..e2063bc 100644 --- a/src/alias.h +++ b/src/alias.h @@ -36,6 +36,9 @@ * @(#)alias.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_ALIAS +#define H_ALIAS 1 + #define ALIASINUSE 1 #define ALIASDEAD 2 @@ -56,3 +59,5 @@ void rmaliases(void); int unalias(const char *); void printalias(const struct alias *); void endaliasuse(void); + +#endif diff --git a/src/arith_yacc.c b/src/arith_yacc.c index cbff673..c4dcd9b 100644 --- a/src/arith_yacc.c +++ b/src/arith_yacc.c @@ -34,8 +34,11 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include +#include #include "arith_yacc.h" #include "expand.h" #include "shell.h" diff --git a/src/arith_yacc.h b/src/arith_yacc.h index ff34d52..9cbfb4b 100644 --- a/src/arith_yacc.h +++ b/src/arith_yacc.h @@ -32,6 +32,11 @@ * SUCH DAMAGE. */ +#ifndef H_ARITH_YACC +#define H_ARITH_YACC 1 + +#include + #define ARITH_ASS 1 #define ARITH_OR 2 @@ -87,3 +92,5 @@ union yystype { extern union yystype yylval; int yylex(void); + +#endif diff --git a/src/arith_yylex.c b/src/arith_yylex.c index d4a1774..086d578 100644 --- a/src/arith_yylex.c +++ b/src/arith_yylex.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include #include diff --git a/src/bltin/printf.c b/src/bltin/printf.c index 783e3cf..3ad699e 100644 --- a/src/bltin/printf.c +++ b/src/bltin/printf.c @@ -31,6 +31,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include diff --git a/src/bltin/test.c b/src/bltin/test.c index efd25a7..120a3fa 100644 --- a/src/bltin/test.c +++ b/src/bltin/test.c @@ -8,6 +8,8 @@ * This program is in the Public Domain. */ +#include "config.h" + #include #include diff --git a/src/bltin/times.c b/src/bltin/times.c index a31f70e..149ed38 100644 --- a/src/bltin/times.c +++ b/src/bltin/times.c @@ -4,6 +4,8 @@ * This file contains code for the times builtin. */ +#include "config.h" + #include #include #ifdef USE_GLIBC_STDIO diff --git a/src/builtins.def.in b/src/builtins.def.in index c70ad28..db4c36a 100644 --- a/src/builtins.def.in +++ b/src/builtins.def.in @@ -36,6 +36,8 @@ * @(#)builtins.def 8.4 (Berkeley) 5/4/95 */ +#include "config.h" + /* * This file lists all the builtin commands. The first column is the name * of a C routine. diff --git a/src/cd.c b/src/cd.c index 8eb4e20..c796b0b 100644 --- a/src/cd.c +++ b/src/cd.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include #include diff --git a/src/cd.h b/src/cd.h index 8763161..71b4867 100644 --- a/src/cd.h +++ b/src/cd.h @@ -30,6 +30,11 @@ * */ +#ifndef H_CD +#define H_CD 1 + int cdcmd(int, char **); int pwdcmd(int, char **); void setpwd(const char *, int); + +#endif diff --git a/src/error.c b/src/error.c index b595302..14f727c 100644 --- a/src/error.c +++ b/src/error.c @@ -32,6 +32,8 @@ * SUCH DAMAGE. */ +#include "config.h" + /* * Errors and exceptions. */ diff --git a/src/error.h b/src/error.h index c794c3d..438acf9 100644 --- a/src/error.h +++ b/src/error.h @@ -36,6 +36,9 @@ * @(#)error.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_ERROR +#define H_ERROR 1 + #include #include @@ -129,3 +132,5 @@ void exerror(int, const char *, ...) __attribute__((__noreturn__)); const char *errmsg(int, int); void sh_warnx(const char *, ...); + +#endif diff --git a/src/eval.c b/src/eval.c index bb99cc5..1c87b94 100644 --- a/src/eval.c +++ b/src/eval.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include #include diff --git a/src/eval.h b/src/eval.h index 6131eb4..b51becb 100644 --- a/src/eval.h +++ b/src/eval.h @@ -34,6 +34,9 @@ * @(#)eval.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_EVAL +#define H_EVAL 1 + extern char *dotfile; /* currently executing . file */ extern char *commandname; /* currently executing command */ extern int exitstatus; /* exit status of last command */ @@ -64,3 +67,5 @@ extern int evalskip; #define SKIPBREAK (1 << 0) #define SKIPCONT (1 << 1) #define SKIPFUNC (1 << 2) + +#endif diff --git a/src/exec.c b/src/exec.c index 900a7d4..ab932ae 100644 --- a/src/exec.c +++ b/src/exec.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include #include diff --git a/src/exec.h b/src/exec.h index e241b74..c5b2ca0 100644 --- a/src/exec.h +++ b/src/exec.h @@ -34,6 +34,9 @@ * @(#)exec.h 8.3 (Berkeley) 6/8/95 */ +#ifndef H_EXEC +#define H_EXEC 1 + /* values of cmdtype */ #define CMDUNKNOWN -1 /* no entry in table for command */ #define CMDNORMAL 0 /* command is an executable program */ @@ -60,6 +63,8 @@ struct cmdentry { extern const char *pathopt; /* set by padvance */ +union node; + void shellexec(char **, const char *, int) __attribute__((__noreturn__)); int padvance(const char **, const char *); @@ -75,3 +80,5 @@ void defun(union node *); void unsetfunc(const char *); int typecmd(int, char **); int commandcmd(int, char **); + +#endif diff --git a/src/expand.c b/src/expand.c index c5393ba..8d8c997 100644 --- a/src/expand.c +++ b/src/expand.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include #include diff --git a/src/expand.h b/src/expand.h index 62def5d..e041d07 100644 --- a/src/expand.h +++ b/src/expand.h @@ -34,6 +34,9 @@ * @(#)expand.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_EXPAND +#define H_EXPAND 1 + #include struct strlist { @@ -83,3 +86,5 @@ void arith_lex_reset(void); #define arith_lex_reset() #endif int yylex(void); + +#endif diff --git a/src/histedit.c b/src/histedit.c index 0b2fa3a..35eac57 100644 --- a/src/histedit.c +++ b/src/histedit.c @@ -34,7 +34,8 @@ * SUCH DAMAGE. */ -#include +#include "config.h" + #ifdef HAVE_PATHS_H #include #endif @@ -211,7 +212,7 @@ histcmd(int argc, char **argv) static int active = 0; struct jmploc jmploc; struct jmploc *volatile savehandler; - char editfile[MAXPATHLEN + 1]; + char editfile[PATH_MAX + 1]; FILE *efp; #ifdef __GNUC__ /* Avoid longjmp clobbering */ diff --git a/src/init.h b/src/init.h index e859117..910bb63 100644 --- a/src/init.h +++ b/src/init.h @@ -36,7 +36,12 @@ * @(#)init.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_INIT +#define H_INIT 1 + void init(void); void exitreset(void); void envreset(void); void reset(void); + +#endif diff --git a/src/input.c b/src/input.c index d85b02f..0502f65 100644 --- a/src/input.c +++ b/src/input.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include /* defines BUFSIZ */ #ifdef WITH_LOCALE #include diff --git a/src/input.h b/src/input.h index 937f9f8..add20df 100644 --- a/src/input.h +++ b/src/input.h @@ -36,7 +36,14 @@ * @(#)input.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_INPUT +#define H_INPUT 1 + +#include "config.h" + +#include #ifdef WITH_LOCALE +#include #include #endif #if defined(WITH_PARSER_LOCALE) && defined(HAVE_XLOCALE_H) @@ -120,3 +127,5 @@ void popfile(void); void unwindfiles(struct parsefile *); void popallfiles(void); void closescript(void); + +#endif diff --git a/src/jobs.c b/src/jobs.c index 1a179c3..384ca38 100644 --- a/src/jobs.c +++ b/src/jobs.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include #include @@ -42,13 +44,11 @@ #include #endif #include -#include #ifdef BSD #include #include #include #endif -#include #include "shell.h" #if JOBS diff --git a/src/jobs.h b/src/jobs.h index 5fe695a..3616e82 100644 --- a/src/jobs.h +++ b/src/jobs.h @@ -36,6 +36,9 @@ * @(#)jobs.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_JOBS +#define H_JOBS 1 + #include #include @@ -94,6 +97,8 @@ extern int jobctl; /* true if doing job control */ #define jobctl 0 #endif +union node; + void setjobctl(int); int killcmd(int, char **); int fgcmd(int, char **); @@ -110,3 +115,5 @@ int stoppedjobs(void); #if ! JOBS #define setjobctl(on) ((void)(on)) /* do nothing */ #endif + +#endif diff --git a/src/machdep.h b/src/machdep.h index f2ff0ad..9b3ab52 100644 --- a/src/machdep.h +++ b/src/machdep.h @@ -34,6 +34,9 @@ * @(#)machdep.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_MACHDEP +#define H_MACHDEP 1 + /* * Most machines require the value returned from malloc to be aligned * in some way. The following macro will get this right on many machines. @@ -45,3 +48,5 @@ * because stalloc() will return a string allocated in a new stackblock. */ #define SHELL_ALIGN(nbytes) (((nbytes) + SHELL_SIZE) & ~SHELL_SIZE) + +#endif diff --git a/src/mail.c b/src/mail.c index 750a4e7..2a1b9b1 100644 --- a/src/mail.c +++ b/src/mail.c @@ -32,6 +32,8 @@ * SUCH DAMAGE. */ +#include "config.h" + /* * Routines to check for mail. (Perhaps make part of main.c?) */ diff --git a/src/mail.h b/src/mail.h index 3c6b21d..7b78ad2 100644 --- a/src/mail.h +++ b/src/mail.h @@ -34,5 +34,10 @@ * @(#)mail.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_MAIL +#define H_MAIL 1 + void chkmail(void); void changemail(const char *); + +#endif diff --git a/src/main.c b/src/main.c index 07e38f3..8b5f95c 100644 --- a/src/main.c +++ b/src/main.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include #include diff --git a/src/main.h b/src/main.h index fa6debf..325a7f7 100644 --- a/src/main.h +++ b/src/main.h @@ -36,6 +36,9 @@ * @(#)main.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_MAIN +#define H_MAIN 1 + #include /* pid of main shell */ @@ -55,3 +58,5 @@ void readcmdfile(char *); int cmdloop(int); int dotcmd(int, char **); int exitcmd(int, char **); + +#endif diff --git a/src/memalloc.c b/src/memalloc.c index d8e4413..559fe78 100644 --- a/src/memalloc.c +++ b/src/memalloc.c @@ -32,6 +32,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include diff --git a/src/memalloc.h b/src/memalloc.h index 4b5be46..d71b7df 100644 --- a/src/memalloc.h +++ b/src/memalloc.h @@ -34,7 +34,13 @@ * @(#)memalloc.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_MEMALLOC +#define H_MEMALLOC 1 + +#include "shell.h" + #include +#include struct stackmark { struct stack_block *stackp; @@ -98,3 +104,5 @@ static inline char *_STPUTC(int c, char *p) { #define stackstrend() ((void *)sstrend) #define ckfree(p) free((pointer)(p)) + +#endif diff --git a/src/miscbltin.c b/src/miscbltin.c index 2094529..d32f2e0 100644 --- a/src/miscbltin.c +++ b/src/miscbltin.c @@ -34,12 +34,13 @@ * SUCH DAMAGE. */ +#include "config.h" + /* * Miscelaneous builtins. */ #include /* quad_t */ -#include /* BSD4_4 */ #include #include #include diff --git a/src/miscbltin.h b/src/miscbltin.h index dd9a8d1..5d4e4b4 100644 --- a/src/miscbltin.h +++ b/src/miscbltin.h @@ -26,6 +26,11 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef H_MISCBLTIN +#define H_MISCBLTIN 1 + int readcmd(int, char **); int umaskcmd(int, char **); int ulimitcmd(int, char **); + +#endif diff --git a/src/mkbuiltins b/src/mkbuiltins index f1f2593..5838a84 100644 --- a/src/mkbuiltins +++ b/src/mkbuiltins @@ -65,6 +65,8 @@ cat <<\! * This file was generated by the mkbuiltins program. */ +#include "config.h" + #include "shell.h" #include "builtins.h" diff --git a/src/mkinit.c b/src/mkinit.c index fe4b8f8..dc88218 100644 --- a/src/mkinit.c +++ b/src/mkinit.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + /* * This program scans all the source files for code to handle various * special events and combines this code into one file. This (allegedly) @@ -101,6 +103,8 @@ char writer[] = "\ /*\n\ * This file was generated by the mkinit program.\n\ */\n\ +\n\ +#include \"config.h\"\n\ \n"; char init[] = "\ diff --git a/src/mknodes.c b/src/mknodes.c index 1903a60..5c32505 100644 --- a/src/mknodes.c +++ b/src/mknodes.c @@ -32,6 +32,8 @@ * SUCH DAMAGE. */ +#include "config.h" + /* * This program reads the nodetypes file and nodes.c.pat file. It generates * the files nodes.h and nodes.c. diff --git a/src/mksyntax.c b/src/mksyntax.c index 65f3aab..6922526 100644 --- a/src/mksyntax.c +++ b/src/mksyntax.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + /* * This program creates syntax.h and syntax.c. */ @@ -42,7 +44,6 @@ #include #include #include -#include "parser.h" struct synclass { @@ -70,6 +71,8 @@ static char writer[] = "\ /*\n\ * This file was generated by the mksyntax program.\n\ */\n\ +\n\ +#include \"config.h\"\n\ \n"; @@ -184,8 +187,8 @@ print(char *name) { int i; - fprintf(hfile, "extern const char %s[];\n", name); - fprintf(cfile, "const char %s[] = {\n ", name); + fprintf(hfile, "extern const unsigned char %s[];\n", name); + fprintf(cfile, "const unsigned char %s[] = {\n ", name); for (i = 0 ;; i++) { fputs(syntax[i], cfile); if (i == 255) diff --git a/src/myhistedit.h b/src/myhistedit.h index fdc8eed..dc3089b 100644 --- a/src/myhistedit.h +++ b/src/myhistedit.h @@ -33,6 +33,9 @@ * @(#)myhistedit.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_MYHISTEDIT +#define H_MYHISTEDIT 1 + #include extern History *hist; @@ -47,3 +50,4 @@ int histcmd(int, char **); int not_fcnumber(char *); int str_to_event(const char *, int); +#endif diff --git a/src/mylocale.c b/src/mylocale.c index e0e1b01..72b5097 100644 --- a/src/mylocale.c +++ b/src/mylocale.c @@ -27,6 +27,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include "mylocale.h" #include "parser.h" diff --git a/src/mylocale.h b/src/mylocale.h index a6d3be3..b2043d3 100644 --- a/src/mylocale.h +++ b/src/mylocale.h @@ -27,6 +27,11 @@ * SUCH DAMAGE. */ +#ifndef H_MYLOCALE +#define H_MYLOCALE 1 + +#include "config.h" + #include #ifdef WITH_LOCALE @@ -39,3 +44,5 @@ size_t mbccnt(const char *p); #define GETC(c, p) ((void) ((c) = *(p)++)) #define GETC_CTLESC(c, p, f) ((void) ((p) += (f) && *(p) == (char)CTLESC, (c) = *(p)++)) #endif + +#endif diff --git a/src/mystring.c b/src/mystring.c index 53d357e..5f30d73 100644 --- a/src/mystring.c +++ b/src/mystring.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + /* * String functions. * diff --git a/src/mystring.h b/src/mystring.h index 447ad4d..b9fd57c 100644 --- a/src/mystring.h +++ b/src/mystring.h @@ -36,6 +36,9 @@ * @(#)mystring.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_MYSTRING +#define H_MYSTRING 1 + #include #include @@ -63,3 +66,5 @@ const char *const *findstring(const char *, const char *const *, size_t); #define equal(s1, s2) (strcmp(s1, s2) == 0) #define scopy(s1, s2) ((void)strcpy(s2, s1)) + +#endif diff --git a/src/nodes.c.pat b/src/nodes.c.pat index 9125bc7..c8a89db 100644 --- a/src/nodes.c.pat +++ b/src/nodes.c.pat @@ -34,6 +34,8 @@ * @(#)nodes.c.pat 8.2 (Berkeley) 5/4/95 */ +#include "config.h" + #include /* * Routine for dealing with parsed shell commands. diff --git a/src/options.c b/src/options.c index ff30ec4..0339f86 100644 --- a/src/options.c +++ b/src/options.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include #include diff --git a/src/options.h b/src/options.h index e28474e..ab0dd9b 100644 --- a/src/options.h +++ b/src/options.h @@ -36,6 +36,9 @@ * @(#)options.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_OPTIONS +#define H_OPTIONS 1 + struct shparam { int nparam; /* # of positional parameters (without $0) */ unsigned char malloc; /* if parameter list dynamically allocated */ @@ -89,3 +92,5 @@ int nextopt(const char *); char *nextarg(int); void endargs(void); void getoptsreset(const char *); + +#endif diff --git a/src/output.c b/src/output.c index a6ec3c3..4788876 100644 --- a/src/output.c +++ b/src/output.c @@ -32,6 +32,8 @@ * SUCH DAMAGE. */ +#include "config.h" + /* * Shell output routines. We use our own output routines because: * When a builtin command is interrupted we have to discard @@ -44,8 +46,6 @@ */ #include /* quad_t */ -#include /* BSD4_4 */ -#include #include /* defines BUFSIZ */ #include diff --git a/src/output.h b/src/output.h index 81f9cba..8fcb084 100644 --- a/src/output.h +++ b/src/output.h @@ -34,7 +34,8 @@ * @(#)output.h 8.2 (Berkeley) 5/4/95 */ -#ifndef OUTPUT_INCL +#ifndef H_OUTPUT +#define H_OUTPUT 1 #include #ifdef USE_GLIBC_STDIO @@ -120,5 +121,4 @@ static inline void outc(int ch, struct output *file) #define out2str(s) outstr((s), out2) #define outerr(f) (f)->error -#define OUTPUT_INCL #endif diff --git a/src/parser.c b/src/parser.c index 555c5e7..c1c7aa1 100644 --- a/src/parser.c +++ b/src/parser.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #if HAVE_ALLOCA_H #include #endif diff --git a/src/parser.h b/src/parser.h index ca7c474..d8a8e40 100644 --- a/src/parser.h +++ b/src/parser.h @@ -36,6 +36,9 @@ * @(#)parser.h 8.3 (Berkeley) 5/4/95 */ +#ifndef H_PARSER +#define H_PARSER 1 + #include "token.h" /* control characters in argument strings */ @@ -121,3 +124,5 @@ static inline int parser_eof(void) { return tokpushback > lasttoken; } + +#endif diff --git a/src/redir.c b/src/redir.c index e5477b1..014500d 100644 --- a/src/redir.c +++ b/src/redir.c @@ -34,9 +34,10 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include -#include /* PIPE_BUF */ #include #include #include diff --git a/src/redir.h b/src/redir.h index 8e56995..3c0793c 100644 --- a/src/redir.h +++ b/src/redir.h @@ -34,6 +34,9 @@ * @(#)redir.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_REDIR +#define H_REDIR 1 + /* flags passed to redirect */ #define REDIR_PUSH 01 /* save previous values of file descriptors */ #ifdef notyet @@ -51,3 +54,4 @@ int redirectsafe(union node *, int); void unwindredir(struct redirtab *stop); struct redirtab *pushredir(union node *redir); +#endif diff --git a/src/shell.h b/src/shell.h index 8954ced..eb06b45 100644 --- a/src/shell.h +++ b/src/shell.h @@ -51,7 +51,8 @@ * a quit signal will generate a core dump. */ -#include +#ifndef H_SHELL +#define H_SHELL 1 #ifndef JOBS #define JOBS 1 @@ -104,3 +105,5 @@ static inline int max_int_length(int bytes) { return (bytes * 8 - 1) * 0.30102999566398119521 + 14; } + +#endif // H_SHELL diff --git a/src/show.c b/src/show.c index 0db6497..d5934f6 100644 --- a/src/show.c +++ b/src/show.c @@ -32,6 +32,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include #include diff --git a/src/show.h b/src/show.h index d0ccac7..a3b8f81 100644 --- a/src/show.h +++ b/src/show.h @@ -31,9 +31,12 @@ * @(#)show.h 1.1 (Berkeley) 5/4/95 */ -#include +#ifndef H_SHOW +#define H_SHOW 1 #ifdef DEBUG +#include + union node; void showtree(union node *); void trace(const char *, ...); @@ -43,3 +46,5 @@ void trputc(int); void trputs(const char *); void opentrace(void); #endif + +#endif diff --git a/src/signames.c b/src/signames.c index da903cf..423f1b4 100644 --- a/src/signames.c +++ b/src/signames.c @@ -27,6 +27,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include const char *const signal_names[] = { diff --git a/src/system.c b/src/system.c index 844a641..18114c0 100644 --- a/src/system.c +++ b/src/system.c @@ -26,6 +26,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #ifndef HAVE_ISALPHA #define isalnum _isalnum #define iscntrl _iscntrl diff --git a/src/system.h b/src/system.h index 6950e6e..5fed460 100644 --- a/src/system.h +++ b/src/system.h @@ -26,6 +26,11 @@ * SUCH DAMAGE. */ +#ifndef H_SYSTEM +#define H_SYSTEM 1 + +#include "config.h" + #include #include #include @@ -103,3 +108,5 @@ int isblank(int c); * code */ #define uninitialized_var(x) x = x + +#endif diff --git a/src/trap.c b/src/trap.c index 3fa8342..bee1abe 100644 --- a/src/trap.c +++ b/src/trap.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include #include diff --git a/src/trap.h b/src/trap.h index 76f39fc..5107d7f 100644 --- a/src/trap.h +++ b/src/trap.h @@ -36,6 +36,9 @@ * @(#)trap.h 8.3 (Berkeley) 6/5/95 */ +#ifndef H_TRAP +#define H_TRAP 1 + #include extern int trapcnt; @@ -57,3 +60,5 @@ static inline int have_traps(void) { return trapcnt > 0; } + +#endif diff --git a/src/var.c b/src/var.c index ed3f445..45f815b 100644 --- a/src/var.c +++ b/src/var.c @@ -34,6 +34,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include #include @@ -42,6 +44,9 @@ #endif #ifdef WITH_LOCALE #include +#ifdef HAVE_ALLOCA_H +#include +#endif #endif /* diff --git a/src/var.h b/src/var.h index 8a26e30..1a9f2ed 100644 --- a/src/var.h +++ b/src/var.h @@ -36,6 +36,11 @@ * @(#)var.h 8.2 (Berkeley) 5/4/95 */ +#ifndef H_VAR +#define H_VAR 1 + +#include "config.h" + #include /* @@ -197,4 +202,4 @@ static inline char *bltinlookup(const char *name) return lookupvar(name); } - +#endif