Compare commits
	
		
			No commits in common. "4c8151674216cfaa0794ff8a7e63d81f992702d4" and "b1a4a1a2b95c708009b1557dc03f453bd1ae8ddd" have entirely different histories.
		
	
	
		
			4c81516742
			...
			b1a4a1a2b9
		
	
		
							
								
								
									
										21
									
								
								src/dj.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								src/dj.c
									
									
									
									
									
								
							| @ -170,6 +170,12 @@ usage(char *argv0) { | ||||
| } | ||||
| 
 | ||||
| int main(int argc, char *argv[]) { | ||||
| #ifdef __OpenBSD__ | ||||
| 	if (pledge("cpath rpath stdio unveil wpath", NULL) == -1) { | ||||
| 		return oserr(NULL", errno); | ||||
| 	} | ||||
| #endif | ||||
| 
 | ||||
|    	int align;    /* low 8b used, negative if no alignment is being done */ | ||||
| 	int count;    /* -1 if dj(1) runs until no more reads are possible */ | ||||
| 	char *fmt;    /* set to fmt_asv (default) or fmt_human (-H) */ | ||||
| @ -177,12 +183,6 @@ int main(int argc, char *argv[]) { | ||||
| 	bool retry;   /* false if exits on partial reads or writes */ | ||||
| 	struct Io io[2 /* { in, out } */]; | ||||
| 
 | ||||
| #ifdef __OpenBSD__ | ||||
| 	if (pledge("cpath rpath stdio unveil wpath", NULL) == -1) { | ||||
| 		return oserr(NULL, errno); | ||||
| 	} | ||||
| #endif | ||||
| 
 | ||||
| 	/* Set defaults. */ | ||||
| 	align = -1; | ||||
| 	count = -1; | ||||
| @ -217,9 +217,13 @@ int main(int argc, char *argv[]) { | ||||
| 						break; | ||||
| 					} else { | ||||
| 						int fd; | ||||
| 
 | ||||
| #ifdef __OpenBSD__ | ||||
| 						if (unveil(optarg, i == 0 ? "r" : "wc") == -1) { | ||||
| 						char *perms = "wc"; | ||||
| 
 | ||||
| 						/* modify perms in-place to read-only */ | ||||
| 						if (i == 0) { perms = "r"; } | ||||
| 
 | ||||
| 						if (unveil(optarg, perms) == -1) { | ||||
| 							return oserr(NULL, errno); | ||||
| 						} | ||||
| #endif | ||||
| @ -263,7 +267,6 @@ int main(int argc, char *argv[]) { | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| #ifdef __OpenBSD__ | ||||
| 	if (unveil(NULL, NULL) == -1) { return oserr(NULL, errno); } | ||||
| #endif | ||||
|  | ||||
							
								
								
									
										18
									
								
								src/npc.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/npc.c
									
									
									
									
									
								
							| @ -39,20 +39,22 @@ usage(char *argv0) { | ||||
| } | ||||
| 
 | ||||
| int main(int argc, char *argv[]) { | ||||
| #ifdef __OpenBSD__ | ||||
| 	program_name = argv[0] == NULL ? program_name : argv[0]; | ||||
| 
 | ||||
| 	if (pledge("stdio", NULL) == -1) { | ||||
| 		perror(program_name); | ||||
| 		return EX_OSERR; | ||||
| 	} | ||||
| #endif | ||||
| 	int c; | ||||
| 	char showend = 0; /* print a dollar sign before each newline */ | ||||
| 	char showtab = 0; /* prints tab characters in caret notation */ | ||||
| 
 | ||||
| #ifdef __OpenBSD__ | ||||
| 	if (pledge("stdio", NULL) == -1) { | ||||
| 		perror(argv[0] == NULL ? program_name : argv[0]); | ||||
| 		return EX_OSERR; | ||||
| 	} | ||||
| #endif | ||||
| 
 | ||||
| 	if (argc > 0) { | ||||
| #ifndef __OpenBSD__ | ||||
| 		program_name = argv[0]; | ||||
| 
 | ||||
| #endif | ||||
| 		while ((c = getopt(argc, argv, "et")) != -1) { | ||||
| 			switch (c){ | ||||
| 				case 'e': showend = 1; break; | ||||
|  | ||||
| @ -17,7 +17,6 @@ | ||||
|  * along with this program. If not, see https://www.gnu.org/licenses/.
 | ||||
|  */ | ||||
| 
 | ||||
| #include <assert.h> /* assert(3) */ | ||||
| #include <stdio.h> /* fprintf(3), stderr, NULL */ | ||||
| #include <stdlib.h> /* EXIT_FAILURE, EXIT_SUCCESS */ | ||||
| #include <string.h> /* memset(3), strchr(3) */ | ||||
| @ -30,7 +29,6 @@ | ||||
| 
 | ||||
| char *program_name = "scrut"; | ||||
| #define OPTS "bcdefgkprsuwxLS" | ||||
| /* this is an array so main:sel's size can be known at compile time */ | ||||
| static char opts[] = OPTS; | ||||
| 
 | ||||
| static int | ||||
| @ -60,10 +58,7 @@ int main(int argc, char *argv[]) { | ||||
| 		memset(sel, '\0', sizeof sel); | ||||
| 		for (int c; (c = getopt(argc, argv, opts)) != -1;) { | ||||
| 			if ((p = strchr(opts, c)) == NULL) { return usage(argv[0]); } | ||||
| 			else { | ||||
| 				assert(p - opts < sizeof sel / sizeof *sel); /* bounds check */ | ||||
| 				sel[p - opts] = c; | ||||
| 			} | ||||
| 			else { sel[p - opts] = c; } | ||||
| 		} | ||||
| 
 | ||||
| 		/* straighten out selections; permute out nulls */ | ||||
| @ -78,7 +73,7 @@ int main(int argc, char *argv[]) { | ||||
| 
 | ||||
| 	if (optind == argc) { return usage(argv[0]); } | ||||
| 
 | ||||
| 	for (argv += optind ; *argv != NULL; argv = &argv[1]) { | ||||
| 	for (argv += optind ; *argv != NULL; ++argv) { | ||||
| 		struct stat buf; | ||||
| 
 | ||||
| #ifdef __OpenBSD__ | ||||
|  | ||||
							
								
								
									
										12
									
								
								src/strcmp.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/strcmp.c
									
									
									
									
									
								
							| @ -26,22 +26,18 @@ | ||||
| char *program_name = "strcmp"; | ||||
| 
 | ||||
| int main(int argc, char *argv[]) { | ||||
| 	unsigned int i; | ||||
| 	program_name = argv[0] == NULL ? program_name : argv[0]; | ||||
| 	int i; | ||||
| 
 | ||||
| #ifdef __OpenBSD__ | ||||
| 	if (pledge("stdio", NULL) == -1) { | ||||
| 		perror(argv[0] == NULL ? program_name : argv[0]); | ||||
| 
 | ||||
| 		perror(program_name); | ||||
| 		return EX_OSERR; | ||||
| 	} | ||||
| #endif | ||||
| 
 | ||||
| 	if (argc < 3) { | ||||
| 		(void)fprintf( | ||||
| 			stderr, | ||||
| 			"Usage: %s string string...\n", | ||||
| 			argv[0] == NULL ? program_name : argv[0] | ||||
| 		); | ||||
| 		(void)fprintf(stderr, "Usage: %s string string...\n", program_name); | ||||
| 
 | ||||
| 		return EX_USAGE; | ||||
| 	} | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user