List Info

Thread: svn commit: trunk/busybox/shell




svn commit: trunk/busybox/shell
country flaguser name
United States
2007-04-13 14:56:57
Author: vda
Date: 2007-04-13 12:56:56 -0700 (Fri, 13 Apr 2007)
New Revision: 18430

Log:
hush: more style fixes.


Modified:
   trunk/busybox/shell/hush.c


Changeset:
Modified: trunk/busybox/shell/hush.c
============================================================
=======
--- trunk/busybox/shell/hush.c	2007-04-13 19:55:50 UTC (rev
18429)
+++ trunk/busybox/shell/hush.c	2007-04-13 19:56:56 UTC (rev
18430)
 -104,7
+104,11 
 
 /* The descrip member of this structure is only used to
make debugging
  * output pretty */
-static const struct {int mode; int default_fd; const char
*descrip;} redir_table[] = {
+static const struct {
+	int mode;
+	int default_fd;
+	const char *descrip;
+} redir_table[] = {
 	{ 0,                         0, "()" },
 	{ O_RDONLY,                  0, "<"  },
 	{ O_CREAT_TRUNC_WRONLY, 
1, ">"  },
 -803,7
+807,7 
  */
 static int b_addqchr(o_string *o, int ch, int quote)
 {
-	if (quote && strchr("*?[\",ch)) {
+	if (quote && strchr("*?[\", ch)) {
 		int rc;
 		rc = b_addchr(o, '\');
 		if (rc)
 -1574,7
+1578,7 
 			continue;
 		save_num_progs = pi->num_progs; /* save number of
programs */
 		rcode = run_pipe_real(pi);
-		debug_printf("run_pipe_real returned
%dn",rcode);
+		debug_printf("run_pipe_real returned %dn",
rcode);
 		if (rcode != -1) {
 			/* We only ran a builtin: rcode was set by the return
value
 			 * of run_pipe_real(), and we don't need to wait for
anything. */
 -1596,7
+1600,7 
 			} else {
 				rcode = checkjobs(pi);
 			}
-			debug_printf("checkjobs returned
%dn",rcode);
+			debug_printf("checkjobs returned %dn",
rcode);
 		}
 		last_return_code = rcode;
 		pi->num_progs = save_num_progs; /* restore number of
programs */
 -2010,7
+2014,7 
 
 	for (r = reserved_list;	r < reserved_list+NRES; r++) {
 		if (strcmp(dest->data, r->literal) == 0) {
-			debug_printf("found reserved word %s, code
%dn",r->literal,r->code);
+			debug_printf("found reserved word %s, code
%dn", r->literal, r->code);
 			if (r->flag & FLAG_START) {
 				struct p_context *new = xmalloc(sizeof(struct
p_context));
 				debug_printf("push stackn");
 -2035,7
+2039,7 
 			if (ctx->old_flag & FLAG_END) {
 				struct p_context *old;
 				debug_printf("pop stackn");
-				done_pipe(ctx,PIPE_SEQ);
+				done_pipe(ctx, PIPE_SEQ);
 				old = ctx->stack;
 				old->child->group = ctx->list_head;
 				old->child->subshell = 0;
 -2070,8
+2074,8 
 			return 1;  /* syntax error, groups and arglists don't
mix */
 		}
 		if (!child->argv && (ctx->type &
FLAG_PARSE_SEMICOLON)) {
-			debug_printf("checking %s for
reserved-nessn",dest->data);
-			if (reserved_word(dest,ctx))
+			debug_printf("checking %s for
reserved-nessn", dest->data);
+			if (reserved_word(dest, ctx))
 				return (ctx->w == RES_SNTX);
 		}
 		glob_target = &child->glob_result;
 -2091,8
+2095,8 
 		child->argv = glob_target->gl_pathv;
 	}
 	if (ctx->w == RES_FOR) {
-		done_word(dest,ctx);
-		done_pipe(ctx,PIPE_SEQ);
+		done_word(dest, ctx);
+		done_pipe(ctx, PIPE_SEQ);
 	}
 	return 0;
 }
 -2116,7
+2120,7 
 		return 0;
 	} else if (prog) {
 		pi->num_progs++;
-		debug_printf("done_command: num_progs incremented to
%dn",pi->num_progs);
+		debug_printf("done_command: num_progs incremented to
%dn", pi->num_progs);
 	} else {
 		debug_printf("done_command: initializingn");
 	}
 -2228,10
+2232,10 
 		}
 		_exit(run_list_real(head));   /* leaks memory */
 	}
-	debug_printf("forked child %dn",pid);
+	debug_printf("forked child %dn", pid);
 	close(channel[1]);
 	pf = fdopen(channel[0],"r");
-	debug_printf("pipe on FILE *%pn",pf);
+	debug_printf("pipe on FILE *%pn", pf);
 	return pf;
 }
 
 -2275,8
+2279,8 
 	 * to the KISS philosophy of this program. */
 	mark_closed(fileno(p));
 	retcode = pclose(p);
-	free_pipe_list(inner.list_head,0);
-	debug_printf("pclosed, retcode=%dn",retcode);
+	free_pipe_list(inner.list_head, 0);
+	debug_printf("pclosed, retcode=%dn", retcode);
 	/* XXX this process fails to trim a single trailing
newline */
 	return retcode;
 }
 -2303,8
+2307,8 
 	default:
 		syntax();   /* really logic error */
 	}
-	rcode = parse_stream(dest,&sub,input,endch);
-	done_word(dest,&sub); /* finish off the final word in
the subcontext */
+	rcode = parse_stream(dest, &sub, input, endch);
+	done_word(dest, &sub); /* finish off the final word in
the subcontext */
 	done_pipe(&sub, PIPE_SEQ);  /* and the final command
there, too */
 	child->group = sub.list_head;
 	return rcode;
 -2330,13
+2334,13 
 	int i, advance = 0;
 	char sep[] = " ";
 	int ch = input->peek(input);  /* first character after
the $ */
-	debug_printf("handle_dollar: ch=%cn",ch);
+	debug_printf("handle_dollar: ch=%cn", ch);
 	if (isalpha(ch)) {
 		b_addchr(dest, SPECIAL_VAR_SYMBOL);
 		ctx->child->sp++;
-		while (ch = b_peek(input),isalnum(ch) || ch == '_') {
+		while (ch = b_peek(input), isalnum(ch) || ch == '_') {
 			b_getch(input);
-			b_addchr(dest,ch);
+			b_addchr(dest, ch);
 		}
 		b_addchr(dest, SPECIAL_VAR_SYMBOL);
 	} else if (isdigit(ch)) {
 -2347,7
+2351,7 
 		advance = 1;
 	} else switch (ch) {
 		case '$':
-			b_adduint(dest,getpid());
+			b_adduint(dest, getpid());
 			advance = 1;
 			break;
 		case '!':
 -2355,11
+2359,11 
 			advance = 1;
 			break;
 		case '?':
-			b_adduint(dest,last_return_code);
+			b_adduint(dest, last_return_code);
 			advance = 1;
 			break;
 		case '#':
-			b_adduint(dest,global_argc ? global_argc-1 : 0);
+			b_adduint(dest, global_argc ? global_argc-1 : 0);
 			advance = 1;
 			break;
 		case '{':
 -2371,7
+2375,7 
 				ch = b_getch(input);
 				if (ch == EOF || ch == '}')
 					break;
-				b_addchr(dest,ch);
+				b_addchr(dest, ch);
 			}
 			if (ch != '}') {
 				syntax();
 -2395,11
+2399,11 
 		case '-':
 		case '_':
 			/* still unhandled, but should be eventually */
-			bb_error_msg("unhandled syntax: $%c",ch);
+			bb_error_msg("unhandled syntax: $%c", ch);
 			return 1;
 			break;
 		default:
-			b_addqchr(dest,'$',dest->quote);
+			b_addqchr(dest,'$', dest->quote);
 	}
 	/* Eat the character if the flag was set.  If the
compiler
 	 * is smart enough, we could substitute
"b_getch(input);"
 -2430,7
+2434,7 
 	 * A single-quote triggers a bypass of the main loop until
its mate is
 	 * found.  When recursing, quote state is passed in via
dest->quote. */
 
-	debug_printf("parse_stream,
end_trigger=%dn",end_trigger);
+	debug_printf("parse_stream, end_trigger=%dn",
end_trigger);
 	while ((ch = b_getch(input)) != EOF) {
 		m = map[ch];
 		next = (ch == 'n') ? 0 : b_peek(input);
 -2447,7
+2451,7 
 			/* If we aren't performing a substitution, treat a
newline as a
 			 * command separator.  */
 			if (end_trigger != '' && ch == 'n')
-				done_pipe(ctx,PIPE_SEQ);
+				done_pipe(ctx, PIPE_SEQ);
 		}
 		if (ch == end_trigger && !dest->quote
&& ctx->w == RES_NONE) {
 			debug_printf("leaving parse_stream
(triggered)n");
 -2485,7
+2489,7 
 				ch = b_getch(input);
 				if (ch == EOF || ch == ''')
 					break;
-				b_addchr(dest,ch);
+				b_addchr(dest, ch);
 			}
 			if (ch == EOF) {
 				syntax();
 -2530,22
+2534,22 
 			break;
 		case ';':
 			done_word(dest, ctx);
-			done_pipe(ctx,PIPE_SEQ);
+			done_pipe(ctx, PIPE_SEQ);
 			break;
 		case '&':
 			done_word(dest, ctx);
 			if (next == '&') {
 				b_getch(input);
-				done_pipe(ctx,PIPE_AND);
+				done_pipe(ctx, PIPE_AND);
 			} else {
-				done_pipe(ctx,PIPE_BG);
+				done_pipe(ctx, PIPE_BG);
 			}
 			break;
 		case '|':
 			done_word(dest, ctx);
 			if (next == '|') {
 				b_getch(input);
-				done_pipe(ctx,PIPE_OR);
+				done_pipe(ctx, PIPE_OR);
 			} else {
 				/* we could pick up a file descriptor choice here
 				 * with redirect_opt_num(), but bash doesn't do it.
 -2623,7
+2627,7 
 		}
 		if (rcode != 1 && ctx.old_flag == 0) {
 			done_word(&temp, &ctx);
-			done_pipe(&ctx,PIPE_SEQ);
+			done_pipe(&ctx, PIPE_SEQ);
 			run_list(ctx.list_head);
 		} else {
 			if (ctx.old_flag != 0) {
 -2661,9
+2665,10 
  * we don't fight over who gets the foreground */
 static void setup_job_control(void)
 {
-	static pid_t shell_pgrp;
+	/*static --why?? */  pid_t shell_pgrp;
+
 	/* Loop until we are in the foreground.  */
-	while (tcgetpgrp (shell_terminal) != (shell_pgrp = getpgrp
()))
+	while (tcgetpgrp(shell_terminal) != (shell_pgrp =
getpgrp()))
 		kill(- shell_pgrp, SIGTTIN);
 
 	/* Ignore interactive and job-control signals.  */
 -2689,7
+2694,7 
 {
 	int opt;
 	FILE *input;
-	char **e = environ;
+	char **e;
 
 #if ENABLE_FEATURE_EDITING
 	line_input_state = new_line_input_t(FOR_SHELL);
 -2720,10
+2725,10 
 
 	/* initialize our shell local variables with the values
 	 * currently living in the environment */
-	if (e) {
-		for (; *e; e++)
-			set_local_var(*e, 2);   /* without call putenv() */
-	}
+	e = environ;
+	if (e)
+		while (*e)
+			set_local_var(*e++, 2);   /* without call putenv() */
 
 	last_return_code = EXIT_SUCCESS;
 
 -2741,37
+2746,34 
 
 	while ((opt = getopt(argc, argv, "cif&qu
ot;)) > 0) {
 		switch (opt) {
-			case 'c':
-				{
-					global_argv = argv+optind;
-					global_argc = argc-optind;
-					opt = parse_string_outer(optarg,
FLAG_PARSE_SEMICOLON);
-					goto final_return;
-				}
-				break;
-			case 'i':
-				interactive++;
-				break;
-			case 'f':
-				fake_mode++;
-				break;
-			default:
+		case 'c':
+			global_argv = argv+optind;
+			global_argc = argc-optind;
+			opt = parse_string_outer(optarg, FLAG_PARSE_SEMICOLON);
+			goto final_return;
+		case 'i':
+			interactive++;
+			break;
+		case 'f':
+			fake_mode++;
+			break;
+		default:
 #ifndef BB_VER
-				fprintf(stderr, "Usage: sh [FILE]...n"
-						"   or: sh -c command [args]...nn");
-				exit(EXIT_FAILURE);
+			fprintf(stderr, "Usage: sh [FILE]...n"
+					"   or: sh -c command [args]...nn");
+			exit(EXIT_FAILURE);
 #else
-				bb_show_usage();
+			bb_show_usage();
 #endif
 		}
 	}
-	/* A shell is interactive if the `-i' flag was given, or
if all of
+	/* A shell is interactive if the '-i' flag was given, or
if all of
 	 * the following conditions are met:
 	 *	  no -c command
 	 *    no arguments remaining or the -s flag given
 	 *    standard input is a terminal
 	 *    standard output is a terminal
-	 *    Refer to Posix.2, the description of the `sh'
utility. */
+	 *    Refer to Posix.2, the description of the 'sh'
utility. */
 	if (argv[optind] == NULL && input == stdin
 	 && isatty(STDIN_FILENO) &&
isatty(STDOUT_FILENO)
 	) {
 -2802,7
+2804,7 
 
 #if ENABLE_FEATURE_CLEAN_UP
 	fclose(input);
-	if (cwd && cwd != bb_msg_unknown)
+	if (cwd != bb_msg_unknown)
 		free((char*)cwd);
 	{
 		struct variables *cur, *tmp;
 -2885,7
+2887,7 
 				len = strlen(p1);
 				p2 = p1 + len;
 			}
-			/* we use n + 2 in realloc for list,because we add
+			/* we use n + 2 in realloc for list, because we add
 			 * new element and then we will add NULL element */
 			list = xrealloc(list, sizeof(*list) * (n + 2));
 			list[n] = xmalloc(2 + name_len + len);

_______________________________________________
busybox-cvs mailing list
busybox-cvsbusybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )