From d95cf70db1c0cc7d80d862b826ea67ac70c3e92d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 31 Jul 2009 20:42:06 +0200 Subject: [apt-pkg/contrib/strutl.cc] enable thousand separator according to the current locale. Patch from Luca Bruno (Closes: #223712) --- apt-pkg/contrib/strutl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index a991b8988..1683868c8 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -304,13 +304,13 @@ string SizeToStr(double Size) { if (ASize < 100 && I != 0) { - sprintf(S,"%.1f%c",ASize,Ext[I]); + sprintf(S,"%'.1f%c",ASize,Ext[I]); break; } if (ASize < 10000) { - sprintf(S,"%.0f%c",ASize,Ext[I]); + sprintf(S,"%'.0f%c",ASize,Ext[I]); break; } ASize /= 1000.0; -- cgit v1.2.3 From 40e7fe0e053129c28c59acc79e94cc10e89e7738 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 3 Aug 2009 14:31:40 +0200 Subject: =?UTF-8?q?[apt-pkg/contrib/fileutl.cc]=20In=20function=20ExecWait?= =?UTF-8?q?():=20fix=20compile=20warning:=20warning:=20suggest=20explicit?= =?UTF-8?q?=20braces=20to=20avoid=20ambiguous=20=E2=80=98else=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apt-pkg/contrib/fileutl.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index a7de09c44..4240d9f49 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -451,10 +451,12 @@ bool ExecWait(pid_t Pid,const char *Name,bool Reap) if (Reap == true) return false; if (WIFSIGNALED(Status) != 0) + { if( WTERMSIG(Status) == SIGSEGV) return _error->Error(_("Sub-process %s received a segmentation fault."),Name); else return _error->Error(_("Sub-process %s received signal %u."),Name, WTERMSIG(Status)); + } if (WIFEXITED(Status) != 0) return _error->Error(_("Sub-process %s returned an error code (%u)"),Name,WEXITSTATUS(Status)); -- cgit v1.2.3 From 50c409c42a971c6e8a25cb32a87992474247834b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 4 Sep 2009 19:32:45 +0200 Subject: add a helper to easily get a vector of strings from the configuration --- apt-pkg/contrib/configuration.cc | 19 +++++++++++++++++++ apt-pkg/contrib/configuration.h | 3 +++ 2 files changed, 22 insertions(+) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 48a5f0bff..b83ece3e4 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -223,6 +223,25 @@ string Configuration::FindDir(const char *Name,const char *Default) const return Res; } /*}}}*/ +// Configuration::FindVector - Find a vector of values /*{{{*/ +// --------------------------------------------------------------------- +/* Returns a vector of config values under the given item */ +vector Configuration::FindVector(const char *Name) const +{ + vector Vec; + const Item *Top = Lookup(Name); + if (Top == NULL) + return Vec; + + Item *I = Top->Child; + while(I != NULL) + { + Vec.push_back(I->Value); + I = I->Next; + } + return Vec; +} + /*}}}*/ // Configuration::FindI - Find an integer value /*{{{*/ // --------------------------------------------------------------------- /* */ diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index 2534692a3..e2da83f5b 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -31,6 +31,7 @@ #include +#include #include using std::string; @@ -70,6 +71,8 @@ class Configuration string Find(const string Name,const char *Default = 0) const {return Find(Name.c_str(),Default);}; string FindFile(const char *Name,const char *Default = 0) const; string FindDir(const char *Name,const char *Default = 0) const; + std::vector FindVector(const string &Name) const; + std::vector FindVector(const char *Name) const; int FindI(const char *Name,int Default = 0) const; int FindI(const string Name,int Default = 0) const {return FindI(Name.c_str(),Default);}; bool FindB(const char *Name,bool Default = false) const; -- cgit v1.2.3 From c914647fb05653878a14ae391f52b5e94cc73b26 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 7 Sep 2009 14:59:19 +0200 Subject: reintroduce #clear and #include in the config files, they there broken since 0.7.21 with the introduction of #-comments --- apt-pkg/contrib/configuration.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index b83ece3e4..4e8586e83 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -601,9 +601,11 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool AsSectional, InQuote = !InQuote; if (InQuote == true) continue; - - if ((*I == '/' && I + 1 != End && I[1] == '/') || *I == '#') - { + + if ((*I == '/' && I + 1 != End && I[1] == '/') || + (*I == '#' && strcmp(string(I,I+6).c_str(),"#clear") != 0 && + strcmp(string(I,I+8).c_str(),"#include") != 0)) + { End = I; break; } -- cgit v1.2.3 From 1f99b6d338186efe80e314268db44600d3c94a1e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 8 Sep 2009 09:47:12 +0200 Subject: replace unknown multibytes with ? in UTF8ToCharset (Closes: #545208) instead of ignoring the returncode and truncating the string on error --- apt-pkg/contrib/strutl.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 1683868c8..4c05f2df8 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -67,9 +67,20 @@ bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest) outbuf = new char[insize+1]; outptr = outbuf; - iconv(cd, &inptr, &insize, &outptr, &outsize); - *outptr = '\0'; + while (insize != 0) + { + size_t const err = iconv(cd, &inptr, &insize, &outptr, &outsize); + if (err == (size_t)(-1)) + { + insize--; + outsize++; + inptr++; + *outptr = '?'; + outptr++; + } + } + *outptr = '\0'; *dest = outbuf; delete[] outbuf; -- cgit v1.2.3