Exemple #1
0
Fichier : dir.c Projet : B-Rich/git
int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec)
{
	size_t len;

	/*
	 * Calculate common prefix for the pathspec, and
	 * use that to optimize the directory walk
	 */
	len = common_prefix_len(pathspec);

	/* Read the directory and prune it */
	read_directory(dir, pathspec->nr ? pathspec->_raw[0] : "", len, pathspec);
	return len;
}
Exemple #2
0
static int request_strings_init(req_list *rlp0) {
	rl.cur_entries = rlp0->cur_entries;
	rl.max_entry_len = rlp0->max_entry_len;
	rl.suffix = rlp0->suffix;
	if (!(rl.entries = calloc(rlp0->cur_entries, sizeof(char *))))	return 0;
	rl.alloc_entries = rlp0->cur_entries;
	memcpy(rl.entries, rlp0->entries, rl.cur_entries * sizeof(char *));
	rl0 = rlp0;
	rl.allow_dupes = rl0->allow_dupes;
	rl.allow_reorder = rl0->allow_reorder;
	rl.ignore_tab = rl0->ignore_tab;
	rl.reordered = rl0->reordered;
	rl.cur_chars = rl.alloc_chars = 0;
	rl.chars = NULL;
	fuzz_len = common_prefix_len(&rl);
	prune = false;
	return rl.cur_entries;
}
Exemple #3
0
int fill_directory(struct dir_struct *dir, const char **pathspec)
{
	const char *path;
	size_t len;

	/*
	 * Calculate common prefix for the pathspec, and
	 * use that to optimize the directory walk
	 */
	len = common_prefix_len(pathspec);
	path = "";

	if (len)
		path = xmemdupz(*pathspec, len);

	/* Read the directory and prune it */
	read_directory(dir, path, len, pathspec);
	if (*path)
		free((char *)path);
	return len;
}
Exemple #4
0
static void fuzz_forward(const int c) {
	const int n0 = PXY2N(page,x,y);
	const char * const p0 = rl.entries[n0];

	assert(fuzz_len >= 0);

	if (prune) {
		int i = 0, n1 = 0;
		for (int j = 0; j < rl.cur_entries; j++) {
			char * const p1 = rl.entries[j];
			const int cmp = strncasecmp(p0, p1, fuzz_len);
			if (! cmp && strlen(p1) > fuzz_len && localised_up_case[(unsigned char)p1[fuzz_len]] == c) {
				if (p1 == p0)
					n1 = i;
				rl.entries[i++] = p1;
			}
		}
		if (i) {
			rl.cur_entries = i;
			fuzz_len = common_prefix_len(&rl);
			page = -1; /* causes normalize() to call print_strings() */
			normalize(n1);
		}
	} else {
		/* find the next matching string, possibly wrapping around */
		for (int n=n0, i=rl.cur_entries; i; i--, n=(n+1)%rl.cur_entries) {
			char * const p1 = rl.entries[n];
			const int cmp = strncasecmp(p0, p1, fuzz_len);
			if (!cmp && strlen(p1) > fuzz_len && localised_up_case[(unsigned char)p1[fuzz_len]] == c) {
				fuzz_len++;
				page = -1;
				normalize(n);
				break;
			}
		}
	}
}
Exemple #5
0
/*
 * Returns a copy of the longest leading path common among all
 * pathspecs.
 */
char *common_prefix(const char **pathspec)
{
	unsigned long len = common_prefix_len(pathspec);

	return len ? xmemdupz(*pathspec, len) : NULL;
}
Exemple #6
0
Fichier : dir.c Projet : B-Rich/git
/*
 * Returns a copy of the longest leading path common among all
 * pathspecs.
 */
char *common_prefix(const struct pathspec *pathspec)
{
	unsigned long len = common_prefix_len(pathspec);

	return len ? xmemdupz(pathspec->items[0].match, len) : NULL;
}