您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ trace_argv_printf函数代码示例

51自学网 2021-06-03 08:56:20
  C++
这篇教程C++ trace_argv_printf函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中trace_argv_printf函数的典型用法代码示例。如果您正苦于以下问题:C++ trace_argv_printf函数的具体用法?C++ trace_argv_printf怎么用?C++ trace_argv_printf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了trace_argv_printf函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: execv_dashed_external

static void execv_dashed_external(const char **argv){	struct child_process cmd = CHILD_PROCESS_INIT;	int status;	if (get_super_prefix())		die("%s doesn't support --super-prefix", argv[0]);	if (use_pager == -1 && !is_builtin(argv[0]))		use_pager = check_pager_config(argv[0]);	commit_pager_choice();	argv_array_pushf(&cmd.args, "git-%s", argv[0]);	argv_array_pushv(&cmd.args, argv + 1);	cmd.clean_on_exit = 1;	cmd.wait_after_clean = 1;	cmd.silent_exec_failure = 1;	trace_argv_printf(cmd.args.argv, "trace: exec:");	/*	 * If we fail because the command is not found, it is	 * OK to return. Otherwise, we just pass along the status code,	 * or our usual generic code if we were not even able to exec	 * the program.	 */	status = run_command(&cmd);	if (status >= 0)		exit(status);	else if (errno != ENOENT)		exit(128);}
开发者ID:ovmine,项目名称:git,代码行数:32,


示例2: execv_dashed_external

static void execv_dashed_external(const char **argv){	struct strbuf cmd = STRBUF_INIT;	const char *tmp;	int status;	commit_pager_choice();	strbuf_addf(&cmd, "git-%s", argv[0]);	/*	 * argv[0] must be the git command, but the argv array	 * belongs to the caller, and may be reused in	 * subsequent loop iterations. Save argv[0] and	 * restore it on error.	 */	tmp = argv[0];	argv[0] = cmd.buf;	trace_argv_printf(argv, "trace: exec:");	/*	 * if we fail because the command is not found, it is	 * OK to return. Otherwise, we just pass along the status code.	 */	status = run_command_v_opt(argv, RUN_SILENT_EXEC_FAILURE);	if (status >= 0 || errno != ENOENT)		exit(status);	argv[0] = tmp;	strbuf_release(&cmd);}
开发者ID:SRabbelier,项目名称:git,代码行数:33,


示例3: run_builtin

static int run_builtin(struct cmd_struct *p, int argc, const char **argv){	int status, help;	struct stat st;	const char *prefix;	prefix = NULL;	help = argc == 2 && !strcmp(argv[1], "-h");	if (!help) {		if (p->option & RUN_SETUP)			prefix = setup_git_directory();		else if (p->option & RUN_SETUP_GENTLY) {			int nongit_ok;			prefix = setup_git_directory_gently(&nongit_ok);		}		if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY))			use_pager = check_pager_config(p->cmd);		if (use_pager == -1 && p->option & USE_PAGER)			use_pager = 1;		if ((p->option & (RUN_SETUP | RUN_SETUP_GENTLY)) &&		    startup_info->have_repository) /* get_git_dir() may set up repo, avoid that */			trace_repo_setup(prefix);	}	commit_pager_choice();	if (!help && get_super_prefix()) {		if (!(p->option & SUPPORT_SUPER_PREFIX))			die("%s doesn't support --super-prefix", p->cmd);		if (prefix)			die("can't use --super-prefix from a subdirectory");	}	if (!help && p->option & NEED_WORK_TREE)		setup_work_tree();	trace_argv_printf(argv, "trace: built-in: git");	status = p->fn(argc, argv, prefix);	if (status)		return status;	/* Somebody closed stdout? */	if (fstat(fileno(stdout), &st))		return 0;	/* Ignore write errors for pipes and sockets.. */	if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode))		return 0;	/* Check for ENOSPC and EIO errors.. */	if (fflush(stdout))		die_errno("write failure on standard output");	if (ferror(stdout))		die("unknown write failure on standard output");	if (fclose(stdout))		die_errno("close failed on standard output");	return 0;}
开发者ID:Ferryworld,项目名称:git,代码行数:59,


