[comp.os.minix] Fix to more.c

hgm@beta.UUCP (07/07/87)

I have been using a Microsoft C  V-4.0 development system under MS-DOS. One
thing that keeps popping up in MINIX software is variables on the stack are
ASSUMED to be initialized to zero. With many compilers, this is not true.
(Likewise for bss variables.)
MSC is one. One problem with the "more" released as part of the 1.2 MINIX
distribution is that fd is on the stack and when argc is one, fd is not
likely to be zero, so piping to "more" doesn't work.  I added the line
indicated below to solve that one.


---------------------------

int isrewind = 0;		/* flag: ' command -- next input() rewind */
int isdone = 0; 		/* flag: return EOF next read even if not */

main(argc, argv)
char **argv; {
	char ch;
	int fd, arg;

	signal(SIGINT, byebye);
	fd = 0;       <--------- add this line ------------
	cbreak();
	if (argc < 2)
		while ((ch = input(fd)) != 0)
			output(ch);
	else
		for (arg = 1; argv[arg] != (char *) 0; arg++) {


----------------------


An aside; several people have asked me for the software relevant to my
MSC cross development environment. If there is enough interest I will
post it, BUT I have reservations about some of it, particularly the
way segments are handled. It seems to work without any glitches save
they way chmem seems to affect codes. It is separate I & D, and the
effect chmem has is not always clear.  The stack & alloc space always
seems to have to be bigger than I feel it should be, and I am not sure why.
If I knew why, I think I would feel better about what I have done
with the segments. Unfortunately, I don't have lots of time to put
in it, and what I have does seem to work; so I'll probably never have time to
get rid of that uneasy feeling about the segments.  With that uneasy feeling,
I am hesitant to post, but if there is enough interest
I'll post the relevant stuff anyway.  I would have thought that there
would be a bunch of the MSC cross development environments out there by now
anyway.


Harry McGavran
Group C-8
Los Alamos National Laboratory
hgm@lanl.GOV