dubois@rhesus.primate.wisc.edu (Paul DuBois) (09/10/87)
The recent posting of less did not compile correctly on my system.
(Ultrix 1.2 on a VAX 8200). The file os.c got three redeclaration
errors, for NULL, EOF and sprintf. The redeclaration for NULL is
ignorable, since less.h defines it the same way as <stdio.h>, but EOF
was defined as 0 (!!) in less.h. The sprintf error was because stdio.h
is not pulled into os.c until after sprintf is used (thus assumed to be
an int function by the compiler), and the char* declaration in stdio.h
results in a conflict. Patches to fix found below. They're quite
trivial - define EOF correctly, and move the #include for stdio.h to
the top of os.c.
*** less.h.orig Thu Sep 10 12:33:10 1987
--- less.h Thu Sep 10 12:33:30 1987
***************
*** 24,30
#define FILENAME 128 /* Max size of a filename */
! #define EOF (0)
#define NULL (0)
/* How quiet should we be? */
--- 24,30 -----
#define FILENAME 128 /* Max size of a filename */
! #define EOF (-1) /* was 0! */
#define NULL (0)
/* How quiet should we be? */
*** os.c.orig Thu Sep 10 12:33:38 1987
--- os.c Thu Sep 10 12:34:12 1987
***************
*** 10,15
* Unix features are present.
*/
#include "less.h"
#include <signal.h>
--- 10,19 -----
* Unix features are present.
*/
+ #if GLOB
+ #include <stdio.h>
+ #endif
+
#include "less.h"
#include <signal.h>
***************
*** 94,100
*/
#if GLOB
! #include <stdio.h>
FILE *popen();
public char *
--- 98,104 -----
*/
#if GLOB
! /*#include <stdio.h>*/
FILE *popen();
public char *
---
Paul DuBois UUCP: {allegra,ihnp4,seismo}!uwvax!rhesus!dubois |
ARPA: dubois@rhesus.primate.wisc.edu --+--
|
"Hard work isn't easy." --Mrs. O. |
eggert@sdcrdcf.UUCP (Paul Eggert) (09/11/87)
In article <237@rhesus.primate.wisc.edu> dubois@rhesus.primate.wisc.edu (Paul DuBois) correctly notes a bug in 'less': less.h attempts to #define EOF 0. Luckily for 'less' customers, the bug that this fixes is rare: it happens only when a filename pattern expander subshell outputs no newline. However, DuBois's suggested fix is not portable because 'less' often stores EOF in char[] buffers; this may not work on machines that have unsigned chars, because EOF is -1. Here's a portable fix: change EOF to EOI uniformly everywhere except in os.c, and make the following change to less.h. The change to the definition of NULL suppresses an unneeded warning about redefining NULL, at least on a Sun. 27,28c27,29 < #define EOF (0) < #define NULL (0) --- > #define EOI 0 /* End of input */ > /* NULL ought to be 0; this ensures a warning if it's not. */ > #define NULL 0