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

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

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

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

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

示例1: cleanup_subject

static void cleanup_subject(struct strbuf *subject){	char *pos;	size_t remove;	while (subject->len) {		switch (*subject->buf) {		case 'r': case 'R':			if (subject->len <= 3)				break;			if (!memcmp(subject->buf + 1, "e:", 2)) {				strbuf_remove(subject, 0, 3);				continue;			}			break;		case ' ': case '/t': case ':':			strbuf_remove(subject, 0, 1);			continue;		case '[':			if ((pos = strchr(subject->buf, ']'))) {				remove = pos - subject->buf;				if (remove <= (subject->len - remove) * 2) {					strbuf_remove(subject, 0, remove + 1);					continue;				}			} else				strbuf_remove(subject, 0, 1);			break;		}		strbuf_trim(subject);		return;	}}
开发者ID:asoltys,项目名称:git,代码行数:32,


示例2: cleanup_subject

static void cleanup_subject(struct mailinfo *mi, struct strbuf *subject){	size_t at = 0;	while (at < subject->len) {		char *pos;		size_t remove;		switch (subject->buf[at]) {		case 'r': case 'R':			if (subject->len <= at + 3)				break;			if ((subject->buf[at + 1] == 'e' ||			     subject->buf[at + 1] == 'E') &&			    subject->buf[at + 2] == ':') {				strbuf_remove(subject, at, 3);				continue;			}			at++;			break;		case ' ': case '/t': case ':':			strbuf_remove(subject, at, 1);			continue;		case '[':			pos = strchr(subject->buf + at, ']');			if (!pos)				break;			remove = pos - subject->buf + at + 1;			if (!mi->keep_non_patch_brackets_in_subject ||			    (7 <= remove &&			     memmem(subject->buf + at, remove, "PATCH", 5)))				strbuf_remove(subject, at, remove);			else {				at += remove;				/*				 * If the input had a space after the ], keep				 * it.  We don't bother with finding the end of				 * the space, since we later normalize it				 * anyway.				 */				if (isspace(subject->buf[at]))					at += 1;			}			continue;		}		break;	}	strbuf_trim(subject);}
开发者ID:9b,项目名称:git,代码行数:49,


示例3: while

static char *replace_encoding_header(char *buf, const char *encoding){	struct strbuf tmp = STRBUF_INIT;	size_t start, len;	char *cp = buf;	/* guess if there is an encoding header before a /n/n */	while (strncmp(cp, "encoding ", strlen("encoding "))) {		cp = strchr(cp, '/n');		if (!cp || *++cp == '/n')			return buf;	}	start = cp - buf;	cp = strchr(cp, '/n');	if (!cp)		return buf; /* should not happen but be defensive */	len = cp + 1 - (buf + start);	strbuf_attach(&tmp, buf, strlen(buf), strlen(buf) + 1);	if (is_encoding_utf8(encoding)) {		/* we have re-coded to UTF-8; drop the header */		strbuf_remove(&tmp, start, len);	} else {		/* just replaces XXXX in 'encoding XXXX/n' */		strbuf_splice(&tmp, start + strlen("encoding "),					  len - strlen("encoding /n"),					  encoding, strlen(encoding));	}	return strbuf_detach(&tmp, NULL);}
开发者ID:CookieChen,项目名称:git,代码行数:30,


示例4: format_sanitized_subject

static void format_sanitized_subject(struct strbuf *sb, const char *msg){	size_t trimlen;	size_t start_len = sb->len;	int space = 2;	for (; *msg && *msg != '/n'; msg++) {		if (istitlechar(*msg)) {			if (space == 1)				strbuf_addch(sb, '-');			space = 0;			strbuf_addch(sb, *msg);			if (*msg == '.')				while (*(msg+1) == '.')					msg++;		} else			space |= 1;	}	/* trim any trailing '.' or '-' characters */	trimlen = 0;	while (sb->len - trimlen > start_len &&		(sb->buf[sb->len - 1 - trimlen] == '.'		|| sb->buf[sb->len - 1 - trimlen] == '-'))		trimlen++;	strbuf_remove(sb, sb->len - trimlen, trimlen);}
开发者ID:CookieChen,项目名称:git,代码行数:27,


示例5: while