示例4: execv_shell_cmd

static int execv_shell_cmd(const char **argv){	const char **nargv = prepare_shell_cmd(argv);	trace_argv_printf(nargv, "trace: exec:");	execvp(nargv[0], (char **)nargv);	free(nargv);	return -1;}
开发者ID:claudelee,项目名称:git,代码行数:8,


示例5: run_argv

static int run_argv(int *argcp, const char ***argv){	int done_alias = 0;	while (1) {		/*		 * If we tried alias and futzed with our environment,		 * it no longer is safe to invoke builtins directly in		 * general.  We have to spawn them as dashed externals.		 *		 * NEEDSWORK: if we can figure out cases		 * where it is safe to do, we can avoid spawning a new		 * process.		 */		if (!done_alias)			handle_builtin(*argcp, *argv);		else if (get_builtin(**argv)) {			struct argv_array args = ARGV_ARRAY_INIT;			int i;			if (get_super_prefix())				die("%s doesn't support --super-prefix", **argv);			commit_pager_choice();			argv_array_push(&args, "git");			for (i = 0; i < *argcp; i++)				argv_array_push(&args, (*argv)[i]);			trace_argv_printf(args.argv, "trace: exec:");			/*			 * if we fail because the command is not found, it is			 * OK to return. Otherwise, we just pass along the status code.			 */			i = run_command_v_opt(args.argv, RUN_SILENT_EXEC_FAILURE |					      RUN_CLEAN_ON_EXIT);			if (i >= 0 || errno != ENOENT)				exit(i);			die("could not execute builtin %s", **argv);		}		/* .. then try the external ones */		execv_dashed_external(*argv);		/* It could be an alias -- this works around the insanity		 * of overriding "git log" with "git show" by having		 * alias.log = show		 */		if (done_alias)			break;		if (!handle_alias(argcp, argv))			break;		done_alias = 1;	}	return done_alias;}
开发者ID:benpeart,项目名称:git,代码行数:58,


示例6: execv_shell_cmd

static int execv_shell_cmd(const char **argv){	struct argv_array nargv = ARGV_ARRAY_INIT;	prepare_shell_cmd(&nargv, argv);	trace_argv_printf(nargv.argv, "trace: exec:");	sane_execvp(nargv.argv[0], (char **)nargv.argv);	argv_array_clear(&nargv);	return -1;}
开发者ID:1742314348,项目名称:git,代码行数:9,


示例7: execv_git_cmd

int execv_git_cmd(const char **argv) {	const char **nargv = prepare_git_cmd(argv);	trace_argv_printf(nargv, "trace: exec:");	/* execvp() can only ever return if it fails */	execvp("git", (char **)nargv);	trace_printf("trace: exec failed: %s/n", strerror(errno));	free(nargv);	return -1;}
开发者ID:emk,项目名称:git,代码行数:12,


示例8: execv_git_cmd

int execv_git_cmd(const char **argv) {	struct argv_array nargv = ARGV_ARRAY_INIT;	prepare_git_cmd(&nargv, argv);	trace_argv_printf(nargv.argv, "trace: exec:");	/* execvp() can only ever return if it fails */	sane_execvp("git", (char **)nargv.argv);	trace_printf("trace: exec failed: %s/n", strerror(errno));	argv_array_clear(&nargv);	return -1;}
开发者ID:9b,项目名称:git,代码行数:14,


示例9: run_builtin

