[pacman-dev] [PATCH] pacman: print error when -Fx is given invalid regex

Allan McRae allan at archlinux.org
Tue Nov 26 00:33:53 UTC 2019

On 12/11/19 11:48 am, morganamilo wrote:
> When processing the targets for -Fx, compile all the regex ahead of
> time, printing an error for each that failed to compile. Then, if they all
> compiled successfully, continue with printing files.
> Signed-off-by: morganamilo <morganamilo at gmail.com>
> diff --git a/src/pacman/files.c b/src/pacman/files.c
> index 3b6dc23b..91d891a6 100644
> --- a/src/pacman/files.c
> +++ b/src/pacman/files.c
> @@ -94,17 +94,26 @@ static void print_match(alpm_list_t *match, alpm_db_t *repo, alpm_pkg_t *pkg, in
>  	}
>  }
> +struct filetarget {
> +	char *targ;
> +	int exact_file;
> +	regex_t reg;
> +};
> +
> +static void filetarget_free(struct filetarget *ftarg) {
> +	regfree(&ftarg->reg);
> +	free(ftarg);
> +}
> +

Rest of the patch looks fine.  But first thing I saw here was we are not
freeing char* targ.  But we don't have to because the memory is held

Add a comment to clarify that an I am happy with the patch.


.git/rebase-apply/patch:42: trailing whitespace.
warning: 1 line adds whitespace errors.

You can enable a git hook to stop you committing files with whitespace

As an aside, now we precompile all regex, I wonder if we should loop
though them withing each package?  e.g. "pacman -F foo bar" in Arch
Luinux gives a result for community/phonegap in two different places in
the output.


More information about the pacman-dev mailing list