parse: move and rework parse_fragment_list() as pkg_fragment_parse().

pull/15/head
William Pitcock 2012-05-06 22:29:59 -05:00
parent db6d0e2309
commit c83fd2e616
3 changed files with 22 additions and 22 deletions

View File

@ -120,3 +120,21 @@ pkg_fragment_free(pkg_fragment_t *head)
foreach_list_entry_safe(head, next, node)
pkg_fragment_delete(node);
}
pkg_fragment_t *
pkg_fragment_parse(pkg_fragment_t *head, pkg_tuple_t *vars, const char *value)
{
int i, argc;
char **argv;
char *repstr = pkg_tuple_parse(vars, value);
pkg_argv_split(repstr, &argc, &argv);
for (i = 0; i < argc; i++)
head = pkg_fragment_add(head, argv[i]);
pkg_argv_free(argv);
free(repstr);
return head;
}

25
parse.c
View File

@ -24,25 +24,6 @@
#include "pkg.h"
#include "bsdstubs.h"
static pkg_fragment_t *
parse_fragment_list(pkg_t *pkg, const char *string)
{
int i, argc;
char **argv;
char *repstr = pkg_tuple_parse(pkg->vars, string);
pkg_fragment_t *head = NULL;
pkg_argv_split(repstr, &argc, &argv);
for (i = 0; i < argc; i++)
head = pkg_fragment_add(head, argv[i]);
pkg_argv_free(argv);
free(repstr);
return head;
}
/*
* pkg_dependency_parse(pkg, depends)
*
@ -362,11 +343,11 @@ pkg_new_from_file(const char *filename, FILE *f)
else if (!strcasecmp(key, "Version"))
pkg->version = pkg_tuple_parse(pkg->vars, value);
else if (!strcasecmp(key, "CFLAGS"))
pkg->cflags = parse_fragment_list(pkg, value);
pkg->cflags = pkg_fragment_parse(pkg->cflags, pkg->vars, value);
else if (!strcasecmp(key, "LIBS"))
pkg->libs = parse_fragment_list(pkg, value);
pkg->libs = pkg_fragment_parse(pkg->libs, pkg->vars, value);
else if (!strcasecmp(key, "LIBS.private"))
pkg->libs_private = parse_fragment_list(pkg, value);
pkg->libs_private = pkg_fragment_parse(pkg->libs_private, pkg->vars, value);
else if (!strcasecmp(key, "Requires"))
pkg->requires = pkg_dependency_parse(pkg, value);
else if (!strcasecmp(key, "Requires.private"))

1
pkg.h
View File

@ -154,6 +154,7 @@ int pkg_argv_split(const char *src, int *argc, char ***argv);
void pkg_argv_free(char **argv);
/* fragment.c */
pkg_fragment_t *pkg_fragment_parse(pkg_fragment_t *head, pkg_tuple_t *vars, const char *value);
pkg_fragment_t *pkg_fragment_append(pkg_fragment_t *head, pkg_fragment_t *tail);
pkg_fragment_t *pkg_fragment_add(pkg_fragment_t *head, const char *string);
pkg_fragment_t *pkg_fragment_copy(pkg_fragment_t *head, pkg_fragment_t *base);