* Convert integer types to size_t where necessary.
* Align other integral types to avoid casts and type warnings.
#ifdef VMS
char *suffix;
#endif
- unsigned int size;
+ size_t size;
struct nameseq *chain;
unsigned int n;
};
Return a malloc'd chain of matching elements (or nil if none). */
struct nameseq *
-ar_glob (const char *arname, const char *member_pattern, unsigned int size)
+ar_glob (const char *arname, const char *member_pattern, size_t size)
{
struct ar_glob_state state;
struct nameseq *n;
if (ar_name (file->name))
{
- unsigned int len;
+ size_t len;
const char *cp;
char *p;
any suffix in the .SUFFIXES list stripped off for
explicit rules. We store this in the 'stem' member. */
const char *name;
- unsigned int len;
+ size_t len;
#ifndef NO_ARCHIVES
if (ar_name (file->name))
for (d = enter_file (strcache_add (".SUFFIXES"))->deps; d ; d = d->next)
{
- unsigned int slen = strlen (dep_name (d));
+ size_t slen = strlen (dep_name (d));
if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
{
file->stem = strcache_add_len (name, len - slen);
{
static char *plus_value=0, *bar_value=0, *qmark_value=0;
- static unsigned int plus_max=0, bar_max=0, qmark_max=0;
+ static size_t plus_max=0, bar_max=0, qmark_max=0;
- unsigned int qmark_len, plus_len, bar_len;
+ size_t qmark_len, plus_len, bar_len;
char *cp;
char *caret_value;
char *qp;
char *bp;
- unsigned int len;
+ size_t len;
struct hash_table dep_hash;
void **slot;
void
chop_commands (struct commands *cmds)
{
- unsigned int nlines, idx;
+ unsigned int nlines;
+ unsigned short idx;
char **lines;
/* If we don't have any commands,
if (one_shell)
{
- int l = strlen (cmds->commands);
+ size_t l = strlen (cmds->commands);
nlines = 1;
lines = xmalloc (nlines * sizeof (char *));
nlines += 2;
lines = xrealloc (lines, nlines * sizeof (char *));
}
- lines[idx++] = xstrndup (p, end - p);
+ lines[idx++] = xstrndup (p, (size_t) (end - p));
p = end;
if (*p != '\0')
++p;
if (nlines > USHRT_MAX)
ON (fatal, &cmds->fileinfo, _("Recipe has too many lines (%ud)"), nlines);
- cmds->ncommand_lines = nlines;
+ cmds->ncommand_lines = (unsigned short)nlines;
cmds->command_lines = lines;
cmds->any_recurse = 0;
struct goaldep
{
DEP (struct goaldep);
- unsigned short error;
+ int error;
floc floc;
};
#ifdef VMS
void *parse_file_seq ();
#else
-void *parse_file_seq (char **stringp, unsigned int size,
+void *parse_file_seq (char **stringp, size_t size,
int stopmap, const char *prefix, int flags);
#endif
char *tilde_expand (const char *name);
#ifndef NO_ARCHIVES
-struct nameseq *ar_glob (const char *arname, const char *member_pattern, unsigned int size);
+struct nameseq *ar_glob (const char *arname, const char *member_pattern, size_t size);
#endif
#define dep_name(d) ((d)->name ? (d)->name : (d)->file->name)
{
const struct dirfile *x = xv;
const struct dirfile *y = yv;
- int result = x->length - y->length;
+ int result = (int) (x->length - y->length);
if (result)
return result;
return_ISTRING_COMPARE (x->name, y->name);
while (1)
{
/* Enter the file in the hash table. */
- unsigned int len;
+ size_t len;
struct dirfile dirfile_key;
struct dirfile **dirfile_slot;
read_dirstream (__ptr_t stream)
{
static char *buf;
- static unsigned int bufsz;
+ static size_t bufsz;
struct dirstream *const ds = (struct dirstream *) stream;
struct directory_contents *dc = ds->contents;
{
/* The glob interface wants a 'struct dirent', so mock one up. */
struct dirent *d;
- unsigned int len = df->length + 1;
- unsigned int sz = sizeof (*d) - sizeof (d->d_name) + len;
+ size_t len = df->length + 1;
+ size_t sz = sizeof (*d) - sizeof (d->d_name) + len;
if (sz > bufsz)
{
bufsz *= 2;
#define VARIABLE_BUFFER_ZONE 5
-static unsigned int variable_buffer_length;
+static size_t variable_buffer_length;
char *variable_buffer;
/* Subroutine of variable_expand and friends:
the following call. */
char *
-variable_buffer_output (char *ptr, const char *string, unsigned int length)
+variable_buffer_output (char *ptr, const char *string, size_t length)
{
- unsigned int newlen = length + (ptr - variable_buffer);
+ size_t newlen = length + (ptr - variable_buffer);
if ((newlen + VARIABLE_BUFFER_ZONE) > variable_buffer_length)
{
- unsigned int offset = ptr - variable_buffer;
+ size_t offset = ptr - variable_buffer;
variable_buffer_length = (newlen + 100 > 2 * variable_buffer_length
? newlen + 100
: 2 * variable_buffer_length);
__inline
#endif
static char *
-reference_variable (char *o, const char *name, unsigned int length)
+reference_variable (char *o, const char *name, size_t length)
{
struct variable *v;
char *value;
NULL.
*/
char *
-variable_expand_string (char *line, const char *string, long length)
+variable_expand_string (char *line, const char *string, size_t length)
{
struct variable *v;
const char *p, *p1;
char *save;
char *o;
- unsigned int line_offset;
+ size_t line_offset;
if (!line)
line = initialize_variable_output ();
/* We need a copy of STRING: due to eval, it's possible that it will get
freed as we process it (it might be the value of a variable that's reset
for example). Also having a nil-terminated string is handy. */
- save = length < 0 ? xstrdup (string) : xstrndup (string, length);
+ save = length == SIZE_MAX ? xstrdup (string) : xstrndup (string, length);
p = save;
while (1)
p1 = strchr (p, '$');
- o = variable_buffer_output (o, p, p1 != 0 ? (unsigned int)(p1 - p) : strlen (p) + 1);
+ o = variable_buffer_output (o, p, p1 != 0 ? (size_t) (p1 - p) : strlen (p) + 1);
if (p1 == 0)
break;
char *
variable_expand (const char *line)
{
- return variable_expand_string (NULL, line, (long)-1);
+ return variable_expand_string (NULL, line, SIZE_MAX);
}
\f
/* Expand an argument for an expansion function.
any upper variable sets. Then expand the resulting value. */
static char *
-variable_append (const char *name, unsigned int length,
+variable_append (const char *name, size_t length,
const struct variable_set_list *set, int local)
{
const struct variable *v;
/* Construct the appended variable value. */
char *obuf = variable_buffer;
- unsigned int olen = variable_buffer_length;
+ size_t olen = variable_buffer_length;
variable_buffer = 0;
char *value;
char *obuf = variable_buffer;
- unsigned int olen = variable_buffer_length;
+ size_t olen = variable_buffer_length;
variable_buffer = 0;
safe-keeping. */
void
-install_variable_buffer (char **bufp, unsigned int *lenp)
+install_variable_buffer (char **bufp, size_t *lenp)
{
*bufp = variable_buffer;
*lenp = variable_buffer_length;
*/
void
-restore_variable_buffer (char *buf, unsigned int len)
+restore_variable_buffer (char *buf, size_t len)
{
free (variable_buffer);
while (dp != 0)
{
char *percent;
- int nl = strlen (dp->name) + 1;
+ size_t nl = strlen (dp->name) + 1;
char *nm = alloca (nl);
memcpy (nm, dp->name, nl);
percent = find_percent (nm);
if (files.ht_fill != last_targ_count)
{
- unsigned long max = EXPANSION_INCREMENT (strlen (value));
- unsigned long len;
+ size_t max = EXPANSION_INCREMENT (strlen (value));
+ size_t len;
char *p;
struct file **fp = (struct file **) files.ht_vec;
struct file **end = &fp[files.ht_size];
if (!HASH_VACANT (*fp) && (*fp)->is_target)
{
struct file *f = *fp;
- int l = strlen (f->name);
+ size_t l = strlen (f->name);
len += l + 1;
if (len > max)
{
- unsigned long off = p - value;
+ size_t off = p - value;
max += EXPANSION_INCREMENT (l + 1);
value = xrealloc (value, max);
char *
subst_expand (char *o, const char *text, const char *subst, const char *replace,
- unsigned int slen, unsigned int rlen, int by_word)
+ size_t slen, size_t rlen, int by_word)
{
const char *t = text;
const char *p;
const char *pattern, const char *replace,
const char *pattern_percent, const char *replace_percent)
{
- unsigned int pattern_prepercent_len, pattern_postpercent_len;
- unsigned int replace_prepercent_len, replace_postpercent_len;
+ size_t pattern_prepercent_len, pattern_postpercent_len;
+ size_t replace_prepercent_len, replace_postpercent_len;
const char *t;
- unsigned int len;
+ size_t len;
int doneany = 0;
/* Record the length of REPLACE before and after the % so we don't have to
return NULL;
function_table_entry_key.name = s;
- function_table_entry_key.len = e - s;
+ function_table_entry_key.len = (unsigned char) (e - s);
return hash_find_item (&function_table, &function_table_entry_key);
}
int
pattern_matches (const char *pattern, const char *percent, const char *str)
{
- unsigned int sfxlen, strlength;
+ size_t sfxlen, strlength;
if (percent == 0)
{
- unsigned int len = strlen (pattern) + 1;
+ size_t len = strlen (pattern) + 1;
char *new_chars = alloca (len);
memcpy (new_chars, pattern, len);
percent = find_percent (new_chars);
string_glob (char *line)
{
static char *result = 0;
- static unsigned int length;
+ static size_t length;
struct nameseq *chain;
- unsigned int idx;
+ size_t idx;
chain = PARSE_FILE_SEQ (&line, struct nameseq, MAP_NUL, NULL,
/* We do not want parse_file_seq to strip './'s.
while (chain != 0)
{
struct nameseq *next = chain->next;
- unsigned int len = strlen (chain->name);
+ size_t len = strlen (chain->name);
if (idx + len + 1 > length)
{
const char *list2_iterator = argv[1];
do
{
- unsigned int len1, len2;
+ size_t len1, len2;
tp = find_next_token (&list1_iterator, &len1);
if (tp != 0)
const char *list_iterator = argv[0];
const char *p2;
int doneany =0;
- unsigned int len=0;
+ size_t len=0;
int is_suffix = funcname[0] == 's';
int is_notdir = !is_suffix;
const char *p3 = argv[0];
const char *p2;
int doneany = 0;
- unsigned int len = 0;
+ size_t len = 0;
int is_basename = funcname[0] == 'b';
int is_dir = !is_basename;
static char *
func_addsuffix_addprefix (char *o, char **argv, const char *funcname)
{
- int fixlen = strlen (argv[0]);
+ size_t fixlen = strlen (argv[0]);
const char *list_iterator = argv[1];
int is_addprefix = funcname[3] == 'p';
int is_addsuffix = !is_addprefix;
int doneany = 0;
const char *p;
- unsigned int len;
+ size_t len;
while ((p = find_next_token (&list_iterator, &len)) != 0)
{
static char *
func_firstword (char *o, char **argv, const char *funcname UNUSED)
{
- unsigned int i;
+ size_t i;
const char *words = argv[0]; /* Use a temp variable for find_next_token */
const char *p = find_next_token (&words, &i);
static char *
func_lastword (char *o, char **argv, const char *funcname UNUSED)
{
- unsigned int i;
+ size_t i;
const char *words = argv[0]; /* Use a temp variable for find_next_token */
const char *p = NULL;
const char *t;
- while ((t = find_next_token (&words, &i)))
+ while ((t = find_next_token (&words, &i)) != NULL)
p = t;
if (p != 0)
int doneany = 0;
const char *list_iterator = list;
const char *p;
- unsigned int len;
+ size_t len;
struct variable *var;
/* Clean up the variable name by removing whitespace. */
struct a_word *next;
struct a_word *chain;
char *str;
- int length;
+ size_t length;
int matched;
};
static int
a_word_hash_cmp (const void *x, const void *y)
{
- int result = ((struct a_word const *) x)->length - ((struct a_word const *) y)->length;
+ int result = (int) ((struct a_word const *) x)->length - ((struct a_word const *) y)->length;
if (result)
return result;
return_STRING_COMPARE (((struct a_word const *) x)->str,
struct a_pattern *next;
char *str;
char *percent;
- int length;
+ size_t length;
};
static char *
int words = 0;
int hashing = 0;
char *p;
- unsigned int len;
+ size_t len;
/* Chop ARGV[0] up into patterns to match against the words.
We don't need to preserve it because our caller frees all the
{
char **argvp;
char *msg, *p;
- int len;
+ size_t len;
/* The arguments will be broken on commas. Rather than create yet
another special case where function arguments aren't broken up,
char **words;
int wordi;
char *p;
- unsigned int len;
+ size_t len;
/* Find the maximum number of words we'll have. */
t = argv[0];
const char *begp = *argv;
const char *endp = begp + strlen (*argv) - 1;
char *expansion;
- int result = 0;
+ size_t result = 0;
/* Find the result of the condition: if it's false keep going. */
{
const char *begp = *argv;
const char *endp = begp + strlen (*argv) - 1;
- int result;
+ size_t result;
/* An empty condition is always false. */
strip_whitespace (&begp, &endp);
func_eval (char *o, char **argv, const char *funcname UNUSED)
{
char *buf;
- unsigned int len;
+ size_t len;
/* Eval the buffer. Pop the current variable buffer setting so that the
eval'd code can use its own without conflicting. */
\r is replaced on UNIX as well. Is this desirable?
*/
static void
-fold_newlines (char *buffer, unsigned int *length, int trim_newlines)
+fold_newlines (char *buffer, size_t *length, int trim_newlines)
{
char *dst = buffer;
char *src = buffer;
{
char *buffer;
- unsigned int maxlen, i;
+ size_t maxlen, i;
int cc;
/* Record the PID for reap_children. */
BPTR child_stdout;
char tmp_output[FILENAME_MAX];
- unsigned int maxlen = 200, i;
+ size_t maxlen = 200, i;
int cc;
char * buffer, * ptr;
char ** aptr;
- int len = 0;
+ size_t len = 0;
char* batch_filename = NULL;
/* Construct the argument list. */
for (start = end = name; *start != '\0'; start = end)
{
- unsigned long len;
+ size_t len;
/* Skip sequence of multiple path-separators. */
while (STOP_SET (*start, MAP_DIRSEP))
const char *p = argv[0];
const char *path = 0;
int doneany = 0;
- unsigned int len = 0;
+ size_t len = 0;
while ((path = find_next_token (&p, &len)) != 0)
{
if (argv[1])
{
- int l = strlen (argv[1]);
+ size_t l = strlen (argv[1]);
int nl = l == 0 || argv[1][l-1] != '\n';
if (fputs (argv[1], fp) == EOF || (nl && fputc ('\n', fp) == EOF))
const char *p = argv[0];
const char *path = 0;
int doneany = 0;
- unsigned int len = 0;
+ size_t len = 0;
while ((path = find_next_token (&p, &len)) != 0)
{
++nargs;
if (nargs == entry_p->maximum_args
- || (! (next = find_next_argument (openparen, closeparen, p, end))))
+ || ((next = find_next_argument (openparen, closeparen, p, end)) == NULL))
next = end;
*argvp = expand_argument (p, next);
}
else
{
- int len = end - beg;
+ size_t len = end - beg;
char *p, *aend;
abeg = xmalloc (len+1);
++nargs;
if (nargs == entry_p->maximum_args
- || (! (next = find_next_argument (openparen, closeparen, p, aend))))
+ || ((next = find_next_argument (openparen, closeparen, p, aend)) == NULL))
next = aend;
*argvp = p;
static int max_args = 0;
char *fname;
char *body;
- int flen;
+ size_t flen;
int i;
int saved_args;
const struct function_table_entry *entry_p;
ent = xmalloc (sizeof (struct function_table_entry));
ent->name = name;
- ent->len = len;
- ent->minimum_args = min;
- ent->maximum_args = max;
+ ent->len = (unsigned char) len;
+ ent->minimum_args = (unsigned char) min;
+ ent->maximum_args = (unsigned char) max;
ent->expand_args = ANY_SET(flags, GMK_FUNC_NOEXPAND) ? 0 : 1;
ent->alloc_fn = 1;
ent->fptr.alloc_func_ptr = func;
#include "makeint.h"
#include "hash.h"
-#define CALLOC(t, n) ((t *) xcalloc (sizeof (t) * (n)))
+#define CALLOC(t, n) ((t *) xcalloc (sizeof (t) * (n)))
#define MALLOC(t, n) ((t *) xmalloc (sizeof (t) * (n)))
#define REALLOC(o, t, n) ((t *) xrealloc ((o), sizeof (t) * (n)))
#define CLONE(o, t, n) ((t *) memcpy (MALLOC (t, (n)), (o), sizeof (t) * (n)))
}
jhash_final(a, b, c);
- return c + (k - start);
+ return c + (unsigned) (k - start);
}
length of the word. */
static const char *
-get_next_word (const char *buffer, unsigned int *length)
+get_next_word (const char *buffer, size_t *length)
{
const char *p = buffer, *beg;
char c;
{
struct rule *rule;
+ /* Stem length for this match. */
+ size_t stemlen;
+
/* Index of the target in this rule that matched the file. */
unsigned int matches;
- /* Stem length for this match. */
- unsigned int stemlen;
-
/* Definition order of this rule. Used to implement stable sort.*/
unsigned int order;
{
const struct tryrule *r1 = v1;
const struct tryrule *r2 = v2;
- int r = r1->stemlen - r2->stemlen;
- return r != 0 ? r : (int)(r1->order - r2->order);
+ int r = (int) (r1->stemlen - r2->stemlen);
+ return r != 0 ? r : (int) (r1->order - r2->order);
}
/* Search the pattern rules for a rule with an existing dependency to make
const char *filename = archive ? strchr (file->name, '(') : file->name;
/* Length of FILENAME. */
- unsigned int namelen = strlen (filename);
+ size_t namelen = strlen (filename);
/* The last slash in FILENAME (or nil if there is none). */
const char *lastslash;
/* The start and length of the stem of FILENAME for the current rule. */
const char *stem = 0;
- unsigned int stemlen = 0;
- unsigned int fullstemlen = 0;
+ size_t stemlen = 0;
+ size_t fullstemlen = 0;
/* Buffer in which we store all the rules that are possibly applicable. */
struct tryrule *tryrules = xmalloc (num_pattern_rules * max_pattern_targets
struct rule *rule;
char *pathdir = NULL;
- unsigned long pathlen;
+ size_t pathlen;
PATH_VAR (stem_str); /* @@ Need to get rid of stem, stemlen, etc. */
else
{
int add_dir = 0;
- unsigned int len;
+ size_t len;
struct dep **dptr;
nptr = get_next_word (nptr, &len);
}
else
{
- unsigned int i = p - nptr;
+ size_t i = p - nptr;
memcpy (depname, nptr, i);
memcpy (depname + i, "$*", 2);
memcpy (depname + i + 2, p + 1, len - i - 1);
if (deps_found > max_deps)
{
- unsigned int l = pat - deplist;
+ size_t l = pat - deplist;
/* This might have changed due to recursion. */
max_pattern_deps = MAX(max_pattern_deps, deps_found);
max_deps = max_pattern_deps;
}
else
{
- int dirlen = (lastslash + 1) - filename;
+ size_t dirlen = (lastslash + 1) - filename;
char *sp;
/* We want to prepend the directory from
/* Default shell to use. */
#ifdef WINDOWS32
-#ifdef HAVE_STRINGS_H
-#include <strings.h> /* for strcasecmp, strncasecmp */
-#endif
-#include <windows.h>
+# ifdef HAVE_STRINGS_H
+# include <strings.h> /* for strcasecmp, strncasecmp */
+# endif
+# include <windows.h>
const char *default_shell = "sh.exe";
int no_default_sh_exe = 1;
launches the next one. */
static unsigned uniq = 0;
static int second_loop = 0;
- const unsigned sizemax = strlen (base) + strlen (ext) + 10;
+ const size_t sizemax = strlen (base) + strlen (ext) + 10;
if (path_size == 0)
{
for (s = unix_shells; *s != NULL; ++s)
{
#if defined(WINDOWS32) || defined(__MSDOS__)
- unsigned int len = strlen (*s);
+ size_t len = strlen (*s);
if ((strlen (name) >= len && STOP_SET (name[len], MAP_DOT|MAP_NUL))
&& strncasecmp (name, *s, len) == 0)
#else
static const char *sh_chars_sh = "#;\"*?[]&|<>(){}$`^~!";
# endif /* HAVE_DOS_PATHS */
#endif
- int i;
+ size_t i;
char *p;
#ifndef NDEBUG
char *end;
argument list. */
char *new_line;
- unsigned int shell_len = strlen (shell);
- unsigned int line_len = strlen (line);
- unsigned int sflags_len = shellflags ? strlen (shellflags) : 0;
+ size_t shell_len = strlen (shell);
+ size_t line_len = strlen (line);
+ size_t sflags_len = shellflags ? strlen (shellflags) : 0;
#ifdef WINDOWS32
char *command_ptr = NULL; /* used for batch_mode_shell mode */
#endif
{
const char *s = shellflags;
char *t;
- unsigned int len;
+ size_t len;
while ((t = find_next_token (&s, &len)) != 0)
new_argv[n++] = xstrndup (t, len);
}
int
load_file (const floc *flocp, const char **ldname, int noerror)
{
- int nmlen = strlen (*ldname);
+ size_t nmlen = strlen (*ldname);
char *new = alloca (nmlen + CSTRLEN (SYMBOL_EXTENSION) + 1);
char *symname = NULL;
char *loaded;
ep = strchr (fp+1, ')');
if (ep && ep[1] == '\0')
{
- int l = fp - *ldname;;
+ size_t l = fp - *ldname;;
++fp;
if (fp == ep)
{
/* Preserve existing variable buffer context. */
char *pbuf;
- unsigned int plen;
+ size_t plen;
char *s;
floc fl;
floc *flp;
static void print_data_base (void);
static void print_version (void);
static void decode_switches (int argc, const char **argv, int env);
-static void decode_env_switches (const char *envar, unsigned int len);
+static void decode_env_switches (const char *envar, size_t len);
static struct variable *define_makeflags (int all, int makefile);
static char *quote_for_env (char *out, const char *in);
static void initialize_global_hash_tables (void);
const char *ep = envp[i];
/* By default, export all variables culled from the environment. */
enum variable_export export = v_export;
- unsigned int len;
+ size_t len;
while (! STOP_SET (*ep, MAP_EQUALS))
++ep;
{
struct command_variable *cv;
struct variable *v;
- unsigned int len = 0;
+ size_t len = 0;
char *value, *p;
/* Figure out how much space will be taken up by the command-line
while (!feof (stdin) && ! ferror (stdin))
{
char buf[2048];
- unsigned int n = fread (buf, 1, sizeof (buf), stdin);
+ size_t n = fread (buf, 1, sizeof (buf), stdin);
if (n > 0 && fwrite (buf, 1, n, outfile) != n)
pfatal_with_name (_("fwrite (temporary file)"));
}
{
char *p, *value;
unsigned int i;
- unsigned int len = (CSTRLEN ("--eval=") + 1) * eval_strings->idx;
+ size_t len = (CSTRLEN ("--eval=") + 1) * eval_strings->idx;
for (i = 0; i < eval_strings->idx; ++i)
{
long_options[i].flag = 0;
long_options[i].val = switches[i].c;
if (short_option (switches[i].c))
- *p++ = switches[i].c;
+ *p++ = (char) switches[i].c;
switch (switches[i].type)
{
case flag:
else
{
/* Paste the old and new values together */
- unsigned int oldlen, newlen;
+ size_t oldlen, newlen;
char *vp;
oldlen = strlen (gv->value);
const char *op = opt;
if (short_option (cs->c))
- opt[0] = cs->c;
+ opt[0] = (char) cs->c;
else
op = cs->long_name;
decode_switches. */
static void
-decode_env_switches (const char *envar, unsigned int len)
+decode_env_switches (const char *envar, size_t len)
{
char *varref = alloca (2 + len + 2);
char *value, *p, *buf;
};
struct flag *flags = 0;
struct flag *last = 0;
- unsigned int flagslen = 0;
+ size_t flagslen = 0;
#define ADD_FLAG(ARG, LEN) \
do { \
struct flag *new = alloca (sizeof (struct flag)); \
/* Add simple options as a group. */
while (flags != 0 && !flags->arg && short_option (flags->cs->c))
{
- *p++ = flags->cs->c;
+ *p++ = (char) flags->cs->c;
flags = flags->next;
}
/* Add the flag letter or name to the string. */
if (short_option (flags->cs->c))
- *p++ = flags->cs->c;
+ *p++ = (char) flags->cs->c;
else
{
/* Long options require a double-dash. */
void pfatal_with_name (const char *) __attribute__ ((noreturn));
void perror_with_name (const char *, const char *);
#define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s))
-void *xmalloc (unsigned int);
-void *xcalloc (unsigned int);
-void *xrealloc (void *, unsigned int);
+void *xmalloc (size_t);
+void *xcalloc (size_t);
+void *xrealloc (void *, size_t);
char *xstrdup (const char *);
-char *xstrndup (const char *, unsigned int);
-char *find_next_token (const char **, unsigned int *);
+char *xstrndup (const char *, size_t);
+char *find_next_token (const char **, size_t *);
char *next_token (const char *);
char *end_of_token (const char *);
void collapse_continuations (char *);
void construct_vpath_list (char *pattern, char *dirpath);
const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr,
unsigned int* vpath_index, unsigned int* path_index);
-int gpath_search (const char *file, unsigned int len);
+int gpath_search (const char *file, size_t len);
void construct_include_path (const char **arg_dirs);
void strcache_print_stats (const char *prefix);
int strcache_iscached (const char *str);
const char *strcache_add (const char *str);
-const char *strcache_add_len (const char *str, unsigned int len);
+const char *strcache_add_len (const char *str, size_t len);
/* Guile support */
int guile_gmake_setup (const floc *flocp);
int remote_status (int *, int *, int *, int);
void block_remote_children (void);
void unblock_remote_children (void);
-int remote_kill (int id, int sig);
+int remote_kill (pid_t id, int sig);
void print_variable_data_base (void);
void print_vpath_data_base (void);
{
char *p = q;
int i;
- int out_line_length;
+ size_t out_line_length;
if (q > line && q[-1] == '\\')
{
const char *
concat (unsigned int num, ...)
{
- static unsigned int rlen = 0;
+ static size_t rlen = 0;
static char *result = NULL;
- unsigned int ri = 0;
+ size_t ri = 0;
va_list args;
va_start (args, num);
while (num-- > 0)
{
const char *s = va_arg (args, const char *);
- unsigned int l = xstrlen (s);
+ size_t l = xstrlen (s);
if (l == 0)
continue;
#undef xstrdup
void *
-xmalloc (unsigned int size)
+xmalloc (size_t size)
{
/* Make sure we don't allocate 0, for pre-ISO implementations. */
void *result = malloc (size ? size : 1);
void *
-xcalloc (unsigned int size)
+xcalloc (size_t size)
{
/* Make sure we don't allocate 0, for pre-ISO implementations. */
void *result = calloc (size ? size : 1, 1);
void *
-xrealloc (void *ptr, unsigned int size)
+xrealloc (void *ptr, size_t size)
{
void *result;
#endif /* HAVE_DMALLOC_H */
char *
-xstrndup (const char *str, unsigned int length)
+xstrndup (const char *str, size_t length)
{
char *result;
of the token, so this function can be called repeatedly in a loop. */
char *
-find_next_token (const char **ptr, unsigned int *lengthptr)
+find_next_token (const char **ptr, size_t *lengthptr)
{
const char *p = next_token (*ptr);
else
{
int fd = is_err ? out->err : out->out;
- int len = strlen (msg);
+ size_t len = strlen (msg);
int r;
EINTRLOOP (r, lseek (fd, 0, SEEK_END));
output_write (fd, msg, len);
log_working_directory (int entering)
{
static char *buf = NULL;
- static unsigned int len = 0;
- unsigned int need;
+ static size_t len = 0;
+ size_t need;
const char *fmt;
char *p;
char *buffer; /* Start of the current line in the buffer. */
char *bufnext; /* Start of the next line in the buffer. */
char *bufstart; /* Start of the entire buffer. */
- unsigned int size; /* Malloc'd size of buffer. */
+ size_t size; /* Malloc'd size of buffer. */
FILE *fp; /* File, or NULL if this is an internal buffer. */
floc floc; /* Info on the file in fp (if any). */
};
/* Maximum length of an element of the above. */
-static unsigned int max_incl_len;
+static size_t max_incl_len;
/* The filename and pointer to line number of the
makefile currently being read in. */
static struct goaldep *read_files = 0;
-static struct goaldep *eval_makefile (const char *filename, int flags);
+static struct goaldep *eval_makefile (const char *filename, unsigned short flags);
static void eval (struct ebuffer *buffer, int flags);
static long readline (struct ebuffer *ebuf);
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 floc *flocp);
+static int conditional_line (char *line, size_t 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,
+ size_t commands_idx, int two_colon,
char prefix, const floc *flocp);
static void record_target_var (struct nameseq *filenames, char *defn,
enum variable_origin origin,
struct vmodifiers *vmod,
const floc *flocp);
static enum make_word_type get_next_mword (char *buffer, char *delim,
- char **startp, unsigned int *length);
+ char **startp, size_t *length);
static void remove_comments (char *line);
static char *find_map_unquote (char *string, int map);
static char *find_char_unquote (char *string, int stop);
{
char *value;
char *name, *p;
- unsigned int length;
+ size_t length;
{
/* Turn off --warn-undefined-variables while we expand MAKEFILES. */
}
\f
static struct goaldep *
-eval_makefile (const char *filename, int flags)
+eval_makefile (const char *filename, unsigned short flags)
{
struct goaldep *deps;
struct ebuffer ebuf;
/* Find the start of the next token. If there isn't one we're done. */
NEXT_TOKEN (line);
if (*line == '\0')
- return (char *)line;
+ return (char *) line;
p = line;
while (1)
{
- int wlen;
+ size_t wlen;
const char *p2;
struct variable v;
}
else
/* Not a variable or modifier: this is not a variable assignment. */
- return (char *)line;
+ return (char *) line;
/* It was a modifier. Try the next word. */
p = next_token (p2);
if (*p == '\0')
- return (char *)line;
+ return (char *) line;
}
/* Found a variable assignment or undefine. */
eval (struct ebuffer *ebuf, int set_default)
{
char *collapsed = 0;
- unsigned int collapsed_length = 0;
- unsigned int commands_len = 200;
+ size_t collapsed_length = 0;
+ size_t commands_len = 200;
char *commands;
- unsigned int commands_idx = 0;
+ size_t commands_idx = 0;
unsigned int cmds_started, tgts_started;
int ignoring = 0, in_ignored_define = 0;
int no_targets = 0; /* Set when reading a rule without targets. */
while (1)
{
- unsigned int linelen;
+ size_t linelen;
char *line;
- unsigned int wlen;
+ size_t wlen;
char *p;
char *p2;
struct vmodifiers vmod;
line = ebuf->buffer;
/* If this is the first line, check for a UTF-8 BOM and skip it. */
- if (ebuf->floc.lineno == 1 && line[0] == (char)0xEF
- && line[1] == (char)0xBB && line[2] == (char)0xBF)
+ if (ebuf->floc.lineno == 1)
{
- line += 3;
- if (ISDB(DB_BASIC))
+ unsigned char *ul = (unsigned char *) line;
+ if (ul[0] == 0xEF && ul[1] == 0xBB && ul[2] == 0xBF)
{
- if (ebuf->floc.filenm)
- printf (_("Skipping UTF-8 BOM in makefile '%s'\n"),
- ebuf->floc.filenm);
- else
- printf (_("Skipping UTF-8 BOM in makefile buffer\n"));
+ line += 3;
+ if (ISDB(DB_BASIC))
+ {
+ if (ebuf->floc.filenm)
+ printf (_("Skipping UTF-8 BOM in makefile '%s'\n"),
+ ebuf->floc.filenm);
+ else
+ printf (_("Skipping UTF-8 BOM in makefile buffer\n"));
+ }
}
}
-
/* If this line is empty, skip it. */
if (line[0] == '\0')
continue;
export_all_variables = exporting;
else
{
- unsigned int l;
+ size_t l;
const char *cp;
char *ap;
{
const char *cp;
char *vpat;
- unsigned int l;
+ size_t l;
/* vpath ends the previous rule. */
record_waiting_files ();
while (files != 0)
{
struct nameseq *next = files->next;
- int flags = (RM_INCLUDED | RM_NO_TILDE
- | (noerror ? RM_DONTCARE : 0)
- | (set_default ? 0 : RM_NO_DEFAULT_GOAL));
+ unsigned short flags = (RM_INCLUDED | RM_NO_TILDE
+ | (noerror ? RM_DONTCARE : 0)
+ | (set_default ? 0 : RM_NO_DEFAULT_GOAL));
struct goaldep *d = eval_makefile (files->name, flags);
{
enum make_word_type wtype;
char *cmdleft, *semip, *lb_next;
- unsigned int plen = 0;
+ size_t plen = 0;
char *colonp;
const char *end, *beg; /* Helpers for whitespace stripping. */
if (cmdleft != 0)
{
- unsigned long p2_off = p2 - variable_buffer;
- unsigned long cmd_off = cmdleft - variable_buffer;
+ size_t p2_off = p2 - variable_buffer;
+ size_t cmd_off = cmdleft - variable_buffer;
char *pend = p2 + strlen (p2);
/* Append any remnants of lb, then cut the line short
entirely consistent, since we do an unconditional
expand below once we know we don't have a
target-specific variable. */
- (void)variable_expand_string (pend, lb_next, (long)-1);
+ variable_expand_string (pend, lb_next, SIZE_MAX);
lb_next += strlen (lb_next);
p2 = variable_buffer + p2_off;
cmdleft = variable_buffer + cmd_off + 1;
of the unparsed section of p2, for later. */
if (*lb_next != '\0')
{
- unsigned int l = p2 - variable_buffer;
+ size_t l = p2 - variable_buffer;
plen = strlen (p2);
variable_buffer_output (p2+plen, lb_next, strlen (lb_next)+1);
p2 = variable_buffer + l;
after it. */
if (semip)
{
- unsigned int l = p2 - variable_buffer;
+ size_t l = p2 - variable_buffer;
*(--semip) = ';';
collapse_continuations (semip);
variable_buffer_output (p2 + strlen (p2),
/* Expand the dependencies, etc. */
if (*lb_next != '\0')
{
- unsigned int l = p2 - variable_buffer;
- (void) variable_expand_string (p2 + plen, lb_next, (long)-1);
+ size_t l = p2 - variable_buffer;
+ variable_expand_string (p2 + plen, lb_next, SIZE_MAX);
p2 = variable_buffer + l;
/* Look for a semicolon in the expanded line. */
if (cmdleft != 0)
{
/* Semicolon means rest of line is a command. */
- unsigned int l = strlen (cmdleft);
+ size_t l = strlen (cmdleft);
cmds_started = fstart->lineno;
}
for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)
{
- unsigned int l = strlen (dep_name (d2));
+ size_t l = strlen (dep_name (d2));
if (!strneq (name, dep_name (d2), l))
continue;
if (streq (name + l, dep_name (d)))
struct variable var;
floc defstart;
int nlevels = 1;
- unsigned int length = 100;
+ size_t length = 100;
char *definition = xmalloc (length);
- unsigned int idx = 0;
+ size_t idx = 0;
char *p, *n;
defstart = ebuf->floc;
/* Now read the value of the variable. */
while (1)
{
- unsigned int len;
+ size_t len;
char *line;
long nlines = readline (ebuf);
1 if following text should be ignored. */
static int
-conditional_line (char *line, int len, const floc *flocp)
+conditional_line (char *line, size_t len, const floc *flocp)
{
const char *cmdname;
enum { c_ifdef, c_ifndef, c_ifeq, c_ifneq, c_else, c_endif } cmdtype;
if (cmdtype == c_ifdef || cmdtype == c_ifndef)
{
+ size_t l;
char *var;
struct variable *v;
char *p;
/* Make sure there's only one variable name to test. */
p = end_of_token (var);
- i = p - var;
+ l = p - var;
NEXT_TOKEN (p);
if (*p != '\0')
return -1;
- var[i] = '\0';
- v = lookup_variable (var, i);
+ var[l] = '\0';
+ v = lookup_variable (var, l);
conditionals->ignoring[o] =
((v != 0 && *v->value != '\0') == (cmdtype == c_ifndef));
{
/* "ifeq" or "ifneq". */
char *s1, *s2;
- unsigned int l;
+ size_t l;
char termin = *line == '(' ? ',' : *line;
if (termin != ',' && termin != '"' && termin != '\'')
if (v->origin != o_override)
{
struct variable *gv;
- int len = strlen (v->name);
+ size_t len = strlen (v->name);
gv = lookup_variable (v->name, len);
if (gv && v != gv
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,
+ size_t commands_idx, int two_colon,
char prefix, const floc *flocp)
{
struct commands *cmds;
{
struct nameseq *nextf;
const char **targets, **target_pats;
- unsigned int c;
+ unsigned short c;
if (pattern != 0)
O (fatal, flocp, _("mixed implicit and static pattern rules"));
static char *
find_map_unquote (char *string, int stopmap)
{
- unsigned int string_len = 0;
+ size_t string_len = 0;
char *p = string;
/* Always stop on NUL. */
static char *
find_char_unquote (char *string, int stop)
{
- unsigned int string_len = 0;
+ size_t string_len = 0;
char *p = string;
while (1)
if (*s == '\\')
{
char *e = s;
- int l;
+ size_t l;
/* We found a backslash. See if it's escaping our character. */
while (*e == '\\')
{
const char *p = *string;
char *new = 0;
- int slen = 0;
+ size_t slen = 0;
/* If the first char is a % return now. This lets us avoid extra tests
inside the loop. */
{
*string = strcache_add (*string);
if (p)
- p = *string + (p - new);
+ p = *string + (p - new);
}
/* If we didn't find a %, return NULL. Otherwise return a ptr to it. */
end = p + ebuf->size;
*p = '\0';
- while (fgets (p, (int)(end - p), ebuf->fp) != 0)
+ while (fgets (p, (int) (end - p), ebuf->fp) != 0)
{
char *p2;
- unsigned long len;
+ size_t len;
int backslash;
len = strlen (p);
Make sure to preserve the current offset of p. */
more_buffer:
{
- unsigned long off = p - start;
+ size_t off = p - start;
ebuf->size *= 2;
start = ebuf->buffer = ebuf->bufstart = xrealloc (start, ebuf->size);
p = start + off;
in a command list, etc.) */
static enum make_word_type
-get_next_mword (char *buffer, char *delim, char **startp, unsigned int *length)
+get_next_mword (char *buffer, char *delim, char **startp, size_t *length)
{
enum make_word_type wtype;
char *p = buffer, *beg;
#endif
const char **dirs;
const char **cpp;
- unsigned int idx;
+ size_t idx;
/* Compute the number of pointers we need in the table. */
idx = sizeof (default_include_directories) / sizeof (const char *);
EINTRLOOP (e, stat (dir, &stbuf));
if (e == 0 && S_ISDIR (stbuf.st_mode))
{
- unsigned int len = strlen (dir);
+ size_t len = strlen (dir);
/* If dir name is written with trailing slashes, discard them. */
while (len > 1 && dir[len - 1] == '/')
--len;
if (djdir)
{
- unsigned int len = strlen (djdir->value) + 8;
+ size_t len = strlen (djdir->value) + 8;
char *defdir = alloca (len + 1);
strcat (strcpy (defdir, djdir->value), "/include");
EINTRLOOP (e, stat (*cpp, &stbuf));
if (e == 0 && S_ISDIR (stbuf.st_mode))
{
- unsigned int len = strlen (*cpp);
+ size_t len = strlen (*cpp);
/* If dir name is written with trailing slashes, discard them. */
while (len > 1 && (*cpp)[len - 1] == '/')
--len;
*/
void *
-parse_file_seq (char **stringp, unsigned int size, int stopmap,
+parse_file_seq (char **stringp, size_t size, int stopmap,
const char *prefix, int flags)
{
/* tmp points to tmpbuf after the prefix, if any.
/* Get enough temporary space to construct the largest possible target. */
{
- static int tmpbuf_len = 0;
- int l = strlen (*stringp) + 1;
+ static size_t tmpbuf_len = 0;
+ size_t l = strlen (*stringp) + 1;
if (l > tmpbuf_len)
{
tmpbuf = xrealloc (tmpbuf, l);
char *memname = 0;
#endif
char *s;
- int nlen;
+ size_t nlen;
int i;
/* Skip whitespace; at the end of the string or STOPCHAR we're done. */
f_mtime (struct file *file, int search)
{
FILE_TIMESTAMP mtime;
- int propagate_timestamp;
+ unsigned int propagate_timestamp;
/* File's mtime is not known; must get it from the system. */
Change the archive-member reference accordingly. */
char *name;
- unsigned int arlen, memlen;
+ size_t arlen, memlen;
arlen = strlen (arfile->hname);
memlen = strlen (memname);
|| (file->name[0] == '-' && file->name[1] == 'l'
&& (name = library_search (file->name, &mtime)) != 0))
{
- int name_len;
+ size_t name_len;
if (mtime != UNKNOWN_MTIME)
/* vpath_search and library_search store UNKNOWN_MTIME
succeeds ONLY if "foo" is a directory. */
if (p > name)
{
- memcpy (tem, name, p - name + 1);
- tstart = tem;
- if (tstart[1] == ':')
- tstart += 2;
- tend = tem + (p - name - 1);
- if (*tend == '.' && tend > tstart)
- tend--;
- if (*tend == '.' && tend > tstart)
- tend--;
- for ( ; tend > tstart && (*tend == '/' || *tend == '\\'); tend--)
- *tend = '\0';
+ memcpy (tem, name, p - name + 1);
+ tstart = tem;
+ if (tstart[1] == ':')
+ tstart += 2;
+ tend = tem + (p - name - 1);
+ if (*tend == '.' && tend > tstart)
+ tend--;
+ if (*tend == '.' && tend > tstart)
+ tend--;
+ for ( ; tend > tstart && (*tend == '/' || *tend == '\\'); tend--)
+ *tend = '\0';
}
else
{
- tem[0] = '\0';
- tend = &tem[0];
+ tem[0] = '\0';
+ tend = &tem[0];
}
e = stat (tem, &st);
if (e == 0 && !_S_ISDIR (st.st_mode) && tend < tem + (p - name - 1))
{
- errno = ENOTDIR;
- e = -1;
+ errno = ENOTDIR;
+ e = -1;
}
}
#else
/* Loop variables for the libpatterns value. */
char *p;
const char *p2;
- unsigned int len;
- unsigned int liblen;
+ size_t len;
+ size_t liblen;
/* Information about the earliest (in the vpath sequence) match. */
unsigned int best_vpath = 0, best_path = 0;
while ((p = find_next_token (&p2, &len)) != 0)
{
static char *buf = NULL;
- static unsigned int buflen = 0;
- static int libdir_maxlen = -1;
+ static size_t buflen = 0;
+ static size_t libdir_maxlen = 0;
static unsigned int std_dirs = 0;
char *libbuf = variable_expand ("");
{
for (dp = dirs; *dp != 0; ++dp)
{
- int l = strlen (*dp);
+ size_t l = strlen (*dp);
if (l > libdir_maxlen)
libdir_maxlen = l;
std_dirs++;
/* Send signal SIG to child ID. Return 0 if successful, -1 if not. */
int
-remote_kill (int id, int sig)
+remote_kill (pid_t id, int sig)
{
return -1;
}
/* Send signal SIG to child ID. Return 0 if successful, -1 if not. */
int
-remote_kill (int id UNUSED, int sig UNUSED)
+remote_kill (pid_t id UNUSED, int sig UNUSED)
{
return -1;
}
/* Maximum length of the name of a dependencies of any pattern rule. */
-unsigned int max_pattern_dep_length;
+size_t max_pattern_dep_length;
/* Pointer to structure for the file .SUFFIXES
whose dependencies are the suffixes to be searched. */
/* Maximum length of a suffix. */
-unsigned int maxsuffix;
+static size_t maxsuffix;
\f
/* Compute the maximum dependency length and maximum number of
dependencies of all implicit rules. Also sets the subdir
count_implicit_rule_limits (void)
{
char *name;
- int namelen;
+ size_t namelen;
struct rule *rule;
num_pattern_rules = max_pattern_targets = max_pattern_deps = 0;
for (dep = rule->deps; dep != 0; dep = dep->next)
{
const char *dname = dep_name (dep);
- unsigned int len = strlen (dname);
+ size_t len = strlen (dname);
#ifdef VMS
const char *p = strrchr (dname, ']');
Extract the directory name. */
if (p == dname)
++p;
- if (p - dname > namelen)
+ if ((size_t) (p - dname) > namelen)
{
namelen = p - dname;
name = xrealloc (name, namelen + 1);
else
{
/* Construct the target name. */
- unsigned int len = strlen (target);
+ size_t len = strlen (target);
char *p = alloca (1 + len + 1);
p[0] = '%';
memcpy (p + 1, target, len + 1);
else
{
/* Construct the dependency name. */
- unsigned int len = strlen (source);
+ size_t len = strlen (source);
char *p = alloca (1 + len + 1);
p[0] = '%';
memcpy (p + 1, source, len + 1);
maxsuffix = 0;
for (d = suffix_file->deps; d != 0; d = d->next)
{
- unsigned int l = strlen (dep_name (d));
+ size_t l = strlen (dep_name (d));
if (l > maxsuffix)
maxsuffix = l;
}
for (d = suffix_file->deps; d != 0; d = d->next)
{
- unsigned int slen;
+ size_t slen;
/* Make a rule that is just the suffix, with no deps or commands.
This rule exists solely to disqualify match-anything rules. */
for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)
{
struct file *f;
- unsigned int s2len;
+ size_t s2len;
s2len = strlen (dep_name (d2));
r->suffixes = xmalloc (sizeof (const char *));
r->lens = xmalloc (sizeof (unsigned int));
- r->lens[0] = strlen (p->target);
+ r->lens[0] = (unsigned int) strlen (p->target);
r->targets[0] = p->target;
r->suffixes[0] = find_percent_cached (&r->targets[0]);
assert (r->suffixes[0] != NULL);
if (new_pattern_rule (r, 0))
{
- r->terminal = terminal;
+ r->terminal = terminal ? 1 : 0;
r->cmds = xmalloc (sizeof (struct commands));
r->cmds->fileinfo.filenm = 0;
r->cmds->fileinfo.lineno = 0;
void
create_pattern_rule (const char **targets, const char **target_percents,
- unsigned int n, int terminal, struct dep *deps,
+ unsigned short n, int terminal, struct dep *deps,
struct commands *commands, int override)
{
unsigned int i;
for (i = 0; i < n; ++i)
{
- r->lens[i] = strlen (targets[i]);
+ r->lens[i] = (unsigned int) strlen (targets[i]);
assert (r->suffixes[i] != NULL);
++r->suffixes[i];
}
if (new_pattern_rule (r, override))
- r->terminal = terminal;
+ r->terminal = terminal ? 1 : 0;
}
\f
/* Print the data base of rules. */
extern unsigned int max_pattern_deps;
extern unsigned int max_pattern_targets;
-extern unsigned int max_pattern_dep_length;
+extern size_t max_pattern_dep_length;
extern struct file *suffix_file;
-extern unsigned int maxsuffix;
void count_implicit_rule_limits (void);
void convert_to_pattern (void);
void install_pattern_rule (struct pspec *p, int terminal);
void create_pattern_rule (const char **targets, const char **target_percents,
- unsigned int num, int terminal, struct dep *deps,
+ unsigned short num, int terminal, struct dep *deps,
struct commands *commands, int override);
void print_rule_data_base (void);
# elif HAVE_DECL___SYS_SIGLIST
# define sys_siglist __sys_siglist
# else
- static char sig_initted = 0;
+ static int sig_initted = 0;
if (!sig_initted)
sig_initted = signame_init ();
}
static const char *
-copy_string (struct strcache *sp, const char *str, unsigned int len)
+copy_string (struct strcache *sp, const char *str, sc_buflen_t len)
{
/* Add the string to this cache. */
char *res = &sp->buffer[sp->end];
}
static const char *
-add_string (const char *str, unsigned int len)
+add_string (const char *str, sc_buflen_t len)
{
const char *res;
struct strcache *sp;
struct strcache **spp = &strcache;
/* We need space for the nul char. */
- unsigned int sz = len + 1;
+ sc_buflen_t sz = len + 1;
++total_strings;
total_size += sz;
static struct hugestring *hugestrings = NULL;
static const char *
-add_hugestring (const char *str, unsigned int len)
+add_hugestring (const char *str, size_t len)
{
struct hugestring *new = xmalloc (sizeof (struct hugestring) + len);
memcpy (new->buffer, str, len);
static unsigned long total_adds = 0;
static const char *
-add_hash (const char *str, unsigned int len)
+add_hash (const char *str, size_t len)
{
char *const *slot;
const char *key;
return key;
/* Not there yet so add it to a buffer, then into the hash table. */
- key = add_string (str, len);
+ key = add_string (str, (sc_buflen_t)len);
hash_insert_at (&strings, key, slot);
return key;
}
}
const char *
-strcache_add_len (const char *str, unsigned int len)
+strcache_add_len (const char *str, size_t len)
{
/* If we're not given a nul-terminated string we have to create one, because
the hashing functions expect it. */
prefix, numbuffs + 1, fullbuffs, total_strings, total_size,
(total_size / total_strings));
- printf (_("%s current buf: size = %hu B / used = %hu B / count = %hu / avg = %hu B\n"),
+ printf (_("%s current buf: size = %hu B / used = %hu B / count = %hu / avg = %u B\n"),
prefix, (sc_buflen_t)BUFSIZE, strcache->end, strcache->count,
- (strcache->end / strcache->count));
+ (unsigned int) (strcache->end / strcache->count));
if (numbuffs)
{
/* Show information about non-current buffers. */
unsigned long sz = total_size - strcache->end;
unsigned long cnt = total_strings - strcache->count;
- sc_buflen_t avgfree = totfree / numbuffs;
+ sc_buflen_t avgfree = (sc_buflen_t) (totfree / numbuffs);
printf (_("%s other used: total = %lu B / count = %lu / avg = %lu B\n"),
prefix, sz, cnt, sz / cnt);
struct pattern_var *
create_pattern_var (const char *target, const char *suffix)
{
- unsigned int len = strlen (target);
+ size_t len = strlen (target);
struct pattern_var *p = xcalloc (sizeof (struct pattern_var));
if (pattern_vars != 0)
lookup_pattern_var (struct pattern_var *start, const char *target)
{
struct pattern_var *p;
- unsigned int targlen = strlen (target);
+ size_t targlen = strlen (target);
for (p = start ? start->next : pattern_vars; p != 0; p = p->next)
{
const char *stem;
- unsigned int stemlen;
+ size_t stemlen;
if (p->len > targlen)
/* It can't possibly match. */
that it should be recursively re-expanded. */
struct variable *
-define_variable_in_set (const char *name, unsigned int length,
+define_variable_in_set (const char *name, size_t length,
const char *value, enum variable_origin origin,
int recursive, struct variable_set *set,
const floc *flocp)
set = &global_variable_set;
var_key.name = (char *) name;
- var_key.length = length;
+ var_key.length = (unsigned int) length;
var_slot = (struct variable **) hash_find_slot (&set->table, &var_key);
v = *var_slot;
v = xmalloc (sizeof (struct variable));
v->name = xstrndup (name, length);
- v->length = length;
+ v->length = (unsigned int) length;
hash_insert_at (&set->table, v, var_slot);
if (set == &global_variable_set)
++variable_changenum;
}
void
-undefine_variable_in_set (const char *name, unsigned int length,
+undefine_variable_in_set (const char *name, size_t length,
enum variable_origin origin,
struct variable_set *set)
{
set = &global_variable_set;
var_key.name = (char *) name;
- var_key.length = length;
+ var_key.length = (unsigned int) length;
var_slot = (struct variable **) hash_find_slot (&set->table, &var_key);
if (env_overrides && origin == o_env)
if (variable_changenum != last_changenum && streq (var->name, ".VARIABLES"))
{
- unsigned long max = EXPANSION_INCREMENT (strlen (var->value));
- unsigned long len;
+ size_t max = EXPANSION_INCREMENT (strlen (var->value));
+ size_t len;
char *p;
struct variable **vp = (struct variable **) global_variable_set.table.ht_vec;
struct variable **end = &vp[global_variable_set.table.ht_size];
len += l + 1;
if (len > max)
{
- unsigned long off = p - var->value;
+ size_t off = p - var->value;
max += EXPANSION_INCREMENT (l + 1);
var->value = xrealloc (var->value, max);
on the variable, or nil if no such variable is defined. */
struct variable *
-lookup_variable (const char *name, unsigned int length)
+lookup_variable (const char *name, size_t length)
{
const struct variable_set_list *setlist;
struct variable var_key;
int is_parent = 0;
var_key.name = (char *) name;
- var_key.length = length;
+ var_key.length = (unsigned int) length;
for (setlist = current_variable_set_list;
setlist != 0; setlist = setlist->next)
on the variable, or nil if no such variable is defined. */
struct variable *
-lookup_variable_in_set (const char *name, unsigned int length,
+lookup_variable_in_set (const char *name, size_t length,
const struct variable_set *set)
{
struct variable var_key;
var_key.name = (char *) name;
- var_key.length = length;
+ var_key.length = (unsigned int) length;
return (struct variable *) hash_find_item ((struct hash_table *) &set->table, &var_key);
}
shell_result (const char *p)
{
char *buf;
- unsigned int len;
+ size_t len;
char *args[2];
char *result;
{
/* Paste the old and new values together in VALUE. */
- unsigned int oldlen, vallen;
+ size_t oldlen, vallen;
const char *val;
char *tp = NULL;
return NULL;
}
- var->length = e - var->name;
+ var->length = (unsigned int) (e - var->name);
var->value = next_token (p);
return (char *)p;
}
{
if (file->variables != 0)
{
- int l = strlen (file->name);
+ size_t l = strlen (file->name);
char *t = alloca (l + 3);
strcpy (t, file->name);
char *name; /* Variable name. */
char *value; /* Variable value. */
floc fileinfo; /* Where the variable was defined. */
- int length; /* strlen (name) */
+ unsigned int length; /* strlen (name) */
unsigned int recursive:1; /* Gets recursively re-evaluated. */
unsigned int append:1; /* Nonzero if an appending target-specific
variable. */
struct pattern_var *next;
const char *suffix;
const char *target;
- unsigned int len;
+ size_t len;
struct variable variable;
};
extern struct variable shell_var;
/* expand.c */
-char *variable_buffer_output (char *ptr, const char *string, unsigned int length);
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t)~(size_t)0)
+#endif
+
+char *variable_buffer_output (char *ptr, const char *string, size_t length);
char *variable_expand (const char *line);
char *variable_expand_for_file (const char *line, struct file *file);
char *allocated_variable_expand_for_file (const char *line, struct file *file);
#define allocated_variable_expand(line) \
allocated_variable_expand_for_file (line, (struct file *) 0)
char *expand_argument (const char *str, const char *end);
-char *variable_expand_string (char *line, const char *string, long length);
-void install_variable_buffer (char **bufp, unsigned int *lenp);
-void restore_variable_buffer (char *buf, unsigned int len);
+char *variable_expand_string (char *line, const char *string, size_t length);
+void install_variable_buffer (char **bufp, size_t *lenp);
+void restore_variable_buffer (char *buf, size_t len);
/* function.c */
int handle_function (char **op, const char **stringp);
int pattern_matches (const char *pattern, const char *percent, const char *str);
char *subst_expand (char *o, const char *text, const char *subst,
- const char *replace, unsigned int slen, unsigned int rlen,
+ const char *replace, size_t slen, size_t rlen,
int by_word);
char *patsubst_expand_pat (char *o, const char *text, const char *pattern,
const char *replace, const char *pattern_percent,
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);
-struct variable *lookup_variable_in_set (const char *name, unsigned int length,
+struct variable *lookup_variable (const char *name, size_t length);
+struct variable *lookup_variable_in_set (const char *name, size_t length,
const struct variable_set *set);
-struct variable *define_variable_in_set (const char *name, unsigned int length,
+struct variable *define_variable_in_set (const char *name, size_t length,
const char *value,
enum variable_origin origin,
int recursive,
#define define_variable_for_file(n,l,v,o,r,f) \
define_variable_in_set((n),(l),(v),(o),(r),(f)->variables->set,NILF)
-void undefine_variable_in_set (const char *name, unsigned int length,
+void undefine_variable_in_set (const char *name, size_t length,
enum variable_origin origin,
struct variable_set *set);
struct vpath
{
- struct vpath *next; /* Pointer to next struct in the linked list. */
- const char *pattern;/* The pattern to match. */
- const char *percent;/* Pointer into 'pattern' where the '%' is. */
- unsigned int patlen;/* Length of the pattern. */
+ struct vpath *next; /* Pointer to next struct in the linked list. */
+ const char *pattern; /* The pattern to match. */
+ const char *percent; /* Pointer into 'pattern' where the '%' is. */
+ size_t patlen; /* Length of the pattern. */
const char **searchpath; /* Null-terminated list of directories. */
- unsigned int maxlen;/* Maximum length of any entry in the list. */
+ size_t maxlen; /* Maximum length of any entry in the list. */
};
/* Linked-list of all selective VPATHs. */
unsigned int elem;
char *p;
const char **vpath;
- unsigned int maxvpath;
+ size_t maxvpath;
unsigned int maxelem;
const char *percent = NULL;
while (*p != '\0')
{
char *v;
- unsigned int len;
+ size_t len;
/* Find the end of this entry. */
v = p;
in. If it is found, return 1. Otherwise we return 0. */
int
-gpath_search (const char *file, unsigned int len)
+gpath_search (const char *file, size_t len)
{
if (gpaths && (len <= gpaths->maxlen))
{
const char *n;
const char *filename;
const char **vpath = path->searchpath;
- unsigned int maxvpath = path->maxlen;
+ size_t maxvpath = path->maxlen;
unsigned int i;
- unsigned int flen, name_dplen;
+ size_t flen, name_dplen;
int exists = 0;
/* Find out if *FILE is a target.
{
int exists_in_cache = 0;
char *p = name;
- unsigned int vlen = strlen (vpath[i]);
+ size_t vlen = strlen (vpath[i]);
/* Put the next VPATH entry into NAME at P and increment P past it. */
memcpy (p, vpath[i], vlen);
struct stat sb;
DIR* pDir;
char* pEndDirName;
- int nBufferLen;
+ size_t nBufferLen;
/* sanity checks */
if (!pDirName) {
/* found one to count, handle things like '.' */
*etok = to_delim;
p = ++etok;
- } else if ((*etok == ':') && (etok = strpbrk(etok+1, ":;"))) {
+ } else if ((*etok == ':') && ((etok = strpbrk(etok+1, ":;")) != NULL)) {
/* found one to count, handle drive letter */
*etok = to_delim;
p = ++etok;
return _stricoll(*((char**)a1),*((char**)a2));
}
bool_t
-arr2envblk(char **arr, char **envblk_out, int *envsize_needed)
+arr2envblk(char **arr, char **envblk_out, size_t *envsize_needed)
{
char **tmp;
- int size_needed;
+ size_t size_needed;
int arrcnt;
char *ptr;
#define E_NO_MEM 103
#define E_FORK 104
-extern bool_t arr2envblk(char **arr, char **envblk_out, int *envsize_needed);
+extern bool_t arr2envblk(char **arr, char **envblk_out, size_t *envsize_needed);
#endif
/* keep track of children so we can implement a waitpid-like routine */
static sub_process *proc_array[GMAKE_MAXIMUM_WAIT_OBJECTS];
-static int proc_index = 0;
-static int fake_exits_pending = 0;
+static unsigned int proc_index = 0;
+static unsigned int fake_exits_pending = 0;
/*
* Address the scalability limit intrisic to WaitForMultipleOjects by
assert(dwMilliseconds == 0 || dwMilliseconds == INFINITE); /* No support for timeouts */
for (; objectCount > 0; blockCount++) {
- DWORD n = objectCount <= MAXIMUM_WAIT_OBJECTS ? objectCount : MAXIMUM_WAIT_OBJECTS;
- objectCount -= n;
- retVal = WaitForMultipleObjects(n, &lpHandles[blockCount * MAXIMUM_WAIT_OBJECTS],
- FALSE, 0);
- switch (retVal) {
- case WAIT_TIMEOUT:
- retVal = GMAKE_WAIT_TIMEOUT;
- continue;
- break;
- case WAIT_FAILED:
- fprintf(stderr,"WaitForMultipleOjbects failed waiting with error %d\n", GetLastError());
- break;
- default:
- if (retVal >= WAIT_ABANDONED_0) {
- assert(retVal < WAIT_ABANDONED_0 + MAXIMUM_WAIT_OBJECTS);
- retVal += blockCount * MAXIMUM_WAIT_OBJECTS - WAIT_ABANDONED_0 + GMAKE_WAIT_ABANDONED_0;
- } else {
- assert(retVal < WAIT_OBJECT_0 + MAXIMUM_WAIT_OBJECTS);
- retVal += blockCount * MAXIMUM_WAIT_OBJECTS;
- }
- break;
- }
-
- return retVal;
+ DWORD n = objectCount <= MAXIMUM_WAIT_OBJECTS ? objectCount : MAXIMUM_WAIT_OBJECTS;
+ objectCount -= n;
+ retVal = WaitForMultipleObjects(n, &lpHandles[blockCount * MAXIMUM_WAIT_OBJECTS],
+ FALSE, 0);
+ switch (retVal) {
+ case WAIT_TIMEOUT:
+ retVal = GMAKE_WAIT_TIMEOUT;
+ continue;
+ break;
+ case WAIT_FAILED:
+ fprintf(stderr,"WaitForMultipleOjbects failed waiting with error %d\n", GetLastError());
+ break;
+ default:
+ if (retVal >= WAIT_ABANDONED_0) {
+ assert(retVal < WAIT_ABANDONED_0 + MAXIMUM_WAIT_OBJECTS);
+ retVal += blockCount * MAXIMUM_WAIT_OBJECTS - WAIT_ABANDONED_0 + GMAKE_WAIT_ABANDONED_0;
+ } else {
+ assert(retVal < WAIT_OBJECT_0 + MAXIMUM_WAIT_OBJECTS);
+ retVal += blockCount * MAXIMUM_WAIT_OBJECTS;
+ }
+ break;
+ }
+
+ return retVal;
}
process_set_handles(HANDLE *handles)
{
DWORD count = 0;
- int i;
+ unsigned int i;
/* Build array of handles to wait for */
for (i = 0; i < proc_index; i++) {
static void
process_adjust_wait_state(sub_process* pproc)
{
- int i;
+ unsigned int i;
if (!proc_index)
return;
{
HANDLE handles[GMAKE_MAXIMUM_WAIT_OBJECTS];
DWORD retval, which;
- int i;
+ unsigned int i;
if (!proc_index)
return NULL;
STARTUPINFO startInfo;
PROCESS_INFORMATION procInfo;
char *envblk=NULL;
- int envsize_needed = 0;
+ size_t envsize_needed = 0;
int pass_null_exec_path = 0;
/*
if (exec_path[0] == '/') {
char *new_argv0;
char **argvi = argv;
- int arglen = 0;
+ size_t arglen = 0;
strcpy(buf, variable_expand ("$(SHELL)"));
shell_name = &buf[0];
&& _stricmp(exec_path, argv[0]) == 0) {
char *new_argv, *p;
char **argvi;
- int arglen, i;
+ size_t arglen;
+ int i;
pass_null_exec_path = 1;
/* Rewrite argv[] replacing argv[0] with exec_fname. */
for (argvi = argv + 1, arglen = strlen(exec_fname) + 1;
if ((pproc->last_err == ERROR_INVALID_PARAMETER
|| pproc->last_err == ERROR_MORE_DATA)
&& envsize_needed > 32*1024) {
- fprintf (stderr, "CreateProcess failed, probably because environment is too large (%d bytes).\n",
+ fprintf (stderr, "CreateProcess failed, probably because environment is too large (%Iu bytes).\n",
envsize_needed);
}
pproc->last_err = 0;
static char *
make_command_line( char *shell_name, char *full_exec_path, char **argv)
{
- int argc = 0;
- char** argvi;
- int* enclose_in_quotes = NULL;
- int* enclose_in_quotes_i;
- unsigned int bytes_required = 0;
- char* command_line;
- char* command_line_i;
+ int argc = 0;
+ char** argvi;
+ int* enclose_in_quotes = NULL;
+ int* enclose_in_quotes_i;
+ size_t bytes_required = 0;
+ char* command_line;
+ char* command_line_i;
int have_sh = 0; /* HAVE_CYGWIN_SHELL */
int cygwin_mode = 0; /* HAVE_CYGWIN_SHELL */