Parse filename until first space then print the rest of the line after file
inclusion This is the same behaviour of heirloom's soelim
This commit is contained in:
parent
28315e27a7
commit
2b30fb2639
@ -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 = walk;
|
||||
while (*cp != '\0' && !isspace(*cp))
|
||||
cp++;
|
||||
*cp = 0;
|
||||
cp--;
|
||||
}
|
||||
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);
|
||||
|
@ -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>
|
||||
|
3
usr.bin/soelim/tests/basic-with-space.in
Normal file
3
usr.bin/soelim/tests/basic-with-space.in
Normal file
@ -0,0 +1,3 @@
|
||||
This is a test
|
||||
.so basic something
|
||||
end
|
4
usr.bin/soelim/tests/basic-with-space.out
Normal file
4
usr.bin/soelim/tests/basic-with-space.out
Normal file
@ -0,0 +1,4 @@
|
||||
This is a test
|
||||
basic has been included
|
||||
something
|
||||
end
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user