/* * Extract branch information from rebase/bisect */static char *read_and_strip_branch(const char *path){	struct strbuf sb = STRBUF_INIT;	unsigned char sha1[20];	if (strbuf_read_file(&sb, git_path("%s", path), 0) <= 0)		goto got_nothing;	while (&sb.len && sb.buf[sb.len - 1] == '/n')		strbuf_setlen(&sb, sb.len - 1);	if (!sb.len)		goto got_nothing;	if (!prefixcmp(sb.buf, "refs/heads/"))		strbuf_remove(&sb,0, strlen("refs/heads/"));	else if (!prefixcmp(sb.buf, "refs/"))		;	else if (!get_sha1_hex(sb.buf, sha1)) {		const char *abbrev;		abbrev = find_unique_abbrev(sha1, DEFAULT_ABBREV);		strbuf_reset(&sb);		strbuf_addstr(&sb, abbrev);	} else if (!strcmp(sb.buf, "detached HEAD")) /* rebase */		goto got_nothing;	else			/* bisect */		;	return strbuf_detach(&sb, NULL);got_nothing:	strbuf_release(&sb);	return NULL;}
开发者ID:ANKIT-KS,项目名称:git,代码行数:34,


示例6: parse_bundle_header

static int parse_bundle_header(int fd, struct bundle_header *header,			       const char *report_path){	struct strbuf buf = STRBUF_INIT;	int status = 0;	/* The bundle header begins with the signature */	if (strbuf_getwholeline_fd(&buf, fd, '/n') ||	    strcmp(buf.buf, bundle_signature)) {		if (report_path)			error("'%s' does not look like a v2 bundle file",			      report_path);		status = -1;		goto abort;	}	/* The bundle header ends with an empty line */	while (!strbuf_getwholeline_fd(&buf, fd, '/n') &&	       buf.len && buf.buf[0] != '/n') {		unsigned char sha1[20];		int is_prereq = 0;		if (*buf.buf == '-') {			is_prereq = 1;			strbuf_remove(&buf, 0, 1);		}		strbuf_rtrim(&buf);		/*		 * Tip lines have object name, SP, and refname.		 * Prerequisites have object name that is optionally		 * followed by SP and subject line.		 */		if (get_sha1_hex(buf.buf, sha1) ||		    (40 <= buf.len && !isspace(buf.buf[40])) ||		    (!is_prereq && buf.len <= 40)) {			if (report_path)				error("unrecognized header: %s%s (%d)",				      (is_prereq ? "-" : ""), buf.buf, (int)buf.len);			status = -1;			break;		} else {			if (is_prereq)				add_to_ref_list(sha1, "", &header->prerequisites);			else				add_to_ref_list(sha1, buf.buf + 41, &header->references);		}	} abort:	if (status) {		close(fd);		fd = -1;	}	strbuf_release(&buf);	return fd;}
开发者ID:avish,项目名称:git,代码行数:57,


示例7: cleanup_space

static void cleanup_space(struct strbuf *sb){	size_t pos, cnt;	for (pos = 0; pos < sb->len; pos++) {		if (isspace(sb->buf[pos])) {			sb->buf[pos] = ' ';			for (cnt = 0; isspace(sb->buf[pos + cnt + 1]); cnt++);			strbuf_remove(sb, pos + 1, cnt);		}	}}
开发者ID:asoltys,项目名称:git,代码行数:11,


示例8: strbuf_stripout

int strbuf_stripout(struct strbuf *sb, void *buf, size_t len){	len = min(len, sb->len);	if (len == 0)		goto out;	memcpy(buf, sb->buf, len);	strbuf_remove(sb, 0, len);out:	return len;}
开发者ID:higkoo,项目名称:sheepdog,代码行数:11,


示例9: item_length

/* return length of 's' in letters, ANSI escapes stripped */static int item_length(unsigned int colopts, const char *s){	int len, i = 0;	struct strbuf str = STRBUF_INIT;	strbuf_addstr(&str, s);	while ((s = strstr(str.buf + i, "/033[")) != NULL) {		int len = strspn(s + 2, "0123456789;");		i = s - str.buf;		strbuf_remove(&str, i, len + 3); /* /033[<len><func char> */	}	len = utf8_strwidth(str.buf);	strbuf_release(&str);	return len;}
开发者ID:AViscatanius,项目名称:git,代码行数:16,


示例10: strbuf_addf

