1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953
|
/* basic_types_strings.c generated by valac, the Vala compiler
* generated from basic_types_strings.vala, do not modify */
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#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_;
gchar* _tmp4_;
const gchar* _tmp5_;
gchar* _tmp6_;
const gchar* _tmp7_;
_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\"");
_tmp4_ = string_replace ("Γειά σου Κόσμε", "Γειά σου ", "");
_g_free0 (s);
s = _tmp4_;
_tmp5_ = s;
_vala_assert (g_strcmp0 (_tmp5_, "Κόσμε") == 0, "s == \"\316\232\317\214\317\203\316\274\316\265\"");
_tmp6_ = string_replace ("こんにちは世界", "世界", "");
_g_free0 (s);
s = _tmp6_;
_tmp7_ = s;
_vala_assert (g_strcmp0 (_tmp7_, "こんにちは") == 0, "s == \"\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257\"");
_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);
}
|