[comp.os.minix] Minor bugs in Atari ST minix library

bammi@dsrgsun.ces.CWRU.edu (Jwahar R. Bammi) (10/22/88)

Found two bugs in the Minix Atari ST distribution from PH:

- popen.c uses _exit(). _exit() is not in the library.
  Quick Fix: replace the one occurance of _exit() with exit()
  (i know they are not the same, but it is close enough for
   goverment work, especially on the atari version where they
   have eliminated _cleanup)

- fdopen.c is missing. Here is one:
/*
 * They missed this in the standard ST distribution
 *   adapted from fopen.c 
 *     ++jrb   bammi@dsrgsun.ces.cwru.edu
 *
 */
#include <stdio.h>


FILE *fdopen(fd,mode)
int fd;
char *mode;
{
	register int i;
	FILE *fp;
	extern char *malloc();
	int  flags = 0;

	/* find a table slot */
	for (i = 0; _io_table[i] != 0 ; i++) 
		if ( i >= NFILES )
			return(NULL); /* if none avail */

	/* set up flags */
	switch(*mode){

	case 'w':
		flags |= WRITEMODE;
		break;

	case 'a': 
		flags |= WRITEMODE;
		break;         

	case 'r':
		flags |= READMODE;	
		break;

	default:
		return(NULL);
	}


	if (( fp = (FILE *) malloc (sizeof( FILE))) == NULL )
		return(NULL);


	fp->_count = 0;
	fp->_fd = fd;
	fp->_flags = flags;
	fp->_buf = malloc( BUFSIZ );
	if ( fp->_buf == NULL )
		fp->_flags |=  UNBUFF;
	else 
		fp->_flags |= IOMYBUF;

	fp->_ptr = fp->_buf;
	_io_table[i] = fp;
	return(fp);
}
/* - eof - */
-- 
usenet: {decvax,sun}!cwjcc!bammi		jwahar r. bammi
csnet:       bammi@dsrgsun.ces.CWRU.edu
arpa:        bammi@dsrgsun.ces.CWRU.edu
compuServe:  71515,155