/* basic_types_strings.c generated by valac, the Vala compiler * generated from basic_types_strings.vala, do not modify */ #include #include #include #if !defined(VALA_EXTERN) #if defined(_MSC_VER) #define VALA_EXTERN __declspec(dllexport) extern #elif __GNUC__ >= 4 #define VALA_EXTERN __attribute__((visibility("default"))) extern #else #define VALA_EXTERN extern #endif #endif #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } #define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; } #define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); VALA_EXTERN void test_string (void); VALA_EXTERN void test_string_concat (void); VALA_EXTERN void test_string_joinv (void); VALA_EXTERN void test_string_printf (void); VALA_EXTERN void test_string_replace (void); VALA_EXTERN void test_string_slice (void); VALA_EXTERN void test_string_splice (void); VALA_EXTERN void test_string_substring (void); static void _vala_main (void); static void _vala_array_destroy (gpointer array, gssize array_length, GDestroyNotify destroy_func); static void _vala_array_free (gpointer array, gssize array_length, GDestroyNotify destroy_func); static gchar* string_slice (const gchar* self, glong start, glong end) { glong string_length = 0L; gint _tmp0_; gint _tmp1_; gboolean _tmp2_ = FALSE; gboolean _tmp3_ = FALSE; gchar* _tmp4_; gchar* result; g_return_val_if_fail (self != NULL, NULL); _tmp0_ = strlen (self); _tmp1_ = _tmp0_; string_length = (glong) _tmp1_; if (start < ((glong) 0)) { start = string_length + start; } if (end < ((glong) 0)) { end = string_length + end; } if (start >= ((glong) 0)) { _tmp2_ = start <= string_length; } else { _tmp2_ = FALSE; } g_return_val_if_fail (_tmp2_, NULL); if (end >= ((glong) 0)) { _tmp3_ = end <= string_length; } else { _tmp3_ = FALSE; } g_return_val_if_fail (_tmp3_, NULL); g_return_val_if_fail (start <= end, NULL); _tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start)); result = _tmp4_; return result; } static gchar string_get (const gchar* self, glong index) { gchar _tmp0_; gchar result; g_return_val_if_fail (self != NULL, '\0'); _tmp0_ = ((gchar*) self)[index]; result = _tmp0_; return result; } void test_string (void) { gchar* s = NULL; gchar* _tmp0_; const gchar* _tmp1_; gchar* _tmp2_; const gchar* _tmp3_; gchar* t = NULL; const gchar* _tmp4_; gchar* _tmp5_; const gchar* _tmp6_; gchar* _tmp7_; const gchar* _tmp8_; gchar* _tmp9_; const gchar* _tmp10_; const gchar* _tmp11_; const gchar* _tmp12_; const gchar* _tmp13_; const gchar* _tmp14_; const gchar* _tmp15_; const gchar* _tmp16_; const gchar* _tmp17_; const gchar* _tmp18_; const gchar* _tmp19_; const gchar* _tmp20_; gchar* _tmp21_; const gchar* _tmp22_; gint _tmp23_; gint _tmp24_; const gchar* _tmp25_; const gchar* _tmp26_; const gchar* _tmp27_; const gchar* _tmp28_; gint _tmp29_; gint _tmp30_; gchar* _tmp31_; const gchar* _tmp32_; gint _tmp33_; gint _tmp34_; const gchar* _tmp35_; const gchar* _tmp36_; const gchar* _tmp37_; gchar* _tmp38_; const gchar* _tmp39_; gint _tmp40_; gint _tmp41_; const gchar* _tmp42_; const gchar* _tmp43_; const gchar* _tmp44_; const gchar* _tmp45_; gint _tmp46_; gint _tmp47_; gchar* _tmp48_; const gchar* _tmp49_; const gchar* _tmp50_; _tmp0_ = g_strdup ("hello"); s = _tmp0_; _tmp1_ = s; _vala_assert (g_strcmp0 (_tmp1_, "hello") == 0, "s == \"hello\""); _tmp2_ = g_strdup ("world"); _g_free0 (s); s = _tmp2_; _tmp3_ = s; _vala_assert (g_strcmp0 (_tmp3_, "world") == 0, "s == \"world\""); _tmp4_ = s; _tmp5_ = g_strdup (_tmp4_); t = _tmp5_; _tmp6_ = t; _vala_assert (g_strcmp0 (_tmp6_, "world") == 0, "t == \"world\""); _tmp7_ = g_strdup ("hello" "world"); _g_free0 (s); s = _tmp7_; _tmp8_ = s; _vala_assert (g_strcmp0 (_tmp8_, "helloworld") == 0, "s == \"helloworld\""); _tmp9_ = g_strdup ("hello"); _g_free0 (s); s = _tmp9_; _tmp10_ = s; _vala_assert (g_strcmp0 (_tmp10_, "hello") == 0, "s == \"hello\""); _tmp11_ = s; _vala_assert (g_strcmp0 (_tmp11_, "world") != 0, "s != \"world\""); _tmp12_ = s; _vala_assert (g_strcmp0 (_tmp12_, "i") < 0, "s < \"i\""); _tmp13_ = s; _vala_assert (!(g_strcmp0 (_tmp13_, "g") < 0), "!(s < \"g\")"); _tmp14_ = s; _vala_assert (g_strcmp0 (_tmp14_, "hello") <= 0, "s <= \"hello\""); _tmp15_ = s; _vala_assert (!(g_strcmp0 (_tmp15_, "g") <= 0), "!(s <= \"g\")"); _tmp16_ = s; _vala_assert (g_strcmp0 (_tmp16_, "hello") >= 0, "s >= \"hello\""); _tmp17_ = s; _vala_assert (!(g_strcmp0 (_tmp17_, "i") >= 0), "!(s >= \"i\")"); _tmp18_ = s; _vala_assert (g_strcmp0 (_tmp18_, "g") > 0, "s > \"g\""); _tmp19_ = s; _vala_assert (!(g_strcmp0 (_tmp19_, "i") > 0), "!(s > \"i\")"); _tmp20_ = s; _tmp21_ = string_slice (_tmp20_, (glong) 2, (glong) 4); _g_free0 (t); t = _tmp21_; _tmp22_ = t; _tmp23_ = strlen (_tmp22_); _tmp24_ = _tmp23_; _vala_assert (_tmp24_ == 2, "t.length == 2"); _tmp25_ = t; _vala_assert (string_get (_tmp25_, (glong) 0) == 'l', "t[0] == 'l'"); _tmp26_ = t; _vala_assert (string_get (_tmp26_, (glong) 1) == 'l', "t[1] == 'l'"); _tmp27_ = s; _tmp28_ = s; _tmp29_ = strlen (_tmp28_); _tmp30_ = _tmp29_; _tmp31_ = string_slice (_tmp28_, (glong) -2, (glong) _tmp30_); _g_free0 (t); t = _tmp31_; _tmp32_ = t; _tmp33_ = strlen (_tmp32_); _tmp34_ = _tmp33_; _vala_assert (_tmp34_ == 2, "t.length == 2"); _tmp35_ = t; _vala_assert (string_get (_tmp35_, (glong) 0) == 'l', "t[0] == 'l'"); _tmp36_ = t; _vala_assert (string_get (_tmp36_, (glong) 1) == 'o', "t[1] == 'o'"); _tmp37_ = s; _tmp38_ = string_slice (_tmp37_, (glong) 0, (glong) 2); _g_free0 (t); t = _tmp38_; _tmp39_ = t; _tmp40_ = strlen (_tmp39_); _tmp41_ = _tmp40_; _vala_assert (_tmp41_ == 2, "t.length == 2"); _tmp42_ = t; _vala_assert (string_get (_tmp42_, (glong) 0) == 'h', "t[0] == 'h'"); _tmp43_ = t; _vala_assert (string_get (_tmp43_, (glong) 1) == 'e', "t[1] == 'e'"); _tmp44_ = s; _tmp45_ = s; _tmp46_ = strlen (_tmp45_); _tmp47_ = _tmp46_; _tmp48_ = string_slice (_tmp45_, (glong) 0, (glong) _tmp47_); _g_free0 (t); t = _tmp48_; _tmp49_ = t; _tmp50_ = s; _vala_assert (g_strcmp0 (_tmp49_, _tmp50_) == 0, "t == s"); _g_free0 (t); _g_free0 (s); } void test_string_concat (void) { gchar* s = NULL; gchar* _tmp0_; _tmp0_ = g_strdup ("hello" "world"); s = _tmp0_; _vala_assert (g_strcmp0 (s, "helloworld") == 0, "s == \"helloworld\""); _g_free0 (s); } static gchar* _vala_g_strjoinv (const gchar* separator, gchar** str_array, gint str_array_length1) { gboolean _tmp0_ = FALSE; gchar* result; if (separator == NULL) { separator = ""; } if (str_array != NULL) { gboolean _tmp1_ = FALSE; if (str_array_length1 > 0) { _tmp1_ = TRUE; } else { gboolean _tmp2_ = FALSE; if (str_array_length1 == -1) { const gchar* _tmp3_; _tmp3_ = str_array[0]; _tmp2_ = _tmp3_ != NULL; } else { _tmp2_ = FALSE; } _tmp1_ = _tmp2_; } _tmp0_ = _tmp1_; } else { _tmp0_ = FALSE; } if (_tmp0_) { gint i = 0; gsize len = 0UL; gint _tmp16_; gint _tmp17_; const gchar* res = NULL; void* _tmp18_; const gchar* _tmp19_ = NULL; const gchar* _tmp20_; void* ptr = NULL; const gchar* _tmp22_; void* _tmp23_; const gchar* _tmp33_; len = (gsize) 1; { gboolean _tmp4_ = FALSE; i = 0; _tmp4_ = TRUE; while (TRUE) { gboolean _tmp6_ = FALSE; gboolean _tmp7_ = FALSE; gint _tmp10_ = 0; const gchar* _tmp11_; if (!_tmp4_) { gint _tmp5_; _tmp5_ = i; i = _tmp5_ + 1; } _tmp4_ = FALSE; if (str_array_length1 != -1) { _tmp7_ = i < str_array_length1; } else { _tmp7_ = FALSE; } if (_tmp7_) { _tmp6_ = TRUE; } else { gboolean _tmp8_ = FALSE; if (str_array_length1 == -1) { const gchar* _tmp9_; _tmp9_ = str_array[i]; _tmp8_ = _tmp9_ != NULL; } else { _tmp8_ = FALSE; } _tmp6_ = _tmp8_; } if (!_tmp6_) { break; } _tmp11_ = str_array[i]; if (_tmp11_ != NULL) { const gchar* _tmp12_; gint _tmp13_; gint _tmp14_; _tmp12_ = str_array[i]; _tmp13_ = strlen ((const gchar*) _tmp12_); _tmp14_ = _tmp13_; _tmp10_ = _tmp14_; } else { _tmp10_ = 0; } len += (gsize) _tmp10_; } } if (i == 0) { gchar* _tmp15_; _tmp15_ = g_strdup (""); result = _tmp15_; return result; } str_array_length1 = i; _tmp16_ = strlen ((const gchar*) separator); _tmp17_ = _tmp16_; len += (gsize) (_tmp17_ * (i - 1)); _tmp18_ = g_malloc (len); res = _tmp18_; _tmp20_ = str_array[0]; if (_tmp20_ != NULL) { const gchar* _tmp21_; _tmp21_ = str_array[0]; _tmp19_ = (const gchar*) _tmp21_; } else { _tmp19_ = ""; } _tmp22_ = res; _tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_); ptr = _tmp23_; { gboolean _tmp24_ = FALSE; i = 1; _tmp24_ = TRUE; while (TRUE) { void* _tmp26_; void* _tmp27_; const gchar* _tmp28_ = NULL; const gchar* _tmp29_; void* _tmp31_; void* _tmp32_; if (!_tmp24_) { gint _tmp25_; _tmp25_ = i; i = _tmp25_ + 1; } _tmp24_ = FALSE; if (!(i < str_array_length1)) { break; } _tmp26_ = ptr; _tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator); ptr = _tmp27_; _tmp29_ = str_array[i]; if (_tmp29_ != NULL) { const gchar* _tmp30_; _tmp30_ = str_array[i]; _tmp28_ = (const gchar*) _tmp30_; } else { _tmp28_ = ""; } _tmp31_ = ptr; _tmp32_ = g_stpcpy (_tmp31_, _tmp28_); ptr = _tmp32_; } } _tmp33_ = res; res = NULL; result = (gchar*) _tmp33_; return result; } else { gchar* _tmp34_; _tmp34_ = g_strdup (""); result = _tmp34_; return result; } } void test_string_joinv (void) { gchar** sa = NULL; gchar* _tmp0_; gchar* _tmp1_; gchar* _tmp2_; gchar** _tmp3_; gint sa_length1; gint _sa_size_; gchar* s = NULL; gchar* _tmp4_; const gchar* _tmp5_; gchar* _tmp6_; const gchar* _tmp7_; gchar* _tmp8_; const gchar* _tmp9_; gchar** _tmp10_; gchar** _tmp11_; gint _tmp11__length1; gchar* _tmp12_; const gchar* _tmp13_; _tmp0_ = g_strdup ("hello"); _tmp1_ = g_strdup ("my"); _tmp2_ = g_strdup ("world"); _tmp3_ = g_new0 (gchar*, 3 + 1); _tmp3_[0] = _tmp0_; _tmp3_[1] = _tmp1_; _tmp3_[2] = _tmp2_; sa = _tmp3_; sa_length1 = 3; _sa_size_ = sa_length1; _tmp4_ = _vala_g_strjoinv (" ", sa, (gint) sa_length1); s = _tmp4_; _tmp5_ = s; _vala_assert (g_strcmp0 (_tmp5_, "hello my world") == 0, "s == \"hello my world\""); sa_length1 = -1; _tmp6_ = _vala_g_strjoinv (":", sa, (gint) sa_length1); _g_free0 (s); s = _tmp6_; _tmp7_ = s; _vala_assert (g_strcmp0 (_tmp7_, "hello:my:world") == 0, "s == \"hello:my:world\""); _tmp8_ = _vala_g_strjoinv ("-", NULL, (gint) 0); _g_free0 (s); s = _tmp8_; _tmp9_ = s; _vala_assert (g_strcmp0 (_tmp9_, "") == 0, "s == \"\""); _tmp10_ = g_new0 (gchar*, 1 + 1); _tmp10_[0] = NULL; _tmp11_ = _tmp10_; _tmp11__length1 = 1; _tmp12_ = _vala_g_strjoinv ("-", _tmp11_, (gint) 1); _g_free0 (s); s = _tmp12_; _tmp11_ = (_vala_array_free (_tmp11_, _tmp11__length1, (GDestroyNotify) g_free), NULL); _tmp13_ = s; _vala_assert (g_strcmp0 (_tmp13_, "") == 0, "s == \"\""); sa_length1 = 3; _g_free0 (s); sa = (_vala_array_free (sa, sa_length1, (GDestroyNotify) g_free), NULL); } void test_string_printf (void) { gchar* s = NULL; gchar* _tmp0_; _tmp0_ = g_strdup_printf ("%i %s %u %.4f", 42, "foo", 4711U, 3.1415); s = _tmp0_; _vala_assert (g_strcmp0 (s, "42 foo 4711 3.1415") == 0, "s == \"42 foo 4711 3.1415\""); _g_free0 (s); } static gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) { gboolean _tmp0_ = FALSE; gboolean _tmp1_ = FALSE; GError* _inner_error0_ = NULL; gchar* result; g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (old != NULL, NULL); g_return_val_if_fail (replacement != NULL, NULL); if ((*((gchar*) self)) == '\0') { _tmp1_ = TRUE; } else { _tmp1_ = (*((gchar*) old)) == '\0'; } if (_tmp1_) { _tmp0_ = TRUE; } else { _tmp0_ = g_strcmp0 (old, replacement) == 0; } if (_tmp0_) { gchar* _tmp2_; _tmp2_ = g_strdup (self); result = _tmp2_; return result; } { GRegex* regex = NULL; gchar* _tmp3_; gchar* _tmp4_; GRegex* _tmp5_; GRegex* _tmp6_; gchar* _tmp7_ = NULL; GRegex* _tmp8_; gchar* _tmp9_; gchar* _tmp10_; _tmp3_ = g_regex_escape_string (old, -1); _tmp4_ = _tmp3_; _tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_); _tmp6_ = _tmp5_; _g_free0 (_tmp4_); regex = _tmp6_; if (G_UNLIKELY (_inner_error0_ != NULL)) { if (_inner_error0_->domain == G_REGEX_ERROR) { goto __catch0_g_regex_error; } g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); g_clear_error (&_inner_error0_); return NULL; } _tmp8_ = regex; _tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_); _tmp7_ = _tmp9_; if (G_UNLIKELY (_inner_error0_ != NULL)) { _g_regex_unref0 (regex); if (_inner_error0_->domain == G_REGEX_ERROR) { goto __catch0_g_regex_error; } g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); g_clear_error (&_inner_error0_); return NULL; } _tmp10_ = _tmp7_; _tmp7_ = NULL; result = _tmp10_; _g_free0 (_tmp7_); _g_regex_unref0 (regex); return result; } goto __finally0; __catch0_g_regex_error: { g_clear_error (&_inner_error0_); g_assert_not_reached (); } __finally0: g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); g_clear_error (&_inner_error0_); return NULL; } void test_string_replace (void) { gchar* s = NULL; gchar* _tmp0_; const gchar* _tmp1_; gchar* _tmp2_; const gchar* _tmp3_; _tmp0_ = g_strdup ("hellomyworld"); s = _tmp0_; _tmp1_ = s; _tmp2_ = string_replace (_tmp1_, "my", "whole"); _g_free0 (s); s = _tmp2_; _tmp3_ = s; _vala_assert (g_strcmp0 (_tmp3_, "hellowholeworld") == 0, "s == \"hellowholeworld\""); _g_free0 (s); } void test_string_slice (void) { gchar* s = NULL; gchar* _tmp0_; gchar* r = NULL; gchar* _tmp1_; const gchar* _tmp2_; gchar* _tmp3_; const gchar* _tmp4_; gchar* _tmp5_; const gchar* _tmp6_; gchar* _tmp7_; const gchar* _tmp8_; gchar* _tmp9_; const gchar* _tmp10_; _tmp0_ = g_strdup ("hellomyworld"); s = _tmp0_; _tmp1_ = string_slice (s, (glong) 5, (glong) 7); r = _tmp1_; _tmp2_ = r; _vala_assert (g_strcmp0 (_tmp2_, "my") == 0, "r == \"my\""); _tmp3_ = string_slice (s, (glong) -7, (glong) 7); _g_free0 (r); r = _tmp3_; _tmp4_ = r; _vala_assert (g_strcmp0 (_tmp4_, "my") == 0, "r == \"my\""); _tmp5_ = string_slice (s, (glong) 5, (glong) -5); _g_free0 (r); r = _tmp5_; _tmp6_ = r; _vala_assert (g_strcmp0 (_tmp6_, "my") == 0, "r == \"my\""); _tmp7_ = string_slice (s, (glong) -7, (glong) -5); _g_free0 (r); r = _tmp7_; _tmp8_ = r; _vala_assert (g_strcmp0 (_tmp8_, "my") == 0, "r == \"my\""); _tmp9_ = string_slice (s, (glong) 0, (glong) 0); _g_free0 (r); r = _tmp9_; _tmp10_ = r; _vala_assert (g_strcmp0 (_tmp10_, "") == 0, "r == \"\""); _g_free0 (r); _g_free0 (s); } static gchar* string_splice (const gchar* self, glong start, glong end, const gchar* str) { glong string_length = 0L; gint _tmp0_; gint _tmp1_; gboolean _tmp2_ = FALSE; gboolean _tmp3_ = FALSE; gsize str_size = 0UL; const gchar* _result_ = NULL; void* _tmp6_; gchar* dest = NULL; const gchar* _tmp7_; gchar* _tmp8_; gchar* _tmp9_; gchar* _tmp12_; const gchar* _tmp13_; gchar* result; g_return_val_if_fail (self != NULL, NULL); _tmp0_ = strlen (self); _tmp1_ = _tmp0_; string_length = (glong) _tmp1_; if (start < ((glong) 0)) { start = string_length + start; } if (end < ((glong) 0)) { end = string_length + end; } if (start >= ((glong) 0)) { _tmp2_ = start <= string_length; } else { _tmp2_ = FALSE; } g_return_val_if_fail (_tmp2_, NULL); if (end >= ((glong) 0)) { _tmp3_ = end <= string_length; } else { _tmp3_ = FALSE; } g_return_val_if_fail (_tmp3_, NULL); g_return_val_if_fail (start <= end, NULL); if (str == NULL) { str_size = (gsize) 0; } else { gint _tmp4_; gint _tmp5_; _tmp4_ = strlen ((const gchar*) str); _tmp5_ = _tmp4_; str_size = (gsize) _tmp5_; } _tmp6_ = g_malloc0 (((string_length - (end - start)) + str_size) + 1); _result_ = _tmp6_; _tmp7_ = _result_; dest = (gchar*) _tmp7_; _tmp8_ = dest; memcpy (_tmp8_, self, (gsize) start); _tmp9_ = dest; dest = _tmp9_ + start; if (str != NULL) { gchar* _tmp10_; gchar* _tmp11_; _tmp10_ = dest; memcpy (_tmp10_, str, str_size); _tmp11_ = dest; dest = _tmp11_ + str_size; } _tmp12_ = dest; memcpy (_tmp12_, ((gchar*) self) + end, (gsize) (string_length - end)); _tmp13_ = _result_; _result_ = NULL; result = (gchar*) _tmp13_; return result; } void test_string_splice (void) { gchar* s = NULL; gchar* _tmp0_; const gchar* _tmp1_; gchar* _tmp2_; const gchar* _tmp3_; const gchar* _tmp4_; gchar* _tmp5_; const gchar* _tmp6_; const gchar* _tmp7_; gchar* _tmp8_; const gchar* _tmp9_; const gchar* _tmp10_; gchar* _tmp11_; const gchar* _tmp12_; const gchar* _tmp13_; gchar* _tmp14_; const gchar* _tmp15_; gchar* _tmp16_; const gchar* _tmp17_; gchar* _tmp18_; const gchar* _tmp19_; _tmp0_ = g_strdup ("hellomyworld"); s = _tmp0_; _tmp1_ = s; _tmp2_ = string_splice (_tmp1_, (glong) 5, (glong) 7, NULL); _g_free0 (s); s = _tmp2_; _tmp3_ = s; _vala_assert (g_strcmp0 (_tmp3_, "helloworld") == 0, "s == \"helloworld\""); _tmp4_ = s; _tmp5_ = string_splice (_tmp4_, (glong) 5, (glong) 5, "whole"); _g_free0 (s); s = _tmp5_; _tmp6_ = s; _vala_assert (g_strcmp0 (_tmp6_, "hellowholeworld") == 0, "s == \"hellowholeworld\""); _tmp7_ = s; _tmp8_ = string_splice (_tmp7_, (glong) 10, (glong) -5, "wide"); _g_free0 (s); s = _tmp8_; _tmp9_ = s; _vala_assert (g_strcmp0 (_tmp9_, "hellowholewideworld") == 0, "s == \"hellowholewideworld\""); _tmp10_ = s; _tmp11_ = string_splice (_tmp10_, (glong) -14, (glong) 5, NULL); _g_free0 (s); s = _tmp11_; _tmp12_ = s; _vala_assert (g_strcmp0 (_tmp12_, "hellowholewideworld") == 0, "s == \"hellowholewideworld\""); _tmp13_ = s; _tmp14_ = string_splice (_tmp13_, (glong) -14, (glong) -5, NULL); _g_free0 (s); s = _tmp14_; _tmp15_ = s; _vala_assert (g_strcmp0 (_tmp15_, "helloworld") == 0, "s == \"helloworld\""); _tmp16_ = string_splice ("hello", (glong) 0, (glong) 0, NULL); _g_free0 (s); s = _tmp16_; _tmp17_ = s; _vala_assert (g_strcmp0 (_tmp17_, "hello") == 0, "s == \"hello\""); _tmp18_ = string_splice ("world", (glong) 0, (glong) 0, "hello"); _g_free0 (s); s = _tmp18_; _tmp19_ = s; _vala_assert (g_strcmp0 (_tmp19_, "helloworld") == 0, "s == \"helloworld\""); _g_free0 (s); } static glong string_strnlen (gchar* str, glong maxlen) { gchar* end = NULL; gchar* _tmp0_; gchar* _tmp1_; glong result; _tmp0_ = memchr (str, 0, (gsize) maxlen); end = _tmp0_; _tmp1_ = end; if (_tmp1_ == NULL) { result = maxlen; return result; } else { gchar* _tmp2_; _tmp2_ = end; result = (glong) (_tmp2_ - str); return result; } } static gchar* string_substring (const gchar* self, glong offset, glong len) { glong string_length = 0L; gboolean _tmp0_ = FALSE; gchar* _tmp3_; gchar* result; g_return_val_if_fail (self != NULL, NULL); if (offset >= ((glong) 0)) { _tmp0_ = len >= ((glong) 0); } else { _tmp0_ = FALSE; } if (_tmp0_) { string_length = string_strnlen ((gchar*) self, offset + len); } else { gint _tmp1_; gint _tmp2_; _tmp1_ = strlen (self); _tmp2_ = _tmp1_; string_length = (glong) _tmp2_; } if (offset < ((glong) 0)) { offset = string_length + offset; g_return_val_if_fail (offset >= ((glong) 0), NULL); } else { g_return_val_if_fail (offset <= string_length, NULL); } if (len < ((glong) 0)) { len = string_length - offset; } g_return_val_if_fail ((offset + len) <= string_length, NULL); _tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len); result = _tmp3_; return result; } void test_string_substring (void) { gchar* s = NULL; gchar* _tmp0_; gchar* r = NULL; gchar* _tmp1_; const gchar* _tmp2_; gchar* _tmp3_; const gchar* _tmp4_; gchar* _tmp5_; const gchar* _tmp6_; gchar* _tmp7_; const gchar* _tmp8_; _tmp0_ = g_strdup ("hellomyworld"); s = _tmp0_; _tmp1_ = string_substring (s, (glong) 5, (glong) 2); r = _tmp1_; _tmp2_ = r; _vala_assert (g_strcmp0 (_tmp2_, "my") == 0, "r == \"my\""); _tmp3_ = string_substring (s, (glong) -7, (glong) 2); _g_free0 (r); r = _tmp3_; _tmp4_ = r; _vala_assert (g_strcmp0 (_tmp4_, "my") == 0, "r == \"my\""); _tmp5_ = string_substring (s, (glong) 5, (glong) -1); _g_free0 (r); r = _tmp5_; _tmp6_ = r; _vala_assert (g_strcmp0 (_tmp6_, "myworld") == 0, "r == \"myworld\""); _tmp7_ = string_substring (s, (glong) -7, (glong) -1); _g_free0 (r); r = _tmp7_; _tmp8_ = r; _vala_assert (g_strcmp0 (_tmp8_, "myworld") == 0, "r == \"myworld\""); _g_free0 (r); _g_free0 (s); } static void _vala_main (void) { test_string (); test_string_concat (); test_string_joinv (); test_string_printf (); test_string_replace (); test_string_slice (); test_string_splice (); test_string_substring (); } int main (int argc, char ** argv) { _vala_main (); return 0; } static void _vala_array_destroy (gpointer array, gssize array_length, GDestroyNotify destroy_func) { if ((array != NULL) && (destroy_func != NULL)) { gssize i; for (i = 0; i < array_length; i = i + 1) { if (((gpointer*) array)[i] != NULL) { destroy_func (((gpointer*) array)[i]); } } } } static void _vala_array_free (gpointer array, gssize array_length, GDestroyNotify destroy_func) { _vala_array_destroy (array, array_length, destroy_func); g_free (array); }