style(9)
This commit is contained in:
		
							
								
								
									
										5
									
								
								eval.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								eval.c
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.12 2006/05/10 18:54:09 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.13 2006/08/01 13:43:26 tg Exp $"); | ||||
|  | ||||
| /* | ||||
|  * string expansion | ||||
| @@ -1074,7 +1074,8 @@ globit(XString *xs,	/* dest string */ | ||||
| 			xp = Xstring(*xs, xp) + prefix_len; | ||||
| 		} | ||||
| 		closedir(dirp); | ||||
| 	  Nodir:; | ||||
|  Nodir: | ||||
| 		; | ||||
| 	} | ||||
|  | ||||
| 	if (np != NULL) | ||||
|   | ||||
							
								
								
									
										2
									
								
								exec.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								exec.c
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.15 2006/05/10 18:54:10 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.16 2006/08/01 13:43:26 tg Exp $"); | ||||
|  | ||||
| static int	comexec(struct op *, struct tbl *volatile, char **, | ||||
| 		    int volatile); | ||||
|   | ||||
							
								
								
									
										2
									
								
								funcs.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								funcs.c
									
									
									
									
									
								
							| @@ -5,7 +5,7 @@ | ||||
|  | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.28 2006/07/03 12:16:30 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.29 2006/08/01 13:43:26 tg Exp $"); | ||||
|  | ||||
| int | ||||
| c_cd(char **wp) | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
|  | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.17 2006/08/01 13:19:42 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.18 2006/08/01 13:43:27 tg Exp $"); | ||||
|  | ||||
| static int	histfd; | ||||
| static int	hsize; | ||||
| @@ -669,8 +669,7 @@ hist_init(Source *s) | ||||
| 			hist_finish(); | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
| 	else if (hsize > 0) { | ||||
| 	} else if (hsize > 0) { | ||||
| 		/* | ||||
| 		 * we have some data | ||||
| 		 */ | ||||
|   | ||||
							
								
								
									
										2
									
								
								jobs.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								jobs.c
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.8 2006/05/10 18:54:11 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.9 2006/08/01 13:43:27 tg Exp $"); | ||||
|  | ||||
| /* Order important! */ | ||||
| #define PRUNNING	0 | ||||
|   | ||||
							
								
								
									
										3
									
								
								lex.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								lex.c
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.13 2006/07/03 12:16:30 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.14 2006/08/01 13:43:27 tg Exp $"); | ||||
|  | ||||
| /* Structure to keep track of the lexing state and the various pieces of info | ||||
|  * needed for each particular state. */ | ||||
| @@ -102,7 +102,6 @@ yylex(int cf) | ||||
| 	char *sp, *dp; | ||||
| 	int c2; | ||||
|  | ||||
|  | ||||
|  Again: | ||||
| 	states[0].ls_state = -1; | ||||
| 	states[0].ls_info.base = NULL; | ||||
|   | ||||
							
								
								
									
										2
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.c
									
									
									
									
									
								
							| @@ -6,7 +6,7 @@ | ||||
| #define	EXTERN				/* define EXTERNs in sh.h */ | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/main.c,v 1.43 2006/08/01 12:22:26 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/main.c,v 1.44 2006/08/01 13:43:27 tg Exp $"); | ||||
|  | ||||
| extern char **environ; | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								misc.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								misc.c
									
									
									
									
									
								
							| @@ -3,7 +3,7 @@ | ||||
|  | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.11 2006/05/10 18:54:11 tg Exp $" | ||||
| __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.12 2006/08/01 13:43:28 tg Exp $" | ||||
| 	"\t" MKSH_SH_H_ID); | ||||
|  | ||||
| short chtypes[UCHAR_MAX+1];	/* type bits for unsigned char */ | ||||
|   | ||||
							
								
								
									
										11
									
								
								setmode.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								setmode.c
									
									
									
									
									
								
							| @@ -48,7 +48,7 @@ | ||||
