struct stateswitch *swtab[NUMSTATES];
enum state sbtab[NUMSTATES];
+ struct joindata jd;
const char *tmplang;
Solvable *solvable;
Id handle;
-
- Id langcache[ID_NUM_INTERNAL];
};
* find value for xml attribute
* I: txt, name of attribute
* I: atts, list of key/value attributes
- * I: dup, strdup it
* O: pointer to value of matching key, or NULL
*
*/
static inline const char *
-find_attr(const char *txt, const char **atts, int dup)
+find_attr(const char *txt, const char **atts)
{
for (; *atts; atts += 2)
{
if (!strcmp(*atts, txt))
- return dup ? strdup(atts[1]) : atts[1];
+ return atts[1];
}
return 0;
}
/*
- * create localized tag
- */
-
-static Id
-langtag(struct parsedata *pd, Id tag, const char *language)
-{
- if (language && !language[0])
- language = 0;
- if (!language || tag >= ID_NUM_INTERNAL)
- return pool_id2langid(pd->repo->pool, tag, language, 1);
- if (!pd->langcache[tag])
- pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, language, 1);
- return pd->langcache[tag];
-}
-
-
-/*
* XML callback: startElement
*/
case STATE_PRODUCT:
{
/* parse 'type' */
- const char *type = find_attr("type", atts, 0);
+ const char *type = find_attr("type", atts);
s = pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
repodata_extend(pd->data, s - pool->solvables);
pd->handle = s - pool->solvables;
if (type)
- {
- repodata_set_str(pd->data, pd->handle, PRODUCT_TYPE, type);
- }
+ repodata_set_str(pd->data, pd->handle, PRODUCT_TYPE, type);
}
break;
case STATE_VERSION:
{
- const char *ver = find_attr("ver", atts, 0);
- const char *rel = find_attr("rel", atts, 0);
- /* const char *epoch = find_attr("epoch", atts, 1); ignored */
- s->evr = makeevr(pd->pool, join2(ver, "-", rel));
+ const char *ver = find_attr("ver", atts);
+ const char *rel = find_attr("rel", atts);
+ /* const char *epoch = find_attr("epoch", atts); ignored */
+ s->evr = makeevr(pd->pool, join2(&pd->jd, ver, "-", rel));
}
break;
/* <summary lang="xy">... */
case STATE_SUMMARY:
- pd->tmplang = find_attr("lang", atts, 1);
+ pd->tmplang = join_dup(&pd->jd, find_attr("lang", atts));
break;
default:
break;
if (!s->evr)
s->evr = ID_EMPTY;
if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
- s->provides = repo_addid_dep(pd->repo, s->provides, rel2id(pd->pool, s->name, s->evr, REL_EQ, 1), 0);
+ s->provides = repo_addid_dep(pd->repo, s->provides, pool_rel2id(pd->pool, s->name, s->evr, REL_EQ, 1), 0);
pd->solvable = 0;
break;
case STATE_NAME:
- s->name = str2id(pd->pool, join2("product", ":", pd->content), 1);
+ s->name = pool_str2id(pd->pool, join2(&pd->jd, "product", ":", pd->content), 1);
break;
case STATE_ARCH:
- s->arch = str2id(pd->pool, pd->content, 1);
+ s->arch = pool_str2id(pd->pool, pd->content, 1);
break;
case STATE_SUMMARY:
- repodata_set_str(pd->data, pd->handle, langtag(pd, SOLVABLE_SUMMARY, pd->tmplang), pd->content);
- pd->tmplang = sat_free((void *)pd->tmplang);
+ repodata_set_str(pd->data, pd->handle, pool_id2langid(pd->pool, SOLVABLE_SUMMARY, pd->tmplang, 1), pd->content);
break;
case STATE_VENDOR:
- s->vendor = str2id(pd->pool, pd->content, 1);
+ s->vendor = pool_str2id(pd->pool, pd->content, 1);
break;
case STATE_INSTALLTIME:
repodata_set_num(pd->data, pd->handle, SOLVABLE_INSTALLTIME, atol(pd->content));
l = fread(buf, 1, sizeof(buf), fp);
if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
{
- pool_debug(pd->pool, SAT_ERROR, "repo_zyppdb: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
+ pool_debug(pd->pool, SOLV_ERROR, "repo_zyppdb: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
return;
}
if (l == 0)
{
if (strlen(entry->d_name) < 3)
continue; /* skip '.' and '..' */
- fullpath = join2(dirpath, "/", entry->d_name);
+ fullpath = join2(&pd.jd, dirpath, "/", entry->d_name);
if ((fp = fopen(fullpath, "r")) == 0)
{
perror(fullpath);
}
closedir(dir);
- sat_free((void *)pd.tmplang);
free(pd.content);
- join_freemem();
+ join_freemem(&pd.jd);
if (!(flags & REPO_NO_INTERNALIZE))
repodata_internalize(data);
}