static char *find_linked_symref(const char *symref, const char *branch,				const char *id){	struct strbuf sb = STRBUF_INIT;	struct strbuf path = STRBUF_INIT;	struct strbuf gitdir = STRBUF_INIT;	char *existing = NULL;	/*	 * $GIT_COMMON_DIR/$symref (e.g. HEAD) is practically outside	 * $GIT_DIR so resolve_ref_unsafe() won't work (it uses	 * git_path). Parse the ref ourselves.	 */	if (id)		strbuf_addf(&path, "%s/worktrees/%s/%s", get_git_common_dir(), id, symref);	else		strbuf_addf(&path, "%s/%s", get_git_common_dir(), symref);	if (!strbuf_readlink(&sb, path.buf, 0)) {		if (!starts_with(sb.buf, "refs/") ||		    check_refname_format(sb.buf, 0))			goto done;	} else if (strbuf_read_file(&sb, path.buf, 0) >= 0 &&	    starts_with(sb.buf, "ref:")) {		strbuf_remove(&sb, 0, strlen("ref:"));		strbuf_trim(&sb);	} else		goto done;	if (strcmp(sb.buf, branch))		goto done;	if (id) {		strbuf_reset(&path);		strbuf_addf(&path, "%s/worktrees/%s/gitdir", get_git_common_dir(), id);		if (strbuf_read_file(&gitdir, path.buf, 0) <= 0)			goto done;		strbuf_rtrim(&gitdir);	} else		strbuf_addstr(&gitdir, get_git_common_dir());	strbuf_strip_suffix(&gitdir, ".git");	existing = strbuf_detach(&gitdir, NULL);done:	strbuf_release(&path);	strbuf_release(&sb);	strbuf_release(&gitdir);	return existing;}
开发者ID:2quala,项目名称:git,代码行数:48,


示例11: rerere_mem_getline

static int rerere_mem_getline(struct strbuf *sb, struct rerere_io *io_){	struct rerere_io_mem *io = (struct rerere_io_mem *)io_;	char *ep;	size_t len;	strbuf_release(sb);	if (!io->input.len)		return -1;	ep = strchrnul(io->input.buf, '/n');	if (*ep == '/n')		ep++;	len = ep - io->input.buf;	strbuf_add(sb, io->input.buf, len);	strbuf_remove(&io->input, 0, len);	return 0;}
开发者ID:LittleForker,项目名称:git,代码行数:17,


示例12: check_emacsclient_version

static int check_emacsclient_version(void){	struct strbuf buffer = STRBUF_INIT;	struct child_process ec_process;	const char *argv_ec[] = { "emacsclient", "--version", NULL };	int version;	/* emacsclient prints its version number on stderr */	memset(&ec_process, 0, sizeof(ec_process));	ec_process.argv = argv_ec;	ec_process.err = -1;	ec_process.stdout_to_stderr = 1;	if (start_command(&ec_process)) {		fprintf(stderr, "Failed to start emacsclient./n");		return -1;	}	strbuf_read(&buffer, ec_process.err, 20);	close(ec_process.err);	/*	 * Don't bother checking return value, because "emacsclient --version"	 * seems to always exits with code 1.	 */	finish_command(&ec_process);	if (prefixcmp(buffer.buf, "emacsclient")) {		fprintf(stderr, "Failed to parse emacsclient version./n");		strbuf_release(&buffer);		return -1;	}	strbuf_remove(&buffer, 0, strlen("emacsclient"));	version = atoi(buffer.buf);	if (version < 22) {		fprintf(stderr,			"emacsclient version '%d' too old (< 22)./n",			version);		strbuf_release(&buffer);		return -1;	}	strbuf_release(&buffer);	return 0;}
开发者ID:Inkdit,项目名称:git,代码行数:45,


示例13: create_directory

static int create_directory(char *p){    int i, ret = 0;    struct strbuf buf = STRBUF_INIT;    strbuf_addstr(&buf, p);    strbuf_addstr(&buf, ".farm");    if (mkdir(buf.buf, 0755) < 0) {        if (errno != EEXIST) {            eprintf("%m/n");            ret = -1;            goto err;        }    }    if (!strlen(farm_dir))        memcpy(farm_dir, buf.buf, buf.len);    strbuf_addstr(&buf, "/objects");    if (mkdir(buf.buf, 0755) < 0) {        if (errno != EEXIST) {            eprintf("%m/n");            ret = -1;            goto err;        }    }    for (i = 0; i < 256; i++) {        strbuf_addf(&buf, "/%02x", i);        if (mkdir(buf.buf, 0755) < 0) {            if (errno != EEXIST) {                eprintf("%m/n");                ret = -1;                goto err;            }        }        strbuf_remove(&buf, buf.len - 3, 3);    }    if (!strlen(farm_obj_dir))        memcpy(farm_obj_dir, buf.buf, buf.len);err:    strbuf_release(&buf);    return ret;}
开发者ID:yaekumo,项目名称:sheepdog,代码行数:44,


示例14: check_emacsclient_version

