ratpoison-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RP] [PATCH 1/3] Limit width of formatted text by characters rather


From: Will Storey
Subject: Re: [RP] [PATCH 1/3] Limit width of formatted text by characters rather than bytes
Date: Sun, 27 Aug 2017 21:20:09 -0700

Hi Spiros

Thank you for looking at this! I'll send an updated patch.

On Sun 2017-08-27 18:26:09 -0700, Spiros Bousbouras wrote:
> 
> >  static void
> >  concat_width (struct sbuf *buf, char *s, int width)
> 
> I would turn this to   const char *s

Good idea. I'll add a few more const's too.

> > +  int i = 0;
> > +  /* The size of a character in bytes. */
> > +  int char_len = 0;
> > +  /* Index of the current character in the string. */
> > +  int char_idx = 0;
> 
> These should be  size_t .

Great catch! I've changed the last 2 to be size_t. I think the first can
still be int though, unless we want to change the function's signature
further.

> > +      /* Invalid character? */
> > +      if (char_len == -1)
> > +        break;
> 
> if (char_len == (size_t) -1)
> 
> +
> +      /* Null character? */
> +      if (char_len == 0)
> +        break;
> 
> Don't we need to check for the case when the return value is
> (size_t) -2 ?

Definitely!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]