static int run_builtin(struct cmd_struct *p, int argc, const char **argv){	int status, help;	struct stat st;	const char *prefix;	prefix = NULL;	help = argc == 2 && !strcmp(argv[1], "-h");	if (!help) {		if (p->option & RUN_SETUP)			prefix = setup_git_directory();		if (p->option & RUN_SETUP_GENTLY) {			int nongit_ok;			prefix = setup_git_directory_gently(&nongit_ok);		}		if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY))			use_pager = check_pager_config(p->cmd);		if (use_pager == -1 && p->option & USE_PAGER)			use_pager = 1;	}	commit_pager_choice();	if (!help && p->option & NEED_WORK_TREE)		setup_work_tree();	trace_argv_printf(argv, "trace: built-in: git");	status = p->fn(argc, argv, prefix);	if (status)		return status;	/* Somebody closed stdout? */	if (fstat(fileno(stdout), &st))		return 0;	/* Ignore write errors for pipes and sockets.. */	if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode))		return 0;	/* Check for ENOSPC and EIO errors.. */	if (fflush(stdout))		die_errno("write failure on standard output");	if (ferror(stdout))		die("unknown write failure on standard output");	if (fclose(stdout))		die_errno("close failed on standard output");	return 0;}
开发者ID:SRabbelier,项目名称:git,代码行数:48,


示例10: start_command

int start_command(struct child_process *cmd){	int need_in, need_out, need_err;	int fdin[2], fdout[2], fderr[2];	/*	 * In case of errors we must keep the promise to close FDs	 * that have been passed in via ->in and ->out.	 */	need_in = !cmd->no_stdin && cmd->in < 0;	if (need_in) {		if (pipe(fdin) < 0) {			if (cmd->out > 0)				close(cmd->out);			return -ERR_RUN_COMMAND_PIPE;		}		cmd->in = fdin[1];	}	need_out = !cmd->no_stdout		&& !cmd->stdout_to_stderr		&& cmd->out < 0;	if (need_out) {		if (pipe(fdout) < 0) {			if (need_in)				close_pair(fdin);			else if (cmd->in)				close(cmd->in);			return -ERR_RUN_COMMAND_PIPE;		}		cmd->out = fdout[0];	}	need_err = !cmd->no_stderr && cmd->err < 0;	if (need_err) {		if (pipe(fderr) < 0) {			if (need_in)				close_pair(fdin);			else if (cmd->in)				close(cmd->in);			if (need_out)				close_pair(fdout);			else if (cmd->out)				close(cmd->out);			return -ERR_RUN_COMMAND_PIPE;		}		cmd->err = fderr[0];	}	trace_argv_printf(cmd->argv, "trace: run_command:");#ifndef __MINGW32__	cmd->pid = fork();	if (!cmd->pid) {		if (cmd->no_stdin)			dup_devnull(0);		else if (need_in) {			dup2(fdin[0], 0);			close_pair(fdin);		} else if (cmd->in) {			dup2(cmd->in, 0);			close(cmd->in);		}		if (cmd->no_stderr)			dup_devnull(2);		else if (need_err) {			dup2(fderr[1], 2);			close_pair(fderr);		}		if (cmd->no_stdout)			dup_devnull(1);		else if (cmd->stdout_to_stderr)			dup2(2, 1);		else if (need_out) {			dup2(fdout[1], 1);			close_pair(fdout);		} else if (cmd->out > 1) {			dup2(cmd->out, 1);			close(cmd->out);		}		if (cmd->dir && chdir(cmd->dir))			die("exec %s: cd to %s failed (%s)", cmd->argv[0],			    cmd->dir, strerror(errno));		if (cmd->env) {			for (; *cmd->env; cmd->env++) {				if (strchr(*cmd->env, '='))					putenv((char*)*cmd->env);				else					unsetenv(*cmd->env);			}		}		if (cmd->git_cmd) {			execv_git_cmd(cmd->argv);		} else {			execvp(cmd->argv[0], (char *const*) cmd->argv);		}//.........这里部分代码省略.........
开发者ID:Pistos,项目名称:git,代码行数:101,


示例11: run_builtin

static int run_builtin(struct cmd_struct *p, int argc, const char **argv){	int status, help;	struct stat st;	const char *prefix;	prefix = NULL;	help = argc == 2 && !strcmp(argv[1], "-h");	if (!help) {		if (p->option & RUN_SETUP)			prefix = setup_git_directory();		else if (p->option & RUN_SETUP_GENTLY) {			int nongit_ok;			prefix = setup_git_directory_gently(&nongit_ok);		}		if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY) &&		    !(p->option & DELAY_PAGER_CONFIG))			use_pager = check_pager_config(p->cmd);		if (use_pager == -1 && p->option & USE_PAGER)			use_pager = 1;		if ((p->option & (RUN_SETUP | RUN_SETUP_GENTLY)) &&		    startup_info->have_repository) /* get_git_dir() may set up repo, avoid that */			trace_repo_setup(prefix);	}	commit_pager_choice();	if (!help && get_super_prefix()) {		if (!(p->option & SUPPORT_SUPER_PREFIX))			die("%s doesn't support --super-prefix", p->cmd);	}	if (!help && p->option & NEED_WORK_TREE)		setup_work_tree();	if (run_pre_command_hook(argv))		die("pre-command hook aborted command");	trace_argv_printf(argv, "trace: built-in: git");	/*	 * Validate the state of the cache entries in the index before and	 * after running the command. Validation is only performed if the	 * appropriate environment variable is set.	 */	validate_cache_entries(&the_index);	exit_code = status = p->fn(argc, argv, prefix);	validate_cache_entries(&the_index);	if (status)		return status;	run_post_command_hook();	/* Somebody closed stdout? */	if (fstat(fileno(stdout), &st))		return 0;	/* Ignore write errors for pipes and sockets.. */	if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode))		return 0;	/* Check for ENOSPC and EIO errors.. */	if (fflush(stdout))		die_errno("write failure on standard output");	if (ferror(stdout))		die("unknown write failure on standard output");	if (fclose(stdout))		die_errno("close failed on standard output");	return 0;}
开发者ID:benpeart,项目名称:git,代码行数:70,


