use a larger buffer on larger machines
This commit is contained in:
		
							parent
							
								
									30959cd73f
								
							
						
					
					
						commit
						d5b2601b8f
					
				
					 7 changed files with 43 additions and 33 deletions
				
			
		|  | @ -4,6 +4,16 @@ | |||
|  * See the copyright notice in the ACK home directory, in the file "Copyright". | ||||
|  */ | ||||
| #define BUFSIZ  1024 | ||||
| #ifdef vax | ||||
| #define _NBF	8 | ||||
| #endif | ||||
| #ifdef mc68020 | ||||
| #define _NBF	8 | ||||
| #endif | ||||
| #ifndef _NBF | ||||
| #define _NBF	1 | ||||
| #endif | ||||
| #define _BUFSIZ	(_NBF * BUFSIZ) | ||||
| #define _NFILES  20 | ||||
| #define NULL       0 | ||||
| #define EOF     (-1) | ||||
|  | @ -24,6 +34,7 @@ extern struct _io_buf { | |||
|     int     _flags; | ||||
|     unsigned char   *_buf; | ||||
|     unsigned char   *_ptr; | ||||
|     int	    _bufsiz; | ||||
| }  *_io_table[_NFILES], _stdin, _stdout, _stderr; | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,19 +1,16 @@ | |||
| /* $Header$ */ | ||||
| #include <stdio.h> | ||||
| 
 | ||||
| unsigned char  _sobuf[BUFSIZ]; | ||||
| unsigned char  _sibuf[BUFSIZ]; | ||||
| 
 | ||||
| struct _io_buf _stdin = { | ||||
| 	0, 0, IO_READMODE , _sibuf, _sibuf | ||||
| 	0, 0, IO_READMODE , 0, 0, 0 | ||||
| }; | ||||
| 
 | ||||
| struct _io_buf _stdout = { | ||||
| 	1, 0, IO_WRITEMODE, 0, 0 | ||||
| 	1, 0, IO_WRITEMODE, 0, 0, 0 | ||||
| }; | ||||
| 
 | ||||
| struct _io_buf _stderr = { | ||||
| 	2, 0, IO_WRITEMODE + IO_UNBUFF, NULL, NULL | ||||
| 	2, 0, IO_WRITEMODE + IO_UNBUFF, 0, 0, 0 | ||||
| }; | ||||
| 
 | ||||
| struct  _io_buf  *_io_table[_NFILES] = { | ||||
|  |  | |||
|  | @ -12,14 +12,14 @@ FILE *iop; | |||
| 	    !io_testflag(iop,IO_WRITEMODE) )  | ||||
| 		return(0); | ||||
| 
 | ||||
| 	count = BUFSIZ - iop->_count; | ||||
| 	count = iop->_bufsiz - iop->_count; | ||||
| 	if ( count <= 0 ) | ||||
| 		return(0); | ||||
| 
 | ||||
| 	c1 = write(iop->_fd,iop->_buf,count); | ||||
| 
 | ||||
| 	if ( count == c1 ) { | ||||
| 		iop->_count = BUFSIZ; | ||||
| 		iop->_count = iop->_bufsiz; | ||||
| 		iop->_ptr   = iop->_buf; | ||||
| 		return(count); | ||||
| 	} | ||||
|  |  | |||
|  | @ -17,13 +17,21 @@ register FILE *iop; | |||
| 		return (EOF); | ||||
| 
 | ||||
| 	if (! io_testflag(iop, IO_UNBUFF) && ! iop->_buf) { | ||||
| 		iop->_buf = (unsigned char *) malloc(BUFSIZ); | ||||
| 		if (! iop->_buf) iop->_flags |= IO_UNBUFF; | ||||
| 		else iop->_flags |= IO_MYBUF; | ||||
| 		iop->_buf = (unsigned char *) malloc(_BUFSIZ); | ||||
| 		if (! iop->_buf) { | ||||
| 			iop->_flags |= IO_UNBUFF; | ||||
| 		} | ||||
| 		else { | ||||
| 			iop->_flags |= IO_MYBUF; | ||||
| 			iop->_bufsiz = _BUFSIZ; | ||||
| 		} | ||||
| 	} | ||||
| 	if (! iop->_buf) { | ||||
| 		iop->_buf = &ch[fileno(iop)]; | ||||
| 		iop->_bufsiz = 1; | ||||
| 	} | ||||
| 	if (! iop->_buf) iop->_buf = &ch[fileno(iop)]; | ||||
| 	iop->_ptr = iop->_buf; | ||||
| 	iop->_count = read(iop->_fd, iop->_buf, io_testflag(iop, IO_UNBUFF)? 1 : BUFSIZ); | ||||
| 	iop->_count = read(iop->_fd, iop->_buf, iop->_bufsiz); | ||||
| 
 | ||||
