Hi. I was playing around with Vala and Genie and I noticed that in the
case of Genie, the compiler adds an extra '\ n' sequence at the end of
some strings. Is that supposed to be?
Test program in Genie
// hello.gs
init
var caption = "Hello World!\n"
var hello = new HelloWorld ()
var message = hello.say (caption)
print ("Message: %s\n", message)
class HelloWorld : Object
def say (greeting : string) : string
print (greeting)
return "OK"
Some fragments of a program in C
// hello.c
...
void _vala_main (gchar** args, int args_length1) {
gchar* _tmp0_;
gchar* caption;
HelloWorld* _tmp1_;
HelloWorld* hello;
gchar* _tmp2_ = NULL;
gchar* message;
_tmp0_ = g_strdup ("Hello World!\n");
caption = _tmp0_;
_tmp1_ = hello_world_new ();
hello = _tmp1_;
_tmp2_ = hello_world_say (hello, caption);
message = _tmp2_;
g_print ("Message: %s\n\n", message); // <-- an extra '\n' here
_g_free0 (message);
_g_object_unref0 (hello);
_g_free0 (caption);
}
...
gchar* hello_world_say (HelloWorld* self, const gchar* greeting) {
gchar* result = NULL;
const gchar* _tmp0_;
gchar* _tmp1_;
gchar* _tmp2_;
gchar* _tmp3_;
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (greeting != NULL, NULL);
_tmp0_ = greeting;
_tmp1_ = g_strconcat (_tmp0_, "\n", NULL); // <-- an extra '\n' here
_tmp2_ = _tmp1_;
g_print ("%s", _tmp2_);
_g_free0 (_tmp2_);
_tmp3_ = g_strdup ("OK");
result = _tmp3_;
return result;
}
...
Attachment:
hello.c
Description: Text Data