| #endif | ||||
|  | ||||
| __SCCSID("@(#)setmode.c	8.2 (Berkeley) 3/25/94"); | ||||
| __RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.2 2006/07/03 12:16:31 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.3 2006/08/01 13:43:28 tg Exp $"); | ||||
|  | ||||
| #define	SET_LEN	6		/* initial # of bitcmd struct to malloc */ | ||||
| #define	SET_LEN_INCR 4		/* # of bitcmd structs to add as needed */ | ||||
| @@ -103,7 +103,8 @@ getmode(const void *bbox, mode_t omode) | ||||
|  | ||||
| 		case 'o': | ||||
| 			value = newmode & S_IRWXO; | ||||
| common:			if (set->cmd2 & CMD2_CLR) { | ||||
|  common: | ||||
| 			if (set->cmd2 & CMD2_CLR) { | ||||
| 				clrval = | ||||
| 				    (set->cmd2 & CMD2_SET) ?  S_IRWXO : value; | ||||
| 				if (set->cmd2 & CMD2_UBITS) | ||||
| @@ -238,7 +239,8 @@ setmode(const char *p) | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| getop:		if ((op = *p++) != '+' && op != '-' && op != '=') { | ||||
|  getop: | ||||
| 		if ((op = *p++) != '+' && op != '-' && op != '=') { | ||||
| 			free(saveset); | ||||
| 			return (NULL); | ||||
| 		} | ||||
| @@ -318,7 +320,8 @@ getop:		if ((op = *p++) != '+' && op != '-' && op != '=') { | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| apply:		if (!*p) | ||||
|  apply: | ||||
| 		if (!*p) | ||||
| 			break; | ||||
| 		if (*p != ',') | ||||
| 			goto getop; | ||||
|   | ||||
							
								
								
									
										117
									
								
								strlfun.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										117
									
								
								strlfun.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,117 @@ | ||||
| /* $MirOS: src/bin/mksh/strlfun.c,v 1.3 2006/08/01 13:43:28 tg Exp $ */ | ||||
| /* _MirOS: src/lib/libc/string/strlfun.c,v 1.7 2006/08/01 13:41:49 tg Exp $ */ | ||||
| /* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */ | ||||
| /* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */ | ||||
|  | ||||
| /*- | ||||
|  * Copyright (c) 2004, 2005, 2006 Thorsten Glaser <tg@mirbsd.de> | ||||
|  * Thanks to Bodo Eggert for optimisation hints | ||||
|  * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | ||||
|  * | ||||
|  * Permission to use, copy, modify, and distribute this software for any | ||||
|  * purpose with or without fee is hereby granted, provided that the above | ||||
|  * copyright notice and this permission notice appear in all copies. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
|  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
|  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
|  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
|  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||
|  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||
|  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
|  */ | ||||
|  | ||||
| #if defined(_KERNEL) || defined(_STANDALONE) | ||||
| # include <lib/libkern/libkern.h> | ||||
| # undef HAVE_STRLCPY | ||||
| # undef HAVE_STRLCAT | ||||
| #else | ||||
| # ifdef HAVE_CONFIG_H	/* usually when packaged with third-party software */ | ||||
| #  include "config.h" | ||||
| # endif | ||||
| # include <sys/types.h> | ||||
|  | ||||
| extern size_t strlen(const char *); | ||||
|  | ||||
| #ifndef __RCSID | ||||
| #define __RCSID(x)	static const char __rcsid[] = (x) | ||||
| #endif | ||||
|  | ||||
| #ifndef __predict_false | ||||
| #define __predict_false(exp)	((exp) != 0) | ||||
| #endif | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/strlfun.c,v 1.3 2006/08/01 13:43:28 tg Exp $"); | ||||
| #endif | ||||
|  | ||||
| size_t strlcat(char *, const char *, size_t); | ||||
| size_t strlcpy(char *, const char *, size_t); | ||||
|  | ||||
| #ifndef	HAVE_STRLCPY | ||||
| /* | ||||
|  * Copy src to string dst of size siz.  At most siz-1 characters | ||||
|  * will be copied.  Always NUL terminates (unless siz == 0). | ||||
|  * Returns strlen(src); if retval >= siz, truncation occurred. | ||||
|  */ | ||||
| size_t | ||||
| strlcpy(char *dst, const char *src, size_t siz) | ||||
| { | ||||
| 	const char *s = src; | ||||
|  | ||||
| 	if (__predict_false(!siz)) | ||||
| 		goto traverse_src; | ||||
|  | ||||
| 	/* copy as many chars as will fit */ | ||||
| 	for (; --siz && (*dst++ = *s++); ) | ||||
| 		; | ||||
|  | ||||
| 	/* not enough room in dst */ | ||||
| 	if (__predict_false(!siz)) { | ||||
| 		/* safe to NUL-terminate dst since copied <= siz-1 chars */ | ||||
| 		*dst = '\0'; | ||||
|  traverse_src: | ||||
| 		/* traverse rest of src */ | ||||
| 		while (*s++) | ||||
| 			; | ||||
| 	} | ||||
|  | ||||
| 	/* count doesn't include NUL */ | ||||
| 	return (s - src - 1); | ||||
| } | ||||
| #endif /* !HAVE_STRLCPY */ | ||||
|  | ||||
| #ifndef	HAVE_STRLCAT | ||||
| /* | ||||
|  * Appends src to string dst of size siz (unlike strncat, siz is the | ||||
|  * full size of dst, not space left).  At most siz-1 characters | ||||
|  * will be copied.  Always NUL terminates (unless siz <= strlen(dst)). | ||||
|  * Returns strlen(src) + MIN(siz, strlen(initial dst)). | ||||
|  * If retval >= siz, truncation occurred. | ||||
|  */ | ||||
| size_t | ||||
| strlcat(char *dst, const char *src, size_t siz) | ||||
| { | ||||
| 	char *d = dst; | ||||
| 	size_t dl, n = siz; | ||||
| 	const size_t sl = strlen(src); | ||||
|  | ||||
| 	while (n-- && (*d++ != '\0')) | ||||
| 		; | ||||
| 	if (!++n && (*d != '\0')) | ||||
| 		return (strlen(src)); | ||||
|  | ||||
| 	dl = --d - dst;		/* original strlen(dst), max. siz-1 */ | ||||
| 	n = siz - dl; | ||||
| 	dl += sl; | ||||
|  | ||||
| 	if (__predict_false(!n--)) | ||||
| 		return (dl); | ||||
|  | ||||
| 	if (__predict_false(n > sl)) | ||||
| 		n = sl;		/* number of chars to copy */ | ||||
| 	for (; n-- && (*d++ = *src++); ) | ||||
| 		; | ||||
| 	*d = '\0';		/* NUL-terminate dst */ | ||||
| 	return (dl); | ||||
| } | ||||
| #endif /* !HAVE_STRLCAT */ | ||||
		Reference in New Issue
	
	Block a user