* src/makeint.h (stpcpy): Add missing declaration.
* src/amiga.c (MyExecute): Avoid extra strlen using stpcpy.
* src/function.c (func_shell_base): Ditto.
(func_error): Use memcpy() not strcpy() when we know the length.
* src/job.c (construct_command_argv_internal): Use stpcpy().
* src/main.c (main): Ditto.
(define_makeflags): Ditto.
* src/variable.c (print_target_variables): Use memcpy() when we know
the length.
* src/commands.c (set_file_variables): Use mempcpy().
* src/expand.c (variable_buffer_output): Ditto.
* src/file.c (expand_deps): Ditto.
* src/function.c (abspath): Ditto.
(handle_function): Ditto.
* src/implicit.c (pattern_search): Ditto.
* src/job.c (construct_command_argv_internal): Use mempcpy() and
don't add multiple spaces when there are no shell flags.
* src/main.c (decode_env_switches): Use mempcpy() to simplify.
(define_makeflags): Ditto.
* src/variable.c (selective_vpath_search): Ditto.
if (((*aptr)[0] == ';' && !(*aptr)[1]))
{
*ptr ++ = '"';
- strcpy (ptr, *aptr);
- ptr += strlen (ptr);
- *ptr ++ = '"';
+ ptr = stpcpy (ptr, *aptr);
+ *(ptr++) = '"';
}
else if ((*aptr)[0] == '@' && (*aptr)[1] == '@' && !(*aptr)[2])
{
continue;
}
else
- {
- strcpy (ptr, *aptr);
- ptr += strlen (ptr);
- }
+ ptr = stpcpy (ptr, *aptr);
*ptr ++ = ' ';
*ptr = 0;
}
#endif
len = strlen (c);
- memcpy (cp, c, len);
- cp += len;
+ cp = mempcpy (cp, c, len);
*cp++ = FILE_LIST_SEPARATOR;
if (! (d->changed || always_make_flag))
qmark_len -= len + 1; /* Don't space in $? for this one. */
if (d->ignore_mtime)
{
- memcpy (bp, c, len);
- bp += len;
+ bp = mempcpy (bp, c, len);
*bp++ = FILE_LIST_SEPARATOR;
}
else
{
- memcpy (cp, c, len);
- cp += len;
+ cp = mempcpy (cp, c, len);
*cp++ = FILE_LIST_SEPARATOR;
if (d->changed || always_make_flag)
{
- memcpy (qp, c, len);
- qp += len;
+ qp = mempcpy (qp, c, len);
*qp++ = FILE_LIST_SEPARATOR;
}
}
ptr = variable_buffer + offset;
}
- memcpy (ptr, string, length);
- return ptr + length;
+ return mempcpy (ptr, string, length);
}
/* Return a pointer to the beginning of the variable buffer.
while (cs)
{
- memcpy (s, pcs, cs - pcs);
- s += cs - pcs;
+ s = mempcpy (s, pcs, cs - pcs);
*(s++) = '$';
*(s++) = '*';
pcs = ++cs;
p = &value[off];
}
- memcpy (p, f->name, l);
- p += l;
+ p = mempcpy (p, f->name, l);
*(p++) = ' ';
}
*(p-1) = '\0';
{
size_t len = strlen (argv[0]);
char *msg = alloca (len + 2);
- strcpy (msg, argv[0]);
+ memcpy (msg, argv[0], len);
msg[len] = '\n';
msg[len + 1] = '\0';
outputs (0, msg);
{
strcpy (ptr, *aptr);
ptr += strlen (ptr) + 1;
- *ptr ++ = ' ';
- *ptr = 0;
+ *(ptr++) = ' ';
+ *ptr = '\0';
}
ptr[-1] = '\n';
if (dest + len >= apath_limit)
return NULL;
- dest = memcpy (dest, start, len);
- dest += len;
+ dest = mempcpy (dest, start, len);
*dest = '\0';
}
}
char *p, *aend;
abeg = xmalloc (len+1);
- memcpy (abeg, beg, len);
- abeg[len] = '\0';
- aend = abeg + len;
+ aend = mempcpy (abeg, beg, len);
+ *aend = '\0';
for (p=abeg, nargs=0; p <= aend; ++argvp)
{
{
char *o = depname;
if (check_lastslash)
- {
- memcpy (o, filename, pathlen);
- o += pathlen;
- }
- memcpy (o, nptr, cp - nptr);
- o += cp - nptr;
- memcpy (o, stem, stemlen);
- o += stemlen;
+ o = mempcpy (o, filename, pathlen);
+ o = mempcpy (o, nptr, cp - nptr);
+ o = mempcpy (o, stem, stemlen);
strcpy (o, cp + 1);
is_explicit = 0;
}
{
size_t i = cp - nptr;
assert (o + i < dend);
- memcpy (o, nptr, i);
- o += i;
+ o = mempcpy (o, nptr, i);
if (check_lastslash)
{
add_dir = 1;
assert (o + 5 < dend);
- memcpy (o, "$(*F)", 5);
- o += 5;
+ o = mempcpy (o, "$(*F)", 5);
}
else
{
assert (o + 2 < dend);
- memcpy (o, "$*", 2);
- o += 2;
+ o = mempcpy (o, "$*", 2);
}
assert (o < dend);
++cp;
struct dep *new = alloc_dep ();
/* GKM FIMXE: handle '|' here too */
- memcpy (p, rule->targets[ri],
- rule->suffixes[ri] - rule->targets[ri] - 1);
- p += rule->suffixes[ri] - rule->targets[ri] - 1;
- memcpy (p, file->stem, fullstemlen);
- p += fullstemlen;
+ p = mempcpy (p, rule->targets[ri],
+ rule->suffixes[ri] - rule->targets[ri] - 1);
+ p = mempcpy (p, file->stem, fullstemlen);
memcpy (p, rule->suffixes[ri],
rule->lens[ri] - (rule->suffixes[ri] - rule->targets[ri])+1);
new->name = strcache_add (nm);
}
*(ap++) = ' ';
if (shellflags)
- memcpy (ap, shellflags, sflags_len);
- ap += sflags_len;
- *(ap++) = ' ';
+ {
+ ap = mempcpy (ap, shellflags, sflags_len);
+ *(ap++) = ' ';
+ }
#ifdef WINDOWS32
command_ptr = ap;
#endif
else if (unixy_shell && strneq (p, "...", 3))
{
/* The case of '...' wildcard again. */
- strcpy (ap, "\\.\\.\\");
- ap += 5;
+ ap = stpcpy (ap, "\\.\\.\\");
p += 2;
}
#endif
p = endp = value = alloca (len);
for (i = 0; i < eval_strings->idx; ++i)
{
- strcpy (p, "--eval=");
- p += CSTRLEN ("--eval=");
+ p = stpcpy (p, "--eval=");
p = quote_for_env (p, eval_strings->list[i]);
endp = p++;
*endp = ' ';
const char **argv;
/* Get the variable's value. */
- varref[0] = '$';
- varref[1] = '(';
- memcpy (&varref[2], envar, len);
- varref[2 + len] = ')';
- varref[2 + len + 1] = '\0';
+ p = varref;
+ *(p++) = '$';
+ *(p++) = '(';
+ p = mempcpy (p, envar, len);
+ *(p++) = ')';
+ *p = '\0';
value = variable_expand (varref);
/* Skip whitespace, and check for an empty value. */
{
/* Long options require a double-dash. */
*p++ = '-';
- strcpy (p, flags->cs->long_name);
- p += strlen (p);
+ p = stpcpy (p, flags->cs->long_name);
}
/* An omitted optional argument has an ARG of "". */
if (flags->arg && flags->arg[0] != '\0')
if (eval_strings)
{
*p++ = ' ';
- memcpy (p, evalref, CSTRLEN (evalref));
- p += CSTRLEN (evalref);
+ p = mempcpy (p, evalref, CSTRLEN (evalref));
}
if (all)
if (v && v->value && v->value[0] != '\0')
{
- strcpy (p, " -- ");
- p += 4;
-
+ p = stpcpy (p, " -- ");
*(p++) = '$';
*(p++) = '(';
- memcpy (p, r, l);
- p += l;
+ p = mempcpy (p, r, l);
*(p++) = ')';
}
}
void *mempcpy (void *dest, const void *src, size_t n);
#endif
+#if !HAVE_STPCPY
+/* Create our own, in misc.c */
+char *stpcpy (char *dest, const char *src);
+#endif
+
#define OUTPUT_SYNC_NONE 0
#define OUTPUT_SYNC_LINE 1
#define OUTPUT_SYNC_TARGET 2
p = &var->value[off];
}
- memcpy (p, v->name, l);
- p += l;
+ p = mempcpy (p, v->name, l);
*(p++) = ' ';
}
*(p-1) = '\0';
size_t l = strlen (file->name);
char *t = alloca (l + 3);
- strcpy (t, file->name);
+ memcpy (t, file->name, l);
t[l] = ':';
t[l+1] = ' ';
t[l+2] = '\0';
size_t vlen = strlen (vpath[i]);
/* Put the next VPATH entry into NAME at P and increment P past it. */
- memcpy (p, vpath[i], vlen);
- p += vlen;
+ p = mempcpy (p, vpath[i], vlen);
/* Add the directory prefix already in *FILE. */
if (name_dplen > 0)
if ((*p != ':') && (*p != ']') && (*p != '>'))
*p++ = '/';
#endif
- memcpy (p, file, name_dplen);
- p += name_dplen;
+ p = mempcpy (p, file, name_dplen);
}
#ifdef HAVE_DOS_PATHS