build: Fix non-literal format string warnings for clang

https://gitlab.gnome.org/GNOME/gitg/issues/160
https://gitlab.gnome.org/GNOME/gitg/issues/161
This commit is contained in:
Ting-Wei Lan 2018-11-03 22:08:14 +08:00 committed by Alberto Fanjul
parent d46caa2527
commit 1e13a055a5
3 changed files with 12 additions and 16 deletions

View file

@ -103,12 +103,12 @@ class RefActionFetch : GitgExt.UIElement, GitgExt.Action, GitgExt.RefAction, Obj
if (a.is_zero())
{
/* Translators: new refers to a new remote reference having been fetched, */
updates.add(@"$name (%s)".printf(_("new")));
updates.add(@"%s (%s)".printf(name, _("new")));
}
else
{
/* Translators: updated refers to a remote reference having been updated, */
updates.add(@"$name (%s)".printf(_("updated")));
updates.add(@"%s (%s)".printf(name, _("updated")));
}
});

View file

@ -30,22 +30,20 @@ class Gitg.DiffImageSideBySide : Gtk.DrawingArea
{
if (d_old_size_layout == null && cache.old_pixbuf != null)
{
string message;
string message = @"$(cache.old_pixbuf.get_width()) × $(cache.old_pixbuf.get_height())";
if (cache.new_pixbuf != null)
{
// Translators: this label is displayed below the image diff, %s
// is substituted with the size of the image
message = _("before (%s)");
d_old_size_layout = create_pango_layout(_("before (%s)").printf(message));
}
else
{
// Translators: this label is displayed below the image diff, %s
// is substituted with the size of the image
message = _("removed (%s)");
d_old_size_layout = create_pango_layout(_("removed (%s)").printf(message));
}
d_old_size_layout = create_pango_layout(message.printf(@"$(cache.old_pixbuf.get_width()) × $(cache.old_pixbuf.get_height())"));
}
return d_old_size_layout;
@ -58,22 +56,20 @@ class Gitg.DiffImageSideBySide : Gtk.DrawingArea
{
if (d_new_size_layout == null && cache.new_pixbuf != null)
{
string message;
string message = @"$(cache.new_pixbuf.get_width()) × $(cache.new_pixbuf.get_height())";
if (cache.old_pixbuf != null)
{
// Translators: this label is displayed below the image diff, %s
// is substituted with the size of the image
message = _("after (%s)");
d_new_size_layout = create_pango_layout(_("after (%s)").printf(message));
}
else
{
// Translators: this label is displayed below the image diff, %s
// is substituted with the size of the image
message = _("added (%s)");
d_new_size_layout = create_pango_layout(_("added (%s)").printf(message));
}
d_new_size_layout = create_pango_layout(message.printf(@"$(cache.new_pixbuf.get_width()) × $(cache.new_pixbuf.get_height())"));
}
return d_new_size_layout;

View file

@ -26,7 +26,7 @@ class Gitg.DiffViewLinesRenderer : Gtk.SourceGutterRendererText
SYMBOL
}
private string d_num_digits_fmts;
private int d_num_digits;
private string d_num_digits_fill;
private ulong d_view_style_updated_id;
@ -182,7 +182,7 @@ class Gitg.DiffViewLinesRenderer : Gtk.SourceGutterRendererText
num_digits = 1;
}
d_num_digits_fmts = @"%$(num_digits)d";
d_num_digits = num_digits;
d_num_digits_fill = string.nfill(num_digits, ' ');
}
@ -207,14 +207,14 @@ class Gitg.DiffViewLinesRenderer : Gtk.SourceGutterRendererText
case Style.NEW:
if (origin == Ggit.DiffLineType.CONTEXT || origin == Ggit.DiffLineType.ADDITION)
{
ltext = d_num_digits_fmts.printf(newn);
ltext = "%*d".printf(d_num_digits, newn);
newn++;
}
break;
case Style.OLD:
if (origin == Ggit.DiffLineType.CONTEXT || origin == Ggit.DiffLineType.DELETION)
{
ltext = d_num_digits_fmts.printf(oldn);
ltext = "%*d".printf(d_num_digits, oldn);
oldn++;
}
break;