[vala/wip/bug769229: 4/6] Do not use non-literal printf format strings
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/bug769229: 4/6] Do not use non-literal printf format strings
- Date: Wed, 2 Nov 2016 19:56:55 +0000 (UTC)
commit de191f7d3cc19539809aaef4389c9cc0faa72f7e
Author: Jürg Billeter <j bitron ch>
Date: Tue Nov 1 18:14:09 2016 +0100
Do not use non-literal printf format strings
codegen/valagvariantmodule.vala | 2 +-
vala/valagenieparser.vala | 6 +++---
vala/valamethod.vala | 2 +-
vala/valamethodcall.vala | 2 +-
vala/valaparser.vala | 4 ++--
5 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/codegen/valagvariantmodule.vala b/codegen/valagvariantmodule.vala
index b2d9861..b50aca0 100644
--- a/codegen/valagvariantmodule.vala
+++ b/codegen/valagvariantmodule.vala
@@ -126,7 +126,7 @@ public class Vala.GVariantModule : GAsyncModule {
}
}
- sig = sig.printf (element_sig);
+ sig = sig.replace ("%s", element_sig);
}
if (sig == null &&
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 25097a5..e7b6902 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -163,7 +163,7 @@ public class Vala.Genie.Parser : CodeVisitor {
TokenType cur = current ();
TokenType pre = tokens[index - 1].type;
- throw new ParseError.SYNTAX (get_error ("expected %s but got %s with previous %s".printf
(type.to_string (), cur.to_string (), pre.to_string())));
+ throw new ParseError.SYNTAX (get_error ("expected %s but got %s with previous %s"),
type.to_string (), cur.to_string (), pre.to_string());
}
inline bool expect_terminator () throws ParseError {
@@ -173,7 +173,7 @@ public class Vala.Genie.Parser : CodeVisitor {
TokenType cur = current ();
- throw new ParseError.SYNTAX (get_error ("expected line end or semicolon but got %s".printf
(cur.to_string())));
+ throw new ParseError.SYNTAX (get_error ("expected line end or semicolon but got %s"),
cur.to_string());
}
inline SourceLocation get_location () {
@@ -2436,7 +2436,7 @@ public class Vala.Genie.Parser : CodeVisitor {
TokenType cur = current ();
TokenType pre = tokens[index-1].type;
- throw new ParseError.SYNTAX (get_error ("expected declaration but got %s with previous
%s".printf (cur.to_string (), pre.to_string())));
+ throw new ParseError.SYNTAX (get_error ("expected declaration but got %s with previous %s"),
cur.to_string (), pre.to_string());
}
void parse_declarations (Symbol parent, bool root = false) throws ParseError {
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index f073c6e..4c7b700 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -1048,7 +1048,7 @@ public class Vala.Method : Subroutine, Callable {
}
}
- public int get_format_arg () {
+ public int get_format_arg_index () {
for (int i = 0; i < parameters.size; i++) {
if (parameters[i].format_arg) {
return i;
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 9d3b141..0be9013 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -726,7 +726,7 @@ public class Vala.MethodCall : Expression {
public StringLiteral? get_format_literal () {
var mtype = this.call.value_type as MethodType;
if (mtype != null) {
- int format_arg = mtype.method_symbol.get_format_arg ();
+ int format_arg = mtype.method_symbol.get_format_arg_index ();
if (format_arg >= 0 && format_arg < argument_list.size) {
return StringLiteral.get_format_literal (argument_list[format_arg]);
}
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 11e8bad..ab3fa15 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -126,7 +126,7 @@ public class Vala.Parser : CodeVisitor {
return true;
}
- throw new ParseError.SYNTAX (get_error ("expected %s".printf (type.to_string ())));
+ throw new ParseError.SYNTAX (get_error ("expected %s"), type.to_string ());
}
inline SourceLocation get_location () {
@@ -2698,7 +2698,7 @@ public class Vala.Parser : CodeVisitor {
if (ModifierFlags.ABSTRACT in flags
|| ModifierFlags.VIRTUAL in flags
|| ModifierFlags.OVERRIDE in flags) {
- throw new ParseError.SYNTAX (get_error ("the modifiers `abstract', `virtual',
and `override' are not valid for %s methods".printf ((ModifierFlags.CLASS in flags) ? "class" : "static")));
+ throw new ParseError.SYNTAX (get_error ("the modifiers `abstract', `virtual',
and `override' are not valid for %s methods"), (ModifierFlags.CLASS in flags) ? "class" : "static");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]