summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2013-07-12 19:04:55 +0200
committerMichael Schroeder <mls@suse.de>2013-07-12 19:04:55 +0200
commit8ce1a1397ea9270918e6ba2e7c15deec1e54af96 (patch)
treeb96108106166682c78739b77c9a87078d5950dec
parent9665e746338a78d717ef8156f0862e74b96a873e (diff)
downloadlibsolv-8ce1a1397ea9270918e6ba2e7c15deec1e54af96.tar.gz
libsolv-8ce1a1397ea9270918e6ba2e7c15deec1e54af96.tar.bz2
libsolv-8ce1a1397ea9270918e6ba2e7c15deec1e54af96.zip
refactor a bit, no functional changes
-rw-r--r--ext/repo_rpmdb.c85
1 files changed, 44 insertions, 41 deletions
diff --git a/ext/repo_rpmdb.c b/ext/repo_rpmdb.c
index 6b1a196..ea04e07 100644
--- a/ext/repo_rpmdb.c
+++ b/ext/repo_rpmdb.c
@@ -771,6 +771,49 @@ addchangelog(Repodata *data, Id handle, RpmHead *rpmhead)
solv_free(cn);
}
+static void
+set_description_author(Repodata *data, Id handle, char *str)
+{
+ char *aut, *p;
+ for (aut = str; (aut = strchr(aut, '\n')) != 0; aut++)
+ if (!strncmp(aut, "\nAuthors:\n--------\n", 19))
+ break;
+ if (aut)
+ {
+ /* oh my, found SUSE special author section */
+ int l = aut - str;
+ str = solv_strdup(str);
+ aut = str + l;
+ str[l] = 0;
+ while (l > 0 && str[l - 1] == '\n')
+ str[--l] = 0;
+ if (l)
+ setutf8string(data, handle, SOLVABLE_DESCRIPTION, str);
+ p = aut + 19;
+ aut = str; /* copy over */
+ while (*p == ' ' || *p == '\n')
+ p++;
+ while (*p)
+ {
+ if (*p == '\n')
+ {
+ *aut++ = *p++;
+ while (*p == ' ')
+ p++;
+ continue;
+ }
+ *aut++ = *p++;
+ }
+ while (aut != str && aut[-1] == '\n')
+ aut--;
+ *aut = 0;
+ if (*str)
+ setutf8string(data, handle, SOLVABLE_AUTHORS, str);
+ free(str);
+ }
+ else if (*str)
+ setutf8string(data, handle, SOLVABLE_DESCRIPTION, str);
+}
static int
rpm2solv(Pool *pool, Repo *repo, Repodata *data, Solvable *s, RpmHead *rpmhead, int flags)
@@ -831,47 +874,7 @@ rpm2solv(Pool *pool, Repo *repo, Repodata *data, Solvable *s, RpmHead *rpmhead,
setutf8string(data, handle, SOLVABLE_SUMMARY, str);
str = headstring(rpmhead, TAG_DESCRIPTION);
if (str)
- {
- char *aut, *p;
- for (aut = str; (aut = strchr(aut, '\n')) != 0; aut++)
- if (!strncmp(aut, "\nAuthors:\n--------\n", 19))
- break;
- if (aut)
- {
- /* oh my, found SUSE special author section */
- int l = aut - str;
- str = solv_strdup(str);
- aut = str + l;
- str[l] = 0;
- while (l > 0 && str[l - 1] == '\n')
- str[--l] = 0;
- if (l)
- setutf8string(data, handle, SOLVABLE_DESCRIPTION, str);
- p = aut + 19;
- aut = str; /* copy over */
- while (*p == ' ' || *p == '\n')
- p++;
- while (*p)
- {
- if (*p == '\n')
- {
- *aut++ = *p++;
- while (*p == ' ')
- p++;
- continue;
- }
- *aut++ = *p++;
- }
- while (aut != str && aut[-1] == '\n')
- aut--;
- *aut = 0;
- if (*str)
- setutf8string(data, handle, SOLVABLE_AUTHORS, str);
- free(str);
- }
- else if (*str)
- setutf8string(data, handle, SOLVABLE_DESCRIPTION, str);
- }
+ set_description_author(data, handle, str);
str = headstring(rpmhead, TAG_GROUP);
if (str)
repodata_set_poolstr(data, handle, SOLVABLE_GROUP, str);