static int check_emacsclient_version(void){	struct strbuf buffer = STRBUF_INIT;	struct child_process ec_process;	const char *argv_ec[] = { "emacsclient", "--version", NULL };	int version;		memset(&ec_process, 0, sizeof(ec_process));	ec_process.argv = argv_ec;	ec_process.err = -1;	ec_process.stdout_to_stderr = 1;	if (start_command(&ec_process)) {		fprintf(stderr, "Failed to start emacsclient./n");		return -1;	}	strbuf_read(&buffer, ec_process.err, 20);	close(ec_process.err);	finish_command(&ec_process);	if (prefixcmp(buffer.buf, "emacsclient")) {		fprintf(stderr, "Failed to parse emacsclient version./n");		strbuf_release(&buffer);		return -1;	}	strbuf_remove(&buffer, 0, strlen("emacsclient"));	version = atoi(buffer.buf);	if (version < 22) {		fprintf(stderr,			"emacsclient version '%d' too old (< 22)./n",			version);		strbuf_release(&buffer);		return -1;	}	strbuf_release(&buffer);	return 0;}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:41,


示例15: move_window

int move_window(struct sliding_view *view, off_t off, size_t width){	off_t file_offset;	assert(view);	assert(view->width <= view->buf.len);	assert(!check_offset_overflow(view->off, view->buf.len));	if (check_offset_overflow(off, width))		return -1;	if (off < view->off || off + width < view->off + view->width) {		printf("invalid delta: window slides left/n");		return -1;	}	if (view->max_off >= 0 && view->max_off < off + (off_t) width) {		printf("delta preimage ends early/n");		return -1;	}	file_offset = view->off + view->buf.len;	if (off < file_offset) {		/* Move the overlapping region into place. */		strbuf_remove(&view->buf, 0, off - view->off);	} else {		/* Seek ahead to skip the gap. */		if (skip_or_whine(view->file, off - file_offset))			return -1;		strbuf_setlen(&view->buf, 0);	}	if (view->buf.len > width)		; /* Already read. */	else if (read_to_fill_or_whine(view->file, &view->buf, width))		return -1;	view->off = off;	view->width = width;	return 0;}
开发者ID:cemeyer,项目名称:git-isvn,代码行数:39,


示例16: create_directory

static int create_directory(const char *p){	int i, ret = 0;	struct strbuf buf = STRBUF_INIT;	strbuf_addstr(&buf, p);	strbuf_addstr(&buf, ".farm");	if (xmkdir(buf.buf, 0755) < 0) {		sd_eprintf("%m");		ret = -1;		goto err;	}	if (!strlen(farm_dir))		strbuf_copyout(&buf, farm_dir, sizeof(farm_dir));	strbuf_addstr(&buf, "/objects");	if (xmkdir(buf.buf, 0755) < 0) {		sd_eprintf("%m");		ret = -1;		goto err;	}	for (i = 0; i < 256; i++) {		strbuf_addf(&buf, "/%02x", i);		if (xmkdir(buf.buf, 0755) < 0) {			sd_eprintf("%m");			ret = -1;			goto err;		}		strbuf_remove(&buf, buf.len - 3, 3);	}	if (!strlen(farm_obj_dir))		strbuf_copyout(&buf, farm_obj_dir, sizeof(farm_obj_dir));err:	strbuf_release(&buf);	return ret;}
开发者ID:Vinchal,项目名称:sheepdog,代码行数:38,


示例17: parse_ref

/* * read 'path_to_ref' into 'ref'.  Also if is_detached is not NULL, * set is_detached to 1 (0) if the ref is detached (is not detached). * * $GIT_COMMON_DIR/$symref (e.g. HEAD) is practically outside $GIT_DIR so * for linked worktrees, `resolve_ref_unsafe()` won't work (it uses * git_path). Parse the ref ourselves. * * return -1 if the ref is not a proper ref, 0 otherwise (success) */static int parse_ref(char *path_to_ref, struct strbuf *ref, int *is_detached){	if (is_detached)		*is_detached = 0;	if (!strbuf_readlink(ref, path_to_ref, 0)) {		/* HEAD is symbolic link */		if (!starts_with(ref->buf, "refs/") ||				check_refname_format(ref->buf, 0))			return -1;	} else if (strbuf_read_file(ref, path_to_ref, 0) >= 0) {		/* textual symref or detached */		if (!starts_with(ref->buf, "ref:")) {			if (is_detached)				*is_detached = 1;		} else {			strbuf_remove(ref, 0, strlen("ref:"));			strbuf_trim(ref);			if (check_refname_format(ref->buf, 0))				return -1;		}	} else		return -1;	return 0;}
开发者ID:9b,项目名称:git,代码行数:34,


