Fix EOF == -1 assumption in 1994/shapiro
The problem is that the getc() functions return EOF on error/EOF but it assumed that it returns -1. EOF is not required to be -1 but merely an int < 0 so on systems where it was not -1 it could be a problem. But changing the != -1 check to be != EOF caused a new compiler warning and errors. However since EOF < 0 and since the code functions fine with the check being >= 0 the code now checks that the return value of getc() >= 0 as the condition of the for loop. This takes care of any problem where EOF != -1. Fixed accidental change in shapiro.md code excerpt. Note that that one (the first one) does not actually work but it never did (or if it did it doesn't in modern systems). I'm not sure this is a problem though as the author stated that without the comments the program will not do anything right. I believe the author was showing the algorithm without comments.
This commit is contained in:
1 parent
e09f677b37
commit
0c543beb0f
4 files changed
+17
-89
No files matched your search
@@ -11,7 +11,7 @@
|
||||
/*T*/,"r");for (;( L/*KPUOWOWMUQ
|
||||
LLOLMPULWLWL WLW LWLWLWLWLWLW
|
||||
LWLWLULVOXP LLV LLLOLMPULOL
|
||||
MMNP*/=getc (J) )!= -1;L/*
|
||||
MMNP*/=getc (J) )>= 0;L/*
|
||||
OLWLRMMQUL VOX PLLVLLLMQO
|
||||
PMPYPXPNP MQL LVLLLWPSP
|
||||
XPOQNQOPMQ LLV LTj*/>='J'
|
||||
|
||||
Reference in new issue
Block a user