示例12: handle_alias

static int handle_alias(int *argcp, const char ***argv){	int envchanged = 0, ret = 0, saved_errno = errno;	int count, option_count;	const char **new_argv;	const char *alias_command;	char *alias_string;	alias_command = (*argv)[0];	alias_string = alias_lookup(alias_command);	if (alias_string) {		if (alias_string[0] == '!') {			struct child_process child = CHILD_PROCESS_INIT;			int nongit_ok;			/* Aliases expect GIT_PREFIX, GIT_DIR etc to be set */			setup_git_directory_gently(&nongit_ok);			commit_pager_choice();			child.use_shell = 1;			argv_array_push(&child.args, alias_string + 1);			argv_array_pushv(&child.args, (*argv) + 1);			ret = run_command(&child);			if (ret >= 0)   /* normal exit */				exit(ret);			die_errno("while expanding alias '%s': '%s'",			    alias_command, alias_string + 1);		}		count = split_cmdline(alias_string, &new_argv);		if (count < 0)			die("Bad alias.%s string: %s", alias_command,			    split_cmdline_strerror(count));		option_count = handle_options(&new_argv, &count, &envchanged);		if (envchanged)			die("alias '%s' changes environment variables./n"				 "You can use '!git' in the alias to do this",				 alias_command);		memmove(new_argv - option_count, new_argv,				count * sizeof(char *));		new_argv -= option_count;		if (count < 1)			die("empty alias for %s", alias_command);		if (!strcmp(alias_command, new_argv[0]))			die("recursive alias: %s", alias_command);		trace_argv_printf(new_argv,				  "trace: alias expansion: %s =>",				  alias_command);		REALLOC_ARRAY(new_argv, count + *argcp);		/* insert after command name */		memcpy(new_argv + count, *argv + 1, sizeof(char *) * *argcp);		*argv = new_argv;		*argcp += count - 1;		ret = 1;	}	errno = saved_errno;	return ret;}
开发者ID:benpeart,项目名称:git,代码行数:68,


示例13: start_command

