2004/burley compiles with clang + try fixing it

main() had one arg, a char *, and this is against clang requirements.

There was no inclusion of setjmp.h and so the longjmp() function
implicitly returned int and was allowed to take the wrong number of
args. It should return void however and this caused a problem with
binary expressions. The comma operator has been used for this but it
might be a problem in that by having ,1 after each it will make
expressions that could turn out to be false to be incorrect.

The longjmp() was being called with one arg which was an element of an
int[4][1000]. This is obviously incorrect but at some point it worked.
Without the prototype this is not a problem but both before (gcc) and
after the compiler fix (with gcc and clang) it did not work with linux
(in this case fedora) or macOS. The code as it now stands has the same
problem as it did before the compilation fix: it lets you input a bet
but then it does not accept any input after that; it prints nothing more
but it should print a new hand. This issue has been put in bugs.md.

My guess (in my tired head) is it has to do with the abuse of the
longjmp() and/or the comma operator making the expressions always 1 (at
least that side of the expression, thus if it gets to the longjmp() part
it will always be 1). Perhaps it should be ,0? I don't know but I might
try that next (I would guess it should be whatever an implicit int would
return without a return statement but that's just a guess). But given
that it stops working at the same spot perhaps it's not the comma
operator. Maybe the function needs to be broken up into several but I
don't know and that might or might not be worth the effort.

Finally it returned main() itself but now it returns poke() which has
the body of what main used to be.

See bugs.md for more details.
This commit is contained in:
Cody Boone Ferguson committed 2023-03-22 06:30:03 -07:00
1 parent 41d2d7fb6a
commit c8c1dd403d
4 files changed
+81 -38

No files matched your search

+15 -3
View File
@@ -11,19 +11,31 @@
make
```
### To run:
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to compile with
clang which requires that the first arg of main() be an int and the remaining
args to be a `char **`. He notes that he could not get the entry to work with
gcc before the fix and it does not work with clang either; see
[/bugs.md](/bugs.md) for information here. Thank you Cody for your assistance!
## To run:
```sh
./burley
```
### Try:
NOTE: you need to input a number first. See judges' comments below for
information on how to play.
## Try:
```sh
echo "Do or do not. There is no try."
```
## Judges' comments
## Judges' comments:
This is a draw poker program. You start with $100. Input alternates
between your bet and which cards to keep. Example: