int main(int argc, char **argv)
{
SilcBool success = FALSE;
- char string[1024];
+ char string[1024], *astring;
SilcBufferStruct buf;
if (argc > 1 && !strcmp(argv[1], "-d")) {
if (strcmp("This is barbar", silc_buffer_data(&buf)))
goto err;
+ silc_snprintf(string, sizeof(string), "This is foobar string!!");
+ astring = silc_memdup(string, strlen(string));
+ silc_buffer_set(&buf, astring, strlen(astring) + 1);
+ SILC_LOG_DEBUG(("sed 's/foo/barbar/g'"));
+ SILC_LOG_DEBUG(("string: %s", astring));
+ if (silc_buffer_format(&buf,
+ SILC_STR_REGEX("foo", SILC_STR_REGEX_ALL |
+ SILC_STR_REGEX_INCLUSIVE),
+ SILC_STR_REPLACE("barbar", 6),
+ SILC_STR_END,
+ SILC_STR_END) < 0)
+ goto err;
+ silc_buffer_printf(&buf, TRUE);
+ if (strcmp("This is barbarbar string!!", silc_buffer_data(&buf)))
+ goto err;
+ silc_buffer_purge(&buf);
+
+ silc_snprintf(string, sizeof(string), "This is foobar string foo!!");
+ astring = silc_memdup(string, strlen(string));
+ silc_buffer_set(&buf, astring, strlen(astring) + 1);
+ SILC_LOG_DEBUG(("sed 's/foo//g'"));
+ SILC_LOG_DEBUG(("string: %s", astring));
+ if (silc_buffer_format(&buf,
+ SILC_STR_REGEX("foo", SILC_STR_REGEX_ALL |
+ SILC_STR_REGEX_INCLUSIVE),
+ SILC_STR_REPLACE("", 0),
+ SILC_STR_END,
+ SILC_STR_END) < 0)
+ goto err;
+ silc_buffer_printf(&buf, TRUE);
+ if (strcmp("This is bar string !!", silc_buffer_data(&buf)))
+ goto err;
+ silc_buffer_purge(&buf);
+
silc_snprintf(string, sizeof(string), "This is foobar\n");
silc_buffer_set(&buf, string, strlen(string));
SILC_LOG_DEBUG(("sed 's/\\n/\\0/'"));