threads / patch / 45154

v2, 2 partsFix l10n

Subject: [PATCH V2 0/2] Fix l10n

## tl;dr

6 messages between Feb 16, 2017 and Feb 17, 2017. Diffs are folded; open one to read it.

replies: 5people: 2as markdown or json

Maxim Moseychuk· Feb 16, 2017, 17:07 UTC · lore

In some places static size buffers can't store formatted string. If it be happen then git die.

Jonathan Tan: Thanks a lot for your help.
Maxim Moseychuk (2):
  bisect_next_all: convert xsnprintf to xstrfmt
  stop_progress_msg: convert xsnprintf to xstrfmt
 bisect.c   | 9 +++++----
 progress.c | 9 +++------
 2 files changed, 8 insertions(+), 10 deletions(-)

-- 2.11.1

Maxim Moseychuk· Feb 16, 2017, 17:07 UTC · re: Maxim Moseychuk · lore

[PATCH V2 1/2] bisect_next_all: convert xsnprintf to xstrfmt

Git can't run bisect between 2048+ commits if use russian translation. Reproduce "LANG=ru_RU.UTF8 git bisect start v4.9 v4.8" on linux sources.

Dummy solution: just increase buffer size but is not safe. Size gettext string is a runtime value.

Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
---
 bisect.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
Show changes to bisect.c +5 −4
diff --git a/bisect.c b/bisect.c
index 21bc6daa4..787543cad 100644
--- a/bisect.c
+++ b/bisect.c
@@ -940,7 +940,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
 	struct commit_list *tried;
 	int reaches = 0, all = 0, nr, steps;
 	const unsigned char *bisect_rev;
-	char steps_msg[32];
+	char *steps_msg;
 
 	read_bisect_terms(&term_bad, &term_good);
 	if (read_bisect_refs())
@@ -990,14 +990,15 @@ int bisect_next_all(const char *prefix, int no_checkout)
 
 	nr = all - reaches - 1;
 	steps = estimate_bisect_steps(all);
-	xsnprintf(steps_msg, sizeof(steps_msg),
-		  Q_("(roughly %d step)", "(roughly %d steps)", steps),
-		  steps);
+
+	steps_msg = xstrfmt(Q_("(roughly %d step)", "(roughly %d steps)",
+		  steps), steps);
 	/* TRANSLATORS: the last %s will be replaced with
 	   "(roughly %d steps)" translation */
 	printf(Q_("Bisecting: %d revision left to test after this %s\n",
 		  "Bisecting: %d revisions left to test after this %s\n",
 		  nr), nr, steps_msg);
+	free(steps_msg);
 
 	return bisect_checkout(bisect_rev, no_checkout);
 }
-- 
2.11.1
Maxim Moseychuk· Feb 16, 2017, 17:07 UTC · re: Maxim Moseychuk · lore

[PATCH V2 2/2] stop_progress_msg: convert xsnprintf to xstrfmt

Replace local safe string buffer allocation by xstrfmt.
Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
---
 progress.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
Show changes to progress.c +3 −6
diff --git a/progress.c b/progress.c
index 76a88c573..29d0dad58 100644
--- a/progress.c
+++ b/progress.c
@@ -243,21 +243,18 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
 	*p_progress = NULL;
 	if (progress->last_value != -1) {
 		/* Force the last update */
-		char buf[128], *bufp;
-		size_t len = strlen(msg) + 5;
+		char *bufp;
 		struct throughput *tp = progress->throughput;
 
-		bufp = (len < sizeof(buf)) ? buf : xmallocz(len);
 		if (tp) {
 			unsigned int rate = !tp->avg_misecs ? 0 :
 					tp->avg_bytes / tp->avg_misecs;
 			throughput_string(&tp->display, tp->curr_total, rate);
 		}
 		progress_update = 1;
-		xsnprintf(bufp, len + 1, ", %s.\n", msg);
+		bufp = xstrfmt(", %s.\n", msg);
 		display(progress, progress->last_value, bufp);
-		if (buf != bufp)
-			free(bufp);
+		free(bufp);
 	}
 	clear_progress_signal();
 	if (progress->throughput)
-- 
2.11.1
Junio C Hamano· Feb 16, 2017, 23:33 UTC · re: Maxim Moseychuk · lore

Re: [PATCH V2 0/2] Fix l10n

Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com> writes:
Show 15 quoted lines
> In some places static size buffers can't store formatted string.
> If it be happen then git die.
>
> Jonathan Tan: Thanks a lot for your help.
>
> Maxim Moseychuk (2):
>   bisect_next_all: convert xsnprintf to xstrfmt
>   stop_progress_msg: convert xsnprintf to xstrfmt
>
>  bisect.c   | 9 +++++----
>  progress.c | 9 +++------
>  2 files changed, 8 insertions(+), 10 deletions(-)
>
> --
> 2.11.1
Thanks.  Queued with minor log message fixes and pushed out.
Unknown· Feb 16, 2017, 23:37 UTC · re: Junio C Hamano · lore

Re: [PATCH V2 0/2] Fix l10n

В Чт, 16/02/2017 в 15:33 -0800, Junio C Hamano пишет:
Show 19 quoted lines
> Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com> writes:
> 
> > In some places static size buffers can't store formatted string.
> > If it be happen then git die.
> > 
> > Jonathan Tan: Thanks a lot for your help.
> > 
> > Maxim Moseychuk (2):
> >   bisect_next_all: convert xsnprintf to xstrfmt
> >   stop_progress_msg: convert xsnprintf to xstrfmt
> > 
> >  bisect.c   | 9 +++++----
> >  progress.c | 9 +++------
> >  2 files changed, 8 insertions(+), 10 deletions(-)
> > 
> > --
> > 2.11.1
> 
> Thanks.  Queued with minor log message fixes and pushed out.
If is not too late, please check the version 3.
Junio C Hamano· Feb 17, 2017, 01:16 UTC · re: Unknown · lore

Re: [PATCH V2 0/2] Fix l10n

Unknown <franchesko.salias.hudro.pedros@gmail.com> writes:
Show 5 quoted lines
> В Чт, 16/02/2017 в 15:33 -0800, Junio C Hamano пишет:
>> 
>> Thanks.  Queued with minor log message fixes and pushed out.
>
> If is not too late, please check the version 3.

I already squashed in the change s/bufp/buf/ in the version I queued and pushed out on 'pu', so we should be good. I compared the result of applying your updated patches and did not see any other changes.

Thanks.

← back to recent threads