int start_command(struct child_process *cmd){	int need_in, need_out, need_err;	int fdin[2], fdout[2], fderr[2];	int failed_errno;	char *str;	if (!cmd->argv)		cmd->argv = cmd->args.argv;	if (!cmd->env)		cmd->env = cmd->env_array.argv;	/*	 * In case of errors we must keep the promise to close FDs	 * that have been passed in via ->in and ->out.	 */	need_in = !cmd->no_stdin && cmd->in < 0;	if (need_in) {		if (pipe(fdin) < 0) {			failed_errno = errno;			if (cmd->out > 0)				close(cmd->out);			str = "standard input";			goto fail_pipe;		}		cmd->in = fdin[1];	}	need_out = !cmd->no_stdout		&& !cmd->stdout_to_stderr		&& cmd->out < 0;	if (need_out) {		if (pipe(fdout) < 0) {			failed_errno = errno;			if (need_in)				close_pair(fdin);			else if (cmd->in)				close(cmd->in);			str = "standard output";			goto fail_pipe;		}		cmd->out = fdout[0];	}	need_err = !cmd->no_stderr && cmd->err < 0;	if (need_err) {		if (pipe(fderr) < 0) {			failed_errno = errno;			if (need_in)				close_pair(fdin);			else if (cmd->in)				close(cmd->in);			if (need_out)				close_pair(fdout);			else if (cmd->out)				close(cmd->out);			str = "standard error";fail_pipe:			error("cannot create %s pipe for %s: %s",				str, cmd->argv[0], strerror(failed_errno));			child_process_clear(cmd);			errno = failed_errno;			return -1;		}		cmd->err = fderr[0];	}	trace_argv_printf(cmd->argv, "trace: run_command:");	fflush(NULL);#ifndef GIT_WINDOWS_NATIVE{	int notify_pipe[2];	if (pipe(notify_pipe))		notify_pipe[0] = notify_pipe[1] = -1;	cmd->pid = fork();	failed_errno = errno;	if (!cmd->pid) {		/*		 * Redirect the channel to write syscall error messages to		 * before redirecting the process's stderr so that all die()		 * in subsequent call paths use the parent's stderr.		 */		if (cmd->no_stderr || need_err) {			int child_err = dup(2);			set_cloexec(child_err);			set_error_handle(fdopen(child_err, "w"));		}		close(notify_pipe[0]);		set_cloexec(notify_pipe[1]);		child_notifier = notify_pipe[1];		atexit(notify_parent);		if (cmd->no_stdin)			dup_devnull(0);		else if (need_in) {			dup2(fdin[0], 0);//.........这里部分代码省略.........
开发者ID:1742314348,项目名称:git,代码行数:101,


示例14: start_command

int start_command(struct child_process *cmd){	int need_in, need_out, need_err;	int fdin[2], fdout[2], fderr[2];	int failed_errno;	char *str;	if (!cmd->argv)		cmd->argv = cmd->args.argv;	if (!cmd->env)		cmd->env = cmd->env_array.argv;	/*	 * In case of errors we must keep the promise to close FDs	 * that have been passed in via ->in and ->out.	 */	need_in = !cmd->no_stdin && cmd->in < 0;	if (need_in) {		if (pipe(fdin) < 0) {			failed_errno = errno;			if (cmd->out > 0)				close(cmd->out);			str = "standard input";			goto fail_pipe;		}		cmd->in = fdin[1];	}	need_out = !cmd->no_stdout		&& !cmd->stdout_to_stderr		&& cmd->out < 0;	if (need_out) {		if (pipe(fdout) < 0) {			failed_errno = errno;			if (need_in)				close_pair(fdin);			else if (cmd->in)				close(cmd->in);			str = "standard output";			goto fail_pipe;		}		cmd->out = fdout[0];	}	need_err = !cmd->no_stderr && cmd->err < 0;	if (need_err) {		if (pipe(fderr) < 0) {			failed_errno = errno;			if (need_in)				close_pair(fdin);			else if (cmd->in)				close(cmd->in);			if (need_out)				close_pair(fdout);			else if (cmd->out)				close(cmd->out);			str = "standard error";fail_pipe:			error("cannot create %s pipe for %s: %s",				str, cmd->argv[0], strerror(failed_errno));			child_process_clear(cmd);			errno = failed_errno;			return -1;		}		cmd->err = fderr[0];	}	trace_argv_printf(cmd->argv, "trace: run_command:");	fflush(NULL);#ifndef GIT_WINDOWS_NATIVE{	int notify_pipe[2];	int null_fd = -1;	char **childenv;	struct argv_array argv = ARGV_ARRAY_INIT;	struct child_err cerr;	struct atfork_state as;	if (pipe(notify_pipe))		notify_pipe[0] = notify_pipe[1] = -1;	if (cmd->no_stdin || cmd->no_stdout || cmd->no_stderr) {		null_fd = open("/dev/null", O_RDWR | O_CLOEXEC);		if (null_fd < 0)			die_errno(_("open /dev/null failed"));		set_cloexec(null_fd);	}	prepare_cmd(&argv, cmd);	childenv = prep_childenv(cmd->env);	atfork_prepare(&as);	/*	 * NOTE: In order to prevent deadlocking when using threads special	 * care should be taken with the function calls made in between the	 * fork() and exec() calls.  No calls should be made to functions which	 * require acquiring a lock (e.g. malloc) as the lock could have been	 * held by another thread at the time of forking, causing the lock to//.........这里部分代码省略.........
开发者ID:ardumont,项目名称:git,代码行数:101,


示例15: start_command

int start_command(struct child_process *cmd){	int need_in, need_out, need_err;	int fdin[2], fdout[2], fderr[2];	int failed_errno = failed_errno;	/*	 * In case of errors we must keep the promise to close FDs	 * that have been passed in via ->in and ->out.	 */	need_in = !cmd->no_stdin && cmd->in < 0;	if (need_in) {		if (pipe(fdin) < 0) {			failed_errno = errno;			if (cmd->out > 0)				close(cmd->out);			goto fail_pipe;		}		cmd->in = fdin[1];	}	need_out = !cmd->no_stdout		&& !cmd->stdout_to_stderr		&& cmd->out < 0;	if (need_out) {		if (pipe(fdout) < 0) {			failed_errno = errno;			if (need_in)				close_pair(fdin);			else if (cmd->in)				close(cmd->in);			goto fail_pipe;		}		cmd->out = fdout[0];	}	need_err = !cmd->no_stderr && cmd->err < 0;	if (need_err) {		if (pipe(fderr) < 0) {			failed_errno = errno;			if (need_in)				close_pair(fdin);			else if (cmd->in)				close(cmd->in);			if (need_out)				close_pair(fdout);			else if (cmd->out)				close(cmd->out);fail_pipe:			error("cannot create pipe for %s: %s",				cmd->argv[0], strerror(failed_errno));			errno = failed_errno;			return -1;		}		cmd->err = fderr[0];	}	trace_argv_printf(cmd->argv, "trace: run_command:");#ifndef WIN32{	int notify_pipe[2];	if (pipe(notify_pipe))		notify_pipe[0] = notify_pipe[1] = -1;	fflush(NULL);	cmd->pid = fork();	if (!cmd->pid) {		/*		 * Redirect the channel to write syscall error messages to		 * before redirecting the process's stderr so that all die()		 * in subsequent call paths use the parent's stderr.		 */		if (cmd->no_stderr || need_err) {			child_err = dup(2);			set_cloexec(child_err);		}		set_die_routine(die_child);		close(notify_pipe[0]);		set_cloexec(notify_pipe[1]);		child_notifier = notify_pipe[1];		atexit(notify_parent);		if (cmd->no_stdin)			dup_devnull(0);		else if (need_in) {			dup2(fdin[0], 0);			close_pair(fdin);		} else if (cmd->in) {			dup2(cmd->in, 0);			close(cmd->in);		}		if (cmd->no_stderr)			dup_devnull(2);		else if (need_err) {			dup2(fderr[1], 2);			close_pair(fderr);//.........这里部分代码省略.........
开发者ID:claudelee,项目名称:git,代码行数:101,


示例16: handle_alias

static int handle_alias(int *argcp, const char ***argv){	int envchanged = 0, ret = 0, saved_errno = errno;	const char *subdir;	int count, option_count;	const char **new_argv;	const char *alias_command;	char *alias_string;	int unused_nongit;	subdir = setup_git_directory_gently(&unused_nongit);	alias_command = (*argv)[0];	alias_string = alias_lookup(alias_command);	if (alias_string) {		if (alias_string[0] == '!') {			const char **alias_argv;			int argc = *argcp, i;			commit_pager_choice();			/* build alias_argv */			alias_argv = xmalloc(sizeof(*alias_argv) * (argc + 1));			alias_argv[0] = alias_string + 1;			for (i = 1; i < argc; ++i)				alias_argv[i] = (*argv)[i];			alias_argv[argc] = NULL;			ret = run_command_v_opt(alias_argv, RUN_USING_SHELL);			if (ret >= 0)   /* normal exit */				exit(ret);			die_errno("While expanding alias '%s': '%s'",			    alias_command, alias_string + 1);		}		count = split_cmdline(alias_string, &new_argv);		if (count < 0)			die("Bad alias.%s string: %s", alias_command,			    split_cmdline_strerror(count));		option_count = handle_options(&new_argv, &count, &envchanged);		if (envchanged)			die("alias '%s' changes environment variables/n"				 "You can use '!git' in the alias to do this.",				 alias_command);		memmove(new_argv - option_count, new_argv,				count * sizeof(char *));		new_argv -= option_count;		if (count < 1)			die("empty alias for %s", alias_command);		if (!strcmp(alias_command, new_argv[0]))			die("recursive alias: %s", alias_command);		trace_argv_printf(new_argv,				  "trace: alias expansion: %s =>",				  alias_command);		new_argv = xrealloc(new_argv, sizeof(char *) *				    (count + *argcp));		/* insert after command name */		memcpy(new_argv + count, *argv + 1, sizeof(char *) * *argcp);		*argv = new_argv;		*argcp += count - 1;		ret = 1;	}	if (subdir && chdir(subdir))		die_errno("Cannot change to '%s'", subdir);	errno = saved_errno;	return ret;}
开发者ID:4dn-oss,项目名称:git,代码行数:76,


示例17: handle_alias

static int handle_alias(int *argcp, const char ***argv){	int envchanged = 0, ret = 0, saved_errno = errno;	const char *subdir;	int count, option_count;	const char **new_argv;	const char *alias_command;	char *alias_string;	int unused_nongit;	subdir = setup_git_directory_gently(&unused_nongit);	alias_command = (*argv)[0];	alias_string = alias_lookup(alias_command);	if (alias_string) {		if (alias_string[0] == '!') {			commit_pager_choice();			if (*argcp > 1) {				struct strbuf buf;				strbuf_init(&buf, PATH_MAX);				strbuf_addstr(&buf, alias_string);				sq_quote_argv(&buf, (*argv) + 1, PATH_MAX);				free(alias_string);				alias_string = buf.buf;			}			trace_printf("trace: alias to shell cmd: %s => %s/n",				     alias_command, alias_string + 1);			ret = system(alias_string + 1);			if (ret >= 0 && WIFEXITED(ret) &&			    WEXITSTATUS(ret) != 127)				exit(WEXITSTATUS(ret));			die("Failed to run '%s' when expanding alias '%s'",			    alias_string + 1, alias_command);		}		count = split_cmdline(alias_string, &new_argv);		if (count < 0)			die("Bad alias.%s string: %s", alias_command,			    split_cmdline_strerror(count));		option_count = handle_options(&new_argv, &count, &envchanged);		if (envchanged)			die("alias '%s' changes environment variables/n"				 "You can use '!git' in the alias to do this.",				 alias_command);		memmove(new_argv - option_count, new_argv,				count * sizeof(char *));		new_argv -= option_count;		if (count < 1)			die("empty alias for %s", alias_command);		if (!strcmp(alias_command, new_argv[0]))			die("recursive alias: %s", alias_command);		trace_argv_printf(new_argv,				  "trace: alias expansion: %s =>",				  alias_command);		new_argv = xrealloc(new_argv, sizeof(char *) *				    (count + *argcp));		/* insert after command name */		memcpy(new_argv + count, *argv + 1, sizeof(char *) * *argcp);		*argv = new_argv;		*argcp += count - 1;		ret = 1;	}	if (subdir && chdir(subdir))		die_errno("Cannot change to '%s'", subdir);	errno = saved_errno;	return ret;}
开发者ID:SRabbelier,项目名称:git,代码行数:76,



注:本文中的trace_argv_printf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ trace_dump_arg函数代码示例
C++ traceMsg函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。