diff --git a/commands.h b/commands.h index f7cf0640..18d8c285 100644 --- a/commands.h +++ b/commands.h @@ -19,7 +19,7 @@ this program. If not, see . */ struct commands { - gmk_floc fileinfo; /* Where commands were defined. */ + floc fileinfo; /* Where commands were defined. */ char *commands; /* Commands text. */ char **command_lines; /* Commands chopped up into lines. */ unsigned char *lines_flags; /* One set of flag bits for each line. */ diff --git a/dep.h b/dep.h index 9e9972be..7f5076ea 100644 --- a/dep.h +++ b/dep.h @@ -63,7 +63,7 @@ struct goaldep { DEP (struct goaldep); unsigned short error; - gmk_floc floc; + floc floc; }; /* Options for parsing lists of filenames. */ @@ -127,5 +127,5 @@ SI void free_goal_chain(struct goaldep *g) { free_dep_chain((struct dep *)g); } struct dep *copy_dep_chain (const struct dep *d); struct goaldep *read_all_makefiles (const char **makefiles); -void eval_buffer (char *buffer, const gmk_floc *floc); +void eval_buffer (char *buffer, const floc *floc); enum update_status update_goal_chain (struct goaldep *goals); diff --git a/expand.c b/expand.c index de832b37..0b5fd011 100644 --- a/expand.c +++ b/expand.c @@ -26,7 +26,7 @@ this program. If not, see . */ /* Initially, any errors reported when expanding strings will be reported against the file where the error appears. */ -const gmk_floc **expanding_var = &reading_file; +const floc **expanding_var = &reading_file; /* The next two describe the variable output buffer. This buffer is used to hold the variable-expansion of a line of the @@ -96,8 +96,8 @@ char * recursively_expand_for_file (struct variable *v, struct file *file) { char *value; - const gmk_floc *this_var; - const gmk_floc **saved_varp; + const floc *this_var; + const floc **saved_varp; struct variable_set_list *save = 0; int set_reading = 0; @@ -458,7 +458,7 @@ variable_expand_for_file (const char *line, struct file *file) { char *result; struct variable_set_list *savev; - const gmk_floc *savef; + const floc *savef; if (file == 0) return variable_expand (line); diff --git a/function.c b/function.c index c9fcec2c..b7f0e56b 100644 --- a/function.c +++ b/function.c @@ -2634,7 +2634,7 @@ func_call (char *o, char **argv, const char *funcname UNUSED) } void -define_new_function (const gmk_floc *flocp, const char *name, +define_new_function (const floc *flocp, const char *name, unsigned int min, unsigned int max, unsigned int flags, gmk_func_ptr func) { diff --git a/gnumake.h b/gnumake.h index 5b441e58..b508562f 100644 --- a/gnumake.h +++ b/gnumake.h @@ -24,7 +24,6 @@ typedef struct { const char *filenm; unsigned long lineno; - unsigned long offset; } gmk_floc; typedef char *(*gmk_func_ptr)(const char *nm, unsigned int argc, char **argv); diff --git a/guile.c b/guile.c index b7bb8fbb..1b055c3d 100644 --- a/guile.c +++ b/guile.c @@ -140,7 +140,7 @@ func_guile (const char *funcname UNUSED, unsigned int argc UNUSED, char **argv) /* We could send the flocp to define_new_function(), but since guile is "kind of" built-in, that didn't seem so useful. */ int -guile_gmake_setup (const gmk_floc *flocp UNUSED) +guile_gmake_setup (const floc *flocp UNUSED) { /* Create a make function "guile". */ gmk_add_function ("guile", func_guile, 0, 1, GMK_FUNC_DEFAULT); @@ -151,7 +151,7 @@ guile_gmake_setup (const gmk_floc *flocp UNUSED) #else int -guile_gmake_setup (const gmk_floc *flocp UNUSED) +guile_gmake_setup (const floc *flocp UNUSED) { return 1; } diff --git a/job.c b/job.c index ddac6c41..f3a9fdbe 100644 --- a/job.c +++ b/job.c @@ -474,7 +474,7 @@ child_error (struct child *child, const char *post = ""; const char *dump = ""; const struct file *f = child->file; - const gmk_floc *flocp = &f->cmds->fileinfo; + const floc *flocp = &f->cmds->fileinfo; const char *nm; size_t l; diff --git a/load.c b/load.c index 2beab83d..37e7b8ea 100644 --- a/load.c +++ b/load.c @@ -45,8 +45,8 @@ struct load_list static struct load_list *loaded_syms = NULL; static load_func_t -load_object (const gmk_floc *flocp, int noerror, - const char *ldname, const char *symname) +load_object (const floc *flocp, int noerror, const char *ldname, + const char *symname) { static void *global_dl = NULL; load_func_t symp; @@ -119,7 +119,7 @@ load_object (const gmk_floc *flocp, int noerror, } int -load_file (const gmk_floc *flocp, const char **ldname, int noerror) +load_file (const floc *flocp, const char **ldname, int noerror) { int nmlen = strlen (*ldname); char *new = alloca (nmlen + CSTRLEN (SYMBOL_EXTENSION) + 1); @@ -249,7 +249,7 @@ unload_file (const char *name) #else int -load_file (const gmk_floc *flocp, const char **ldname UNUSED, int noerror) +load_file (const floc *flocp, const char **ldname UNUSED, int noerror) { if (! noerror) O (fatal, flocp, diff --git a/loadapi.c b/loadapi.c index 4c1f6cf5..14b75f8f 100644 --- a/loadapi.c +++ b/loadapi.c @@ -37,17 +37,29 @@ gmk_free (char *s) /* Evaluate a buffer as make syntax. Ideally eval_buffer() will take const char *, but not yet. */ void -gmk_eval (const char *buffer, const gmk_floc *floc) +gmk_eval (const char *buffer, const gmk_floc *gfloc) { /* Preserve existing variable buffer context. */ char *pbuf; unsigned int plen; char *s; + floc fl; + floc *flp; + + if (gfloc) + { + fl.filenm = gfloc->filenm; + fl.lineno = gfloc->lineno; + fl.offset = 0; + flp = &fl; + } + else + flp = NULL; install_variable_buffer (&pbuf, &plen); s = xstrdup (buffer); - eval_buffer (s, floc); + eval_buffer (s, flp); free (s); restore_variable_buffer (pbuf, plen); diff --git a/makeint.h b/makeint.h index ad0a511e..8f718ebf 100644 --- a/makeint.h +++ b/makeint.h @@ -452,7 +452,7 @@ extern struct rlimit stack_limit; #include -#define NILF ((gmk_floc *)0) +#define NILF ((floc *)0) #define CSTRLEN(_s) (sizeof (_s)-1) #define STRING_SIZE_TUPLE(_s) (_s), CSTRLEN(_s) @@ -468,13 +468,22 @@ extern struct rlimit stack_limit; #endif + +/* Specify the location of elements read from makefiles. */ +typedef struct + { + const char *filenm; + unsigned long lineno; + unsigned long offset; + } floc; + const char *concat (unsigned int, ...); void message (int prefix, size_t length, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); -void error (const gmk_floc *flocp, size_t length, const char *fmt, ...) +void error (const floc *flocp, size_t length, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); -void fatal (const gmk_floc *flocp, size_t length, const char *fmt, ...) - __attribute__ ((noreturn, __format__ (__printf__, 3, 4))); +void fatal (const floc *flocp, size_t length, const char *fmt, ...) + __attribute__ ((noreturn, __format__ (__printf__, 3, 4))); #define O(_t,_a,_f) _t((_a), 0, (_f)) #define OS(_t,_a,_f,_s) _t((_a), strlen (_s), (_f), (_s)) @@ -569,11 +578,11 @@ const char *strcache_add (const char *str); const char *strcache_add_len (const char *str, unsigned int len); /* Guile support */ -int guile_gmake_setup (const gmk_floc *flocp); +int guile_gmake_setup (const floc *flocp); /* Loadable object support. Sets to the strcached name of the loaded file. */ -typedef int (*load_func_t)(const gmk_floc *flocp); -int load_file (const gmk_floc *flocp, const char **filename, int noerror); +typedef int (*load_func_t)(const floc *flocp); +int load_file (const floc *flocp, const char **filename, int noerror); void unload_file (const char *name); /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION, @@ -627,8 +636,8 @@ int strncasecmp (const char *s1, const char *s2, int n); /* Non-GNU systems may not declare this in unistd.h. */ extern char **environ; -extern const gmk_floc *reading_file; -extern const gmk_floc **expanding_var; +extern const floc *reading_file; +extern const floc **expanding_var; extern unsigned short stopchar_map[]; diff --git a/output.c b/output.c index 0a0420c6..65182c4b 100644 --- a/output.c +++ b/output.c @@ -640,7 +640,7 @@ message (int prefix, size_t len, const char *fmt, ...) /* Print an error message. */ void -error (const gmk_floc *flocp, size_t len, const char *fmt, ...) +error (const floc *flocp, size_t len, const char *fmt, ...) { va_list args; char *p; @@ -671,7 +671,7 @@ error (const gmk_floc *flocp, size_t len, const char *fmt, ...) /* Print an error message and exit. */ void -fatal (const gmk_floc *flocp, size_t len, const char *fmt, ...) +fatal (const floc *flocp, size_t len, const char *fmt, ...) { va_list args; const char *stop = _(". Stop.\n"); diff --git a/read.c b/read.c index c6eb5c88..5de5a483 100644 --- a/read.c +++ b/read.c @@ -52,7 +52,7 @@ struct ebuffer char *bufstart; /* Start of the entire buffer. */ unsigned int size; /* Malloc'd size of buffer. */ FILE *fp; /* File, or NULL if this is an internal buffer. */ - gmk_floc floc; /* Info on the file in fp (if any). */ + floc floc; /* Info on the file in fp (if any). */ }; /* Track the modifiers we can have on variable assignments */ @@ -126,7 +126,7 @@ static unsigned int max_incl_len; /* The filename and pointer to line number of the makefile currently being read in. */ -const gmk_floc *reading_file = 0; +const floc *reading_file = 0; /* The chain of files read by read_all_makefiles. */ @@ -140,16 +140,16 @@ static void do_undefine (char *name, enum variable_origin origin, struct ebuffer *ebuf); static struct variable *do_define (char *name, enum variable_origin origin, struct ebuffer *ebuf); -static int conditional_line (char *line, int len, const gmk_floc *flocp); +static int conditional_line (char *line, int len, const floc *flocp); static void record_files (struct nameseq *filenames, const char *pattern, const char *pattern_percent, char *depstr, unsigned int cmds_started, char *commands, unsigned int commands_idx, int two_colon, - char prefix, const gmk_floc *flocp); + char prefix, const floc *flocp); static void record_target_var (struct nameseq *filenames, char *defn, enum variable_origin origin, struct vmodifiers *vmod, - const gmk_floc *flocp); + const floc *flocp); static enum make_word_type get_next_mword (char *buffer, char *delim, char **startp, unsigned int *length); static void remove_comments (char *line); @@ -316,7 +316,7 @@ eval_makefile (const char *filename, int flags) { struct goaldep *deps; struct ebuffer ebuf; - const gmk_floc *curfile; + const floc *curfile; char *expanded = 0; int makefile_errno; @@ -448,12 +448,12 @@ eval_makefile (const char *filename, int flags) } void -eval_buffer (char *buffer, const gmk_floc *floc) +eval_buffer (char *buffer, const floc *flocp) { struct ebuffer ebuf; struct conditionals *saved; struct conditionals new; - const gmk_floc *curfile; + const floc *curfile; /* Evaluate the buffer */ @@ -461,8 +461,8 @@ eval_buffer (char *buffer, const gmk_floc *floc) ebuf.buffer = ebuf.bufnext = ebuf.bufstart = buffer; ebuf.fp = NULL; - if (floc) - ebuf.floc = *floc; + if (flocp) + ebuf.floc = *flocp; else if (reading_file) ebuf.floc = *reading_file; else @@ -583,8 +583,8 @@ eval (struct ebuffer *ebuf, int set_default) char prefix = cmd_prefix; const char *pattern = 0; const char *pattern_percent; - gmk_floc *fstart; - gmk_floc fi; + floc *fstart; + floc fi; #define record_waiting_files() \ do \ @@ -1444,7 +1444,7 @@ do_define (char *name, enum variable_origin origin, struct ebuffer *ebuf) { struct variable *v; struct variable var; - gmk_floc defstart; + floc defstart; int nlevels = 1; unsigned int length = 100; char *definition = xmalloc (length); @@ -1560,7 +1560,7 @@ do_define (char *name, enum variable_origin origin, struct ebuffer *ebuf) 1 if following text should be ignored. */ static int -conditional_line (char *line, int len, const gmk_floc *flocp) +conditional_line (char *line, int len, const floc *flocp) { const char *cmdname; enum { c_ifdef, c_ifndef, c_ifeq, c_ifneq, c_else, c_endif } cmdtype; @@ -1831,7 +1831,7 @@ conditional_line (char *line, int len, const gmk_floc *flocp) static void record_target_var (struct nameseq *filenames, char *defn, enum variable_origin origin, struct vmodifiers *vmod, - const gmk_floc *flocp) + const floc *flocp) { struct nameseq *nextf; struct variable_set_list *global; @@ -1935,7 +1935,7 @@ record_files (struct nameseq *filenames, const char *pattern, const char *pattern_percent, char *depstr, unsigned int cmds_started, char *commands, unsigned int commands_idx, int two_colon, - char prefix, const gmk_floc *flocp) + char prefix, const floc *flocp) { struct commands *cmds; struct dep *deps; diff --git a/variable.c b/variable.c index 26baabd4..36ab1f45 100644 --- a/variable.c +++ b/variable.c @@ -196,7 +196,7 @@ struct variable * define_variable_in_set (const char *name, unsigned int length, const char *value, enum variable_origin origin, int recursive, struct variable_set *set, - const gmk_floc *flocp) + const floc *flocp) { struct variable *v; struct variable **var_slot; @@ -1157,7 +1157,7 @@ shell_result (const char *p) See the try_variable_definition() function for details on the parameters. */ struct variable * -do_variable_definition (const gmk_floc *flocp, const char *varname, +do_variable_definition (const floc *flocp, const char *varname, const char *value, enum variable_origin origin, enum variable_flavor flavor, int target_var) { @@ -1592,7 +1592,7 @@ assign_variable_definition (struct variable *v, const char *line) returned. */ struct variable * -try_variable_definition (const gmk_floc *flocp, const char *line, +try_variable_definition (const floc *flocp, const char *line, enum variable_origin origin, int target_var) { struct variable v; diff --git a/variable.h b/variable.h index 583a65f4..fe1d609d 100644 --- a/variable.h +++ b/variable.h @@ -51,7 +51,7 @@ struct variable { char *name; /* Variable name. */ char *value; /* Variable value. */ - gmk_floc fileinfo; /* Where the variable was defined. */ + floc fileinfo; /* Where the variable was defined. */ int length; /* strlen (name) */ unsigned int recursive:1; /* Gets recursively re-evaluated. */ unsigned int append:1; /* Nonzero if an appending target-specific @@ -152,7 +152,7 @@ void print_file_variables (const struct file *file); void print_target_variables (const struct file *file); void merge_variable_set_lists (struct variable_set_list **to_list, struct variable_set_list *from_list); -struct variable *do_variable_definition (const gmk_floc *flocp, +struct variable *do_variable_definition (const floc *flocp, const char *name, const char *value, enum variable_origin origin, enum variable_flavor flavor, @@ -160,12 +160,12 @@ struct variable *do_variable_definition (const gmk_floc *flocp, char *parse_variable_definition (const char *line, struct variable *v); struct variable *assign_variable_definition (struct variable *v, const char *line); -struct variable *try_variable_definition (const gmk_floc *flocp, const char *line, +struct variable *try_variable_definition (const floc *flocp, const char *line, enum variable_origin origin, int target_var); void init_hash_global_variable_set (void); void hash_init_function_table (void); -void define_new_function(const gmk_floc *flocp, const char *name, +void define_new_function(const floc *flocp, const char *name, unsigned int min, unsigned int max, unsigned int flags, gmk_func_ptr func); struct variable *lookup_variable (const char *name, unsigned int length); @@ -177,7 +177,7 @@ struct variable *define_variable_in_set (const char *name, unsigned int length, enum variable_origin origin, int recursive, struct variable_set *set, - const gmk_floc *flocp); + const floc *flocp); /* Define a variable in the current variable set. */