summaryrefslogtreecommitdiffstats
path: root/usr.bin/xargs
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2002-06-22 12:58:42 +0000
committerjmallett <jmallett@FreeBSD.org>2002-06-22 12:58:42 +0000
commit70dd16c278dcc371e00dd7aed915ab3b233770f1 (patch)
tree03c9d22367316a2f7388386291cfb5d1ec71d3aa /usr.bin/xargs
parent5f785ab6ddf246014a12006e50bb06e8a8bb9fe7 (diff)
downloadFreeBSD-src-70dd16c278dcc371e00dd7aed915ab3b233770f1.zip
FreeBSD-src-70dd16c278dcc371e00dd7aed915ab3b233770f1.tar.gz
Check for results of repeated calls to strnsubst(), as well as for the
behaviour with NULL match string, as that has changed over time.
Diffstat (limited to 'usr.bin/xargs')
-rw-r--r--usr.bin/xargs/strnsubst.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/usr.bin/xargs/strnsubst.c b/usr.bin/xargs/strnsubst.c
index b6668b7..fc00ea0 100644
--- a/usr.bin/xargs/strnsubst.c
+++ b/usr.bin/xargs/strnsubst.c
@@ -73,14 +73,25 @@ done:
int
main(void)
{
- char *x, *y;
+ char *x, *y, *z, *za;
- y = x = "{}{}{}";
- strnsubst(&x, "{}", "v ybir whyv! ", 12);
- if (strcmp(x, "v ybir whyv! ") == 0)
- printf("strnsubst() seems to work as expected.\n");
- printf("x: %s\ny: %s\n", x, y);
+ x = "{}%$";
+ strnsubst(&x, "%$", "{} enpury!", 255);
+ y = x;
+ strnsubst(&y, "}{}", "ybir", 255);
+ z = y;
+ strnsubst(&z, "{", "v ", 255);
+ za = z;
+ strnsubst(&z, NULL, za, 255);
+ if (strcmp(z, "v ybir enpury!") == 0)
+ printf("strnsubst() seems to work!\n");
+ else
+ printf("strnsubst() is broken.\n");
+ printf("%s\n", z);
free(x);
+ free(y);
+ free(z);
+ free(za);
return 0;
}
#endif
OpenPOWER on IntegriCloud