[pacman-dev] [PATCH] Extract a write_deps function from local database writing

Dan McGee dpmcgee at gmail.com
Fri Mar 9 15:26:13 EST 2012


On Fri, Mar 9, 2012 at 2:16 PM, Dave Reisner <d at falconindy.com> wrote:
> On Fri, Mar 09, 2012 at 02:11:08PM -0600, Dan McGee wrote:
>> This reduces a lot of code duplication in the write function, which
>> cleans it up a bit.
>>
>> Signed-off-by: Dan McGee <dan at archlinux.org>
>> ---
>>  lib/libalpm/be_local.c |   67 ++++++++++++++++--------------------------------
>>  1 file changed, 22 insertions(+), 45 deletions(-)
>>
>> diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
>> index 16c794e..7cce022 100644
>> --- a/lib/libalpm/be_local.c
>> +++ b/lib/libalpm/be_local.c
>> @@ -749,6 +749,22 @@ int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info)
>>       return retval;
>>  }
>>
>> +void write_deps(FILE *fp, const char *header, alpm_list_t *deplist)
>
> static?
Yes, good catch, thanks.

>> +{
>> +     alpm_list_t *lp;
>> +     if(!deplist) {
>> +             return;
>> +     }
>> +     fputs(header, fp);
>> +     fputc('\n', fp);
>> +     for(lp = deplist; lp; lp = lp->next) {
>> +             char *depstring = alpm_dep_compute_string(lp->data);
>> +             fprintf(fp, "%s\n", depstring);
>
> if you're going to use the fputs/fputc combo above for the header, why
> not here as well?
Agreed; I have another patch that converts a number of fprintf() calls
to simpler fputs/fputc calls that don't require %% escaping.

-Dan


More information about the pacman-dev mailing list