summaryrefslogtreecommitdiff
path: root/lib/query.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2000-02-23 17:34:41 +0000
committerjbj <devnull@localhost>2000-02-23 17:34:41 +0000
commitbecec721d0a3e2f927b1abed7ef792724f9a642d (patch)
tree01256b4dd77fe33cd5b8c739510445d28d6e9924 /lib/query.c
parent6e545408441c511267b1252e29ea0668f3cc37ce (diff)
downloadrpm-becec721d0a3e2f927b1abed7ef792724f9a642d.tar.gz
rpm-becec721d0a3e2f927b1abed7ef792724f9a642d.tar.bz2
rpm-becec721d0a3e2f927b1abed7ef792724f9a642d.zip
i18n lookaside.
CVS patchset: 3581 CVS date: 2000/02/23 17:34:41
Diffstat (limited to 'lib/query.c')
-rw-r--r--lib/query.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/lib/query.c b/lib/query.c
index 531077d41..1b1a8439b 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -7,6 +7,8 @@
#include "rpmbuild.h"
#include <rpmurl.h>
+int specedit = 0;
+
/* ======================================================================== */
static char * permsString(int mode)
{
@@ -131,11 +133,11 @@ static void printFileInfo(FILE *fp, const char * name,
static int queryHeader(FILE *fp, Header h, const char * chptr)
{
char * str;
- const char * error;
+ const char * errstr;
- str = headerSprintf(h, chptr, rpmTagTable, rpmHeaderFormats, &error);
- if (!str) {
- fprintf(stderr, _("error in format: %s\n"), error);
+ str = headerSprintf(h, chptr, rpmTagTable, rpmHeaderFormats, &errstr);
+ if (str == NULL) {
+ fprintf(stderr, _("error in format: %s\n"), errstr);
return 1;
}
@@ -329,28 +331,29 @@ int showQueryPackage(QVA_t *qva, /*@unused@*/rpmdb db, Header h)
static void
printNewSpecfile(Spec spec)
{
+ Header h = spec->packages->header;
struct speclines *sl = spec->sl;
struct spectags *st = spec->st;
- char buf[8192];
+ const char * msgstr = NULL;
int i, j;
if (sl == NULL || st == NULL)
return;
for (i = 0; i < st->st_ntags; i++) {
- char *msgstr;
- struct spectag *t;
- t = st->st_t + i;
-
- /* XXX Summary tag often precedes name, so build msgid now. */
- if (t->t_msgid == NULL) {
- char *n;
- headerGetEntry(spec->packages->header, RPMTAG_NAME, NULL,
- (void **) &n, NULL);
- sprintf(buf, "%s(%s)", n, tagName(t->t_tag));
- t->t_msgid = xstrdup(buf);
+ struct spectag * t = st->st_t + i;
+ const char * tn = tagName(t->t_tag);
+ const char * errstr;
+ char fmt[128];
+
+ fmt[0] = '\0';
+ (void) stpcpy( stpcpy( stpcpy( fmt, "%{"), tn), "}\n");
+ if (msgstr) xfree(msgstr);
+ msgstr = headerSprintf(h, fmt, rpmTagTable, rpmHeaderFormats, &errstr);
+ if (msgstr == NULL) {
+ fprintf(stderr, _("can't query %s: %s\n"), tn, errstr);
+ return;
}
- msgstr = xstrdup(/*@-unrecog@*/ dgettext(specedit, t->t_msgid) /*@=unrecog@*/);
switch(t->t_tag) {
case RPMTAG_SUMMARY:
@@ -359,10 +362,10 @@ printNewSpecfile(Spec spec)
sl->sl_lines[t->t_startx] = NULL;
if (t->t_lang && strcmp(t->t_lang, RPMBUILD_DEFAULT_LANG))
continue;
- sprintf(buf, "%s: %s\n",
- ((t->t_tag == RPMTAG_GROUP) ? "Group" : "Summary"),
- msgstr);
- sl->sl_lines[t->t_startx] = xstrdup(buf);
+ { char *buf = xmalloc(strlen(tn) + sizeof(": ") + strlen(msgstr));
+ (void) stpcpy( stpcpy( stpcpy(buf, tn), ": "), msgstr);
+ sl->sl_lines[t->t_startx] = buf;
+ }
break;
case RPMTAG_DESCRIPTION:
for (j = 1; j < t->t_nlines; j++) {
@@ -380,6 +383,7 @@ printNewSpecfile(Spec spec)
break;
}
}
+ if (msgstr) xfree(msgstr);
for (i = 0; i < sl->sl_nlines; i++) {
if (sl->sl_lines[i] == NULL)
@@ -447,7 +451,6 @@ int (*parseSpecVec) (Spec *specp, const char *specFile, const char *rootdir,
const char *buildRoot, int inBuildArch, const char *passPhrase,
char *cookie, int anyarch, int force) = NULL;
void (*freeSpecVec) (Spec spec) = NULL;
-char *specedit = NULL;
int rpmQueryVerify(QVA_t *qva, enum rpmQVSources source, const char * arg,
rpmdb db, QVF_t showPackage)
@@ -545,7 +548,7 @@ int rpmQueryVerify(QVA_t *qva, enum rpmQVSources source, const char * arg,
break;
}
- if (specedit != NULL) {
+ if (specedit) {
printNewSpecfile(spec);
freeSpecVec(spec);
retcode = 0;
@@ -804,9 +807,8 @@ struct poptOption rpmQueryPoptTable[] = {
POPT_QUERYFORMAT, NULL, NULL },
{ "queryformat", '\0', POPT_ARG_STRING, 0, POPT_QUERYFORMAT,
N_("use the following query format"), "QUERYFORMAT" },
- { "specedit", '\0', POPT_ARG_STRING, &specedit, 0,
- N_("substitute i18n sections from the following catalogue"),
- "METACATALOGUE" },
+ { "specedit", '\0', POPT_ARG_VAL, &specedit, -1,
+ N_("substitute i18n sections into spec file"), NULL },
{ "state", 's', 0, 0, 's',
N_("display the states of the listed files"), NULL },
{ "verbose", 'v', 0, 0, 'v',