[PATCH 1/5] html: html_ntxt with no ellipsis

John Keeping john at keeping.me.uk
Sat Sep 30 13:55:27 CEST 2017


On Wed, Sep 27, 2017 at 05:43:27PM -0500, Jeff Smith wrote:
> For implementing a ui-blame page, there is need for a function that
> outputs a selection from a block of text, transformed for HTML output,
> but with no further modifications or additions.
> 
> Signed-off-by: Jeff Smith <whydoubt at gmail.com>
> ---
>  html.c        | 24 ++++--------------------
>  html.h        |  2 +-
>  ui-repolist.c |  3 ++-
>  3 files changed, 7 insertions(+), 22 deletions(-)
> 
> diff --git a/html.c b/html.c
> index e7e6e07..87ef5aa 100644
> --- a/html.c
> +++ b/html.c
> @@ -124,26 +124,11 @@ void html_vtxtf(const char *format, va_list ap)
[snip]
> -void html_ntxt(int len, const char *txt)
> +int html_ntxt(int len, const char *txt)

Should this be:

	ssize_t html_ntxt(size_t len, const char *txt)

?  Maybe with a check to die if len > SSIZE_MAX.

>  {
>  	const char *t = txt;
>  	while (t && *t && len--) {
> @@ -162,8 +147,7 @@ void html_ntxt(int len, const char *txt)
>  	}
>  	if (t != txt)
>  		html_raw(txt, t - txt);
> -	if (len < 0)
> -		html("...");
> +	return len;
>  }


More information about the CGit mailing list