extern void tv_mul(struct timeval *, struct timeval *, int);
extern void tv_div(struct timeval *, struct timeval *, int);
+/* Some libc have stpcpy, some don't. Sigh...
+ * Roll our private implementation...
+ */
+#undef stpcpy
+#define stpcpy strace_stpcpy
+extern char *stpcpy(char *dst, const char *src);
+
#ifdef SUNOS4
extern int fixvfork(struct tcb *);
#endif
}
#endif
-/*
- * Pity stpcpy() is not standardized...
- */
-static char *
-str_append(char *dst, const char *src)
-{
- while ((*dst = *src++) != '\0')
- dst++;
- return dst;
-}
-
/*
* low bits of the open(2) flags define access mode,
* other bits are real flags.
const char *str;
const struct xlat *x;
- p = str_append(outstr, "flags ");
+ p = stpcpy(outstr, "flags ");
str = xlookup(open_access_modes, flags & 3);
if (str) {
- p = str_append(p, str);
+ p = stpcpy(p, str);
flags &= ~3;
if (!flags)
return outstr;
if ((flags & x->val) == x->val) {
if (sep)
*p++ = sep;
- p = str_append(p, x->str);
+ p = stpcpy(p, x->str);
flags &= ~x->val;
if (!flags)
return outstr;
return NULL;
}
+char *
+stpcpy(char *dst, const char *src)
+{
+ while ((*dst = *src++) != '\0')
+ dst++;
+ return dst;
+}
+
/*
* Generic ptrace wrapper which tracks ESRCH errors
* by setting tcp->ptrace_errno to ESRCH.
sprintflags(const char *prefix, const struct xlat *xlat, int flags)
{
static char outstr[1024];
+ char *outptr;
int found = 0;
- strcpy(outstr, prefix);
+ outptr = stpcpy(outstr, prefix);
for (; xlat->str; xlat++) {
if ((flags & xlat->val) == xlat->val) {
if (found)
- strcat(outstr, "|");
- strcat(outstr, xlat->str);
+ *outptr++ = '|';
+ outptr = stpcpy(outptr, xlat->str);
flags &= ~xlat->val;
found = 1;
}
}
if (flags) {
if (found)
- strcat(outstr, "|");
- sprintf(outstr + strlen(outstr), "%#x", flags);
+ *outptr++ = '|';
+ outptr += sprintf(outptr, "%#x", flags);
}
return outstr;
tprintf("%#lx", addr);
else {
static char outstr[4*(sizeof path - 1) + sizeof "\"...\""];
+ const char *fmt;
int trunc = (path[n] != '\0');
if (trunc)
path[n] = '\0';
- (void) string_quote(path, outstr, -1, n + 1);
+ string_quote(path, outstr, -1, n + 1);
+ fmt = "%s";
if (trunc)
- strcat(outstr, "...");
- tprintf("%s", outstr);
+ fmt = "%s...";
+ tprintf(fmt, outstr);
}
}
static char *str = NULL;
static char *outstr;
int size;
+ const char *fmt;
if (!addr) {
tprintf("NULL");
*/
size = max_strlen + 1;
str[max_strlen] = '\0';
+ /* FIXME! umovestr can overwrite the '\0' stored above??? */
if (umovestr(tcp, addr, size, str) < 0) {
tprintf("%#lx", addr);
return;
}
}
+ fmt = "%s";
if (string_quote(str, outstr, len, size) &&
(len < 0 || len > max_strlen))
- strcat(outstr, "...");
+ fmt = "%s...";
- tprintf("%s", outstr);
+ tprintf(fmt, outstr);
}
#if HAVE_SYS_UIO_H