fix 1988/spinellis

Prevent the Makefile from hanging on stdin by
providing some sample input files and asking the
user to run the command themselves.
This commit is contained in:
Landon Curt Noll committed 2023-07-02 18:23:59 -07:00
1 parent 6dd2573efd
commit 95e41fa835
5 files changed
+40 -39

No files matched your search

+8 -5
View File
@@ -108,7 +108,7 @@ ENTRY= spinellis
PROG= ${ENTRY}
#
OBJ= ${PROG}.o
DATA= spinellis.data
DATA= spinellis.data input.txt input2.txt
TARGET= ${PROG}
#
ALT_OBJ= ${PROG}.alt.o
@@ -126,19 +126,22 @@ all: data ${TARGET}
love haste waste maker easter_egg sandwich \
supernova deep_magic magic charon pluto
${PROG}: ${PROG}.c
${PROG}: ${PROG}.c input.txt
@echo "NOTE: this entry will not compile with some compilers like clang."
@echo "NOTE: use make alt for clang."
${CC} ${CFLAGS} $< -o $@ ${LIBS}
@echo Now run the following command:
${RM} -f $@
@echo ${CC} ${CFLAGS} $< -o $@ ${LIBS} '<' input.txt '&&' ./${PROG}
# alternative executable
#
alt: data ${ALT_TARGET}
@${TRUE}
${PROG}.alt: ${PROG}.alt.c
${PROG}.alt: ${PROG}.alt.c input.txt
${CC} ${CFLAGS} -Wno-implicit-function-declaration $< -o $@ ${LIBS}
@while read -r r; do echo $$r ; done | ./${PROG}.alt
@echo Now run the following command:
@echo ./${PROG}.alt '<' input.txt '&&' ./${PROG}.alt
# data files
#
+12 -33
View File
@@ -11,52 +11,31 @@ Mastodon: <https://mstdn.social/@DSpinellis>
make all
```
and then type a C program into followed by EOF (usually `^D`, ctrl-d).
An alternate version (also one-line) that will work with clang has been
provided. See the Alternate code section below for how to use.
## Try:
```sh
make clobber all
main()
{
printf("Hello world\n");
}
^D
./spinellis
make clobber all
int main()
{
int i;
for (i = 0; i < 5; ++i)
printf("%d\n", i);
}
^D
./spinellis
rm -f spinellis ; cc spinellis.c -o spinellis < input.txt && ./spinellis
```
NOTE: you need to make clobber first for this entry to work right.
and try:
```
rm -f spinellis ; cc spinellis.c -o spinellis < input2.txt && ./spinellis
```
## Alternate code:
For clang try the alt code like:
```sh
make clobber alt
#include <stdio.h>
main()
{
puts("Hello world\n");
}
^D
./spinellis
cc spinellis.alt.c -o spinellis.alt < input.txt && ./spinellis.alt
```
NOTE: you need to make clobber first for this entry to work right.
and try:
```
cc spinellis.alt.c -o spinellis.alt < input2.txt && ./spinellis.alt
```
## Judges' remarks:
+8
View File
@@ -0,0 +1,8 @@
#include <stdio.h>
int
main(void)
{
printf("Hello, world!\n");
return 0;
}
+11
View File
@@ -0,0 +1,11 @@
#include <stdio.h>
int
main(void)
{
int i;
for (i = 0; i < 5; ++i) {
printf("%d\n", i);
}
return 0;
}
+1 -1
View File
@@ -1 +1 @@
main(){system("gcc -x c - -o spinellis");}
int main(void){system("rm -f spinellis.alt; cc -x c - -o spinellis.alt");return 0;}