summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2001-07-18 23:03:27 +0000
committerjbj <devnull@localhost>2001-07-18 23:03:27 +0000
commit7bfb0979b655aefaf148534a722356cc92c272f8 (patch)
tree17f871dfaae435efb2332459bc96e0444cbbe7c4 /lib
parent2225886928ab5e2784cf782f36355753236a1097 (diff)
downloadrpm-7bfb0979b655aefaf148534a722356cc92c272f8.tar.gz
rpm-7bfb0979b655aefaf148534a722356cc92c272f8.tar.bz2
rpm-7bfb0979b655aefaf148534a722356cc92c272f8.zip
- resurrect --specedit for i18n.
CVS patchset: 4957 CVS date: 2001/07/18 23:03:27
Diffstat (limited to 'lib')
-rw-r--r--lib/query.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/lib/query.c b/lib/query.c
index ccc52deb9..2408edfab 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -388,7 +388,7 @@ exit:
static void
printNewSpecfile(Spec spec)
{
- Header h = spec->packages->header;
+ Header h;
speclines sl = spec->sl;
spectags st = spec->st;
const char * msgstr = NULL;
@@ -401,11 +401,38 @@ printNewSpecfile(Spec spec)
spectag t = st->st_t + i;
const char * tn = tagName(t->t_tag);
const char * errstr;
- char fmt[128];
+ char fmt[1024];
+
+ fmt[0] = '\0';
+ if (t->t_msgid == NULL)
+ h = spec->packages->header;
+ else {
+ Package pkg;
+ char *fe;
+
+ strcpy(fmt, t->t_msgid);
+ for (fe = fmt; *fe && *fe != '('; fe++)
+ {} ;
+ if (*fe == '(') *fe = '\0';
+ h = NULL;
+ for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
+ const char *pkgname;
+ h = pkg->header;
+ headerNVR(h, &pkgname, NULL, NULL);
+ if (!strcmp(pkgname, fmt))
+ break;
+ }
+ if (pkg == NULL || h == NULL)
+ h = spec->packages->header;
+ }
+
+ if (h == NULL)
+ continue;
fmt[0] = '\0';
- (void) stpcpy( stpcpy( stpcpy( fmt, "%{"), tn), "}\n");
+ (void) stpcpy( stpcpy( stpcpy( fmt, "%{"), tn), "}");
msgstr = _free(msgstr);
+
msgstr = headerSprintf(h, fmt, rpmTagTable, rpmHeaderFormats, &errstr);
if (msgstr == NULL) {
rpmError(RPMERR_QFMT, _("can't query %s: %s\n"), tn, errstr);
@@ -427,6 +454,8 @@ printNewSpecfile(Spec spec)
break;
case RPMTAG_DESCRIPTION:
for (j = 1; j < t->t_nlines; j++) {
+ if (*sl->sl_lines[t->t_startx + j] == '%')
+ continue;
/*@-unqualifiedtrans@*/
sl->sl_lines[t->t_startx + j] =
_free(sl->sl_lines[t->t_startx + j]);
@@ -445,9 +474,12 @@ printNewSpecfile(Spec spec)
msgstr = _free(msgstr);
for (i = 0; i < sl->sl_nlines; i++) {
- if (sl->sl_lines[i] == NULL)
+ const char * s = sl->sl_lines[i];
+ if (s == NULL)
continue;
- printf("%s", sl->sl_lines[i]);
+ printf("%s", s);
+ if (strchr(s, '\n') == NULL && s[strlen(s)-1] != '\n')
+ printf("\n");
}
}