[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: |
Spiros Bousbouras |
Subject: |
Re: [RP] [PATCH 1/3] Limit width of formatted text by characters rather than bytes |
Date: |
Sun, 27 Aug 2017 18:26:09 -0700 (PDT) |
On Sunday 2017-08-27 Will Storey wrote :
> static void
> concat_width (struct sbuf *buf, char *s, int width)
I would turn this to const char *s
> + 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 .
> + /* 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 ?