| 	if (iop->_count <= 0){ | ||||
| 		if (iop->_count == 0) { | ||||
|  |  | |||
|  | @ -8,26 +8,19 @@ _flushbuf(c, iop) | |||
| 	if (fileno(iop) < 0) return EOF; | ||||
| 	if (! io_testflag(iop, IO_UNBUFF)) { | ||||
| 		if (iop->_buf == 0) { | ||||
| 			if (iop == stdout) { | ||||
| 				if (isatty(fileno(stdout))) { | ||||
| 			if (iop == stdout && isatty(fileno(stdout))) { | ||||
| 				iop->_flags |= IO_UNBUFF; | ||||
| 			} | ||||
| 				else { | ||||
| 					extern unsigned char _sobuf[]; | ||||
| 
 | ||||
| 					iop->_buf = _sobuf; | ||||
| 					iop->_count = BUFSIZ-1; | ||||
| 				} | ||||
| 			} | ||||
| 			else { | ||||
| 				extern char *malloc(); | ||||
| 	 | ||||
| 				if (!(iop->_buf = (unsigned char *) malloc(BUFSIZ))) { | ||||
| 				if (!(iop->_buf = (unsigned char *) malloc(_BUFSIZ))) { | ||||
| 					iop->_flags |= IO_UNBUFF; | ||||
| 				} | ||||
| 				else { | ||||
| 					iop->_flags |= IO_MYBUF; | ||||
| 					iop->_count = BUFSIZ-1; | ||||
| 					iop->_bufsiz = _BUFSIZ; | ||||
| 					iop->_count = _BUFSIZ-1; | ||||
| 				} | ||||
| 			} | ||||
| 			iop->_ptr = iop->_buf; | ||||
|  | @ -47,7 +40,7 @@ _flushbuf(c, iop) | |||
| 	else { | ||||
| 		int count = iop->_ptr - iop->_buf; | ||||
| 
 | ||||
| 		iop->_count = BUFSIZ - 1; | ||||
| 		iop->_count = iop->_bufsiz - 1; | ||||
| 		iop->_ptr = iop->_buf + 1; | ||||
| 
 | ||||
| 		if (count > 0) { | ||||
|  |  | |||
|  | @ -8,7 +8,6 @@ FILE *freopen(name,mode,fp) | |||
| char *name , *mode; | ||||
| register FILE *fp; | ||||
| { | ||||
| 	char *malloc(); | ||||
| 	int fd, | ||||
| 	flags = fp->_flags & ~(IO_WRITEMODE|IO_READMODE|IO_ERR|IO_EOF|IO_PERPRINTF); | ||||
| 
 | ||||
|  | @ -52,7 +51,7 @@ register FILE *fp; | |||
| 	} | ||||
| 	fp->_count = 0; | ||||
| 	if (fp->_buf && !(flags & IO_UNBUFF) && (flags & IO_WRITEMODE))  | ||||
| 		fp->_count = BUFSIZ; | ||||
| 		fp->_count = fp->_bufsiz; | ||||
| 	fp->_fd = fd; | ||||
| 	fp->_flags = flags; | ||||
| 	return(fp); | ||||
|  |  | |||
|  | @ -13,10 +13,12 @@ char *buffer; | |||
| 	iop->_buf = (unsigned char *) buffer; | ||||
| 
 | ||||
| 	iop->_count = 0; | ||||
| 	if ( iop->_buf == NULL ) | ||||
| 	if ( iop->_buf == NULL ) { | ||||
| 		iop->_flags |= IO_UNBUFF; | ||||
| 	else | ||||
| 		iop->_count = BUFSIZ; | ||||
| 
 | ||||
| 		iop->_bufsiz = 1; | ||||
| 	} else { | ||||
| 		if (io_testflag(iop, IO_WRITEMODE)) iop->_count = BUFSIZ; | ||||
| 		iop->_bufsiz = BUFSIZ; | ||||
| 	} | ||||
| 	iop->_ptr = iop->_buf; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue