diff --git a/util/ack/ack.h b/util/ack/ack.h index 01eec8212..144fd5343 100644 --- a/util/ack/ack.h +++ b/util/ack/ack.h @@ -12,8 +12,8 @@ /* User settable options */ /****************************************************************************/ -#define FRONTENDS "fe" /* The front-end definitions */ -#define TMPNAME "Ack_%x" /* Naming of temp. files */ +#define FRONTENDS "fe" /* The front-end definitions */ +#define TMPNAME "Ack_%x" /* Naming of temp. files */ /****************************************************************************/ /* Internal mnemonics, should not be tinkered with */ @@ -21,77 +21,76 @@ /* The names of some string variables */ -#define HOME "EM" -#define RTS "RTS" -#define HEAD "HEAD" -#define TAIL "TAIL" -#define SRC "SOURCE" -#define LIBVAR "LNAME" -#define SUFFIX "SUFFIX" +#define HOME "EM" +#define RTS "RTS" +#define HEAD "HEAD" +#define TAIL "TAIL" +#define SRC "SOURCE" +#define LIBVAR "LNAME" +#define SUFFIX "SUFFIX" /* Intended for flags, possibly in bit fields */ -#define YES 1 -#define NO 0 -#define MAYBE 2 +#define YES 1 +#define NO 0 +#define MAYBE 2 -#define EXTERN extern +#define SUFCHAR '.' /* Start of SUFFIX in file name */ +#define SPACE ' ' +#define TAB '\t' +#define EQUAL '=' +#define S_VAR '{' /* Start of variable */ +#define C_VAR '}' /* End of variable */ +#define A_VAR '?' /* Variable alternative */ +#define BSLASH '\\' /* Backslash */ +#define STAR '*' /* STAR */ +#define C_IN '<' /* Token specifying input */ +#define C_OUT '>' /* Token specifying output */ +#define S_EXPR '(' /* Start of expression */ +#define C_EXPR ')' /* End of expression */ +#define M_EXPR ':' /* Middle of two suffix lists */ +#define T_EXPR '=' /* Start of tail */ -#define SUFCHAR '.' /* Start of SUFFIX in file name */ -#define SPACE ' ' -#define TAB '\t' -#define EQUAL '=' -#define S_VAR '{' /* Start of variable */ -#define C_VAR '}' /* End of variable */ -#define A_VAR '?' /* Variable alternative */ -#define BSLASH '\\' /* Backslash */ -#define STAR '*' /* STAR */ -#define C_IN '<' /* Token specifying input */ -#define C_OUT '>' /* Token specifying output */ -#define S_EXPR '(' /* Start of expression */ -#define C_EXPR ')' /* End of expression */ -#define M_EXPR ':' /* Middle of two suffix lists */ -#define T_EXPR '=' /* Start of tail */ +#define NO_SCAN 0200 /* Bit set in character to defeat recogn. */ -#define NO_SCAN 0200 /* Bit set in character to defeat recogn. */ +typedef struct +{ + char* p_path; /* points to the full pathname */ + int p_keeps : 1; /* The string should be thrown when unused */ + int p_keep : 1; /* The file should be thrown away after use */ +} path; -typedef struct { - char *p_path; /* points to the full pathname */ - int p_keeps:1; /* The string should be thrown when unused */ - int p_keep:1; /* The file should be thrown away after use */ -} path ; - -#define p_cont(elem) ((path *)l_content(elem)) +#define p_cont(elem) ((path*)l_content(elem)) /* Own routines */ /* rmach.c */ -void setlist(char *); +extern void setlist(char*); /* svars.c */ -void setsvar(char *, char *); -void setpvar(char *, char *(*)(void)); -char *getvar(const char *); +extern void setsvar(char*, char*); +extern void setpvar(char*, char* (*)(void)); +extern char* getvar(const char*); /* util.c */ -char *ack_basename(const char *); -char *skipblank(char *); -char *firstblank(char *); -void fatal(const char *, ...); -void vprint(const char *, ...); -void fuerror(const char *, ...); -void werror(const char *, ...); -void quit(int); -char *keeps(const char *); -#define throws(str) free(str) -void *getcore(size_t); -void *changecore(void *, size_t); -#define freecore(area) free(area) +extern char* ack_basename(const char*); +extern char* skipblank(char*); +extern char* firstblank(char*); +extern void fatal(const char*, ...); +extern void vprint(const char*, ...); +extern void fuerror(const char*, ...); +extern void werror(const char*, ...); +extern void quit(int); +extern char* keeps(const char*); +#define throws(str) free(str) +extern void* getcore(size_t); +extern void* changecore(void*, size_t); +#define freecore(area) free(area) -#define DEBUG 1 /* Allow debugging of Ack */ +#define DEBUG 1 /* Allow debugging of Ack */ #ifndef DEBUG -# define debug 0 /* To surprise all these 'if ( debug ) 's */ +#define debug 0 /* To surprise all these 'if ( debug ) 's */ #else -extern int debug ; +extern int debug; #endif diff --git a/util/ack/data.c b/util/ack/data.c index 2a6946597..168894dfd 100644 --- a/util/ack/data.c +++ b/util/ack/data.c @@ -5,12 +5,48 @@ #include "ack.h" #include "list.h" #include "trans.h" - -/* Include once without redefining EXTERN, to declare all the symbols as extern. */ #include "data.h" -/* And again without EXTERN, to define them here. Without the extern versions above - * then these symbols will all end up as COMMON, which is poorly supported on OSX. */ -#undef EXTERN -#define EXTERN -#include "data.h" +char* stopsuffix = NULL; /* Suffix to stop at */ +char* machine = NULL; /* The machine id */ +char* callname = NULL; /* argv[0] */ +char* rts = NULL; /* The runtime-system */ +char* rtsuf = NULL; /* The runtime-system module suffix */ +char* Optlist = NULL; /* Which optimizers */ + +list_head arguments = {}; /* List of arguments */ +list_head flags = {}; /* List of flags */ + +list_head tr_list = {}; /* List of transformations */ + +list_head R_list = {}; /* List of -R flags */ +list_head head_list = {}; /* List of suffices for headers */ +list_head tail_list = {}; /* List of suffices for tails */ + +int k_flag = 0; /* Like -k of lint */ +int t_flag = 0; /* Preserve intermediate files */ +int v_flag = 0; /* Verbose */ +int w_flag = 0; /* Don't print warnings */ +int nill_flag = 0; /* Don't print file names */ +int Optlevel = 0; /* Optimizing */ + +#ifdef DEBUG +int debug = 0; /* Debugging control */ +#endif + +int n_error = 0; /* Number of errors encountered */ + +char* progname = NULL; /* The program call name */ + +char* outfile = NULL; /* The result file e.g. a.out */ +char template[20] = {}; /* The template for temporary file + names */ + +trf* linker = NULL; /* Pointer to the Loader/Linker */ +trf* cpp_trafo = NULL; /* Pointer to C-preprocessor */ + +path in = {}; /* The current single input pathname */ +path out = {}; /* The current output pathname */ +path orig = {}; /* The original input path */ +char* p_basename = NULL; /* The current basename */ +const char* p_suffix = NULL; /* The current input suffix */ diff --git a/util/ack/data.h b/util/ack/data.h index faa094c0d..c775e82c0 100644 --- a/util/ack/data.h +++ b/util/ack/data.h @@ -3,48 +3,51 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ -/* WARNING: don't put guards around this file (there are reasons). See data.c. */ +#ifndef DATA_H +#define DATA_H -EXTERN char *stopsuffix; /* Suffix to stop at */ -EXTERN char *machine; /* The machine id */ -EXTERN char *callname; /* argv[0] */ -EXTERN char *rts; /* The runtime-system */ -EXTERN char *rtsuf; /* The runtime-system module suffix */ -EXTERN char *Optlist; /* Which optimizers */ +extern char* stopsuffix; /* Suffix to stop at */ +extern char* machine; /* The machine id */ +extern char* callname; /* argv[0] */ +extern char* rts; /* The runtime-system */ +extern char* rtsuf; /* The runtime-system module suffix */ +extern char* Optlist; /* Which optimizers */ -EXTERN list_head arguments; /* List of arguments */ -EXTERN list_head flags; /* List of flags */ +extern list_head arguments; /* List of arguments */ +extern list_head flags; /* List of flags */ -EXTERN list_head tr_list; /* List of transformations */ +extern list_head tr_list; /* List of transformations */ -EXTERN list_head R_list; /* List of -R flags */ -EXTERN list_head head_list; /* List of suffices for headers */ -EXTERN list_head tail_list; /* List of suffices for tails */ +extern list_head R_list; /* List of -R flags */ +extern list_head head_list; /* List of suffices for headers */ +extern list_head tail_list; /* List of suffices for tails */ -EXTERN int k_flag; /* Like -k of lint */ -EXTERN int t_flag; /* Preserve intermediate files */ -EXTERN int v_flag; /* Verbose */ -EXTERN int w_flag; /* Don't print warnings */ -EXTERN int nill_flag; /* Don't print file names */ -EXTERN int Optlevel; /* Optimizing */ +extern int k_flag; /* Like -k of lint */ +extern int t_flag; /* Preserve intermediate files */ +extern int v_flag; /* Verbose */ +extern int w_flag; /* Don't print warnings */ +extern int nill_flag; /* Don't print file names */ +extern int Optlevel; /* Optimizing */ #ifdef DEBUG -EXTERN int debug; /* Debugging control */ +extern int debug; /* Debugging control */ #endif -EXTERN int n_error; /* Number of errors encountered */ +extern int n_error; /* Number of errors encountered */ -EXTERN char *progname; /* The program call name */ +extern char* progname; /* The program call name */ -EXTERN char *outfile; /* The result file e.g. a.out */ -EXTERN char template[20]; /* The template for temporary file - names */ +extern char* outfile; /* The result file e.g. a.out */ +extern char template[20]; /* The template for temporary file + names */ -EXTERN trf *linker; /* Pointer to the Loader/Linker */ -EXTERN trf *cpp_trafo; /* Pointer to C-preprocessor */ +extern trf* linker; /* Pointer to the Loader/Linker */ +extern trf* cpp_trafo; /* Pointer to C-preprocessor */ -EXTERN path in; /* The current single input pathname */ -EXTERN path out; /* The current output pathname */ -EXTERN path orig; /* The original input path */ -EXTERN char *p_basename; /* The current basename */ -EXTERN const char *p_suffix; /* The current input suffix */ +extern path in; /* The current single input pathname */ +extern path out; /* The current output pathname */ +extern path orig; /* The original input path */ +extern char* p_basename; /* The current basename */ +extern const char* p_suffix; /* The current input suffix */ + +#endif