parse: move OPERATOR_CHAR() and friends to pkg.h

feature/tap-sh
William Pitcock 2012-05-05 21:26:15 -05:00
parent 4692277660
commit 433d697351
2 changed files with 11 additions and 11 deletions

19
parse.c
View File

@ -166,9 +166,6 @@ pkg_dependency_add(pkg_dependency_t *head, const char *package, const char *vers
return dep;
}
#define MODULE_SEPARATOR(c) ((c) == ',' || isspace ((c)))
#define OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=')
pkg_dependency_t *
pkg_dependency_append(pkg_dependency_t *head, pkg_dependency_t *tail)
{
@ -213,7 +210,7 @@ parse_deplist(pkg_t *pkg, const char *depends)
switch (state)
{
case OUTSIDE_MODULE:
if (!MODULE_SEPARATOR(*ptr))
if (!PKG_MODULE_SEPARATOR(*ptr))
state = INSIDE_MODULE_NAME;
break;
@ -228,14 +225,14 @@ parse_deplist(pkg_t *pkg, const char *depends)
if (*sptr == '\0')
state = OUTSIDE_MODULE;
else if (MODULE_SEPARATOR(*sptr))
else if (PKG_MODULE_SEPARATOR(*sptr))
state = OUTSIDE_MODULE;
else if (OPERATOR_CHAR(*sptr))
else if (PKG_OPERATOR_CHAR(*sptr))
state = BEFORE_OPERATOR;
else
state = OUTSIDE_MODULE;
}
else if (MODULE_SEPARATOR(*ptr))
else if (PKG_MODULE_SEPARATOR(*ptr))
state = OUTSIDE_MODULE;
else if (*(ptr + 1) == '\0')
{
@ -247,7 +244,7 @@ parse_deplist(pkg_t *pkg, const char *depends)
{
char *iter = start;
while (MODULE_SEPARATOR(*iter))
while (PKG_MODULE_SEPARATOR(*iter))
iter++;
package = strndup(iter, ptr - iter);
@ -282,7 +279,7 @@ parse_deplist(pkg_t *pkg, const char *depends)
break;
case BEFORE_OPERATOR:
if (OPERATOR_CHAR(*ptr))
if (PKG_OPERATOR_CHAR(*ptr))
{
switch(*ptr)
{
@ -308,7 +305,7 @@ parse_deplist(pkg_t *pkg, const char *depends)
break;
case INSIDE_OPERATOR:
if (!OPERATOR_CHAR(*ptr))
if (!PKG_OPERATOR_CHAR(*ptr))
state = AFTER_OPERATOR;
else if (*ptr == '=')
{
@ -340,7 +337,7 @@ parse_deplist(pkg_t *pkg, const char *depends)
break;
case INSIDE_VERSION:
if (MODULE_SEPARATOR(*ptr) || *(ptr + 1) == '\0')
if (PKG_MODULE_SEPARATOR(*ptr) || *(ptr + 1) == '\0')
{
version = strndup(vstart, (ptr - vstart));
state = OUTSIDE_MODULE;

3
pkg.h
View File

@ -109,6 +109,9 @@ struct pkg_ {
pkg_tuple_t *vars;
};
#define PKG_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((c)))
#define PKG_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=')
#define PKGF_NONE 0x0
#define PKGF_SEARCH_PRIVATE 0x1
#define PKGF_ENV_ONLY 0x2