Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Save file pattern separately in job pattern.
Vsevolod Stakhov committed 12 years ago
commit 78fd7d0935042fef0185148382a194094086fde3
parent 15661fd
2 files changed +13 -1
modified libpkg/pkg_jobs.c
@@ -98,6 +98,8 @@ pkg_jobs_pattern_free(struct job_pattern *jp)
{
	if (jp->pattern != NULL)
		free(jp->pattern);
+
	if (jp->path != NULL)
+
		free(jp->path);

	free(jp);
}
@@ -139,6 +141,9 @@ pkg_jobs_maybe_match_file(struct job_pattern *jp, const char *pattern)
	const char *dot_pos;
	char *pkg_path;

+
	assert(jp != NULL);
+
	assert(pattern != NULL);
+

	dot_pos = strrchr(pattern, '.');
	if (dot_pos != NULL) {
		/*
@@ -150,8 +155,14 @@ pkg_jobs_maybe_match_file(struct job_pattern *jp, const char *pattern)
			strcmp(dot_pos, "tgz") == 0 ||
			strcmp(dot_pos, "tar") == 0) {
			if ((pkg_path = realpath(pattern, pkg_path)) != NULL) {
+
				/* Dot pos is one character after the dot */
+
				int len = dot_pos - pattern;
+

				jp->is_file = true;
-
				jp->pattern = pkg_path;
+
				jp->path = pkg_path;
+
				jp->pattern = malloc(len);
+
				strlcpy(jp->pattern, pattern, len);
+

				return (true);
			}
		}
modified libpkg/private/pkg.h
@@ -241,6 +241,7 @@ struct pkg_jobs {

struct job_pattern {
	char		*pattern;
+
	char		*path;
	match_t		match;
	bool		is_file;
	UT_hash_handle hh;