From d4cd303eae3d686b62b55e8a8202a3430b16f038 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 8 Dec 2008 09:58:04 -0800 Subject: [PATCH] * apt-pkg/indexrecords.cc: - fix some i18n issues * apt-pkg/contrib/strutl.h: - add new strprintf() function to make i18n strings easier --- apt-pkg/contrib/strutl.cc | 15 +++++++++++++++ apt-pkg/contrib/strutl.h | 1 + apt-pkg/indexrecords.cc | 6 +++--- debian/changelog | 4 ++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index bd374fd1e..cdd88827b 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1032,6 +1032,21 @@ void ioprintf(ostream &out,const char *format,...) out << S; } /*}}}*/ +// strprintf - C format string outputter to C++ strings /*{{{*/ +// --------------------------------------------------------------------- +/* This is used to make the internationalization strings easier to translate + and to allow reordering of parameters */ +void strprintf(string &out,const char *format,...) +{ + va_list args; + va_start(args,format); + + // sprintf the description + char S[1024]; + vsnprintf(S,sizeof(S),format,args); + out = string(S); +} + /*}}}*/ // safe_snprintf - Safer snprintf /*{{{*/ // --------------------------------------------------------------------- /* This is a snprintf that will never (ever) go past 'End' and returns a diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 53146ced7..d9972abf4 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -59,6 +59,7 @@ bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length); bool TokSplitString(char Tok,char *Input,char **List, unsigned long ListMax); void ioprintf(ostream &out,const char *format,...) APT_FORMAT2; +void strprintf(string &out,const char *format,...) APT_FORMAT2; char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_FORMAT3; bool CheckDomainList(const string &Host, const string &List); diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 502f454a8..ab208e246 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -37,14 +37,14 @@ bool indexRecords::Load(const string Filename) pkgTagFile TagFile(&Fd, Fd.Size() + 256); // XXX if (_error->PendingError() == true) { - ErrorText = _(("Unable to parse Release file " + Filename).c_str()); + strprintf(ErrorText, _("Unable to parse Release file %s"),Filename.c_str()); return false; } pkgTagSection Section; if (TagFile.Step(Section) == false) { - ErrorText = _(("No sections in Release file " + Filename).c_str()); + strprintf(ErrorText, _("No sections in Release file %s"), Filename.c_str()); return false; } @@ -78,7 +78,7 @@ bool indexRecords::Load(const string Filename) if(HashString::SupportedHashes()[i] == NULL) { - ErrorText = _(("No Hash entry in Release file " + Filename).c_str()); + strprintf(ErrorText, _("No Hash entry in Release file %s"), Filename.c_str()); return false; } diff --git a/debian/changelog b/debian/changelog index 1ab8e0968..77a5bac1f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -35,6 +35,10 @@ apt (0.7.17) UNRELEASED; urgency=low * apt-pkg/deb/dpkgpm.cc: - fix potential hang when in a backgroud process group - fix SIGHUP handling (closes: #463030) + * apt-pkg/indexrecords.cc: + - fix some i18n issues + * apt-pkg/contrib/strutl.h: + - add new strprintf() function to make i18n strings easier [ Dereck Wonnacott ] * apt-ftparchive might write corrupt Release files (LP: #46439) -- 2.45.2