On 28/11/19 3:45 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 <[email protected]> > > --- > > v2: > Add comment about why we don't free targ > Fix whitespace error > > I have vim set to display trialing whitespace so normally I catch it. > Not sure why I didn't this time. > > Also I agree that running all the regex against each target before > moving on to the next is a good improvement. This patch is already kinda > long though, so I'll do it another time. > > diff --git a/src/pacman/files.c b/src/pacman/files.c > index 3b6dc23b..6fcc6e9b 100644 > --- a/src/pacman/files.c > +++ b/src/pacman/files.c > @@ -94,17 +94,27 @@ 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); > + /* we don't own ftarg->targ so don't free it */
Patch looks good. I changed that comment to: do not free ftarg->targ as it is owned by the caller of files_search This does a few useful things: 1) gets the "do not free" right at the start of the comment 2) specifies where the memory is owned 3) does not use contractions - apparently the use of "not" make the negative clearer for non-native speakers, although I am not sure what sort of evidence is behind that is claim... Allan
