svn commit: r282425 - in head/usr.bin/soelim: . tests
Baptiste Daroussin
bapt at FreeBSD.org
Mon May 4 18:20:33 UTC 2015
Author: bapt
Date: Mon May 4 18:20:31 2015
New Revision: 282425
URL: https://svnweb.freebsd.org/changeset/base/282425
Log:
Parse filename until first space then print the rest of the line after file
inclusion
This is the same behaviour of heirloom's soelim
Added:
head/usr.bin/soelim/tests/basic-with-space.in (contents, props changed)
head/usr.bin/soelim/tests/basic-with-space.out (contents, props changed)
Modified:
head/usr.bin/soelim/soelim.c
head/usr.bin/soelim/tests/Makefile
head/usr.bin/soelim/tests/soelim.sh
Modified: head/usr.bin/soelim/soelim.c
==============================================================================
--- head/usr.bin/soelim/soelim.c Mon May 4 17:59:39 2015 (r282424)
+++ head/usr.bin/soelim/soelim.c Mon May 4 18:20:31 2015 (r282425)
@@ -108,11 +108,12 @@ soelim_file(FILE *f, int flag)
while (isspace(*walk))
walk++;
- cp = walk + strlen(walk) - 1;
- while (cp > walk && isspace(*cp)) {
- *cp = 0;
- cp--;
- }
+ cp = walk;
+ while (*cp != '\0' && !isspace(*cp))
+ cp++;
+ *cp = 0;
+ if (cp < line + linelen)
+ cp++;
if (*walk == '\0') {
printf("%s", line);
@@ -122,6 +123,8 @@ soelim_file(FILE *f, int flag)
free(line);
return (1);
}
+ if (*cp != '\0')
+ printf("%s", cp);
}
free(line);
Modified: head/usr.bin/soelim/tests/Makefile
==============================================================================
--- head/usr.bin/soelim/tests/Makefile Mon May 4 17:59:39 2015 (r282424)
+++ head/usr.bin/soelim/tests/Makefile Mon May 4 18:20:31 2015 (r282425)
@@ -7,7 +7,9 @@ ATF_TESTS_SH= soelim
FILES= nonexisting.in \
basic.in \
basic \
- basic.out
+ basic.out \
+ basic-with-space.in \
+ basic-with-space.out
FILESDIR= ${TESTSDIR}
.include <bsd.test.mk>
Added: head/usr.bin/soelim/tests/basic-with-space.in
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/usr.bin/soelim/tests/basic-with-space.in Mon May 4 18:20:31 2015 (r282425)
@@ -0,0 +1,3 @@
+This is a test
+.so basic something
+end
Added: head/usr.bin/soelim/tests/basic-with-space.out
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/usr.bin/soelim/tests/basic-with-space.out Mon May 4 18:20:31 2015 (r282425)
@@ -0,0 +1,4 @@
+This is a test
+basic has been included
+something
+end
Modified: head/usr.bin/soelim/tests/soelim.sh
==============================================================================
--- head/usr.bin/soelim/tests/soelim.sh Mon May 4 17:59:39 2015 (r282424)
+++ head/usr.bin/soelim/tests/soelim.sh Mon May 4 18:20:31 2015 (r282425)
@@ -87,6 +87,13 @@ files_body()
-e empty \
-s exit:0 \
soelim -I$(atf_get_srcdir) $(atf_get_srcdir)/basic.in
+
+ atf_check \
+ -o file:$(atf_get_srcdir)/basic-with-space.out \
+ -e empty \
+ -s exit:0 \
+ soelim -I$(atf_get_srcdir) $(atf_get_srcdir)/basic-with-space.in
+
}
atf_init_test_cases()
More information about the svn-src-head
mailing list