Re: [PATCH v3 1/2] diff.c: When appropriate, use utf8_strwidth(), part1
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Sep 2, 2022, 09:39 UTC
- Message-ID
- <9o5o2rqs-r7q4-p22r-0oss-1n09por2n248@tzk.qr>
- In-Reply-To
- <20220902042133.13883-1-tboegi@web.de>
Hi Torsten,
On Fri, 2 Sep 2022, tboegi@web.de wrote:
Show 10 quoted lines
> diff --git a/diff.c b/diff.c > index 974626a621..b5df464de5 100644 > --- a/diff.c > +++ b/diff.c > @@ -2620,7 +2620,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options) > continue; > } > fill_print_name(file); > - len = strlen(file->print_name); > + len = utf8_strwidth(file->print_name);
So this is no longer a length (in bytes) but a width (in columns).
In 2/2, a similar change incurs renaming `max_len` to `max_width`.
I would prefer for 1/2 and 2/2 to be on the same page here: either they both rename variables that have `len` in their name but are actually about a width (in columns), or neither of the patches rename these variables.
Thanks, Dscho
Show 16 quoted lines
> if (max_len < len)
> max_len = len;
>
> @@ -2743,7 +2743,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
> * "scale" the filename
> */
> len = name_width;
> - name_len = strlen(name);
> + name_len = utf8_strwidth(name);
> if (name_width < name_len) {
> char *slash;
> prefix = "...";
> --
> 2.34.0
>
>