2007-08-01 Roland McGrath <roland@redhat.com>
* util.c (printstr): Don't print ... if the string matches the length limit exactly.
This commit is contained in:
parent
dd519cc7c0
commit
a503dcf820
11
util.c
11
util.c
@ -442,13 +442,14 @@ int len;
|
||||
static char *outstr;
|
||||
int i, n, c, usehex;
|
||||
char *s, *outend;
|
||||
int trunc;
|
||||
|
||||
if (!addr) {
|
||||
tprintf("NULL");
|
||||
return;
|
||||
}
|
||||
if (!str) {
|
||||
if ((str = malloc(max_strlen)) == NULL
|
||||
if ((str = malloc(max_strlen + 1)) == NULL
|
||||
|| (outstr = malloc(4*max_strlen
|
||||
+ sizeof "\"\"...")) == NULL) {
|
||||
fprintf(stderr, "out of memory\n");
|
||||
@ -458,20 +459,22 @@ int len;
|
||||
}
|
||||
outend = outstr + max_strlen * 4;
|
||||
if (len < 0) {
|
||||
n = max_strlen;
|
||||
n = max_strlen + 1;
|
||||
if (umovestr(tcp, addr, n, (char *) str) < 0) {
|
||||
tprintf("%#lx", addr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
n = MIN(len, max_strlen);
|
||||
n = MIN(len, max_strlen + 1);
|
||||
if (umoven(tcp, addr, n, (char *) str) < 0) {
|
||||
tprintf("%#lx", addr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
trunc = n > max_strlen && str[--n] != 0;
|
||||
|
||||
usehex = 0;
|
||||
if (xflag > 1)
|
||||
usehex = 1;
|
||||
@ -538,7 +541,7 @@ int len;
|
||||
}
|
||||
|
||||
*s++ = '\"';
|
||||
if (i < len || (len < 0 && (i == n || s > outend))) {
|
||||
if (i < len || (len < 0 && (trunc || s > outend))) {
|
||||
*s++ = '.'; *s++ = '.'; *s++ = '.';
|
||||
}
|
||||
*s = '\0';
|
||||
|
Loading…
x
Reference in New Issue
Block a user