--- libelwix/example/test_find2replace.c 2024/10/26 14:24:07 1.1 +++ libelwix/example/test_find2replace.c 2024/10/28 09:58:51 1.2 @@ -0,0 +1,44 @@ +#include +#include +#include + + +int +main(int argc, char **argv) +{ + int mlen, hm; + char *str; + const char *cs = "ABCDEF123GHIJ321KL123MNOP123QRST122UWV123XYZ"; + const char *csb = "123ABCDEF123GHIJ321KL123MNOP123QRST122UWV123XYZ"; + const char *cse = "ABCDEF123GHIJ321KL123MNOP123QRST122UWV123XYZ123"; + const char *csn = ""; + const char *cso = "AB"; + + hm = str_find2replace(cs, "123", NULL, NULL, NULL); + printf("s&r howmany=%d only\n", hm); + + hm = str_find2replace(cs, "123", "*3245*", &str, &mlen); + printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, cs, mlen, str); + e_free(str); + hm = str_find2replace(csb, "123", "*3245*", &str, &mlen); + printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, csb, mlen, str); + e_free(str); + hm = str_find2replace(cse, "123", "*3245*", &str, &mlen); + printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, cse, mlen, str); + e_free(str); + hm = str_find2replace(csn, "123", "*3245*", &str, &mlen); + printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, csn, mlen, str); + e_free(str); + hm = str_find2replace(cso, "123", "*3245*", &str, &mlen); + printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, cso, mlen, str); + e_free(str); + + hm = str_find2replace(cs, "123", NULL, &str, &mlen); + printf("s&e howmany=%d origin=%s new(%d)=%s\n", hm, cs, mlen, str); + e_free(str); + + hm = str_find2replace(cs, "123", "*", &str, &mlen); + printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, cs, mlen, str); + e_free(str); + return 0; +}