From 652d2679d0dedaa11820c730311f9c56859432bb Mon Sep 17 00:00:00 2001 From: ketmar Date: Wed, 17 Aug 2011 14:37:42 +0300 Subject: [PATCH] cosmetix --- builtins.h | 61 +++++++------- command.h | 13 ++- compile.h | 129 +++++++++++++++-------------- expand.h | 9 +- filesys.h | 12 ++- hash.h | 17 ++-- hdrmacro.h | 11 ++- headers.h | 9 +- jam.h | 273 +++++++++++++++++++++++++++---------------------------------- jambase.h | 11 ++- kstrings.h | 26 +++--- lists.h | 50 ++++++----- make.c | 2 +- make.h | 11 ++- make1.c | 6 +- newstr.h | 15 ++-- option.h | 17 ++-- parse.c | 218 +++++++++++++++++++++--------------------------- parse.h | 25 +++--- rules.h | 5 +- 20 files changed, 460 insertions(+), 460 deletions(-) rewrite builtins.h (73%) rewrite compile.h (74%) rewrite parse.c (62%) diff --git a/builtins.h b/builtins.h dissimilarity index 73% index 74ce092..9894add 100644 --- a/builtins.h +++ b/builtins.h @@ -1,28 +1,33 @@ -/* - * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. - * - * This file is part of Jam - see jam.c for Copyright information. - */ - -/* - * builtins.h - compile parsed jam statements - * - * 01/10/01 (seiwald) - split from compile.h - */ - -void load_builtins (void); - - -LIST *builtin_depends (PARSE *parse, LOL *args, int *jmp); -LIST *builtin_echo (PARSE *parse, LOL *args, int *jmp); -LIST *builtin_echon (PARSE *parse, LOL *args, int *jmp); -LIST *builtin_oflush (PARSE *parse, LOL *args, int *jmp); -LIST *builtin_exit (PARSE *parse, LOL *args, int *jmp); -LIST *builtin_flags (PARSE *parse, LOL *args, int *jmp); -LIST *builtin_glob (PARSE *parse, LOL *args, int *jmp); -LIST *builtin_match (PARSE *parse, LOL *args, int *jmp); -LIST *builtin_hdrmacro (PARSE *parse, LOL *args, int *jmp); - -LIST *builtin_pwd (PARSE *parse, LOL *args, int *jmp); -LIST *builtin_sort (PARSE *parse, LOL *args, int *jmp); -LIST *builtin_command (PARSE *parse, LOL *args, int *jmp); +/* + * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. + * + * This file is part of Jam - see jam.c for Copyright information. + */ +/* + * builtins.h - compile parsed jam statements + * + * 01/10/01 (seiwald) - split from compile.h + */ +#ifndef JAMH_BUILTINS_H +#define JAMH_BUILTINS_H + + +extern void load_builtins (void); + + +extern LIST *builtin_depends (PARSE *parse, LOL *args, int *jmp); +extern LIST *builtin_echo (PARSE *parse, LOL *args, int *jmp); +extern LIST *builtin_echon (PARSE *parse, LOL *args, int *jmp); +extern LIST *builtin_oflush (PARSE *parse, LOL *args, int *jmp); +extern LIST *builtin_exit (PARSE *parse, LOL *args, int *jmp); +extern LIST *builtin_flags (PARSE *parse, LOL *args, int *jmp); +extern LIST *builtin_glob (PARSE *parse, LOL *args, int *jmp); +extern LIST *builtin_match (PARSE *parse, LOL *args, int *jmp); +extern LIST *builtin_hdrmacro (PARSE *parse, LOL *args, int *jmp); + +extern LIST *builtin_pwd (PARSE *parse, LOL *args, int *jmp); +extern LIST *builtin_sort (PARSE *parse, LOL *args, int *jmp); +extern LIST *builtin_command (PARSE *parse, LOL *args, int *jmp); + + +#endif diff --git a/command.h b/command.h index 19f92d1..b52f10d 100644 --- a/command.h +++ b/command.h @@ -3,7 +3,6 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * command.h - the CMD structure and routines to manipulate them * @@ -30,6 +29,9 @@ * cmd_free() - delete CMD and its parts * cmd_next() - walk the CMD chain */ +#ifndef JAMH_COMMAND_H +#define JAMH_COMMAND_H + /* * CMD - an action, ready to be formatted into a buffer and executed @@ -43,16 +45,19 @@ struct _cmd { LIST *shell; /* $(SHELL) value */ LOL args; /* LISTs for $(<), $(>) */ char buf[MAXLINE]; /* actual commands */ -} ; +}; -CMD *cmd_new ( +extern CMD *cmd_new ( RULE *rule, /* rule (referenced) */ LIST *targets, /* $(<) (freed) */ LIST *sources, /* $(>) (freed) */ LIST *shell, /* $(SHELL) (freed) */ int maxline); /* max line length */ -void cmd_free (CMD *cmd); +extern void cmd_free (CMD *cmd); #define cmd_next(c) ((c)->next) + + +#endif diff --git a/compile.h b/compile.h dissimilarity index 74% index 1c0bf08..aaef311 100644 --- a/compile.h +++ b/compile.h @@ -1,61 +1,68 @@ -/* - * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. - * - * This file is part of Jam - see jam.c for Copyright information. - */ - -/* - * compile.h - compile parsed jam statements - * - * 01/22/01 (seiwald) - replace evaluate_if() with compile_eval() - * 01/24/01 (seiwald) - 'while' statement - * 03/02/02 (seiwald) - rules can be invoked via variable names - * 02/28/02 (seiwald) - merge EXEC_xxx flags in with RULE_xxx - * 10/22/02 (seiwald) - working return/break/continue statements - * 11/04/02 (seiwald) - const-ing for string literals - */ - -void compile_builtins (); - -LIST *compile_append (PARSE *parse, LOL *args, int *jmp); -LIST *compile_break (PARSE *parse, LOL *args, int *jmp); -LIST *compile_foreach (PARSE *parse, LOL *args, int *jmp); -LIST *compile_if (PARSE *parse, LOL *args, int *jmp); -LIST *compile_eval (PARSE *parse, LOL *args, int *jmp); -LIST *compile_include (PARSE *parse, LOL *args, int *jmp); -LIST *compile_list (PARSE *parse, LOL *args, int *jmp); -LIST *compile_local (PARSE *parse, LOL *args, int *jmp); -LIST *compile_null (PARSE *parse, LOL *args, int *jmp); -LIST *compile_on (PARSE *parse, LOL *args, int *jmp); -LIST *compile_rule (PARSE *parse, LOL *args, int *jmp); -LIST *compile_rules (PARSE *parse, LOL *args, int *jmp); -LIST *compile_set (PARSE *parse, LOL *args, int *jmp); -LIST *compile_setcomp (PARSE *parse, LOL *args, int *jmp); -LIST *compile_setexec (PARSE *parse, LOL *args, int *jmp); -LIST *compile_settings (PARSE *parse, LOL *args, int *jmp); -LIST *compile_switch (PARSE *parse, LOL *args, int *jmp); -LIST *compile_while (PARSE *parse, LOL *args, int *jmp); - -LIST *evaluate_rule (const char *rulename, LOL *args, LIST *result); - -/* Conditions for compile_if() */ - -# define EXPR_NOT 0 /* ! cond */ -# define EXPR_AND 1 /* cond && cond */ -# define EXPR_OR 2 /* cond || cond */ - -# define EXPR_EXISTS 3 /* arg */ -# define EXPR_EQUALS 4 /* arg = arg */ -# define EXPR_NOTEQ 5 /* arg != arg */ -# define EXPR_LESS 6 /* arg < arg */ -# define EXPR_LESSEQ 7 /* arg <= arg */ -# define EXPR_MORE 8 /* arg > arg */ -# define EXPR_MOREEQ 9 /* arg >= arg */ -# define EXPR_IN 10 /* arg in arg */ - -/* Flags for compile_return */ - -# define JMP_NONE 0 /* flow continues */ -# define JMP_BREAK 1 /* break out of loop */ -# define JMP_CONTINUE 2 /* step to end of loop */ -# define JMP_RETURN 3 /* return from rule */ +/* + * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. + * + * This file is part of Jam - see jam.c for Copyright information. + */ +/* + * compile.h - compile parsed jam statements + * + * 01/22/01 (seiwald) - replace evaluate_if() with compile_eval() + * 01/24/01 (seiwald) - 'while' statement + * 03/02/02 (seiwald) - rules can be invoked via variable names + * 02/28/02 (seiwald) - merge EXEC_xxx flags in with RULE_xxx + * 10/22/02 (seiwald) - working return/break/continue statements + * 11/04/02 (seiwald) - const-ing for string literals + */ +#ifndef JAMH_COMPILE_H +#define JAMH_COMPILE_H + +extern void compile_builtins (void); + +extern LIST *compile_append (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_break (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_foreach (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_if (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_eval (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_include (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_list (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_local (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_null (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_on (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_rule (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_rules (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_set (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_setcomp (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_setexec (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_settings (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_switch (PARSE *parse, LOL *args, int *jmp); +extern LIST *compile_while (PARSE *parse, LOL *args, int *jmp); + +extern LIST *evaluate_rule (const char *rulename, LOL *args, LIST *result); + +/* conditions for compile_if() */ +enum { + EXPR_NOT, /* ! cond */ + EXPR_AND, /* cond && cond */ + EXPR_OR, /* cond || cond */ + + EXPR_EXISTS, /* arg */ + EXPR_EQUALS, /* arg = arg */ + EXPR_NOTEQ, /* arg != arg */ + EXPR_LESS, /* arg < arg */ + EXPR_LESSEQ, /* arg <= arg */ + EXPR_MORE, /* arg > arg */ + EXPR_MOREEQ, /* arg >= arg */ + EXPR_IN /* arg in arg */ +}; + + +/* Flags for compile_return */ +enum { + JMP_NONE, /* flow continues */ + JMP_BREAK, /* break out of loop */ + JMP_CONTINUE, /* step to end of loop */ + JMP_RETURN /* return from rule */ +}; + + +#endif diff --git a/expand.h b/expand.h index 6fc64a5..92d3dd2 100644 --- a/expand.h +++ b/expand.h @@ -3,11 +3,16 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * expand.h - expand a buffer, given variable values * * 11/04/02 (seiwald) - const-ing for string literals */ +#ifndef JAMH_EXPAND_H +#define JAMH_EXPAND_H + + +extern LIST *var_expand (LIST *l, const char *in, const char *end, LOL *lol, int cancopyin); + -LIST *var_expand (LIST *l, const char *in, const char *end, LOL *lol, int cancopyin); +#endif diff --git a/filesys.h b/filesys.h index 2fcdca3..a82ecc6 100644 --- a/filesys.h +++ b/filesys.h @@ -3,16 +3,20 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * filesys.h - OS specific file routines * * 11/04/02 (seiwald) - const-ing for string literals */ +#ifndef JAMH_FILESYS_H +#define JAMH_FILESYS_H typedef void (*scanback) (void *closure, const char *file, int found, time_t t); -void file_dirscan (const char *dir, scanback func, void *closure); -void file_archscan (const char *arch, scanback func, void *closure); +extern void file_dirscan (const char *dir, scanback func, void *closure); +extern void file_archscan (const char *arch, scanback func, void *closure); + +extern int file_time (const char *filename, time_t *time); + -int file_time (const char *filename, time_t *time); +#endif diff --git a/hash.h b/hash.h index 303ed21..957dca9 100644 --- a/hash.h +++ b/hash.h @@ -3,18 +3,23 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * hash.h - simple in-memory hashing routines * * 11/04/02 (seiwald) - const-ing for string literals */ +#ifndef JAMH_HASH_H +#define JAMH_HASH_H + typedef struct hashdata HASHDATA; -struct hash *hashinit (int datalen, const char *name); -int hashitem (struct hash *hp, HASHDATA **data, int enter); -void hashdone (struct hash *hp); +extern struct hash *hashinit (int datalen, const char *name); +extern int hashitem (struct hash *hp, HASHDATA **data, int enter); +extern void hashdone (struct hash *hp); + +#define hashenter(hp, data) (!hashitem(hp, data, !0)) +#define hashcheck(hp, data) (hashitem(hp, data, 0)) + -# define hashenter( hp, data ) !hashitem( hp, data, !0 ) -# define hashcheck( hp, data ) hashitem( hp, data, 0 ) +#endif diff --git a/hdrmacro.h b/hdrmacro.h index 979cb3e..9e4db00 100644 --- a/hdrmacro.h +++ b/hdrmacro.h @@ -3,12 +3,17 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * hdrmacro.h - parses header files for #define MACRO or * #define MACRO "filename" definitions */ +#ifndef JAMH_HRDMACRO_H +#define JAMH_HRDMACRO_H + + +extern void macro_headers (TARGET *t); + +extern const char *macro_header_get (const char *macro_name); -void macro_headers (TARGET *t); -const char *macro_header_get (const char *macro_name); +#endif diff --git a/headers.h b/headers.h index 0cb6067..479c1a9 100644 --- a/headers.h +++ b/headers.h @@ -3,9 +3,14 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * headers.h - handle #includes in source files */ +#ifndef JAMH_HEADERS_H +#define JAMH_HEADERS_H + + +extern void headers (TARGET *t); + -void headers (TARGET *t); +#endif diff --git a/jam.h b/jam.h index 1851120..1d70507 100644 --- a/jam.h +++ b/jam.h @@ -3,7 +3,6 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * jam.h - includes and globals for jam * @@ -37,13 +36,12 @@ * 09/19/02 (seiwald) - new -d displays * 11/05/02 (seiwald) - OSPLAT now set to sparc on solaris. */ +#ifndef JAMH_MAIN_H +#define JAMH_MAIN_H -/* - * Windows NT - */ - -# ifdef NT +/* Windows NT */ +#ifdef NT # include # include # include @@ -64,25 +62,11 @@ /*# define USE_EXECNT*/ # define PATH_DELIM '\\' # define DOWNSHIFT_PATHS +#endif -/* AS400 cross-compile from NT */ - -# ifdef AS400 -# undef OSMINOR -# undef OSMAJOR -# define OSMAJOR "AS400=true" -# define OSMINOR "OS=AS400" -# define OS_AS400 -# endif - -# endif - -/* - * Windows MingW32 - */ - -# ifdef MINGW +/* Windows MingW32 */ +#ifdef MINGW # include # include # include @@ -102,16 +86,11 @@ # define USE_PATHUNIX # define PATH_DELIM '\\' # define DOWNSHIFT_PATHS +#endif -# endif - - -/* - * God fearing UNIX - */ - -# ifndef OSMINOR +/* God fearing UNIX */ +#ifndef OSMINOR # define OSMAJOR "UNIX=true" # define USE_EXECUNIX # define USE_FILEUNIX @@ -119,47 +98,46 @@ # define PATH_DELIM '/' # ifdef __FreeBSD__ -# define OSMINOR "OS=FREEBSD" -# define OS_FREEBSD +# define OSMINOR "OS=FREEBSD" +# define OS_FREEBSD # endif # ifdef linux -# define OSMINOR "OS=LINUX" -# define OS_LINUX +# define OSMINOR "OS=LINUX" +# define OS_LINUX # endif # ifdef __NetBSD__ -# define unix -# define OSMINOR "OS=NETBSD" -# define OS_NETBSD -# define NO_VFORK +# define unix +# define OSMINOR "OS=NETBSD" +# define OS_NETBSD +# define NO_VFORK # endif # ifdef __QNX__ -# ifdef __QNXNTO__ -# define OSMINOR "OS=QNXNTO" -# define OS_QNXNTO -# else -# define unix -# define OSMINOR "OS=QNX" -# define OS_QNX -# define NO_VFORK -# define MAXLINE 996 -# endif +# ifdef __QNXNTO__ +# define OSMINOR "OS=QNXNTO" +# define OS_QNXNTO +# else +# define unix +# define OSMINOR "OS=QNX" +# define OS_QNX +# define NO_VFORK +# define MAXLINE 996 +# endif # endif # ifdef __APPLE__ -# define unix -# define OSMINOR "OS=MACOSX" -# define OS_MACOSX +# define unix +# define OSMINOR "OS=MACOSX" +# define OS_MACOSX # endif # ifndef OSMINOR -# define OSMINOR "OS=UNKNOWN" +# define OSMINOR "OS=UNKNOWN" # endif /* All the UNIX includes */ - # include # include # ifndef OS_MPEIX -# include +# include # endif # include @@ -170,147 +148,140 @@ # include # ifndef OS_QNX -# include +# include # endif # ifndef OS_ULTRIX -# include -# endif - -# if !defined(OS_BSDI) && \ - !defined(OS_FREEBSD) && \ - !defined(OS_NEXT) && \ - !defined(OS_MACHTEN) && \ - !defined(OS_MACOSX) && \ - !defined(OS_RHAPSODY) && \ - !defined(OS_MVS) -# include +# include # endif -#include -#include -#include - +# if !defined(OS_BSDI) && \ + !defined(OS_FREEBSD) && \ + !defined(OS_NEXT) && \ + !defined(OS_MACHTEN) && \ + !defined(OS_MACOSX) && \ + !defined(OS_RHAPSODY) && \ + !defined(OS_MVS) +# include # endif -/* - * OSPLAT definitions - suppressed when it's a one-of-a-kind - */ - -# if defined( _M_PPC ) || \ - defined( PPC ) || \ - defined( ppc ) || \ - defined( __powerpc__ ) || \ - defined( __POWERPC__ ) || \ - defined( __ppc__ ) +# include +# include +# include +#endif + + +/* OSPLAT definitions - suppressed when it's a one-of-a-kind */ +#if defined(_M_PPC) || \ + defined(PPC) || \ + defined(ppc) || \ + defined(__powerpc__) || \ + defined(__POWERPC__) || \ + defined(__ppc__) # define OSPLAT "OSPLAT=PPC" +#endif + +#if defined(_i386_) || \ + defined(__i386__) || \ + defined(_M_IX86) +# if !defined(OS_FREEBSD) && \ + !defined(OS_OS2) +# define OSPLAT "OSPLAT=X86" # endif +#endif -# if defined( _ALPHA_ ) || \ - defined( __alpha__ ) -# define OSPLAT "OSPLAT=AXP" -# endif - -# if defined( _i386_ ) || \ - defined( __i386__ ) || \ - defined( _M_IX86 ) -# if !defined( OS_FREEBSD ) && \ - !defined( OS_OS2 ) && \ - !defined( OS_AS400 ) -# define OSPLAT "OSPLAT=X86" -# endif -# endif - -# ifdef __sparc__ +#ifdef __sparc__ # if !defined( OS_SUNOS ) -# define OSPLAT "OSPLAT=SPARC" -# endif +# define OSPLAT "OSPLAT=SPARC" # endif +#endif -# ifdef __mips__ +#ifdef __mips__ # if !defined( OS_SGI ) -# define OSPLAT "OSPLAT=MIPS" -# endif +# define OSPLAT "OSPLAT=MIPS" # endif +#endif -# ifdef __arm__ +#ifdef __arm__ # define OSPLAT "OSPLAT=ARM" -# endif +#endif -# if defined( __ia64__ ) || \ - defined( __IA64__ ) || \ - defined( _M_IA64 ) +#if defined(__ia64__) || \ + defined(__IA64__) || \ + defined(_M_IA64) # define OSPLAT "OSPLAT=IA64" -# endif +#endif -# ifdef __s390__ +#ifdef __s390__ # define OSPLAT "OSPLAT=390" -# endif +#endif -# ifndef OSPLAT +#ifndef OSPLAT # define OSPLAT "" -# endif +#endif -/* - * Jam implementation misc. - */ -# ifndef MAXLINE -# define MAXLINE 10240 /* longest 'together' actions' */ -# endif +/* Jam implementation misc. */ -# ifndef EXITOK -# define EXITOK 0 -# define EXITBAD 1 -# endif +#ifndef MAXLINE +# define MAXLINE 10240 /* longest 'together' actions' */ +#endif -# ifndef SPLITPATH +#ifndef EXITOK +# define EXITOK 0 +# define EXITBAD 1 +#endif + +#ifndef SPLITPATH # define SPLITPATH ':' -# endif +#endif + /* You probably don't need to muck with these. */ +#define MAXSYM 1024 /* longest symbol in the environment */ +#define MAXJPATH 1024 /* longest filename */ -# define MAXSYM 1024 /* longest symbol in the environment */ -# define MAXJPATH 1024 /* longest filename */ +#define MAXJOBS 64 /* silently enforce -j limit */ +#define MAXARGC 32 /* words in $(JAMSHELL) */ -# define MAXJOBS 64 /* silently enforce -j limit */ -# define MAXARGC 32 /* words in $(JAMSHELL) */ /* Jam private definitions below. */ - -# define DEBUG_MAX 15 +#define DEBUG_MAX 15 struct globs { int noexec; int jobs; int quitquick; - int newestfirst; /* build newest sources first */ - char debug[DEBUG_MAX]; - FILE *cmdout; /* print cmds, not run them */ + int newestfirst; /* build newest sources first */ + char debug[DEBUG_MAX]; + FILE *cmdout; /* print cmds, not run them */ } ; extern struct globs globs; -# define DEBUG_MAKE ( globs.debug[1] ) /* -da show actions when executed */ -# define DEBUG_MAKEPROG ( globs.debug[3] ) /* -dm show progress of make0 */ +#define DEBUG_MAKE (globs.debug[1]) /* -da show actions when executed */ +#define DEBUG_MAKEPROG (globs.debug[3]) /* -dm show progress of make0 */ + +#define DEBUG_EXECCMD (globs.debug[4]) /* show execcmds()'s work */ + +#define DEBUG_COMPILE (globs.debug[5]) /* show rule invocations */ -# define DEBUG_EXECCMD ( globs.debug[4] ) /* show execcmds()'s work */ +#define DEBUG_HEADER (globs.debug[6]) /* show result of header scan */ +#define DEBUG_BINDSCAN (globs.debug[6]) /* show result of dir scan */ +#define DEBUG_SEARCH (globs.debug[6]) /* show attempts at binding */ -# define DEBUG_COMPILE ( globs.debug[5] ) /* show rule invocations */ +#define DEBUG_VARSET (globs.debug[7]) /* show variable settings */ +#define DEBUG_VARGET (globs.debug[8]) /* show variable fetches */ +#define DEBUG_VAREXP (globs.debug[8]) /* show variable expansions */ +#define DEBUG_IF (globs.debug[8]) /* show 'if' calculations */ +#define DEBUG_LISTS (globs.debug[9]) /* show list manipulation */ +#define DEBUG_SCAN (globs.debug[9]) /* show scanner tokens */ +#define DEBUG_MEM (globs.debug[9]) /* show memory use */ -# define DEBUG_HEADER ( globs.debug[6] ) /* show result of header scan */ -# define DEBUG_BINDSCAN ( globs.debug[6] ) /* show result of dir scan */ -# define DEBUG_SEARCH ( globs.debug[6] ) /* show attempts at binding */ +#define DEBUG_MAKEQ (globs.debug[11]) /* -da show even quiet actions */ +#define DEBUG_EXEC (globs.debug[12]) /* -dx show text of actions */ +#define DEBUG_DEPENDS (globs.debug[13]) /* -dd show dependency graph */ +#define DEBUG_CAUSES (globs.debug[14]) /* -dc show dependency graph */ -# define DEBUG_VARSET ( globs.debug[7] ) /* show variable settings */ -# define DEBUG_VARGET ( globs.debug[8] ) /* show variable fetches */ -# define DEBUG_VAREXP ( globs.debug[8] ) /* show variable expansions */ -# define DEBUG_IF ( globs.debug[8] ) /* show 'if' calculations */ -# define DEBUG_LISTS ( globs.debug[9] ) /* show list manipulation */ -# define DEBUG_SCAN ( globs.debug[9] ) /* show scanner tokens */ -# define DEBUG_MEM ( globs.debug[9] ) /* show memory use */ -# define DEBUG_MAKEQ ( globs.debug[11] ) /* -da show even quiet actions */ -# define DEBUG_EXEC ( globs.debug[12] ) /* -dx show text of actions */ -# define DEBUG_DEPENDS ( globs.debug[13] ) /* -dd show dependency graph */ -# define DEBUG_CAUSES ( globs.debug[14] ) /* -dc show dependency graph */ +#endif diff --git a/jambase.h b/jambase.h index c05ec79..5914008 100644 --- a/jambase.h +++ b/jambase.h @@ -3,13 +3,18 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * jambase.h - declaration for the internal jambase * * The file Jambase is turned into a C array of strings in jambase.c - * so that it can be built in to the executable. This is the - * declaration for that array. + * so that it can be built in to the executable. + * This is the declaration for that array. */ +#ifndef JAMH_JAMBASE_H +#define JAMH_JAMBASE_H + extern char *jambase[]; + + +#endif diff --git a/kstrings.h b/kstrings.h index e3015c2..9c048b0 100644 --- a/kstrings.h +++ b/kstrings.h @@ -1,5 +1,5 @@ -#ifndef KSTRINGS_H -#define KSTRINGS_H +#ifndef JAMH_KSTRINGS_H +#define JAMH_KSTRINGS_H /* Copyright David Abrahams 2004. Distributed under the Boost */ /* Software License, Version 1.0. (See accompanying */ /* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ @@ -18,19 +18,19 @@ typedef struct { } tKString; -void kStringNew (tKString *s); -void kStringFree (tKString *s); -void kStringReserve (tKString *self, size_t capacity); -void kStringAppend (tKString *self, char const *rhs); -void kStringAppendRange (tKString *self, char const *start, char const *finish); -void kStringCopy (tKString *s, char const *rhs); -void kStringTruncate (tKString *self, size_t n); -void kStringPopBack (tKString *self); -void kStringPushBack (tKString *self, char x); -char kStringBack (tKString *self); +extern void kStringNew (tKString *s); +extern void kStringFree (tKString *s); +extern void kStringReserve (tKString *self, size_t capacity); +extern void kStringAppend (tKString *self, char const *rhs); +extern void kStringAppendRange (tKString *self, char const *start, char const *finish); +extern void kStringCopy (tKString *s, char const *rhs); +extern void kStringTruncate (tKString *self, size_t n); +extern void kStringPopBack (tKString *self); +extern void kStringPushBack (tKString *self, char x); +extern char kStringBack (tKString *self); #ifndef NDEBUG -void kStringUnitTest (void); +extern void kStringUnitTest (void); #endif diff --git a/lists.h b/lists.h index afe0803..e49cf97 100644 --- a/lists.h +++ b/lists.h @@ -3,7 +3,6 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * lists.h - the LIST structure and routines to manipulate them * @@ -39,13 +38,12 @@ * 11/04/02 (seiwald) - const-ing for string literals * 12/09/02 (seiwald) - new list_printq() for writing lists to Jambase */ +#ifndef JAMH_LISTS_H +#define JAMH_LISTS_H -/* - * LIST - list of strings - */ +/* LIST - list of strings */ typedef struct _list LIST; - struct _list { LIST *next; LIST *tail; /* only valid in head node */ @@ -53,35 +51,33 @@ struct _list { } ; -/* - * LOL - list of LISTs - */ - +/* LOL - list of LISTs */ +#define LOL_MAX (32) typedef struct _lol LOL; - -# define LOL_MAX 9 - struct _lol { int count; LIST *list[LOL_MAX]; }; -LIST *list_append (LIST *l, LIST *nl); -LIST *list_copy (LIST *l, LIST *nl); -void list_free (LIST *head); -LIST *list_new (LIST *head, const char *string, int copy); -void list_print (LIST *l); -int list_length (LIST *l); -LIST *list_sublist (LIST *l, int start, int count); -LIST *list_sort (LIST *l); +extern LIST *list_append (LIST *l, LIST *nl); +extern LIST *list_copy (LIST *l, LIST *nl); +extern void list_free (LIST *head); +extern LIST *list_new (LIST *head, const char *string, int copy); +extern void list_print (LIST *l); +extern int list_length (LIST *l); +extern LIST *list_sublist (LIST *l, int start, int count); +extern LIST *list_sort (LIST *l); + +#define list_next(l) ((l)->next) + +#define L0 ((LIST *)0) -# define list_next( l ) ((l)->next) +extern void lol_add (LOL *lol, LIST *l); +extern void lol_init (LOL *lol); +extern void lol_free (LOL *lol); +extern LIST *lol_get (LOL *lol, int i); +extern void lol_print (LOL *lol); -# define L0 ((LIST *)0) -void lol_add (LOL *lol, LIST *l); -void lol_init (LOL *lol); -void lol_free (LOL *lol); -LIST *lol_get (LOL *lol, int i); -void lol_print (LOL *lol); +#endif diff --git a/make.c b/make.c index fe8efc1..36141f7 100644 --- a/make.c +++ b/make.c @@ -178,7 +178,7 @@ static void make0 ( t->binding = T_BIND_PARENTS; ptime = p; } -#ifndef JAM_OPT_SEMAPHORE +#ifdef JAM_OPT_SEMAPHORE { LIST *var = var_get("JAM_SEMAPHORE"); if (var) { diff --git a/make.h b/make.h index 9ffe992..88dd41a 100644 --- a/make.h +++ b/make.h @@ -3,12 +3,17 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * make.h - bring a target up to date, once rules are in place * * 11/04/02 (seiwald) - const-ing for string literals */ +#ifndef JAMH_MAKE_H +#define JAMH_MAKE_H + + +extern int make (int n_targets, const char **targets, int anyhow); +extern int make1 (TARGET *t); + -int make (int n_targets, const char **targets, int anyhow); -int make1 (TARGET *t); +#endif diff --git a/make1.c b/make1.c index 4c10526..13829be 100644 --- a/make1.c +++ b/make1.c @@ -145,7 +145,7 @@ static void make1b (TARGET *t) { /* if any dependents are still outstanding, wait until they */ /* call make1b() to signal their completion */ if (--t->asynccnt) return; -#ifndef JAM_OPT_SEMAPHORE +#ifdef JAM_OPT_SEMAPHORE if (t->semaphore && t->semaphore->asynccnt) { /* append 't' to the list of targets waiting on semaphore. */ t->semaphore->parents = targetentry(t->semaphore->parents, t); @@ -203,7 +203,7 @@ static void make1b (TARGET *t) { /* (because of dependency failures or because no commands need to */ /* be run) the chain will be empty and make1c() will directly */ /* signal the completion of target. */ -#ifndef JAM_OPT_SEMAPHORE +#ifdef JAM_OPT_SEMAPHORE /* If there is a semaphore, indicate that it is in use. */ if (pState->t->semaphore) { ++pState->t->semaphore->asynccnt; @@ -260,7 +260,7 @@ static void make1c (TARGET *t) { /* tell parents dependent has been built */ t->progress = T_MAKE_DONE; for (c = t->parents; c; c = c->next) make1b(c->target); -#ifndef JAM_OPT_SEMAPHORE +#ifdef JAM_OPT_SEMAPHORE /* If there is a semaphore, it is now free. */ if (t->semaphore) { assert(t->semaphore->asynccnt == 1); diff --git a/newstr.h b/newstr.h index 243d840..ee44593 100644 --- a/newstr.h +++ b/newstr.h @@ -3,14 +3,19 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * newstr.h - string manipulation routines * * 11/04/02 (seiwald) - const-ing for string literals */ +#ifndef JAMH_NEWSTR_H +#define JAMH_NEWSTR_H + + +extern const char *newstr (const char *string); +extern const char *copystr (const char *s); +extern void freestr (const char *s); +extern void donestr (void); + -const char *newstr (const char *string); -const char *copystr (const char *s); -void freestr (const char *s); -void donestr (void); +#endif diff --git a/option.h b/option.h index 8de42f4..29562f7 100644 --- a/option.h +++ b/option.h @@ -3,7 +3,6 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * option.h - command line option processing * @@ -12,14 +11,20 @@ * * 11/04/02 (seiwald) - const-ing for string literals */ +#ifndef JAMH_OPTION_H +#define JAMH_OPTION_H + typedef struct option { - char flag; /* filled in by getoption() */ + char flag; /* filled in by getoption() */ const char *val; /* set to random address if true */ } option; -# define N_OPTS 256 -# define N_TARGETS 256 +#define N_OPTS (256) +#define N_TARGETS (256) + +extern int getoptions (int argc, char **argv, const char *opts, option *optv, char **targets); +extern const char *getoptval (option *optv, char opt, int subopt); + -int getoptions (int argc, char **argv, const char *opts, option *optv, char **targets); -const char *getoptval (option *optv, char opt, int subopt); +#endif diff --git a/parse.c b/parse.c dissimilarity index 62% index 1a32c4b..9bb9329 100644 --- a/parse.c +++ b/parse.c @@ -1,124 +1,94 @@ -/* - * Copyright 1993, 2000 Christopher Seiwald. - * - * This file is part of Jam - see jam.c for Copyright information. - */ - -/* - * parse.c - make and destroy parse trees as driven by the parser - * - * 09/07/00 (seiwald) - ref count on PARSE to avoid freeing when used, - * as per Matt Armstrong. - * 09/11/00 (seiwald) - structure reworked to reflect that (*func)() - * returns a LIST *. - * 10/22/02 (seiwald) - working return/break/continue statements - * 11/04/02 (seiwald) - const-ing for string literals - */ - -# include "jam.h" -# include "lists.h" -# include "parse.h" -# include "scan.h" -# include "newstr.h" - -static PARSE *yypsave; - -void -parse_file( const char *f ) -{ - /* Suspend scan of current file */ - /* and push this new file in the stream */ - - yyfparse(f); - - /* Now parse each block of rules and execute it. */ - /* Execute it outside of the parser so that recursive */ - /* calls to yyrun() work (no recursive yyparse's). */ - - for(;;) - { - LOL l; - PARSE *p; - int jmp = 0; /* JMP_NONE */ - - /* $(<) and $(>) empty in outer scope. */ - - lol_init( &l ); - - /* Filled by yyparse() calling parse_save() */ - - yypsave = 0; - - /* If parse error or empty parse, outta here */ - - if( yyparse() || !( p = yypsave ) ) - break; - - /* Run the parse tree. */ - - list_free( (*(p->func))( p, &l, &jmp ) ); - - parse_free( p ); - } -} - -void -parse_save( PARSE *p ) -{ - yypsave = p; -} - -PARSE * -parse_make( - LIST *(*func)( PARSE *p, LOL *args, int *jmp ), - PARSE *left, - PARSE *right, - PARSE *third, - const char *string, - const char *string1, - int num ) -{ - PARSE *p = (PARSE *)malloc( sizeof( PARSE ) ); - - p->func = func; - p->left = left; - p->right = right; - p->third = third; - p->string = string; - p->string1 = string1; - p->num = num; - p->refs = 1; - - return p; -} - -void -parse_refer( PARSE *p ) -{ - ++p->refs; -} - -void -parse_free( PARSE *p ) -{ - if( --p->refs ) - return; - - if( p->string ) - freestr( p->string ); - if( p->string1 ) - freestr( p->string1 ); - if( p->left ) - parse_free( p->left ); - if( p->right ) - parse_free( p->right ); - if( p->third ) - parse_free( p->third ); - - free( (char *)p ); -} - - -const char *multiFormSfx (int cnt) { - return cnt==1 ? "" : "s"; -} +/* + * Copyright 1993, 2000 Christopher Seiwald. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* + * parse.c - make and destroy parse trees as driven by the parser + * + * 09/07/00 (seiwald) - ref count on PARSE to avoid freeing when used, + * as per Matt Armstrong. + * 09/11/00 (seiwald) - structure reworked to reflect that (*func)() + * returns a LIST *. + * 10/22/02 (seiwald) - working return/break/continue statements + * 11/04/02 (seiwald) - const-ing for string literals + */ +#include "jam.h" +#include "lists.h" +#include "parse.h" +#include "scan.h" +#include "newstr.h" + + +static PARSE *yypsave; + +void parse_file (const char *f) { + /* suspend scan of current file and push this new file in the stream */ + yyfparse(f); + /* now parse each block of rules and execute it */ + /* execute it outside of the parser so that recursive */ + /* calls to yyrun() work (no recursive yyparse's) */ + for (;;) { + LOL l; + PARSE *p; + int jmp = 0; /* JMP_NONE */ + /* $(<) and $(>) empty in outer scope */ + lol_init(&l); + /* filled by yyparse() calling parse_save() */ + yypsave = 0; + /* if parse error or empty parse, outta here */ + if (yyparse() || !(p = yypsave)) break; + /* run the parse tree */ + list_free((*(p->func))(p, &l, &jmp)); + parse_free(p); + } +} + + +void parse_save (PARSE *p) { + yypsave = p; +} + + +PARSE *parse_make ( + LIST *(*func) (PARSE *p, LOL *args, int *jmp), + PARSE *left, + PARSE *right, + PARSE *third, + const char *string, + const char *string1, + int num) +{ + PARSE *p = (PARSE *)malloc(sizeof(PARSE)); + p->func = func; + p->left = left; + p->right = right; + p->third = third; + p->string = string; + p->string1 = string1; + p->num = num; + p->refs = 1; + return p; +} + + +void parse_refer (PARSE *p) { + ++p->refs; +} + + +void parse_free (PARSE *p) { + if (--p->refs) return; + if (p->string) freestr( p->string ); + if (p->string1) freestr( p->string1 ); + if (p->left) parse_free( p->left ); + if (p->right) parse_free( p->right ); + if (p->third) parse_free( p->third ); + free((char *)p); +} + + +const char *multiFormSfx (int cnt) { + return cnt==1?"":"s"; +} diff --git a/parse.h b/parse.h index 3b7b53a..c6e9bda 100644 --- a/parse.h +++ b/parse.h @@ -3,22 +3,20 @@ * * This file is part of Jam - see jam.c for Copyright information. */ - /* * parse.h - make and destroy parse trees as driven by the parser * * 10/22/02 (seiwald) - working return/break/continue statements * 11/04/02 (seiwald) - const-ing for string literals */ +#ifndef JAMH_PARSE_H +#define JAMH_PARSE_H -/* - * parse tree node - */ +/* parse tree node */ typedef struct _PARSE PARSE; - struct _PARSE { - LIST *(*func)(PARSE *p, LOL *args, int *jmp); + LIST *(*func) (PARSE *p, LOL *args, int *jmp); PARSE *left; PARSE *right; PARSE *third; @@ -29,11 +27,11 @@ struct _PARSE { }; -void parse_file (const char *f); -void parse_save (PARSE *p); +extern void parse_file (const char *f); +extern void parse_save (PARSE *p); PARSE *parse_make ( - LIST *(*func)(PARSE *p, LOL *args, int *jmp), + LIST *(*func) (PARSE *p, LOL *args, int *jmp), PARSE *left, PARSE *right, PARSE *third, @@ -42,8 +40,11 @@ PARSE *parse_make ( int num ); -void parse_refer (PARSE *p); -void parse_free (PARSE *p); +extern void parse_refer (PARSE *p); +extern void parse_free (PARSE *p); + + +extern const char *multiFormSfx (int cnt); -const char *multiFormSfx (int cnt); +#endif diff --git a/rules.h b/rules.h index 8594c6e..b372596 100644 --- a/rules.h +++ b/rules.h @@ -45,6 +45,7 @@ typedef struct _action ACTION; typedef struct _actions ACTIONS; typedef struct _settings SETTINGS ; + /* RULE - a generic jam rule, the product of RULE and ACTIONS */ enum { RULE_UPDATED = 0x01, /* $(>) is updated sources only */ @@ -142,7 +143,7 @@ enum { T_MAKE_ACTIVE, /* make1(target) in make1b() */ T_MAKE_RUNNING, /* make1(target) running commands */ T_MAKE_DONE /* make1(target) done */ -#ifndef JAM_OPT_SEMAPHORE +#ifdef JAM_OPT_SEMAPHORE ,T_MAKE_SEMAPHORE /* special target type for semaphores */ #endif }; @@ -166,7 +167,7 @@ struct _target { char progress; /* tracks make1() progress (T_MAKE_XXX)*/ -#ifndef JAM_OPT_SEMAPHORE +#ifdef JAM_OPT_SEMAPHORE TARGET *semaphore; /* used in serialization */ #endif -- 2.11.4.GIT