示例18: merge_name

/* Get the name for the merge commit's message. */static void merge_name(const char *remote, struct strbuf *msg){	struct commit *remote_head;	unsigned char branch_head[20];	struct strbuf buf = STRBUF_INIT;	struct strbuf bname = STRBUF_INIT;	const char *ptr;	char *found_ref;	int len, early;	strbuf_branchname(&bname, remote);	remote = bname.buf;	memset(branch_head, 0, sizeof(branch_head));	remote_head = get_merge_parent(remote);	if (!remote_head)		die(_("'%s' does not point to a commit"), remote);	if (dwim_ref(remote, strlen(remote), branch_head, &found_ref) > 0) {		if (!prefixcmp(found_ref, "refs/heads/")) {			strbuf_addf(msg, "%s/t/tbranch '%s' of ./n",				    sha1_to_hex(branch_head), remote);			goto cleanup;		}		if (!prefixcmp(found_ref, "refs/tags/")) {			strbuf_addf(msg, "%s/t/ttag '%s' of ./n",				    sha1_to_hex(branch_head), remote);			goto cleanup;		}		if (!prefixcmp(found_ref, "refs/remotes/")) {			strbuf_addf(msg, "%s/t/tremote-tracking branch '%s' of ./n",				    sha1_to_hex(branch_head), remote);			goto cleanup;		}	}	/* See if remote matches <name>^^^.. or <name>~<number> */	for (len = 0, ptr = remote + strlen(remote);	     remote < ptr && ptr[-1] == '^';	     ptr--)		len++;	if (len)		early = 1;	else {		early = 0;		ptr = strrchr(remote, '~');		if (ptr) {			int seen_nonzero = 0;			len++; /* count ~ */			while (*++ptr && isdigit(*ptr)) {				seen_nonzero |= (*ptr != '0');				len++;			}			if (*ptr)				len = 0; /* not ...~<number> */			else if (seen_nonzero)				early = 1;			else if (len == 1)				early = 1; /* "name~" is "name~1"! */		}	}	if (len) {		struct strbuf truname = STRBUF_INIT;		strbuf_addstr(&truname, "refs/heads/");		strbuf_addstr(&truname, remote);		strbuf_setlen(&truname, truname.len - len);		if (ref_exists(truname.buf)) {			strbuf_addf(msg,				    "%s/t/tbranch '%s'%s of ./n",				    sha1_to_hex(remote_head->object.sha1),				    truname.buf + 11,				    (early ? " (early part)" : ""));			strbuf_release(&truname);			goto cleanup;		}	}	if (!strcmp(remote, "FETCH_HEAD") &&			!access(git_path("FETCH_HEAD"), R_OK)) {		const char *filename;		FILE *fp;		struct strbuf line = STRBUF_INIT;		char *ptr;		filename = git_path("FETCH_HEAD");		fp = fopen(filename, "r");		if (!fp)			die_errno(_("could not open '%s' for reading"),				  filename);		strbuf_getline(&line, fp, '/n');		fclose(fp);		ptr = strstr(line.buf, "/tnot-for-merge/t");		if (ptr)			strbuf_remove(&line, ptr-line.buf+1, 13);		strbuf_addbuf(msg, &line);		strbuf_release(&line);		goto cleanup;	}//.........这里部分代码省略.........
开发者ID:carey94tt,项目名称:git,代码行数:101,


示例19: handle_from

static void handle_from(const struct strbuf *from){	char *at;	size_t el;	struct strbuf f;	strbuf_init(&f, from->len);	strbuf_addbuf(&f, from);	at = strchr(f.buf, '@');	if (!at) {		parse_bogus_from(from);		return;	}	/*	 * If we already have one email, don't take any confusing lines	 */	if (email.len && strchr(at + 1, '@')) {		strbuf_release(&f);		return;	}	/* Pick up the string around '@', possibly delimited with <>	 * pair; that is the email part.	 */	while (at > f.buf) {		char c = at[-1];		if (isspace(c))			break;		if (c == '<') {			at[-1] = ' ';			break;		}		at--;	}	el = strcspn(at, " /n/t/r/v/f>");	strbuf_reset(&email);	strbuf_add(&email, at, el);	strbuf_remove(&f, at - f.buf, el + (at[el] ? 1 : 0));	/* The remainder is name.  It could be	 *	 * - "John Doe <[email
C++ strbuf_setlen函数代码示例
C++ strbuf_release函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。