err-in-string
This is a small patch to avoid an endless loop. In case of an error textwrap() adds <ERR> at the end of the string and returns with the string that was built up to that error. Gbp-Pq: Name 01-237630-err-in-string.patch
This commit is contained in:
parent
5af6d1418e
commit
1cec3406ce
|
@ -78,6 +78,9 @@ proper number of space code (0x20) by \fBtextwrap\fR.
|
||||||
.SH RETURN VALUE
|
.SH RETURN VALUE
|
||||||
\fBtextwrap()\fR returns the line-folded text.
|
\fBtextwrap()\fR returns the line-folded text.
|
||||||
You can free(3) the given value.
|
You can free(3) the given value.
|
||||||
|
|
||||||
|
In case of any error while processing the string, the text <ERR> will be
|
||||||
|
appended to the output and processing will be aborted.
|
||||||
.\" ********************************************************************
|
.\" ********************************************************************
|
||||||
.SH EXAMPLE
|
.SH EXAMPLE
|
||||||
.nf
|
.nf
|
||||||
|
|
|
@ -300,6 +300,14 @@ textwrap(const textwrap_t *prop, const char *text)
|
||||||
|
|
||||||
now = p; /* current character */
|
now = p; /* current character */
|
||||||
ml = mblen(p, MB_CUR_MAX);
|
ml = mblen(p, MB_CUR_MAX);
|
||||||
|
if (ml<0) {
|
||||||
|
/*
|
||||||
|
* stringt_addstr will take care about enough
|
||||||
|
* memory for out
|
||||||
|
*/
|
||||||
|
stringt_addstr(out, " <ERR>");
|
||||||
|
return stringt_destroy_extract(out);
|
||||||
|
}
|
||||||
w = mbwidth(p, ml);
|
w = mbwidth(p, ml);
|
||||||
b = breakable(p, ml, encoding_type);
|
b = breakable(p, ml, encoding_type);
|
||||||
p += ml;
|
p += ml;
|
||||||
|
|
Loading…
Reference in New Issue