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:
1 parent
6dd2573efd
commit
95e41fa835
5 files changed
+40
-39
No files matched your search
@@ -108,7 +108,7 @@ ENTRY= spinellis
|
|||||||
PROG= ${ENTRY}
|
PROG= ${ENTRY}
|
||||||
#
|
#
|
||||||
OBJ= ${PROG}.o
|
OBJ= ${PROG}.o
|
||||||
DATA= spinellis.data
|
DATA= spinellis.data input.txt input2.txt
|
||||||
TARGET= ${PROG}
|
TARGET= ${PROG}
|
||||||
#
|
#
|
||||||
ALT_OBJ= ${PROG}.alt.o
|
ALT_OBJ= ${PROG}.alt.o
|
||||||
@@ -126,19 +126,22 @@ all: data ${TARGET}
|
|||||||
love haste waste maker easter_egg sandwich \
|
love haste waste maker easter_egg sandwich \
|
||||||
supernova deep_magic magic charon pluto
|
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: this entry will not compile with some compilers like clang."
|
||||||
@echo "NOTE: use make alt for 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
|
# alternative executable
|
||||||
#
|
#
|
||||||
alt: data ${ALT_TARGET}
|
alt: data ${ALT_TARGET}
|
||||||
@${TRUE}
|
@${TRUE}
|
||||||
|
|
||||||
${PROG}.alt: ${PROG}.alt.c
|
${PROG}.alt: ${PROG}.alt.c input.txt
|
||||||
${CC} ${CFLAGS} -Wno-implicit-function-declaration $< -o $@ ${LIBS}
|
${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
|
# data files
|
||||||
#
|
#
|
||||||
|
|||||||
+12
-33
@@ -11,52 +11,31 @@ Mastodon: <https://mstdn.social/@DSpinellis>
|
|||||||
make all
|
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:
|
## Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make clobber all
|
rm -f spinellis ; cc spinellis.c -o spinellis < input.txt && ./spinellis
|
||||||
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
|
|
||||||
```
|
```
|
||||||
|
|
||||||
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:
|
## Alternate code:
|
||||||
|
|
||||||
For clang try the alt code like:
|
For clang try the alt code like:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make clobber alt
|
cc spinellis.alt.c -o spinellis.alt < input.txt && ./spinellis.alt
|
||||||
#include <stdio.h>
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
puts("Hello world\n");
|
|
||||||
}
|
|
||||||
^D
|
|
||||||
./spinellis
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
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:
|
## Judges' remarks:
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
printf("Hello, world!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -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 @@
|
|||||||
main(){system("gcc -x c - -o spinellis");}
|
int main(void){system("rm -f spinellis.alt; cc -x c - -o spinellis.alt");return 0;}
|
||||||
Reference in new issue
Block a user