Resolve most of the Windows Visual Studio warnings.

* Convert integer types to size_t where necessary.
* Align other integral types to avoid casts and type warnings.
This commit is contained in:
Paul Smith 2018-07-01 20:00:53 -04:00
parent c808f10d08
commit 0ce880e5ee
32 changed files with 362 additions and 354 deletions

View File

@ -186,7 +186,7 @@ struct ar_glob_state
#ifdef VMS #ifdef VMS
char *suffix; char *suffix;
#endif #endif
unsigned int size; size_t size;
struct nameseq *chain; struct nameseq *chain;
unsigned int n; unsigned int n;
}; };
@ -258,7 +258,7 @@ ar_glob_pattern_p (const char *pattern, int quote)
Return a malloc'd chain of matching elements (or nil if none). */ Return a malloc'd chain of matching elements (or nil if none). */
struct nameseq * 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 ar_glob_state state;
struct nameseq *n; struct nameseq *n;

View File

@ -72,7 +72,7 @@ set_file_variables (struct file *file)
if (ar_name (file->name)) if (ar_name (file->name))
{ {
unsigned int len; size_t len;
const char *cp; const char *cp;
char *p; char *p;
@ -101,7 +101,7 @@ set_file_variables (struct file *file)
any suffix in the .SUFFIXES list stripped off for any suffix in the .SUFFIXES list stripped off for
explicit rules. We store this in the 'stem' member. */ explicit rules. We store this in the 'stem' member. */
const char *name; const char *name;
unsigned int len; size_t len;
#ifndef NO_ARCHIVES #ifndef NO_ARCHIVES
if (ar_name (file->name)) if (ar_name (file->name))
@ -118,7 +118,7 @@ set_file_variables (struct file *file)
for (d = enter_file (strcache_add (".SUFFIXES"))->deps; d ; d = d->next) 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)) if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
{ {
file->stem = strcache_add_len (name, len - slen); file->stem = strcache_add_len (name, len - slen);
@ -159,14 +159,14 @@ set_file_variables (struct file *file)
{ {
static char *plus_value=0, *bar_value=0, *qmark_value=0; 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 *cp;
char *caret_value; char *caret_value;
char *qp; char *qp;
char *bp; char *bp;
unsigned int len; size_t len;
struct hash_table dep_hash; struct hash_table dep_hash;
void **slot; void **slot;
@ -326,7 +326,8 @@ set_file_variables (struct file *file)
void void
chop_commands (struct commands *cmds) chop_commands (struct commands *cmds)
{ {
unsigned int nlines, idx; unsigned int nlines;
unsigned short idx;
char **lines; char **lines;
/* If we don't have any commands, /* If we don't have any commands,
@ -339,7 +340,7 @@ chop_commands (struct commands *cmds)
if (one_shell) if (one_shell)
{ {
int l = strlen (cmds->commands); size_t l = strlen (cmds->commands);
nlines = 1; nlines = 1;
lines = xmalloc (nlines * sizeof (char *)); lines = xmalloc (nlines * sizeof (char *));
@ -382,7 +383,7 @@ chop_commands (struct commands *cmds)
nlines += 2; nlines += 2;
lines = xrealloc (lines, nlines * sizeof (char *)); lines = xrealloc (lines, nlines * sizeof (char *));
} }
lines[idx++] = xstrndup (p, end - p); lines[idx++] = xstrndup (p, (size_t) (end - p));
p = end; p = end;
if (*p != '\0') if (*p != '\0')
++p; ++p;
@ -401,7 +402,7 @@ chop_commands (struct commands *cmds)
if (nlines > USHRT_MAX) if (nlines > USHRT_MAX)
ON (fatal, &cmds->fileinfo, _("Recipe has too many lines (%ud)"), nlines); 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->command_lines = lines;
cmds->any_recurse = 0; cmds->any_recurse = 0;

View File

@ -62,7 +62,7 @@ struct dep
struct goaldep struct goaldep
{ {
DEP (struct goaldep); DEP (struct goaldep);
unsigned short error; int error;
floc floc; floc floc;
}; };
@ -83,14 +83,14 @@ struct goaldep
#ifdef VMS #ifdef VMS
void *parse_file_seq (); void *parse_file_seq ();
#else #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); int stopmap, const char *prefix, int flags);
#endif #endif
char *tilde_expand (const char *name); char *tilde_expand (const char *name);
#ifndef NO_ARCHIVES #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 #endif
#define dep_name(d) ((d)->name ? (d)->name : (d)->file->name) #define dep_name(d) ((d)->name ? (d)->name : (d)->file->name)

View File

@ -426,7 +426,7 @@ dirfile_hash_cmp (const void *xv, const void *yv)
{ {
const struct dirfile *x = xv; const struct dirfile *x = xv;
const struct dirfile *y = yv; const struct dirfile *y = yv;
int result = x->length - y->length; int result = (int) (x->length - y->length);
if (result) if (result)
return result; return result;
return_ISTRING_COMPARE (x->name, y->name); return_ISTRING_COMPARE (x->name, y->name);
@ -687,7 +687,7 @@ dir_contents_file_exists_p (struct directory_contents *dir,
while (1) while (1)
{ {
/* Enter the file in the hash table. */ /* Enter the file in the hash table. */
unsigned int len; size_t len;
struct dirfile dirfile_key; struct dirfile dirfile_key;
struct dirfile **dirfile_slot; struct dirfile **dirfile_slot;
@ -1208,7 +1208,7 @@ static struct dirent *
read_dirstream (__ptr_t stream) read_dirstream (__ptr_t stream)
{ {
static char *buf; static char *buf;
static unsigned int bufsz; static size_t bufsz;
struct dirstream *const ds = (struct dirstream *) stream; struct dirstream *const ds = (struct dirstream *) stream;
struct directory_contents *dc = ds->contents; struct directory_contents *dc = ds->contents;
@ -1221,8 +1221,8 @@ read_dirstream (__ptr_t stream)
{ {
/* The glob interface wants a 'struct dirent', so mock one up. */ /* The glob interface wants a 'struct dirent', so mock one up. */
struct dirent *d; struct dirent *d;
unsigned int len = df->length + 1; size_t len = df->length + 1;
unsigned int sz = sizeof (*d) - sizeof (d->d_name) + len; size_t sz = sizeof (*d) - sizeof (d->d_name) + len;
if (sz > bufsz) if (sz > bufsz)
{ {
bufsz *= 2; bufsz *= 2;

View File

@ -42,7 +42,7 @@ const floc **expanding_var = &reading_file;
#define VARIABLE_BUFFER_ZONE 5 #define VARIABLE_BUFFER_ZONE 5
static unsigned int variable_buffer_length; static size_t variable_buffer_length;
char *variable_buffer; char *variable_buffer;
/* Subroutine of variable_expand and friends: /* Subroutine of variable_expand and friends:
@ -53,13 +53,13 @@ char *variable_buffer;
the following call. */ the following call. */
char * 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) 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 variable_buffer_length = (newlen + 100 > 2 * variable_buffer_length
? newlen + 100 ? newlen + 100
: 2 * variable_buffer_length); : 2 * variable_buffer_length);
@ -157,7 +157,7 @@ recursively_expand_for_file (struct variable *v, struct file *file)
__inline __inline
#endif #endif
static char * 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; struct variable *v;
char *value; char *value;
@ -191,13 +191,13 @@ reference_variable (char *o, const char *name, unsigned int length)
NULL. NULL.
*/ */
char * 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; struct variable *v;
const char *p, *p1; const char *p, *p1;
char *save; char *save;
char *o; char *o;
unsigned int line_offset; size_t line_offset;
if (!line) if (!line)
line = initialize_variable_output (); line = initialize_variable_output ();
@ -213,7 +213,7 @@ variable_expand_string (char *line, const char *string, long length)
/* We need a copy of STRING: due to eval, it's possible that it will get /* 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 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. */ 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; p = save;
while (1) while (1)
@ -224,7 +224,7 @@ variable_expand_string (char *line, const char *string, long length)
p1 = strchr (p, '$'); 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) if (p1 == 0)
break; break;
@ -414,7 +414,7 @@ variable_expand_string (char *line, const char *string, long length)
char * char *
variable_expand (const char *line) variable_expand (const char *line)
{ {
return variable_expand_string (NULL, line, (long)-1); return variable_expand_string (NULL, line, SIZE_MAX);
} }
/* Expand an argument for an expansion function. /* Expand an argument for an expansion function.
@ -485,7 +485,7 @@ variable_expand_for_file (const char *line, struct file *file)
any upper variable sets. Then expand the resulting value. */ any upper variable sets. Then expand the resulting value. */
static char * 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_set_list *set, int local)
{ {
const struct variable *v; const struct variable *v;
@ -535,7 +535,7 @@ allocated_variable_append (const struct variable *v)
/* Construct the appended variable value. */ /* Construct the appended variable value. */
char *obuf = variable_buffer; char *obuf = variable_buffer;
unsigned int olen = variable_buffer_length; size_t olen = variable_buffer_length;
variable_buffer = 0; variable_buffer = 0;
@ -559,7 +559,7 @@ allocated_variable_expand_for_file (const char *line, struct file *file)
char *value; char *value;
char *obuf = variable_buffer; char *obuf = variable_buffer;
unsigned int olen = variable_buffer_length; size_t olen = variable_buffer_length;
variable_buffer = 0; variable_buffer = 0;
@ -575,7 +575,7 @@ allocated_variable_expand_for_file (const char *line, struct file *file)
safe-keeping. */ safe-keeping. */
void void
install_variable_buffer (char **bufp, unsigned int *lenp) install_variable_buffer (char **bufp, size_t *lenp)
{ {
*bufp = variable_buffer; *bufp = variable_buffer;
*lenp = variable_buffer_length; *lenp = variable_buffer_length;
@ -588,7 +588,7 @@ install_variable_buffer (char **bufp, unsigned int *lenp)
*/ */
void void
restore_variable_buffer (char *buf, unsigned int len) restore_variable_buffer (char *buf, size_t len)
{ {
free (variable_buffer); free (variable_buffer);

View File

@ -492,7 +492,7 @@ enter_prereqs (struct dep *deps, const char *stem)
while (dp != 0) while (dp != 0)
{ {
char *percent; char *percent;
int nl = strlen (dp->name) + 1; size_t nl = strlen (dp->name) + 1;
char *nm = alloca (nl); char *nm = alloca (nl);
memcpy (nm, dp->name, nl); memcpy (nm, dp->name, nl);
percent = find_percent (nm); percent = find_percent (nm);
@ -1100,8 +1100,8 @@ build_target_list (char *value)
if (files.ht_fill != last_targ_count) if (files.ht_fill != last_targ_count)
{ {
unsigned long max = EXPANSION_INCREMENT (strlen (value)); size_t max = EXPANSION_INCREMENT (strlen (value));
unsigned long len; size_t len;
char *p; char *p;
struct file **fp = (struct file **) files.ht_vec; struct file **fp = (struct file **) files.ht_vec;
struct file **end = &fp[files.ht_size]; struct file **end = &fp[files.ht_size];
@ -1115,12 +1115,12 @@ build_target_list (char *value)
if (!HASH_VACANT (*fp) && (*fp)->is_target) if (!HASH_VACANT (*fp) && (*fp)->is_target)
{ {
struct file *f = *fp; struct file *f = *fp;
int l = strlen (f->name); size_t l = strlen (f->name);
len += l + 1; len += l + 1;
if (len > max) if (len > max)
{ {
unsigned long off = p - value; size_t off = p - value;
max += EXPANSION_INCREMENT (l + 1); max += EXPANSION_INCREMENT (l + 1);
value = xrealloc (value, max); value = xrealloc (value, max);

View File

@ -78,7 +78,7 @@ static struct hash_table function_table;
char * char *
subst_expand (char *o, const char *text, const char *subst, const char *replace, 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 *t = text;
const char *p; const char *p;
@ -148,10 +148,10 @@ patsubst_expand_pat (char *o, const char *text,
const char *pattern, const char *replace, const char *pattern, const char *replace,
const char *pattern_percent, const char *replace_percent) const char *pattern_percent, const char *replace_percent)
{ {
unsigned int pattern_prepercent_len, pattern_postpercent_len; size_t pattern_prepercent_len, pattern_postpercent_len;
unsigned int replace_prepercent_len, replace_postpercent_len; size_t replace_prepercent_len, replace_postpercent_len;
const char *t; const char *t;
unsigned int len; size_t len;
int doneany = 0; int doneany = 0;
/* Record the length of REPLACE before and after the % so we don't have to /* Record the length of REPLACE before and after the % so we don't have to
@ -280,7 +280,7 @@ lookup_function (const char *s)
return NULL; return NULL;
function_table_entry_key.name = s; 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); return hash_find_item (&function_table, &function_table_entry_key);
} }
@ -291,11 +291,11 @@ lookup_function (const char *s)
int int
pattern_matches (const char *pattern, const char *percent, const char *str) pattern_matches (const char *pattern, const char *percent, const char *str)
{ {
unsigned int sfxlen, strlength; size_t sfxlen, strlength;
if (percent == 0) if (percent == 0)
{ {
unsigned int len = strlen (pattern) + 1; size_t len = strlen (pattern) + 1;
char *new_chars = alloca (len); char *new_chars = alloca (len);
memcpy (new_chars, pattern, len); memcpy (new_chars, pattern, len);
percent = find_percent (new_chars); percent = find_percent (new_chars);
@ -357,9 +357,9 @@ static char *
string_glob (char *line) string_glob (char *line)
{ {
static char *result = 0; static char *result = 0;
static unsigned int length; static size_t length;
struct nameseq *chain; struct nameseq *chain;
unsigned int idx; size_t idx;
chain = PARSE_FILE_SEQ (&line, struct nameseq, MAP_NUL, NULL, chain = PARSE_FILE_SEQ (&line, struct nameseq, MAP_NUL, NULL,
/* We do not want parse_file_seq to strip './'s. /* We do not want parse_file_seq to strip './'s.
@ -377,7 +377,7 @@ string_glob (char *line)
while (chain != 0) while (chain != 0)
{ {
struct nameseq *next = chain->next; struct nameseq *next = chain->next;
unsigned int len = strlen (chain->name); size_t len = strlen (chain->name);
if (idx + len + 1 > length) if (idx + len + 1 > length)
{ {
@ -430,7 +430,7 @@ func_join (char *o, char **argv, const char *funcname UNUSED)
const char *list2_iterator = argv[1]; const char *list2_iterator = argv[1];
do do
{ {
unsigned int len1, len2; size_t len1, len2;
tp = find_next_token (&list1_iterator, &len1); tp = find_next_token (&list1_iterator, &len1);
if (tp != 0) if (tp != 0)
@ -519,7 +519,7 @@ func_notdir_suffix (char *o, char **argv, const char *funcname)
const char *list_iterator = argv[0]; const char *list_iterator = argv[0];
const char *p2; const char *p2;
int doneany =0; int doneany =0;
unsigned int len=0; size_t len=0;
int is_suffix = funcname[0] == 's'; int is_suffix = funcname[0] == 's';
int is_notdir = !is_suffix; int is_notdir = !is_suffix;
@ -595,7 +595,7 @@ func_basename_dir (char *o, char **argv, const char *funcname)
const char *p3 = argv[0]; const char *p3 = argv[0];
const char *p2; const char *p2;
int doneany = 0; int doneany = 0;
unsigned int len = 0; size_t len = 0;
int is_basename = funcname[0] == 'b'; int is_basename = funcname[0] == 'b';
int is_dir = !is_basename; int is_dir = !is_basename;
@ -668,14 +668,14 @@ func_basename_dir (char *o, char **argv, const char *funcname)
static char * static char *
func_addsuffix_addprefix (char *o, char **argv, const char *funcname) 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]; const char *list_iterator = argv[1];
int is_addprefix = funcname[3] == 'p'; int is_addprefix = funcname[3] == 'p';
int is_addsuffix = !is_addprefix; int is_addsuffix = !is_addprefix;
int doneany = 0; int doneany = 0;
const char *p; const char *p;
unsigned int len; size_t len;
while ((p = find_next_token (&list_iterator, &len)) != 0) while ((p = find_next_token (&list_iterator, &len)) != 0)
{ {
@ -708,7 +708,7 @@ func_subst (char *o, char **argv, const char *funcname UNUSED)
static char * static char *
func_firstword (char *o, char **argv, const char *funcname UNUSED) 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 *words = argv[0]; /* Use a temp variable for find_next_token */
const char *p = find_next_token (&words, &i); const char *p = find_next_token (&words, &i);
@ -721,12 +721,12 @@ func_firstword (char *o, char **argv, const char *funcname UNUSED)
static char * static char *
func_lastword (char *o, char **argv, const char *funcname UNUSED) 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 *words = argv[0]; /* Use a temp variable for find_next_token */
const char *p = NULL; const char *p = NULL;
const char *t; const char *t;
while ((t = find_next_token (&words, &i))) while ((t = find_next_token (&words, &i)) != NULL)
p = t; p = t;
if (p != 0) if (p != 0)
@ -871,7 +871,7 @@ func_foreach (char *o, char **argv, const char *funcname UNUSED)
int doneany = 0; int doneany = 0;
const char *list_iterator = list; const char *list_iterator = list;
const char *p; const char *p;
unsigned int len; size_t len;
struct variable *var; struct variable *var;
/* Clean up the variable name by removing whitespace. */ /* Clean up the variable name by removing whitespace. */
@ -913,7 +913,7 @@ struct a_word
struct a_word *next; struct a_word *next;
struct a_word *chain; struct a_word *chain;
char *str; char *str;
int length; size_t length;
int matched; int matched;
}; };
@ -932,7 +932,7 @@ a_word_hash_2 (const void *key)
static int static int
a_word_hash_cmp (const void *x, const void *y) 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) if (result)
return result; return result;
return_STRING_COMPARE (((struct a_word const *) x)->str, return_STRING_COMPARE (((struct a_word const *) x)->str,
@ -944,7 +944,7 @@ struct a_pattern
struct a_pattern *next; struct a_pattern *next;
char *str; char *str;
char *percent; char *percent;
int length; size_t length;
}; };
static char * static char *
@ -965,7 +965,7 @@ func_filter_filterout (char *o, char **argv, const char *funcname)
int words = 0; int words = 0;
int hashing = 0; int hashing = 0;
char *p; char *p;
unsigned int len; size_t len;
/* Chop ARGV[0] up into patterns to match against the words. /* Chop ARGV[0] up into patterns to match against the words.
We don't need to preserve it because our caller frees all the We don't need to preserve it because our caller frees all the
@ -1115,7 +1115,7 @@ func_error (char *o, char **argv, const char *funcname)
{ {
char **argvp; char **argvp;
char *msg, *p; char *msg, *p;
int len; size_t len;
/* The arguments will be broken on commas. Rather than create yet /* The arguments will be broken on commas. Rather than create yet
another special case where function arguments aren't broken up, another special case where function arguments aren't broken up,
@ -1168,7 +1168,7 @@ func_sort (char *o, char **argv, const char *funcname UNUSED)
char **words; char **words;
int wordi; int wordi;
char *p; char *p;
unsigned int len; size_t len;
/* Find the maximum number of words we'll have. */ /* Find the maximum number of words we'll have. */
t = argv[0]; t = argv[0];
@ -1292,7 +1292,7 @@ func_or (char *o, char **argv, const char *funcname UNUSED)
const char *begp = *argv; const char *begp = *argv;
const char *endp = begp + strlen (*argv) - 1; const char *endp = begp + strlen (*argv) - 1;
char *expansion; char *expansion;
int result = 0; size_t result = 0;
/* Find the result of the condition: if it's false keep going. */ /* Find the result of the condition: if it's false keep going. */
@ -1343,7 +1343,7 @@ func_and (char *o, char **argv, const char *funcname UNUSED)
{ {
const char *begp = *argv; const char *begp = *argv;
const char *endp = begp + strlen (*argv) - 1; const char *endp = begp + strlen (*argv) - 1;
int result; size_t result;
/* An empty condition is always false. */ /* An empty condition is always false. */
strip_whitespace (&begp, &endp); strip_whitespace (&begp, &endp);
@ -1398,7 +1398,7 @@ static char *
func_eval (char *o, char **argv, const char *funcname UNUSED) func_eval (char *o, char **argv, const char *funcname UNUSED)
{ {
char *buf; char *buf;
unsigned int len; size_t len;
/* Eval the buffer. Pop the current variable buffer setting so that the /* Eval the buffer. Pop the current variable buffer setting so that the
eval'd code can use its own without conflicting. */ eval'd code can use its own without conflicting. */
@ -1430,7 +1430,7 @@ func_value (char *o, char **argv, const char *funcname UNUSED)
\r is replaced on UNIX as well. Is this desirable? \r is replaced on UNIX as well. Is this desirable?
*/ */
static void 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 *dst = buffer;
char *src = buffer; char *src = buffer;
@ -1806,7 +1806,7 @@ func_shell_base (char *o, char **argv, int trim_newlines)
{ {
char *buffer; char *buffer;
unsigned int maxlen, i; size_t maxlen, i;
int cc; int cc;
/* Record the PID for reap_children. */ /* Record the PID for reap_children. */
@ -1916,11 +1916,11 @@ func_shell_base (char *o, char **argv, int trim_newlines)
BPTR child_stdout; BPTR child_stdout;
char tmp_output[FILENAME_MAX]; char tmp_output[FILENAME_MAX];
unsigned int maxlen = 200, i; size_t maxlen = 200, i;
int cc; int cc;
char * buffer, * ptr; char * buffer, * ptr;
char ** aptr; char ** aptr;
int len = 0; size_t len = 0;
char* batch_filename = NULL; char* batch_filename = NULL;
/* Construct the argument list. */ /* Construct the argument list. */
@ -2104,7 +2104,7 @@ abspath (const char *name, char *apath)
for (start = end = name; *start != '\0'; start = end) for (start = end = name; *start != '\0'; start = end)
{ {
unsigned long len; size_t len;
/* Skip sequence of multiple path-separators. */ /* Skip sequence of multiple path-separators. */
while (STOP_SET (*start, MAP_DIRSEP)) while (STOP_SET (*start, MAP_DIRSEP))
@ -2158,7 +2158,7 @@ func_realpath (char *o, char **argv, const char *funcname UNUSED)
const char *p = argv[0]; const char *p = argv[0];
const char *path = 0; const char *path = 0;
int doneany = 0; int doneany = 0;
unsigned int len = 0; size_t len = 0;
while ((path = find_next_token (&p, &len)) != 0) while ((path = find_next_token (&p, &len)) != 0)
{ {
@ -2227,7 +2227,7 @@ func_file (char *o, char **argv, const char *funcname UNUSED)
if (argv[1]) if (argv[1])
{ {
int l = strlen (argv[1]); size_t l = strlen (argv[1]);
int nl = l == 0 || argv[1][l-1] != '\n'; int nl = l == 0 || argv[1][l-1] != '\n';
if (fputs (argv[1], fp) == EOF || (nl && fputc ('\n', fp) == EOF)) if (fputs (argv[1], fp) == EOF || (nl && fputc ('\n', fp) == EOF))
@ -2291,7 +2291,7 @@ func_abspath (char *o, char **argv, const char *funcname UNUSED)
const char *p = argv[0]; const char *p = argv[0];
const char *path = 0; const char *path = 0;
int doneany = 0; int doneany = 0;
unsigned int len = 0; size_t len = 0;
while ((path = find_next_token (&p, &len)) != 0) while ((path = find_next_token (&p, &len)) != 0)
{ {
@ -2498,7 +2498,7 @@ handle_function (char **op, const char **stringp)
++nargs; ++nargs;
if (nargs == entry_p->maximum_args 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; next = end;
*argvp = expand_argument (p, next); *argvp = expand_argument (p, next);
@ -2507,7 +2507,7 @@ handle_function (char **op, const char **stringp)
} }
else else
{ {
int len = end - beg; size_t len = end - beg;
char *p, *aend; char *p, *aend;
abeg = xmalloc (len+1); abeg = xmalloc (len+1);
@ -2522,7 +2522,7 @@ handle_function (char **op, const char **stringp)
++nargs; ++nargs;
if (nargs == entry_p->maximum_args 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; next = aend;
*argvp = p; *argvp = p;
@ -2556,7 +2556,7 @@ func_call (char *o, char **argv, const char *funcname UNUSED)
static int max_args = 0; static int max_args = 0;
char *fname; char *fname;
char *body; char *body;
int flen; size_t flen;
int i; int i;
int saved_args; int saved_args;
const struct function_table_entry *entry_p; const struct function_table_entry *entry_p;
@ -2670,9 +2670,9 @@ define_new_function (const floc *flocp, const char *name,
ent = xmalloc (sizeof (struct function_table_entry)); ent = xmalloc (sizeof (struct function_table_entry));
ent->name = name; ent->name = name;
ent->len = len; ent->len = (unsigned char) len;
ent->minimum_args = min; ent->minimum_args = (unsigned char) min;
ent->maximum_args = max; ent->maximum_args = (unsigned char) max;
ent->expand_args = ANY_SET(flags, GMK_FUNC_NOEXPAND) ? 0 : 1; ent->expand_args = ANY_SET(flags, GMK_FUNC_NOEXPAND) ? 0 : 1;
ent->alloc_fn = 1; ent->alloc_fn = 1;
ent->fptr.alloc_func_ptr = func; ent->fptr.alloc_func_ptr = func;

View File

@ -17,7 +17,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "makeint.h" #include "makeint.h"
#include "hash.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 MALLOC(t, n) ((t *) xmalloc (sizeof (t) * (n)))
#define REALLOC(o, t, n) ((t *) xrealloc ((o), 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))) #define CLONE(o, t, n) ((t *) memcpy (MALLOC (t, (n)), (o), sizeof (t) * (n)))
@ -473,5 +473,5 @@ unsigned jhash_string(unsigned const char *k)
} }
jhash_final(a, b, c); jhash_final(a, b, c);
return c + (k - start); return c + (unsigned) (k - start);
} }

View File

@ -66,7 +66,7 @@ try_implicit_rule (struct file *file, unsigned int depth)
length of the word. */ length of the word. */
static const char * 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; const char *p = buffer, *beg;
char c; char c;
@ -161,12 +161,12 @@ struct tryrule
{ {
struct rule *rule; struct rule *rule;
/* Stem length for this match. */
size_t stemlen;
/* Index of the target in this rule that matched the file. */ /* Index of the target in this rule that matched the file. */
unsigned int matches; unsigned int matches;
/* Stem length for this match. */
unsigned int stemlen;
/* Definition order of this rule. Used to implement stable sort.*/ /* Definition order of this rule. Used to implement stable sort.*/
unsigned int order; unsigned int order;
@ -179,8 +179,8 @@ stemlen_compare (const void *v1, const void *v2)
{ {
const struct tryrule *r1 = v1; const struct tryrule *r1 = v1;
const struct tryrule *r2 = v2; const struct tryrule *r2 = v2;
int r = r1->stemlen - r2->stemlen; int r = (int) (r1->stemlen - r2->stemlen);
return r != 0 ? r : (int)(r1->order - r2->order); return r != 0 ? r : (int) (r1->order - r2->order);
} }
/* Search the pattern rules for a rule with an existing dependency to make /* Search the pattern rules for a rule with an existing dependency to make
@ -205,7 +205,7 @@ pattern_search (struct file *file, int archive,
const char *filename = archive ? strchr (file->name, '(') : file->name; const char *filename = archive ? strchr (file->name, '(') : file->name;
/* Length of FILENAME. */ /* Length of FILENAME. */
unsigned int namelen = strlen (filename); size_t namelen = strlen (filename);
/* The last slash in FILENAME (or nil if there is none). */ /* The last slash in FILENAME (or nil if there is none). */
const char *lastslash; const char *lastslash;
@ -225,8 +225,8 @@ pattern_search (struct file *file, int archive,
/* The start and length of the stem of FILENAME for the current rule. */ /* The start and length of the stem of FILENAME for the current rule. */
const char *stem = 0; const char *stem = 0;
unsigned int stemlen = 0; size_t stemlen = 0;
unsigned int fullstemlen = 0; size_t fullstemlen = 0;
/* Buffer in which we store all the rules that are possibly applicable. */ /* Buffer in which we store all the rules that are possibly applicable. */
struct tryrule *tryrules = xmalloc (num_pattern_rules * max_pattern_targets struct tryrule *tryrules = xmalloc (num_pattern_rules * max_pattern_targets
@ -252,7 +252,7 @@ pattern_search (struct file *file, int archive,
struct rule *rule; struct rule *rule;
char *pathdir = NULL; char *pathdir = NULL;
unsigned long pathlen; size_t pathlen;
PATH_VAR (stem_str); /* @@ Need to get rid of stem, stemlen, etc. */ PATH_VAR (stem_str); /* @@ Need to get rid of stem, stemlen, etc. */
@ -573,7 +573,7 @@ pattern_search (struct file *file, int archive,
else else
{ {
int add_dir = 0; int add_dir = 0;
unsigned int len; size_t len;
struct dep **dptr; struct dep **dptr;
nptr = get_next_word (nptr, &len); nptr = get_next_word (nptr, &len);
@ -607,7 +607,7 @@ pattern_search (struct file *file, int archive,
} }
else else
{ {
unsigned int i = p - nptr; size_t i = p - nptr;
memcpy (depname, nptr, i); memcpy (depname, nptr, i);
memcpy (depname + i, "$*", 2); memcpy (depname + i, "$*", 2);
memcpy (depname + i + 2, p + 1, len - i - 1); memcpy (depname + i + 2, p + 1, len - i - 1);
@ -672,7 +672,7 @@ pattern_search (struct file *file, int archive,
if (deps_found > max_deps) if (deps_found > max_deps)
{ {
unsigned int l = pat - deplist; size_t l = pat - deplist;
/* This might have changed due to recursion. */ /* This might have changed due to recursion. */
max_pattern_deps = MAX(max_pattern_deps, deps_found); max_pattern_deps = MAX(max_pattern_deps, deps_found);
max_deps = max_pattern_deps; max_deps = max_pattern_deps;
@ -931,7 +931,7 @@ pattern_search (struct file *file, int archive,
} }
else else
{ {
int dirlen = (lastslash + 1) - filename; size_t dirlen = (lastslash + 1) - filename;
char *sp; char *sp;
/* We want to prepend the directory from /* We want to prepend the directory from

View File

@ -29,10 +29,10 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Default shell to use. */ /* Default shell to use. */
#ifdef WINDOWS32 #ifdef WINDOWS32
#ifdef HAVE_STRINGS_H # ifdef HAVE_STRINGS_H
#include <strings.h> /* for strcasecmp, strncasecmp */ # include <strings.h> /* for strcasecmp, strncasecmp */
#endif # endif
#include <windows.h> # include <windows.h>
const char *default_shell = "sh.exe"; const char *default_shell = "sh.exe";
int no_default_sh_exe = 1; int no_default_sh_exe = 1;
@ -281,7 +281,7 @@ create_batch_file (char const *base, int unixy, int *fd)
launches the next one. */ launches the next one. */
static unsigned uniq = 0; static unsigned uniq = 0;
static int second_loop = 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) if (path_size == 0)
{ {
@ -451,7 +451,7 @@ is_bourne_compatible_shell (const char *path)
for (s = unix_shells; *s != NULL; ++s) for (s = unix_shells; *s != NULL; ++s)
{ {
#if defined(WINDOWS32) || defined(__MSDOS__) #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)) if ((strlen (name) >= len && STOP_SET (name[len], MAP_DOT|MAP_NUL))
&& strncasecmp (name, *s, len) == 0) && strncasecmp (name, *s, len) == 0)
#else #else
@ -2637,7 +2637,7 @@ construct_command_argv_internal (char *line, char **restp, const char *shell,
static const char *sh_chars_sh = "#;\"*?[]&|<>(){}$`^~!"; static const char *sh_chars_sh = "#;\"*?[]&|<>(){}$`^~!";
# endif /* HAVE_DOS_PATHS */ # endif /* HAVE_DOS_PATHS */
#endif #endif
int i; size_t i;
char *p; char *p;
#ifndef NDEBUG #ifndef NDEBUG
char *end; char *end;
@ -3049,9 +3049,9 @@ construct_command_argv_internal (char *line, char **restp, const char *shell,
argument list. */ argument list. */
char *new_line; char *new_line;
unsigned int shell_len = strlen (shell); size_t shell_len = strlen (shell);
unsigned int line_len = strlen (line); size_t line_len = strlen (line);
unsigned int sflags_len = shellflags ? strlen (shellflags) : 0; size_t sflags_len = shellflags ? strlen (shellflags) : 0;
#ifdef WINDOWS32 #ifdef WINDOWS32
char *command_ptr = NULL; /* used for batch_mode_shell mode */ char *command_ptr = NULL; /* used for batch_mode_shell mode */
#endif #endif
@ -3208,7 +3208,7 @@ construct_command_argv_internal (char *line, char **restp, const char *shell,
{ {
const char *s = shellflags; const char *s = shellflags;
char *t; char *t;
unsigned int len; size_t len;
while ((t = find_next_token (&s, &len)) != 0) while ((t = find_next_token (&s, &len)) != 0)
new_argv[n++] = xstrndup (t, len); new_argv[n++] = xstrndup (t, len);
} }

View File

@ -121,7 +121,7 @@ load_object (const floc *flocp, int noerror, const char *ldname,
int int
load_file (const floc *flocp, const char **ldname, int noerror) 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 *new = alloca (nmlen + CSTRLEN (SYMBOL_EXTENSION) + 1);
char *symname = NULL; char *symname = NULL;
char *loaded; char *loaded;
@ -142,7 +142,7 @@ load_file (const floc *flocp, const char **ldname, int noerror)
ep = strchr (fp+1, ')'); ep = strchr (fp+1, ')');
if (ep && ep[1] == '\0') if (ep && ep[1] == '\0')
{ {
int l = fp - *ldname;; size_t l = fp - *ldname;;
++fp; ++fp;
if (fp == ep) if (fp == ep)

View File

@ -41,7 +41,7 @@ gmk_eval (const char *buffer, const gmk_floc *gfloc)
{ {
/* Preserve existing variable buffer context. */ /* Preserve existing variable buffer context. */
char *pbuf; char *pbuf;
unsigned int plen; size_t plen;
char *s; char *s;
floc fl; floc fl;
floc *flp; floc *flp;

View File

@ -105,7 +105,7 @@ static void clean_jobserver (int status);
static void print_data_base (void); static void print_data_base (void);
static void print_version (void); static void print_version (void);
static void decode_switches (int argc, const char **argv, int env); 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 struct variable *define_makeflags (int all, int makefile);
static char *quote_for_env (char *out, const char *in); static char *quote_for_env (char *out, const char *in);
static void initialize_global_hash_tables (void); static void initialize_global_hash_tables (void);
@ -1355,7 +1355,7 @@ main (int argc, char **argv, char **envp)
const char *ep = envp[i]; const char *ep = envp[i];
/* By default, export all variables culled from the environment. */ /* By default, export all variables culled from the environment. */
enum variable_export export = v_export; enum variable_export export = v_export;
unsigned int len; size_t len;
while (! STOP_SET (*ep, MAP_EQUALS)) while (! STOP_SET (*ep, MAP_EQUALS))
++ep; ++ep;
@ -1648,7 +1648,7 @@ main (int argc, char **argv, char **envp)
{ {
struct command_variable *cv; struct command_variable *cv;
struct variable *v; struct variable *v;
unsigned int len = 0; size_t len = 0;
char *value, *p; char *value, *p;
/* Figure out how much space will be taken up by the command-line /* Figure out how much space will be taken up by the command-line
@ -1828,7 +1828,7 @@ main (int argc, char **argv, char **envp)
while (!feof (stdin) && ! ferror (stdin)) while (!feof (stdin) && ! ferror (stdin))
{ {
char buf[2048]; 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) if (n > 0 && fwrite (buf, 1, n, outfile) != n)
pfatal_with_name (_("fwrite (temporary file)")); pfatal_with_name (_("fwrite (temporary file)"));
} }
@ -1925,7 +1925,7 @@ main (int argc, char **argv, char **envp)
{ {
char *p, *value; char *p, *value;
unsigned int i; 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) for (i = 0; i < eval_strings->idx; ++i)
{ {
@ -2646,7 +2646,7 @@ init_switches (void)
long_options[i].flag = 0; long_options[i].flag = 0;
long_options[i].val = switches[i].c; long_options[i].val = switches[i].c;
if (short_option (switches[i].c)) if (short_option (switches[i].c))
*p++ = switches[i].c; *p++ = (char) switches[i].c;
switch (switches[i].type) switch (switches[i].type)
{ {
case flag: case flag:
@ -2769,7 +2769,7 @@ handle_non_switch_argument (const char *arg, int env)
else else
{ {
/* Paste the old and new values together */ /* Paste the old and new values together */
unsigned int oldlen, newlen; size_t oldlen, newlen;
char *vp; char *vp;
oldlen = strlen (gv->value); oldlen = strlen (gv->value);
@ -2890,7 +2890,7 @@ decode_switches (int argc, const char **argv, int env)
const char *op = opt; const char *op = opt;
if (short_option (cs->c)) if (short_option (cs->c))
opt[0] = cs->c; opt[0] = (char) cs->c;
else else
op = cs->long_name; op = cs->long_name;
@ -3013,7 +3013,7 @@ decode_switches (int argc, const char **argv, int env)
decode_switches. */ decode_switches. */
static void 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 *varref = alloca (2 + len + 2);
char *value, *p, *buf; char *value, *p, *buf;
@ -3125,7 +3125,7 @@ define_makeflags (int all, int makefile)
}; };
struct flag *flags = 0; struct flag *flags = 0;
struct flag *last = 0; struct flag *last = 0;
unsigned int flagslen = 0; size_t flagslen = 0;
#define ADD_FLAG(ARG, LEN) \ #define ADD_FLAG(ARG, LEN) \
do { \ do { \
struct flag *new = alloca (sizeof (struct flag)); \ struct flag *new = alloca (sizeof (struct flag)); \
@ -3247,7 +3247,7 @@ define_makeflags (int all, int makefile)
/* Add simple options as a group. */ /* Add simple options as a group. */
while (flags != 0 && !flags->arg && short_option (flags->cs->c)) while (flags != 0 && !flags->arg && short_option (flags->cs->c))
{ {
*p++ = flags->cs->c; *p++ = (char) flags->cs->c;
flags = flags->next; flags = flags->next;
} }
@ -3259,7 +3259,7 @@ define_makeflags (int all, int makefile)
/* Add the flag letter or name to the string. */ /* Add the flag letter or name to the string. */
if (short_option (flags->cs->c)) if (short_option (flags->cs->c))
*p++ = flags->cs->c; *p++ = (char) flags->cs->c;
else else
{ {
/* Long options require a double-dash. */ /* Long options require a double-dash. */

View File

@ -514,12 +514,12 @@ void die (int) __attribute__ ((noreturn));
void pfatal_with_name (const char *) __attribute__ ((noreturn)); void pfatal_with_name (const char *) __attribute__ ((noreturn));
void perror_with_name (const char *, const char *); void perror_with_name (const char *, const char *);
#define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s)) #define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s))
void *xmalloc (unsigned int); void *xmalloc (size_t);
void *xcalloc (unsigned int); void *xcalloc (size_t);
void *xrealloc (void *, unsigned int); void *xrealloc (void *, size_t);
char *xstrdup (const char *); char *xstrdup (const char *);
char *xstrndup (const char *, unsigned int); char *xstrndup (const char *, size_t);
char *find_next_token (const char **, unsigned int *); char *find_next_token (const char **, size_t *);
char *next_token (const char *); char *next_token (const char *);
char *end_of_token (const char *); char *end_of_token (const char *);
void collapse_continuations (char *); void collapse_continuations (char *);
@ -568,7 +568,7 @@ void build_vpath_lists (void);
void construct_vpath_list (char *pattern, char *dirpath); void construct_vpath_list (char *pattern, char *dirpath);
const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr, const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr,
unsigned int* vpath_index, unsigned int* path_index); 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 construct_include_path (const char **arg_dirs);
@ -585,7 +585,7 @@ void strcache_init (void);
void strcache_print_stats (const char *prefix); void strcache_print_stats (const char *prefix);
int strcache_iscached (const char *str); int strcache_iscached (const char *str);
const char *strcache_add (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 */ /* Guile support */
int guile_gmake_setup (const floc *flocp); int guile_gmake_setup (const floc *flocp);
@ -711,7 +711,7 @@ int start_remote_job (char **, char **, int, int *, int *, int *);
int remote_status (int *, int *, int *, int); int remote_status (int *, int *, int *, int);
void block_remote_children (void); void block_remote_children (void);
void unblock_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_variable_data_base (void);
void print_vpath_data_base (void); void print_vpath_data_base (void);

View File

@ -67,7 +67,7 @@ collapse_continuations (char *line)
{ {
char *p = q; char *p = q;
int i; int i;
int out_line_length; size_t out_line_length;
if (q > line && q[-1] == '\\') if (q > line && q[-1] == '\\')
{ {
@ -132,9 +132,9 @@ print_spaces (unsigned int n)
const char * const char *
concat (unsigned int num, ...) concat (unsigned int num, ...)
{ {
static unsigned int rlen = 0; static size_t rlen = 0;
static char *result = NULL; static char *result = NULL;
unsigned int ri = 0; size_t ri = 0;
va_list args; va_list args;
va_start (args, num); va_start (args, num);
@ -142,7 +142,7 @@ concat (unsigned int num, ...)
while (num-- > 0) while (num-- > 0)
{ {
const char *s = va_arg (args, const char *); const char *s = va_arg (args, const char *);
unsigned int l = xstrlen (s); size_t l = xstrlen (s);
if (l == 0) if (l == 0)
continue; continue;
@ -203,7 +203,7 @@ strerror (int errnum)
#undef xstrdup #undef xstrdup
void * void *
xmalloc (unsigned int size) xmalloc (size_t size)
{ {
/* Make sure we don't allocate 0, for pre-ISO implementations. */ /* Make sure we don't allocate 0, for pre-ISO implementations. */
void *result = malloc (size ? size : 1); void *result = malloc (size ? size : 1);
@ -214,7 +214,7 @@ xmalloc (unsigned int size)
void * void *
xcalloc (unsigned int size) xcalloc (size_t size)
{ {
/* Make sure we don't allocate 0, for pre-ISO implementations. */ /* Make sure we don't allocate 0, for pre-ISO implementations. */
void *result = calloc (size ? size : 1, 1); void *result = calloc (size ? size : 1, 1);
@ -225,7 +225,7 @@ xcalloc (unsigned int size)
void * void *
xrealloc (void *ptr, unsigned int size) xrealloc (void *ptr, size_t size)
{ {
void *result; void *result;
@ -263,7 +263,7 @@ xstrdup (const char *ptr)
#endif /* HAVE_DMALLOC_H */ #endif /* HAVE_DMALLOC_H */
char * char *
xstrndup (const char *str, unsigned int length) xstrndup (const char *str, size_t length)
{ {
char *result; char *result;
@ -321,7 +321,7 @@ next_token (const char *s)
of the token, so this function can be called repeatedly in a loop. */ of the token, so this function can be called repeatedly in a loop. */
char * 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); const char *p = next_token (*ptr);

View File

@ -86,7 +86,7 @@ _outputs (struct output *out, int is_err, const char *msg)
else else
{ {
int fd = is_err ? out->err : out->out; int fd = is_err ? out->err : out->out;
int len = strlen (msg); size_t len = strlen (msg);
int r; int r;
EINTRLOOP (r, lseek (fd, 0, SEEK_END)); EINTRLOOP (r, lseek (fd, 0, SEEK_END));
output_write (fd, msg, len); output_write (fd, msg, len);
@ -100,8 +100,8 @@ static int
log_working_directory (int entering) log_working_directory (int entering)
{ {
static char *buf = NULL; static char *buf = NULL;
static unsigned int len = 0; static size_t len = 0;
unsigned int need; size_t need;
const char *fmt; const char *fmt;
char *p; char *p;

View File

@ -51,7 +51,7 @@ struct ebuffer
char *buffer; /* Start of the current line in the buffer. */ char *buffer; /* Start of the current line in the buffer. */
char *bufnext; /* Start of the next line in the buffer. */ char *bufnext; /* Start of the next line in the buffer. */
char *bufstart; /* Start of the entire 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. */ FILE *fp; /* File, or NULL if this is an internal buffer. */
floc floc; /* Info on the file in fp (if any). */ floc floc; /* Info on the file in fp (if any). */
}; };
@ -122,7 +122,7 @@ static const char **include_directories;
/* Maximum length of an element of the above. */ /* 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 /* The filename and pointer to line number of the
makefile currently being read in. */ makefile currently being read in. */
@ -133,7 +133,7 @@ const floc *reading_file = 0;
static struct goaldep *read_files = 0; 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 void eval (struct ebuffer *buffer, int flags);
static long readline (struct ebuffer *ebuf); static long readline (struct ebuffer *ebuf);
@ -141,18 +141,18 @@ static void do_undefine (char *name, enum variable_origin origin,
struct ebuffer *ebuf); struct ebuffer *ebuf);
static struct variable *do_define (char *name, enum variable_origin origin, static struct variable *do_define (char *name, enum variable_origin origin,
struct ebuffer *ebuf); 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, static void record_files (struct nameseq *filenames, const char *pattern,
const char *pattern_percent, char *depstr, const char *pattern_percent, char *depstr,
unsigned int cmds_started, char *commands, 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); char prefix, const floc *flocp);
static void record_target_var (struct nameseq *filenames, char *defn, static void record_target_var (struct nameseq *filenames, char *defn,
enum variable_origin origin, enum variable_origin origin,
struct vmodifiers *vmod, struct vmodifiers *vmod,
const floc *flocp); const floc *flocp);
static enum make_word_type get_next_mword (char *buffer, char *delim, 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 void remove_comments (char *line);
static char *find_map_unquote (char *string, int map); static char *find_map_unquote (char *string, int map);
static char *find_char_unquote (char *string, int stop); static char *find_char_unquote (char *string, int stop);
@ -186,7 +186,7 @@ read_all_makefiles (const char **makefiles)
{ {
char *value; char *value;
char *name, *p; char *name, *p;
unsigned int length; size_t length;
{ {
/* Turn off --warn-undefined-variables while we expand MAKEFILES. */ /* Turn off --warn-undefined-variables while we expand MAKEFILES. */
@ -314,7 +314,7 @@ restore_conditionals (struct conditionals *saved)
} }
static struct goaldep * static struct goaldep *
eval_makefile (const char *filename, int flags) eval_makefile (const char *filename, unsigned short flags)
{ {
struct goaldep *deps; struct goaldep *deps;
struct ebuffer ebuf; struct ebuffer ebuf;
@ -504,12 +504,12 @@ parse_var_assignment (const char *line, struct vmodifiers *vmod)
/* Find the start of the next token. If there isn't one we're done. */ /* Find the start of the next token. If there isn't one we're done. */
NEXT_TOKEN (line); NEXT_TOKEN (line);
if (*line == '\0') if (*line == '\0')
return (char *)line; return (char *) line;
p = line; p = line;
while (1) while (1)
{ {
int wlen; size_t wlen;
const char *p2; const char *p2;
struct variable v; struct variable v;
@ -545,12 +545,12 @@ parse_var_assignment (const char *line, struct vmodifiers *vmod)
} }
else else
/* Not a variable or modifier: this is not a variable assignment. */ /* 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. */ /* It was a modifier. Try the next word. */
p = next_token (p2); p = next_token (p2);
if (*p == '\0') if (*p == '\0')
return (char *)line; return (char *) line;
} }
/* Found a variable assignment or undefine. */ /* Found a variable assignment or undefine. */
@ -567,10 +567,10 @@ static void
eval (struct ebuffer *ebuf, int set_default) eval (struct ebuffer *ebuf, int set_default)
{ {
char *collapsed = 0; char *collapsed = 0;
unsigned int collapsed_length = 0; size_t collapsed_length = 0;
unsigned int commands_len = 200; size_t commands_len = 200;
char *commands; char *commands;
unsigned int commands_idx = 0; size_t commands_idx = 0;
unsigned int cmds_started, tgts_started; unsigned int cmds_started, tgts_started;
int ignoring = 0, in_ignored_define = 0; int ignoring = 0, in_ignored_define = 0;
int no_targets = 0; /* Set when reading a rule without targets. */ int no_targets = 0; /* Set when reading a rule without targets. */
@ -620,9 +620,9 @@ eval (struct ebuffer *ebuf, int set_default)
while (1) while (1)
{ {
unsigned int linelen; size_t linelen;
char *line; char *line;
unsigned int wlen; size_t wlen;
char *p; char *p;
char *p2; char *p2;
struct vmodifiers vmod; struct vmodifiers vmod;
@ -639,20 +639,22 @@ eval (struct ebuffer *ebuf, int set_default)
line = ebuf->buffer; line = ebuf->buffer;
/* If this is the first line, check for a UTF-8 BOM and skip it. */ /* If this is the first line, check for a UTF-8 BOM and skip it. */
if (ebuf->floc.lineno == 1 && line[0] == (char)0xEF if (ebuf->floc.lineno == 1)
&& line[1] == (char)0xBB && line[2] == (char)0xBF)
{ {
line += 3; unsigned char *ul = (unsigned char *) line;
if (ISDB(DB_BASIC)) if (ul[0] == 0xEF && ul[1] == 0xBB && ul[2] == 0xBF)
{ {
if (ebuf->floc.filenm) line += 3;
printf (_("Skipping UTF-8 BOM in makefile '%s'\n"), if (ISDB(DB_BASIC))
ebuf->floc.filenm); {
else if (ebuf->floc.filenm)
printf (_("Skipping UTF-8 BOM in makefile buffer\n")); 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 this line is empty, skip it. */
if (line[0] == '\0') if (line[0] == '\0')
continue; continue;
@ -803,7 +805,7 @@ eval (struct ebuffer *ebuf, int set_default)
export_all_variables = exporting; export_all_variables = exporting;
else else
{ {
unsigned int l; size_t l;
const char *cp; const char *cp;
char *ap; char *ap;
@ -830,7 +832,7 @@ eval (struct ebuffer *ebuf, int set_default)
{ {
const char *cp; const char *cp;
char *vpat; char *vpat;
unsigned int l; size_t l;
/* vpath ends the previous rule. */ /* vpath ends the previous rule. */
record_waiting_files (); record_waiting_files ();
@ -895,9 +897,9 @@ eval (struct ebuffer *ebuf, int set_default)
while (files != 0) while (files != 0)
{ {
struct nameseq *next = files->next; struct nameseq *next = files->next;
int flags = (RM_INCLUDED | RM_NO_TILDE unsigned short flags = (RM_INCLUDED | RM_NO_TILDE
| (noerror ? RM_DONTCARE : 0) | (noerror ? RM_DONTCARE : 0)
| (set_default ? 0 : RM_NO_DEFAULT_GOAL)); | (set_default ? 0 : RM_NO_DEFAULT_GOAL));
struct goaldep *d = eval_makefile (files->name, flags); struct goaldep *d = eval_makefile (files->name, flags);
@ -992,7 +994,7 @@ eval (struct ebuffer *ebuf, int set_default)
{ {
enum make_word_type wtype; enum make_word_type wtype;
char *cmdleft, *semip, *lb_next; char *cmdleft, *semip, *lb_next;
unsigned int plen = 0; size_t plen = 0;
char *colonp; char *colonp;
const char *end, *beg; /* Helpers for whitespace stripping. */ const char *end, *beg; /* Helpers for whitespace stripping. */
@ -1054,8 +1056,8 @@ eval (struct ebuffer *ebuf, int set_default)
if (cmdleft != 0) if (cmdleft != 0)
{ {
unsigned long p2_off = p2 - variable_buffer; size_t p2_off = p2 - variable_buffer;
unsigned long cmd_off = cmdleft - variable_buffer; size_t cmd_off = cmdleft - variable_buffer;
char *pend = p2 + strlen (p2); char *pend = p2 + strlen (p2);
/* Append any remnants of lb, then cut the line short /* Append any remnants of lb, then cut the line short
@ -1070,7 +1072,7 @@ eval (struct ebuffer *ebuf, int set_default)
entirely consistent, since we do an unconditional entirely consistent, since we do an unconditional
expand below once we know we don't have a expand below once we know we don't have a
target-specific variable. */ 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); lb_next += strlen (lb_next);
p2 = variable_buffer + p2_off; p2 = variable_buffer + p2_off;
cmdleft = variable_buffer + cmd_off + 1; cmdleft = variable_buffer + cmd_off + 1;
@ -1150,7 +1152,7 @@ eval (struct ebuffer *ebuf, int set_default)
of the unparsed section of p2, for later. */ of the unparsed section of p2, for later. */
if (*lb_next != '\0') if (*lb_next != '\0')
{ {
unsigned int l = p2 - variable_buffer; size_t l = p2 - variable_buffer;
plen = strlen (p2); plen = strlen (p2);
variable_buffer_output (p2+plen, lb_next, strlen (lb_next)+1); variable_buffer_output (p2+plen, lb_next, strlen (lb_next)+1);
p2 = variable_buffer + l; p2 = variable_buffer + l;
@ -1163,7 +1165,7 @@ eval (struct ebuffer *ebuf, int set_default)
after it. */ after it. */
if (semip) if (semip)
{ {
unsigned int l = p2 - variable_buffer; size_t l = p2 - variable_buffer;
*(--semip) = ';'; *(--semip) = ';';
collapse_continuations (semip); collapse_continuations (semip);
variable_buffer_output (p2 + strlen (p2), variable_buffer_output (p2 + strlen (p2),
@ -1190,8 +1192,8 @@ eval (struct ebuffer *ebuf, int set_default)
/* Expand the dependencies, etc. */ /* Expand the dependencies, etc. */
if (*lb_next != '\0') if (*lb_next != '\0')
{ {
unsigned int l = p2 - variable_buffer; size_t l = p2 - variable_buffer;
(void) variable_expand_string (p2 + plen, lb_next, (long)-1); variable_expand_string (p2 + plen, lb_next, SIZE_MAX);
p2 = variable_buffer + l; p2 = variable_buffer + l;
/* Look for a semicolon in the expanded line. */ /* Look for a semicolon in the expanded line. */
@ -1281,7 +1283,7 @@ eval (struct ebuffer *ebuf, int set_default)
if (cmdleft != 0) if (cmdleft != 0)
{ {
/* Semicolon means rest of line is a command. */ /* Semicolon means rest of line is a command. */
unsigned int l = strlen (cmdleft); size_t l = strlen (cmdleft);
cmds_started = fstart->lineno; cmds_started = fstart->lineno;
@ -1347,7 +1349,7 @@ eval (struct ebuffer *ebuf, int set_default)
} }
for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next) 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)) if (!strneq (name, dep_name (d2), l))
continue; continue;
if (streq (name + l, dep_name (d))) if (streq (name + l, dep_name (d)))
@ -1442,9 +1444,9 @@ do_define (char *name, enum variable_origin origin, struct ebuffer *ebuf)
struct variable var; struct variable var;
floc defstart; floc defstart;
int nlevels = 1; int nlevels = 1;
unsigned int length = 100; size_t length = 100;
char *definition = xmalloc (length); char *definition = xmalloc (length);
unsigned int idx = 0; size_t idx = 0;
char *p, *n; char *p, *n;
defstart = ebuf->floc; defstart = ebuf->floc;
@ -1475,7 +1477,7 @@ do_define (char *name, enum variable_origin origin, struct ebuffer *ebuf)
/* Now read the value of the variable. */ /* Now read the value of the variable. */
while (1) while (1)
{ {
unsigned int len; size_t len;
char *line; char *line;
long nlines = readline (ebuf); long nlines = readline (ebuf);
@ -1556,7 +1558,7 @@ do_define (char *name, enum variable_origin origin, struct ebuffer *ebuf)
1 if following text should be ignored. */ 1 if following text should be ignored. */
static int static int
conditional_line (char *line, int len, const floc *flocp) conditional_line (char *line, size_t len, const floc *flocp)
{ {
const char *cmdname; const char *cmdname;
enum { c_ifdef, c_ifndef, c_ifeq, c_ifneq, c_else, c_endif } cmdtype; enum { c_ifdef, c_ifndef, c_ifeq, c_ifneq, c_else, c_endif } cmdtype;
@ -1689,6 +1691,7 @@ conditional_line (char *line, int len, const floc *flocp)
if (cmdtype == c_ifdef || cmdtype == c_ifndef) if (cmdtype == c_ifdef || cmdtype == c_ifndef)
{ {
size_t l;
char *var; char *var;
struct variable *v; struct variable *v;
char *p; char *p;
@ -1699,13 +1702,13 @@ conditional_line (char *line, int len, const floc *flocp)
/* Make sure there's only one variable name to test. */ /* Make sure there's only one variable name to test. */
p = end_of_token (var); p = end_of_token (var);
i = p - var; l = p - var;
NEXT_TOKEN (p); NEXT_TOKEN (p);
if (*p != '\0') if (*p != '\0')
return -1; return -1;
var[i] = '\0'; var[l] = '\0';
v = lookup_variable (var, i); v = lookup_variable (var, l);
conditionals->ignoring[o] = conditionals->ignoring[o] =
((v != 0 && *v->value != '\0') == (cmdtype == c_ifndef)); ((v != 0 && *v->value != '\0') == (cmdtype == c_ifndef));
@ -1716,7 +1719,7 @@ conditional_line (char *line, int len, const floc *flocp)
{ {
/* "ifeq" or "ifneq". */ /* "ifeq" or "ifneq". */
char *s1, *s2; char *s1, *s2;
unsigned int l; size_t l;
char termin = *line == '(' ? ',' : *line; char termin = *line == '(' ? ',' : *line;
if (termin != ',' && termin != '"' && termin != '\'') if (termin != ',' && termin != '"' && termin != '\'')
@ -1899,7 +1902,7 @@ record_target_var (struct nameseq *filenames, char *defn,
if (v->origin != o_override) if (v->origin != o_override)
{ {
struct variable *gv; struct variable *gv;
int len = strlen (v->name); size_t len = strlen (v->name);
gv = lookup_variable (v->name, len); gv = lookup_variable (v->name, len);
if (gv && v != gv if (gv && v != gv
@ -1930,7 +1933,7 @@ static void
record_files (struct nameseq *filenames, const char *pattern, record_files (struct nameseq *filenames, const char *pattern,
const char *pattern_percent, char *depstr, const char *pattern_percent, char *depstr,
unsigned int cmds_started, char *commands, 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) char prefix, const floc *flocp)
{ {
struct commands *cmds; struct commands *cmds;
@ -1999,7 +2002,7 @@ record_files (struct nameseq *filenames, const char *pattern,
{ {
struct nameseq *nextf; struct nameseq *nextf;
const char **targets, **target_pats; const char **targets, **target_pats;
unsigned int c; unsigned short c;
if (pattern != 0) if (pattern != 0)
O (fatal, flocp, _("mixed implicit and static pattern rules")); O (fatal, flocp, _("mixed implicit and static pattern rules"));
@ -2234,7 +2237,7 @@ record_files (struct nameseq *filenames, const char *pattern,
static char * static char *
find_map_unquote (char *string, int stopmap) find_map_unquote (char *string, int stopmap)
{ {
unsigned int string_len = 0; size_t string_len = 0;
char *p = string; char *p = string;
/* Always stop on NUL. */ /* Always stop on NUL. */
@ -2316,7 +2319,7 @@ find_map_unquote (char *string, int stopmap)
static char * static char *
find_char_unquote (char *string, int stop) find_char_unquote (char *string, int stop)
{ {
unsigned int string_len = 0; size_t string_len = 0;
char *p = string; char *p = string;
while (1) while (1)
@ -2366,7 +2369,7 @@ unescape_char (char *string, int c)
if (*s == '\\') if (*s == '\\')
{ {
char *e = s; char *e = s;
int l; size_t l;
/* We found a backslash. See if it's escaping our character. */ /* We found a backslash. See if it's escaping our character. */
while (*e == '\\') while (*e == '\\')
@ -2420,7 +2423,7 @@ find_percent_cached (const char **string)
{ {
const char *p = *string; const char *p = *string;
char *new = 0; char *new = 0;
int slen = 0; size_t slen = 0;
/* If the first char is a % return now. This lets us avoid extra tests /* If the first char is a % return now. This lets us avoid extra tests
inside the loop. */ inside the loop. */
@ -2478,7 +2481,7 @@ find_percent_cached (const char **string)
{ {
*string = strcache_add (*string); *string = strcache_add (*string);
if (p) if (p)
p = *string + (p - new); p = *string + (p - new);
} }
/* If we didn't find a %, return NULL. Otherwise return a ptr to it. */ /* If we didn't find a %, return NULL. Otherwise return a ptr to it. */
@ -2562,10 +2565,10 @@ readline (struct ebuffer *ebuf)
end = p + ebuf->size; end = p + ebuf->size;
*p = '\0'; *p = '\0';
while (fgets (p, (int)(end - p), ebuf->fp) != 0) while (fgets (p, (int) (end - p), ebuf->fp) != 0)
{ {
char *p2; char *p2;
unsigned long len; size_t len;
int backslash; int backslash;
len = strlen (p); len = strlen (p);
@ -2626,7 +2629,7 @@ readline (struct ebuffer *ebuf)
Make sure to preserve the current offset of p. */ Make sure to preserve the current offset of p. */
more_buffer: more_buffer:
{ {
unsigned long off = p - start; size_t off = p - start;
ebuf->size *= 2; ebuf->size *= 2;
start = ebuf->buffer = ebuf->bufstart = xrealloc (start, ebuf->size); start = ebuf->buffer = ebuf->bufstart = xrealloc (start, ebuf->size);
p = start + off; p = start + off;
@ -2665,7 +2668,7 @@ readline (struct ebuffer *ebuf)
in a command list, etc.) */ in a command list, etc.) */
static enum make_word_type 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; enum make_word_type wtype;
char *p = buffer, *beg; char *p = buffer, *beg;
@ -2847,7 +2850,7 @@ construct_include_path (const char **arg_dirs)
#endif #endif
const char **dirs; const char **dirs;
const char **cpp; const char **cpp;
unsigned int idx; size_t idx;
/* Compute the number of pointers we need in the table. */ /* Compute the number of pointers we need in the table. */
idx = sizeof (default_include_directories) / sizeof (const char *); idx = sizeof (default_include_directories) / sizeof (const char *);
@ -2885,7 +2888,7 @@ construct_include_path (const char **arg_dirs)
EINTRLOOP (e, stat (dir, &stbuf)); EINTRLOOP (e, stat (dir, &stbuf));
if (e == 0 && S_ISDIR (stbuf.st_mode)) 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. */ /* If dir name is written with trailing slashes, discard them. */
while (len > 1 && dir[len - 1] == '/') while (len > 1 && dir[len - 1] == '/')
--len; --len;
@ -2907,7 +2910,7 @@ construct_include_path (const char **arg_dirs)
if (djdir) if (djdir)
{ {
unsigned int len = strlen (djdir->value) + 8; size_t len = strlen (djdir->value) + 8;
char *defdir = alloca (len + 1); char *defdir = alloca (len + 1);
strcat (strcpy (defdir, djdir->value), "/include"); strcat (strcpy (defdir, djdir->value), "/include");
@ -2926,7 +2929,7 @@ construct_include_path (const char **arg_dirs)
EINTRLOOP (e, stat (*cpp, &stbuf)); EINTRLOOP (e, stat (*cpp, &stbuf));
if (e == 0 && S_ISDIR (stbuf.st_mode)) 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. */ /* If dir name is written with trailing slashes, discard them. */
while (len > 1 && (*cpp)[len - 1] == '/') while (len > 1 && (*cpp)[len - 1] == '/')
--len; --len;
@ -3043,7 +3046,7 @@ tilde_expand (const char *name)
*/ */
void * 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) const char *prefix, int flags)
{ {
/* tmp points to tmpbuf after the prefix, if any. /* tmp points to tmpbuf after the prefix, if any.
@ -3077,8 +3080,8 @@ parse_file_seq (char **stringp, unsigned int size, int stopmap,
/* Get enough temporary space to construct the largest possible target. */ /* Get enough temporary space to construct the largest possible target. */
{ {
static int tmpbuf_len = 0; static size_t tmpbuf_len = 0;
int l = strlen (*stringp) + 1; size_t l = strlen (*stringp) + 1;
if (l > tmpbuf_len) if (l > tmpbuf_len)
{ {
tmpbuf = xrealloc (tmpbuf, l); tmpbuf = xrealloc (tmpbuf, l);
@ -3100,7 +3103,7 @@ parse_file_seq (char **stringp, unsigned int size, int stopmap,
char *memname = 0; char *memname = 0;
#endif #endif
char *s; char *s;
int nlen; size_t nlen;
int i; int i;
/* Skip whitespace; at the end of the string or STOPCHAR we're done. */ /* Skip whitespace; at the end of the string or STOPCHAR we're done. */

View File

@ -1255,7 +1255,7 @@ FILE_TIMESTAMP
f_mtime (struct file *file, int search) f_mtime (struct file *file, int search)
{ {
FILE_TIMESTAMP mtime; FILE_TIMESTAMP mtime;
int propagate_timestamp; unsigned int propagate_timestamp;
/* File's mtime is not known; must get it from the system. */ /* File's mtime is not known; must get it from the system. */
@ -1284,7 +1284,7 @@ f_mtime (struct file *file, int search)
Change the archive-member reference accordingly. */ Change the archive-member reference accordingly. */
char *name; char *name;
unsigned int arlen, memlen; size_t arlen, memlen;
arlen = strlen (arfile->hname); arlen = strlen (arfile->hname);
memlen = strlen (memname); memlen = strlen (memname);
@ -1332,7 +1332,7 @@ f_mtime (struct file *file, int search)
|| (file->name[0] == '-' && file->name[1] == 'l' || (file->name[0] == '-' && file->name[1] == 'l'
&& (name = library_search (file->name, &mtime)) != 0)) && (name = library_search (file->name, &mtime)) != 0))
{ {
int name_len; size_t name_len;
if (mtime != UNKNOWN_MTIME) if (mtime != UNKNOWN_MTIME)
/* vpath_search and library_search store UNKNOWN_MTIME /* vpath_search and library_search store UNKNOWN_MTIME
@ -1480,29 +1480,29 @@ name_mtime (const char *name)
succeeds ONLY if "foo" is a directory. */ succeeds ONLY if "foo" is a directory. */
if (p > name) if (p > name)
{ {
memcpy (tem, name, p - name + 1); memcpy (tem, name, p - name + 1);
tstart = tem; tstart = tem;
if (tstart[1] == ':') if (tstart[1] == ':')
tstart += 2; tstart += 2;
tend = tem + (p - name - 1); tend = tem + (p - name - 1);
if (*tend == '.' && tend > tstart) if (*tend == '.' && tend > tstart)
tend--; tend--;
if (*tend == '.' && tend > tstart) if (*tend == '.' && tend > tstart)
tend--; tend--;
for ( ; tend > tstart && (*tend == '/' || *tend == '\\'); tend--) for ( ; tend > tstart && (*tend == '/' || *tend == '\\'); tend--)
*tend = '\0'; *tend = '\0';
} }
else else
{ {
tem[0] = '\0'; tem[0] = '\0';
tend = &tem[0]; tend = &tem[0];
} }
e = stat (tem, &st); e = stat (tem, &st);
if (e == 0 && !_S_ISDIR (st.st_mode) && tend < tem + (p - name - 1)) if (e == 0 && !_S_ISDIR (st.st_mode) && tend < tem + (p - name - 1))
{ {
errno = ENOTDIR; errno = ENOTDIR;
e = -1; e = -1;
} }
} }
#else #else
@ -1622,8 +1622,8 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
/* Loop variables for the libpatterns value. */ /* Loop variables for the libpatterns value. */
char *p; char *p;
const char *p2; const char *p2;
unsigned int len; size_t len;
unsigned int liblen; size_t liblen;
/* Information about the earliest (in the vpath sequence) match. */ /* Information about the earliest (in the vpath sequence) match. */
unsigned int best_vpath = 0, best_path = 0; unsigned int best_vpath = 0, best_path = 0;
@ -1643,8 +1643,8 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
while ((p = find_next_token (&p2, &len)) != 0) while ((p = find_next_token (&p2, &len)) != 0)
{ {
static char *buf = NULL; static char *buf = NULL;
static unsigned int buflen = 0; static size_t buflen = 0;
static int libdir_maxlen = -1; static size_t libdir_maxlen = 0;
static unsigned int std_dirs = 0; static unsigned int std_dirs = 0;
char *libbuf = variable_expand (""); char *libbuf = variable_expand ("");
@ -1709,7 +1709,7 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
{ {
for (dp = dirs; *dp != 0; ++dp) for (dp = dirs; *dp != 0; ++dp)
{ {
int l = strlen (*dp); size_t l = strlen (*dp);
if (l > libdir_maxlen) if (l > libdir_maxlen)
libdir_maxlen = l; libdir_maxlen = l;
std_dirs++; std_dirs++;

View File

@ -294,7 +294,7 @@ unblock_remote_children (void)
/* Send signal SIG to child ID. Return 0 if successful, -1 if not. */ /* Send signal SIG to child ID. Return 0 if successful, -1 if not. */
int int
remote_kill (int id, int sig) remote_kill (pid_t id, int sig)
{ {
return -1; return -1;
} }

View File

@ -93,7 +93,7 @@ unblock_remote_children (void)
/* Send signal SIG to child ID. Return 0 if successful, -1 if not. */ /* Send signal SIG to child ID. Return 0 if successful, -1 if not. */
int int
remote_kill (int id UNUSED, int sig UNUSED) remote_kill (pid_t id UNUSED, int sig UNUSED)
{ {
return -1; return -1;
} }

View File

@ -49,7 +49,7 @@ unsigned int max_pattern_deps;
/* Maximum length of the name of a dependencies of any pattern rule. */ /* 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 /* Pointer to structure for the file .SUFFIXES
whose dependencies are the suffixes to be searched. */ whose dependencies are the suffixes to be searched. */
@ -58,7 +58,7 @@ struct file *suffix_file;
/* Maximum length of a suffix. */ /* Maximum length of a suffix. */
unsigned int maxsuffix; static size_t maxsuffix;
/* Compute the maximum dependency length and maximum number of /* Compute the maximum dependency length and maximum number of
dependencies of all implicit rules. Also sets the subdir dependencies of all implicit rules. Also sets the subdir
@ -69,7 +69,7 @@ void
count_implicit_rule_limits (void) count_implicit_rule_limits (void)
{ {
char *name; char *name;
int namelen; size_t namelen;
struct rule *rule; struct rule *rule;
num_pattern_rules = max_pattern_targets = max_pattern_deps = 0; num_pattern_rules = max_pattern_targets = max_pattern_deps = 0;
@ -92,7 +92,7 @@ count_implicit_rule_limits (void)
for (dep = rule->deps; dep != 0; dep = dep->next) for (dep = rule->deps; dep != 0; dep = dep->next)
{ {
const char *dname = dep_name (dep); const char *dname = dep_name (dep);
unsigned int len = strlen (dname); size_t len = strlen (dname);
#ifdef VMS #ifdef VMS
const char *p = strrchr (dname, ']'); const char *p = strrchr (dname, ']');
@ -115,7 +115,7 @@ count_implicit_rule_limits (void)
Extract the directory name. */ Extract the directory name. */
if (p == dname) if (p == dname)
++p; ++p;
if (p - dname > namelen) if ((size_t) (p - dname) > namelen)
{ {
namelen = p - dname; namelen = p - dname;
name = xrealloc (name, namelen + 1); name = xrealloc (name, namelen + 1);
@ -173,7 +173,7 @@ convert_suffix_rule (const char *target, const char *source,
else else
{ {
/* Construct the target name. */ /* Construct the target name. */
unsigned int len = strlen (target); size_t len = strlen (target);
char *p = alloca (1 + len + 1); char *p = alloca (1 + len + 1);
p[0] = '%'; p[0] = '%';
memcpy (p + 1, target, len + 1); memcpy (p + 1, target, len + 1);
@ -186,7 +186,7 @@ convert_suffix_rule (const char *target, const char *source,
else else
{ {
/* Construct the dependency name. */ /* Construct the dependency name. */
unsigned int len = strlen (source); size_t len = strlen (source);
char *p = alloca (1 + len + 1); char *p = alloca (1 + len + 1);
p[0] = '%'; p[0] = '%';
memcpy (p + 1, source, len + 1); memcpy (p + 1, source, len + 1);
@ -214,7 +214,7 @@ convert_to_pattern (void)
maxsuffix = 0; maxsuffix = 0;
for (d = suffix_file->deps; d != 0; d = d->next) 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) if (l > maxsuffix)
maxsuffix = l; maxsuffix = l;
} }
@ -224,7 +224,7 @@ convert_to_pattern (void)
for (d = suffix_file->deps; d != 0; d = d->next) 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. /* Make a rule that is just the suffix, with no deps or commands.
This rule exists solely to disqualify match-anything rules. */ This rule exists solely to disqualify match-anything rules. */
@ -242,7 +242,7 @@ convert_to_pattern (void)
for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next) for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)
{ {
struct file *f; struct file *f;
unsigned int s2len; size_t s2len;
s2len = strlen (dep_name (d2)); s2len = strlen (dep_name (d2));
@ -365,7 +365,7 @@ install_pattern_rule (struct pspec *p, int terminal)
r->suffixes = xmalloc (sizeof (const char *)); r->suffixes = xmalloc (sizeof (const char *));
r->lens = xmalloc (sizeof (unsigned int)); 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->targets[0] = p->target;
r->suffixes[0] = find_percent_cached (&r->targets[0]); r->suffixes[0] = find_percent_cached (&r->targets[0]);
assert (r->suffixes[0] != NULL); assert (r->suffixes[0] != NULL);
@ -376,7 +376,7 @@ install_pattern_rule (struct pspec *p, int terminal)
if (new_pattern_rule (r, 0)) if (new_pattern_rule (r, 0))
{ {
r->terminal = terminal; r->terminal = terminal ? 1 : 0;
r->cmds = xmalloc (sizeof (struct commands)); r->cmds = xmalloc (sizeof (struct commands));
r->cmds->fileinfo.filenm = 0; r->cmds->fileinfo.filenm = 0;
r->cmds->fileinfo.lineno = 0; r->cmds->fileinfo.lineno = 0;
@ -442,7 +442,7 @@ freerule (struct rule *rule, struct rule *lastrule)
void void
create_pattern_rule (const char **targets, const char **target_percents, 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) struct commands *commands, int override)
{ {
unsigned int i; unsigned int i;
@ -457,13 +457,13 @@ create_pattern_rule (const char **targets, const char **target_percents,
for (i = 0; i < n; ++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); assert (r->suffixes[i] != NULL);
++r->suffixes[i]; ++r->suffixes[i];
} }
if (new_pattern_rule (r, override)) if (new_pattern_rule (r, override))
r->terminal = terminal; r->terminal = terminal ? 1 : 0;
} }
/* Print the data base of rules. */ /* Print the data base of rules. */

View File

@ -43,16 +43,15 @@ extern unsigned int num_pattern_rules;
extern unsigned int max_pattern_deps; extern unsigned int max_pattern_deps;
extern unsigned int max_pattern_targets; 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 struct file *suffix_file;
extern unsigned int maxsuffix;
void count_implicit_rule_limits (void); void count_implicit_rule_limits (void);
void convert_to_pattern (void); void convert_to_pattern (void);
void install_pattern_rule (struct pspec *p, int terminal); void install_pattern_rule (struct pspec *p, int terminal);
void create_pattern_rule (const char **targets, const char **target_percents, 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); struct commands *commands, int override);
void print_rule_data_base (void); void print_rule_data_base (void);

View File

@ -237,7 +237,7 @@ strsignal (int sig)
# elif HAVE_DECL___SYS_SIGLIST # elif HAVE_DECL___SYS_SIGLIST
# define sys_siglist __sys_siglist # define sys_siglist __sys_siglist
# else # else
static char sig_initted = 0; static int sig_initted = 0;
if (!sig_initted) if (!sig_initted)
sig_initted = signame_init (); sig_initted = signame_init ();

View File

@ -72,7 +72,7 @@ new_cache (struct strcache **head, sc_buflen_t buflen)
} }
static const char * 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. */ /* Add the string to this cache. */
char *res = &sp->buffer[sp->end]; char *res = &sp->buffer[sp->end];
@ -87,13 +87,13 @@ copy_string (struct strcache *sp, const char *str, unsigned int len)
} }
static const char * static const char *
add_string (const char *str, unsigned int len) add_string (const char *str, sc_buflen_t len)
{ {
const char *res; const char *res;
struct strcache *sp; struct strcache *sp;
struct strcache **spp = &strcache; struct strcache **spp = &strcache;
/* We need space for the nul char. */ /* We need space for the nul char. */
unsigned int sz = len + 1; sc_buflen_t sz = len + 1;
++total_strings; ++total_strings;
total_size += sz; total_size += sz;
@ -143,7 +143,7 @@ struct hugestring {
static struct hugestring *hugestrings = NULL; static struct hugestring *hugestrings = NULL;
static const char * 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); struct hugestring *new = xmalloc (sizeof (struct hugestring) + len);
memcpy (new->buffer, str, len); memcpy (new->buffer, str, len);
@ -179,7 +179,7 @@ static struct hash_table strings;
static unsigned long total_adds = 0; static unsigned long total_adds = 0;
static const char * static const char *
add_hash (const char *str, unsigned int len) add_hash (const char *str, size_t len)
{ {
char *const *slot; char *const *slot;
const char *key; const char *key;
@ -200,7 +200,7 @@ add_hash (const char *str, unsigned int len)
return key; return key;
/* Not there yet so add it to a buffer, then into the hash table. */ /* 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); hash_insert_at (&strings, key, slot);
return key; return key;
} }
@ -238,7 +238,7 @@ strcache_add (const char *str)
} }
const char * 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 /* If we're not given a nul-terminated string we have to create one, because
the hashing functions expect it. */ the hashing functions expect it. */
@ -305,16 +305,16 @@ strcache_print_stats (const char *prefix)
prefix, numbuffs + 1, fullbuffs, total_strings, total_size, prefix, numbuffs + 1, fullbuffs, total_strings, total_size,
(total_size / total_strings)); (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, prefix, (sc_buflen_t)BUFSIZE, strcache->end, strcache->count,
(strcache->end / strcache->count)); (unsigned int) (strcache->end / strcache->count));
if (numbuffs) if (numbuffs)
{ {
/* Show information about non-current buffers. */ /* Show information about non-current buffers. */
unsigned long sz = total_size - strcache->end; unsigned long sz = total_size - strcache->end;
unsigned long cnt = total_strings - strcache->count; 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"), printf (_("%s other used: total = %lu B / count = %lu / avg = %lu B\n"),
prefix, sz, cnt, sz / cnt); prefix, sz, cnt, sz / cnt);

View File

@ -50,7 +50,7 @@ static struct pattern_var *last_pattern_vars[256];
struct pattern_var * struct pattern_var *
create_pattern_var (const char *target, const char *suffix) 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)); struct pattern_var *p = xcalloc (sizeof (struct pattern_var));
if (pattern_vars != 0) if (pattern_vars != 0)
@ -101,12 +101,12 @@ static struct pattern_var *
lookup_pattern_var (struct pattern_var *start, const char *target) lookup_pattern_var (struct pattern_var *start, const char *target)
{ {
struct pattern_var *p; 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) for (p = start ? start->next : pattern_vars; p != 0; p = p->next)
{ {
const char *stem; const char *stem;
unsigned int stemlen; size_t stemlen;
if (p->len > targlen) if (p->len > targlen)
/* It can't possibly match. */ /* It can't possibly match. */
@ -193,7 +193,7 @@ init_hash_global_variable_set (void)
that it should be recursively re-expanded. */ that it should be recursively re-expanded. */
struct variable * 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, const char *value, enum variable_origin origin,
int recursive, struct variable_set *set, int recursive, struct variable_set *set,
const floc *flocp) const floc *flocp)
@ -206,7 +206,7 @@ define_variable_in_set (const char *name, unsigned int length,
set = &global_variable_set; set = &global_variable_set;
var_key.name = (char *) name; 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); var_slot = (struct variable **) hash_find_slot (&set->table, &var_key);
v = *var_slot; v = *var_slot;
@ -269,7 +269,7 @@ define_variable_in_set (const char *name, unsigned int length,
v = xmalloc (sizeof (struct variable)); v = xmalloc (sizeof (struct variable));
v->name = xstrndup (name, length); v->name = xstrndup (name, length);
v->length = length; v->length = (unsigned int) length;
hash_insert_at (&set->table, v, var_slot); hash_insert_at (&set->table, v, var_slot);
if (set == &global_variable_set) if (set == &global_variable_set)
++variable_changenum; ++variable_changenum;
@ -330,7 +330,7 @@ free_variable_set (struct variable_set_list *list)
} }
void 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, enum variable_origin origin,
struct variable_set *set) struct variable_set *set)
{ {
@ -342,7 +342,7 @@ undefine_variable_in_set (const char *name, unsigned int length,
set = &global_variable_set; set = &global_variable_set;
var_key.name = (char *) name; 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); var_slot = (struct variable **) hash_find_slot (&set->table, &var_key);
if (env_overrides && origin == o_env) if (env_overrides && origin == o_env)
@ -412,8 +412,8 @@ lookup_special_var (struct variable *var)
if (variable_changenum != last_changenum && streq (var->name, ".VARIABLES")) if (variable_changenum != last_changenum && streq (var->name, ".VARIABLES"))
{ {
unsigned long max = EXPANSION_INCREMENT (strlen (var->value)); size_t max = EXPANSION_INCREMENT (strlen (var->value));
unsigned long len; size_t len;
char *p; char *p;
struct variable **vp = (struct variable **) global_variable_set.table.ht_vec; struct variable **vp = (struct variable **) global_variable_set.table.ht_vec;
struct variable **end = &vp[global_variable_set.table.ht_size]; struct variable **end = &vp[global_variable_set.table.ht_size];
@ -433,7 +433,7 @@ lookup_special_var (struct variable *var)
len += l + 1; len += l + 1;
if (len > max) if (len > max)
{ {
unsigned long off = p - var->value; size_t off = p - var->value;
max += EXPANSION_INCREMENT (l + 1); max += EXPANSION_INCREMENT (l + 1);
var->value = xrealloc (var->value, max); var->value = xrealloc (var->value, max);
@ -460,14 +460,14 @@ lookup_special_var (struct variable *var)
on the variable, or nil if no such variable is defined. */ on the variable, or nil if no such variable is defined. */
struct variable * struct variable *
lookup_variable (const char *name, unsigned int length) lookup_variable (const char *name, size_t length)
{ {
const struct variable_set_list *setlist; const struct variable_set_list *setlist;
struct variable var_key; struct variable var_key;
int is_parent = 0; int is_parent = 0;
var_key.name = (char *) name; var_key.name = (char *) name;
var_key.length = length; var_key.length = (unsigned int) length;
for (setlist = current_variable_set_list; for (setlist = current_variable_set_list;
setlist != 0; setlist = setlist->next) setlist != 0; setlist = setlist->next)
@ -547,13 +547,13 @@ lookup_variable (const char *name, unsigned int length)
on the variable, or nil if no such variable is defined. */ on the variable, or nil if no such variable is defined. */
struct variable * 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) const struct variable_set *set)
{ {
struct variable var_key; struct variable var_key;
var_key.name = (char *) name; 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); return (struct variable *) hash_find_item ((struct hash_table *) &set->table, &var_key);
} }
@ -1138,7 +1138,7 @@ static char *
shell_result (const char *p) shell_result (const char *p)
{ {
char *buf; char *buf;
unsigned int len; size_t len;
char *args[2]; char *args[2];
char *result; char *result;
@ -1237,7 +1237,7 @@ do_variable_definition (const floc *flocp, const char *varname,
{ {
/* Paste the old and new values together in VALUE. */ /* Paste the old and new values together in VALUE. */
unsigned int oldlen, vallen; size_t oldlen, vallen;
const char *val; const char *val;
char *tp = NULL; char *tp = NULL;
@ -1567,7 +1567,7 @@ parse_variable_definition (const char *p, struct variable *var)
return NULL; return NULL;
} }
var->length = e - var->name; var->length = (unsigned int) (e - var->name);
var->value = next_token (p); var->value = next_token (p);
return (char *)p; return (char *)p;
} }
@ -1788,7 +1788,7 @@ print_target_variables (const struct file *file)
{ {
if (file->variables != 0) if (file->variables != 0)
{ {
int l = strlen (file->name); size_t l = strlen (file->name);
char *t = alloca (l + 3); char *t = alloca (l + 3);
strcpy (t, file->name); strcpy (t, file->name);

View File

@ -53,7 +53,7 @@ struct variable
char *name; /* Variable name. */ char *name; /* Variable name. */
char *value; /* Variable value. */ char *value; /* Variable value. */
floc fileinfo; /* Where the variable was defined. */ 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 recursive:1; /* Gets recursively re-evaluated. */
unsigned int append:1; /* Nonzero if an appending target-specific unsigned int append:1; /* Nonzero if an appending target-specific
variable. */ variable. */
@ -104,7 +104,7 @@ struct pattern_var
struct pattern_var *next; struct pattern_var *next;
const char *suffix; const char *suffix;
const char *target; const char *target;
unsigned int len; size_t len;
struct variable variable; struct variable variable;
}; };
@ -114,22 +114,26 @@ extern struct variable *default_goal_var;
extern struct variable shell_var; extern struct variable shell_var;
/* expand.c */ /* 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 (const char *line);
char *variable_expand_for_file (const char *line, struct file *file); char *variable_expand_for_file (const char *line, struct file *file);
char *allocated_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) \ #define allocated_variable_expand(line) \
allocated_variable_expand_for_file (line, (struct file *) 0) allocated_variable_expand_for_file (line, (struct file *) 0)
char *expand_argument (const char *str, const char *end); char *expand_argument (const char *str, const char *end);
char *variable_expand_string (char *line, const char *string, long length); char *variable_expand_string (char *line, const char *string, size_t length);
void install_variable_buffer (char **bufp, unsigned int *lenp); void install_variable_buffer (char **bufp, size_t *lenp);
void restore_variable_buffer (char *buf, unsigned int len); void restore_variable_buffer (char *buf, size_t len);
/* function.c */ /* function.c */
int handle_function (char **op, const char **stringp); int handle_function (char **op, const char **stringp);
int pattern_matches (const char *pattern, const char *percent, const char *str); int pattern_matches (const char *pattern, const char *percent, const char *str);
char *subst_expand (char *o, const char *text, const char *subst, 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); int by_word);
char *patsubst_expand_pat (char *o, const char *text, const char *pattern, char *patsubst_expand_pat (char *o, const char *text, const char *pattern,
const char *replace, const char *pattern_percent, const char *replace, const char *pattern_percent,
@ -169,11 +173,11 @@ void hash_init_function_table (void);
void define_new_function(const floc *flocp, const char *name, void define_new_function(const floc *flocp, const char *name,
unsigned int min, unsigned int max, unsigned int flags, unsigned int min, unsigned int max, unsigned int flags,
gmk_func_ptr func); gmk_func_ptr func);
struct variable *lookup_variable (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, unsigned int length, struct variable *lookup_variable_in_set (const char *name, size_t length,
const struct variable_set *set); 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, const char *value,
enum variable_origin origin, enum variable_origin origin,
int recursive, int recursive,
@ -208,7 +212,7 @@ struct variable *define_variable_in_set (const char *name, unsigned int length,
#define define_variable_for_file(n,l,v,o,r,f) \ #define define_variable_for_file(n,l,v,o,r,f) \
define_variable_in_set((n),(l),(v),(o),(r),(f)->variables->set,NILF) 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, enum variable_origin origin,
struct variable_set *set); struct variable_set *set);

View File

@ -26,12 +26,12 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
struct vpath struct vpath
{ {
struct vpath *next; /* Pointer to next struct in the linked list. */ struct vpath *next; /* Pointer to next struct in the linked list. */
const char *pattern;/* The pattern to match. */ const char *pattern; /* The pattern to match. */
const char *percent;/* Pointer into 'pattern' where the '%' is. */ const char *percent; /* Pointer into 'pattern' where the '%' is. */
unsigned int patlen;/* Length of the pattern. */ size_t patlen; /* Length of the pattern. */
const char **searchpath; /* Null-terminated list of directories. */ 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. */ /* Linked-list of all selective VPATHs. */
@ -160,7 +160,7 @@ construct_vpath_list (char *pattern, char *dirpath)
unsigned int elem; unsigned int elem;
char *p; char *p;
const char **vpath; const char **vpath;
unsigned int maxvpath; size_t maxvpath;
unsigned int maxelem; unsigned int maxelem;
const char *percent = NULL; const char *percent = NULL;
@ -229,7 +229,7 @@ construct_vpath_list (char *pattern, char *dirpath)
while (*p != '\0') while (*p != '\0')
{ {
char *v; char *v;
unsigned int len; size_t len;
/* Find the end of this entry. */ /* Find the end of this entry. */
v = p; v = p;
@ -304,7 +304,7 @@ construct_vpath_list (char *pattern, char *dirpath)
in. If it is found, return 1. Otherwise we return 0. */ in. If it is found, return 1. Otherwise we return 0. */
int int
gpath_search (const char *file, unsigned int len) gpath_search (const char *file, size_t len)
{ {
if (gpaths && (len <= gpaths->maxlen)) if (gpaths && (len <= gpaths->maxlen))
{ {
@ -333,9 +333,9 @@ selective_vpath_search (struct vpath *path, const char *file,
const char *n; const char *n;
const char *filename; const char *filename;
const char **vpath = path->searchpath; const char **vpath = path->searchpath;
unsigned int maxvpath = path->maxlen; size_t maxvpath = path->maxlen;
unsigned int i; unsigned int i;
unsigned int flen, name_dplen; size_t flen, name_dplen;
int exists = 0; int exists = 0;
/* Find out if *FILE is a target. /* Find out if *FILE is a target.
@ -376,7 +376,7 @@ selective_vpath_search (struct vpath *path, const char *file,
{ {
int exists_in_cache = 0; int exists_in_cache = 0;
char *p = name; 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. */ /* Put the next VPATH entry into NAME at P and increment P past it. */
memcpy (p, vpath[i], vlen); memcpy (p, vpath[i], vlen);

View File

@ -30,7 +30,7 @@ opendir(const char* pDirName)
struct stat sb; struct stat sb;
DIR* pDir; DIR* pDir;
char* pEndDirName; char* pEndDirName;
int nBufferLen; size_t nBufferLen;
/* sanity checks */ /* sanity checks */
if (!pDirName) { if (!pDirName) {

View File

@ -65,7 +65,7 @@ convert_Path_to_windows32(char *Path, char to_delim)
/* found one to count, handle things like '.' */ /* found one to count, handle things like '.' */
*etok = to_delim; *etok = to_delim;
p = ++etok; p = ++etok;
} else if ((*etok == ':') && (etok = strpbrk(etok+1, ":;"))) { } else if ((*etok == ':') && ((etok = strpbrk(etok+1, ":;")) != NULL)) {
/* found one to count, handle drive letter */ /* found one to count, handle drive letter */
*etok = to_delim; *etok = to_delim;
p = ++etok; p = ++etok;

View File

@ -36,10 +36,10 @@ int _cdecl compare(const void *a1, const void *a2)
return _stricoll(*((char**)a1),*((char**)a2)); return _stricoll(*((char**)a1),*((char**)a2));
} }
bool_t bool_t
arr2envblk(char **arr, char **envblk_out, int *envsize_needed) arr2envblk(char **arr, char **envblk_out, size_t *envsize_needed)
{ {
char **tmp; char **tmp;
int size_needed; size_t size_needed;
int arrcnt; int arrcnt;
char *ptr; char *ptr;

View File

@ -24,6 +24,6 @@ typedef int bool_t;
#define E_NO_MEM 103 #define E_NO_MEM 103
#define E_FORK 104 #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 #endif

View File

@ -66,8 +66,8 @@ typedef struct sub_process_t {
/* keep track of children so we can implement a waitpid-like routine */ /* keep track of children so we can implement a waitpid-like routine */
static sub_process *proc_array[GMAKE_MAXIMUM_WAIT_OBJECTS]; static sub_process *proc_array[GMAKE_MAXIMUM_WAIT_OBJECTS];
static int proc_index = 0; static unsigned int proc_index = 0;
static int fake_exits_pending = 0; static unsigned int fake_exits_pending = 0;
/* /*
* Address the scalability limit intrisic to WaitForMultipleOjects by * Address the scalability limit intrisic to WaitForMultipleOjects by
@ -98,30 +98,30 @@ DWORD process_wait_for_multiple_objects(
assert(dwMilliseconds == 0 || dwMilliseconds == INFINITE); /* No support for timeouts */ assert(dwMilliseconds == 0 || dwMilliseconds == INFINITE); /* No support for timeouts */
for (; objectCount > 0; blockCount++) { for (; objectCount > 0; blockCount++) {
DWORD n = objectCount <= MAXIMUM_WAIT_OBJECTS ? objectCount : MAXIMUM_WAIT_OBJECTS; DWORD n = objectCount <= MAXIMUM_WAIT_OBJECTS ? objectCount : MAXIMUM_WAIT_OBJECTS;
objectCount -= n; objectCount -= n;
retVal = WaitForMultipleObjects(n, &lpHandles[blockCount * MAXIMUM_WAIT_OBJECTS], retVal = WaitForMultipleObjects(n, &lpHandles[blockCount * MAXIMUM_WAIT_OBJECTS],
FALSE, 0); FALSE, 0);
switch (retVal) { switch (retVal) {
case WAIT_TIMEOUT: case WAIT_TIMEOUT:
retVal = GMAKE_WAIT_TIMEOUT; retVal = GMAKE_WAIT_TIMEOUT;
continue; continue;
break; break;
case WAIT_FAILED: case WAIT_FAILED:
fprintf(stderr,"WaitForMultipleOjbects failed waiting with error %d\n", GetLastError()); fprintf(stderr,"WaitForMultipleOjbects failed waiting with error %d\n", GetLastError());
break; break;
default: default:
if (retVal >= WAIT_ABANDONED_0) { if (retVal >= WAIT_ABANDONED_0) {
assert(retVal < WAIT_ABANDONED_0 + MAXIMUM_WAIT_OBJECTS); assert(retVal < WAIT_ABANDONED_0 + MAXIMUM_WAIT_OBJECTS);
retVal += blockCount * MAXIMUM_WAIT_OBJECTS - WAIT_ABANDONED_0 + GMAKE_WAIT_ABANDONED_0; retVal += blockCount * MAXIMUM_WAIT_OBJECTS - WAIT_ABANDONED_0 + GMAKE_WAIT_ABANDONED_0;
} else { } else {
assert(retVal < WAIT_OBJECT_0 + MAXIMUM_WAIT_OBJECTS); assert(retVal < WAIT_OBJECT_0 + MAXIMUM_WAIT_OBJECTS);
retVal += blockCount * MAXIMUM_WAIT_OBJECTS; retVal += blockCount * MAXIMUM_WAIT_OBJECTS;
} }
break; break;
} }
return retVal; return retVal;
} }
@ -139,7 +139,7 @@ DWORD
process_set_handles(HANDLE *handles) process_set_handles(HANDLE *handles)
{ {
DWORD count = 0; DWORD count = 0;
int i; unsigned int i;
/* Build array of handles to wait for */ /* Build array of handles to wait for */
for (i = 0; i < proc_index; i++) { for (i = 0; i < proc_index; i++) {
@ -160,7 +160,7 @@ process_set_handles(HANDLE *handles)
static void static void
process_adjust_wait_state(sub_process* pproc) process_adjust_wait_state(sub_process* pproc)
{ {
int i; unsigned int i;
if (!proc_index) if (!proc_index)
return; return;
@ -186,7 +186,7 @@ process_wait_for_any_private(int block, DWORD* pdwWaitStatus)
{ {
HANDLE handles[GMAKE_MAXIMUM_WAIT_OBJECTS]; HANDLE handles[GMAKE_MAXIMUM_WAIT_OBJECTS];
DWORD retval, which; DWORD retval, which;
int i; unsigned int i;
if (!proc_index) if (!proc_index)
return NULL; return NULL;
@ -578,7 +578,7 @@ process_begin(
STARTUPINFO startInfo; STARTUPINFO startInfo;
PROCESS_INFORMATION procInfo; PROCESS_INFORMATION procInfo;
char *envblk=NULL; char *envblk=NULL;
int envsize_needed = 0; size_t envsize_needed = 0;
int pass_null_exec_path = 0; int pass_null_exec_path = 0;
/* /*
@ -615,7 +615,7 @@ process_begin(
if (exec_path[0] == '/') { if (exec_path[0] == '/') {
char *new_argv0; char *new_argv0;
char **argvi = argv; char **argvi = argv;
int arglen = 0; size_t arglen = 0;
strcpy(buf, variable_expand ("$(SHELL)")); strcpy(buf, variable_expand ("$(SHELL)"));
shell_name = &buf[0]; shell_name = &buf[0];
@ -708,7 +708,8 @@ process_begin(
&& _stricmp(exec_path, argv[0]) == 0) { && _stricmp(exec_path, argv[0]) == 0) {
char *new_argv, *p; char *new_argv, *p;
char **argvi; char **argvi;
int arglen, i; size_t arglen;
int i;
pass_null_exec_path = 1; pass_null_exec_path = 1;
/* Rewrite argv[] replacing argv[0] with exec_fname. */ /* Rewrite argv[] replacing argv[0] with exec_fname. */
for (argvi = argv + 1, arglen = strlen(exec_fname) + 1; for (argvi = argv + 1, arglen = strlen(exec_fname) + 1;
@ -743,7 +744,7 @@ process_begin(
if ((pproc->last_err == ERROR_INVALID_PARAMETER if ((pproc->last_err == ERROR_INVALID_PARAMETER
|| pproc->last_err == ERROR_MORE_DATA) || pproc->last_err == ERROR_MORE_DATA)
&& envsize_needed > 32*1024) { && 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); envsize_needed);
} }
pproc->last_err = 0; pproc->last_err = 0;
@ -1196,13 +1197,13 @@ process_cleanup(
static char * static char *
make_command_line( char *shell_name, char *full_exec_path, char **argv) make_command_line( char *shell_name, char *full_exec_path, char **argv)
{ {
int argc = 0; int argc = 0;
char** argvi; char** argvi;
int* enclose_in_quotes = NULL; int* enclose_in_quotes = NULL;
int* enclose_in_quotes_i; int* enclose_in_quotes_i;
unsigned int bytes_required = 0; size_t bytes_required = 0;
char* command_line; char* command_line;
char* command_line_i; char* command_line_i;
int have_sh = 0; /* HAVE_CYGWIN_SHELL */ int have_sh = 0; /* HAVE_CYGWIN_SHELL */
int cygwin_mode = 0; /* HAVE_CYGWIN_SHELL */ int cygwin_mode = 0; /* HAVE_CYGWIN_SHELL */