[vala/wip/profile-posix] SQUASH codegen: Fix string concatenation (POSIX)
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/profile-posix] SQUASH codegen: Fix string concatenation (POSIX)
- Date: Mon, 19 Mar 2018 15:54:29 +0000 (UTC)
commit 4a0222e06f84ae63c8b6c99a7b0cac8f041248c5
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Mar 19 16:46:30 2018 +0100
SQUASH codegen: Fix string concatenation (POSIX)
codegen/valaccodebasemodule.vala | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 7ff9776..23cce16 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5507,38 +5507,38 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
set_cvalue (expr, new CCodeConstant ("%s %s".printf (left, right)));
return;
} else {
+ var temp_value = create_temp_value (expr.value_type, false, expr);
+ CCodeFunctionCall ccall;
+
if (context.profile == Profile.POSIX) {
- // convert to
strcat(strcpy(malloc(1+strlen(a)+strlen(b)),a),b)
- var strcat = new CCodeFunctionCall (new CCodeIdentifier
("strcat"));
+ // convert to strcat (strcpy (malloc (1 + strlen (a) + strlen
(b)), a), b)
+ ccall = new CCodeFunctionCall (new CCodeIdentifier
("strcat"));
var strcpy = new CCodeFunctionCall (new CCodeIdentifier
("strcpy"));
var malloc = new CCodeFunctionCall (new CCodeIdentifier
("malloc"));
var strlen_a = new CCodeFunctionCall (new CCodeIdentifier
("strlen"));
- strlen_a.add_argument(cleft);
+ strlen_a.add_argument (cleft);
var strlen_b = new CCodeFunctionCall (new CCodeIdentifier
("strlen"));
- strlen_b.add_argument(cright);
- var newlength = new CCodeBinaryExpression
(CCodeBinaryOperator.PLUS, new CCodeIdentifier("1"),
+ strlen_b.add_argument (cright);
+ var newlength = new CCodeBinaryExpression
(CCodeBinaryOperator.PLUS, new CCodeIdentifier ("1"),
new CCodeBinaryExpression (CCodeBinaryOperator.PLUS,
strlen_a, strlen_b));
- malloc.add_argument(newlength);
+ malloc.add_argument (newlength);
- strcpy.add_argument(malloc);
- strcpy.add_argument(cleft);
+ strcpy.add_argument (malloc);
+ strcpy.add_argument (cleft);
- strcat.add_argument(strcpy);
- strcat.add_argument(cright);
- set_cvalue (expr, strcat);
+ ccall.add_argument (strcpy);
+ ccall.add_argument (cright);
} else {
// convert to g_strconcat (a, b, NULL)
- var temp_value = create_temp_value (expr.value_type, false,
expr);
-
- var ccall = new CCodeFunctionCall (new CCodeIdentifier
("g_strconcat"));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier
("g_strconcat"));
ccall.add_argument (cleft);
ccall.add_argument (cright);
ccall.add_argument (new CCodeConstant("NULL"));
-
- ccode.add_assignment (get_cvalue_ (temp_value), ccall);
- expr.target_value = temp_value;
}
+
+ ccode.add_assignment (get_cvalue_ (temp_value), ccall);
+ expr.target_value = temp_value;
return;
}
} else if (expr.operator == BinaryOperator.EQUALITY
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]