forked from bonsai/harakit
		
	mm(1): fix full file handling
This commit is contained in:
		
							parent
							
								
									395205d4c6
								
							
						
					
					
						commit
						d74bc715cf
					
				
							
								
								
									
										11
									
								
								src/mm.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/mm.c
									
									
									
									
									
								
							| @ -23,7 +23,8 @@ | ||||
| #include <stdlib.h> /* free(3), realloc(3) */ | ||||
| #include <string.h> /* strcmp(3), strerror(3) */ | ||||
| #include <unistd.h> /* getopt(3) */ | ||||
| #if !defined EX_OSERR || !defined EX_USAGE | ||||
| #if !defined EX_IOERR || !defined EX_OK || !defined EX_OSERR \ | ||||
| 		|| !defined EX_USAGE | ||||
| #	include <sysexits.h> | ||||
| #endif | ||||
| extern int errno; | ||||
| @ -192,7 +193,7 @@ int main(int argc, char *argv[]){ | ||||
| 			setvbuf(files[1].files[i++], NULL, _IONBF, 0)); | ||||
| 	} | ||||
| 
 | ||||
| 	retval = 0; | ||||
| 	retval = EX_OK; | ||||
| 
 | ||||
| 	/* Actual program loop. */ | ||||
| 	for(i = 0; i < files[0].s; ++i) /* iterate ins */ | ||||
| @ -200,16 +201,16 @@ int main(int argc, char *argv[]){ | ||||
| 			for(j = 0; j < files[1].s; ++j) /* iterate outs */ | ||||
| 				if(putc(c, files[1].files[j]) == EOF){ | ||||
| 					/* notebook's full */ | ||||
| 					retval = 1; | ||||
| 					retval = EX_IOERR; | ||||
| 					if(fclose(files[1].files[j]) == EOF) | ||||
| 						fprintf(stderr, "%s: %s: %s\n", | ||||
| 							program_name, files[1].names[j], strerror(errno)); | ||||
| 					/* massage out the tense muscle */ | ||||
| 					for(k = j; k < files[1].s - 1; ++k){ | ||||
| 					for(k = j--; k < files[1].s - 1; ++k){ | ||||
| 						files[1].files[k] = files[1].files[k+1]; | ||||
| 						files[1].names[k] = files[1].names[k+1]; | ||||
| 					} | ||||
| 					if(--files[i].s == 0) | ||||
| 					if(--files[1].s == 0) | ||||
| 						terminate; | ||||
| 				} | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user