summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-05-28 13:22:38 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2016-05-28 18:12:02 +0200
commit8b79c94af7f7cf2e5e5342294bc6e5a908cacabf (patch)
treeb5e7c254f6a4aa96203aee262cf5fb13ded87fbb /methods
parenteceb219c2a64f3f81421c3c6587380b6ae81a530 (diff)
use std::locale::global instead of setlocale
We use a wild mixture of C and C++ ways of generating output, so having a consistent world-view in both styles sounds like a good idea and should help in preventing regressions.
Diffstat (limited to 'methods')
-rw-r--r--methods/aptmethod.h5
-rw-r--r--methods/cdrom.cc15
-rw-r--r--methods/copy.cc7
-rw-r--r--methods/file.cc6
-rw-r--r--methods/ftp.cc10
-rw-r--r--methods/ftp.h1
-rw-r--r--methods/gpgv.cc7
-rw-r--r--methods/http.cc1
-rw-r--r--methods/http.h1
-rw-r--r--methods/http_main.cc6
-rw-r--r--methods/https.cc8
-rw-r--r--methods/https.h3
-rw-r--r--methods/mirror.cc7
-rw-r--r--methods/mirror.h5
-rw-r--r--methods/rred.cc4
-rw-r--r--methods/rsh.cc6
-rw-r--r--methods/rsh.h1
-rw-r--r--methods/server.cc1
-rw-r--r--methods/server.h1
-rw-r--r--methods/store.cc6
20 files changed, 24 insertions, 77 deletions
diff --git a/methods/aptmethod.h b/methods/aptmethod.h
index f8a68c92b..cf3496e45 100644
--- a/methods/aptmethod.h
+++ b/methods/aptmethod.h
@@ -4,6 +4,7 @@
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/configuration.h>
+#include <locale>
#include <string>
class aptMethod : public pkgAcqMethod
@@ -44,7 +45,9 @@ public:
aptMethod(char const * const Binary, char const * const Ver, unsigned long const Flags) :
pkgAcqMethod(Ver, Flags), Binary(Binary)
- {}
+ {
+ std::locale::global(std::locale(""));
+ }
};
#endif
diff --git a/methods/cdrom.cc b/methods/cdrom.cc
index d9ddecb6a..161822ac6 100644
--- a/methods/cdrom.cc
+++ b/methods/cdrom.cc
@@ -10,7 +10,6 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/cdrom.h>
#include <apt-pkg/cdromutl.h>
#include <apt-pkg/error.h>
@@ -19,6 +18,8 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/hashes.h>
+#include "aptmethod.h"
+
#include <string>
#include <vector>
#include <sys/stat.h>
@@ -29,7 +30,7 @@
using namespace std;
-class CDROMMethod : public pkgAcqMethod
+class CDROMMethod : public aptMethod
{
bool DatabaseLoaded;
bool Debug;
@@ -54,9 +55,9 @@ class CDROMMethod : public pkgAcqMethod
// CDROMMethod::CDROMethod - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly |
+CDROMMethod::CDROMMethod() : aptMethod("cdrom", "1.0",SingleInstance | LocalOnly |
SendConfig | NeedsCleanup |
- Removable),
+ Removable),
DatabaseLoaded(false),
Debug(false),
MountedByApt(false)
@@ -279,8 +280,6 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
int main()
{
- setlocale(LC_ALL, "");
-
- CDROMMethod Mth;
- return Mth.Run();
+ _config->CndSet("Binary::cdrom::Debug::NoDropPrivs", true);
+ return CDROMMethod().Run();
}
diff --git a/methods/copy.cc b/methods/copy.cc
index e515b2def..5e3654389 100644
--- a/methods/copy.cc
+++ b/methods/copy.cc
@@ -13,7 +13,6 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/configuration.h>
@@ -95,9 +94,5 @@ bool CopyMethod::Fetch(FetchItem *Itm)
int main()
{
- setlocale(LC_ALL, "");
-
- CopyMethod Mth;
-
- return Mth.Run();
+ return CopyMethod().Run();
}
diff --git a/methods/file.cc b/methods/file.cc
index 36f3c39b9..5cbf1924e 100644
--- a/methods/file.cc
+++ b/methods/file.cc
@@ -15,7 +15,6 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
@@ -129,8 +128,5 @@ bool FileMethod::Fetch(FetchItem *Itm)
int main()
{
- setlocale(LC_ALL, "");
-
- FileMethod Mth;
- return Mth.Run();
+ return FileMethod().Run();
}
diff --git a/methods/ftp.cc b/methods/ftp.cc
index a8bc95938..6a886dd19 100644
--- a/methods/ftp.cc
+++ b/methods/ftp.cc
@@ -18,7 +18,6 @@
#include <config.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/netrc.h>
@@ -1115,9 +1114,7 @@ bool FtpMethod::Fetch(FetchItem *Itm)
/*}}}*/
int main(int, const char *argv[])
-{
- setlocale(LC_ALL, "");
-
+{
/* See if we should be come the http client - we do this for http
proxy urls */
if (getenv("ftp_proxy") != 0)
@@ -1140,8 +1137,5 @@ int main(int, const char *argv[])
exit(100);
}
}
-
- FtpMethod Mth;
-
- return Mth.Run();
+ return FtpMethod().Run();
}
diff --git a/methods/ftp.h b/methods/ftp.h
index de2c232bd..6a12475a0 100644
--- a/methods/ftp.h
+++ b/methods/ftp.h
@@ -10,7 +10,6 @@
#ifndef APT_FTP_H
#define APT_FTP_H
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/strutl.h>
#include "aptmethod.h"
diff --git a/methods/gpgv.cc b/methods/gpgv.cc
index dd395d659..fc6eb9159 100644
--- a/methods/gpgv.cc
+++ b/methods/gpgv.cc
@@ -1,6 +1,5 @@
#include <config.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/gpgv.h>
@@ -427,9 +426,5 @@ bool GPGVMethod::URIAcquire(std::string const &Message, FetchItem *Itm)
int main()
{
- setlocale(LC_ALL, "");
-
- GPGVMethod Mth;
-
- return Mth.Run();
+ return GPGVMethod().Run();
}
diff --git a/methods/http.cc b/methods/http.cc
index 0c3803fbb..b861e61ee 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -28,7 +28,6 @@
#include <config.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
diff --git a/methods/http.h b/methods/http.h
index 9e2b1da5c..5567de715 100644
--- a/methods/http.h
+++ b/methods/http.h
@@ -12,7 +12,6 @@
#define APT_HTTP_H
#include <apt-pkg/strutl.h>
-#include <apt-pkg/acquire-method.h>
#include <string>
#include <sys/time.h>
diff --git a/methods/http_main.cc b/methods/http_main.cc
index cd52c42e8..fa183ddb3 100644
--- a/methods/http_main.cc
+++ b/methods/http_main.cc
@@ -7,13 +7,9 @@
int main()
{
- setlocale(LC_ALL, "");
-
// ignore SIGPIPE, this can happen on write() if the socket
// closes the connection (this is dealt with via ServerDie())
signal(SIGPIPE, SIG_IGN);
- HttpMethod Mth;
-
- return Mth.Loop();
+ return HttpMethod().Loop();
}
diff --git a/methods/https.cc b/methods/https.cc
index fc439bef8..35992ee96 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -13,7 +13,6 @@
#include <config.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/netrc.h>
@@ -528,11 +527,6 @@ std::unique_ptr<ServerState> HttpsMethod::CreateServerState(URI const &uri)/*{{{
int main()
{
- setlocale(LC_ALL, "");
-
- HttpsMethod Mth;
- curl_global_init(CURL_GLOBAL_SSL) ;
-
- return Mth.Run();
+ return HttpsMethod().Run();
}
diff --git a/methods/https.h b/methods/https.h
index 4d50c5a04..74b86a24f 100644
--- a/methods/https.h
+++ b/methods/https.h
@@ -11,8 +11,6 @@
#ifndef APT_HTTPS_H
#define APT_HTTPS_H
-#include <apt-pkg/acquire-method.h>
-
#include <curl/curl.h>
#include <iostream>
#include <stddef.h>
@@ -82,6 +80,7 @@ class HttpsMethod : public ServerMethod
HttpsMethod() : ServerMethod("https","1.2",Pipeline | SendConfig)
{
+ curl_global_init(CURL_GLOBAL_SSL);
curl = curl_easy_init();
};
diff --git a/methods/mirror.cc b/methods/mirror.cc
index 01eed09f0..9d900771b 100644
--- a/methods/mirror.cc
+++ b/methods/mirror.cc
@@ -12,7 +12,6 @@
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/acquire.h>
#include <apt-pkg/error.h>
@@ -465,11 +464,7 @@ void MirrorMethod::URIDone(FetchResult &Res,FetchResult *Alt)
int main()
{
- setlocale(LC_ALL, "");
-
- MirrorMethod Mth;
-
- return Mth.Loop();
+ return MirrorMethod().Loop();
}
diff --git a/methods/mirror.h b/methods/mirror.h
index 425bea673..6ebe08e6b 100644
--- a/methods/mirror.h
+++ b/methods/mirror.h
@@ -1,6 +1,5 @@
// -*- mode: cpp; mode: fold -*-
-// Description /*{{{*/// $Id: http.h,v 1.12 2002/04/18 05:09:38 jgg Exp $
-// $Id: http.h,v 1.12 2002/04/18 05:09:38 jgg Exp $
+// Description /*{{{*/
/* ######################################################################
MIRROR Acquire Method - This is the MIRROR acquire method for APT.
@@ -11,8 +10,6 @@
#ifndef APT_MIRROR_H
#define APT_MIRROR_H
-#include <apt-pkg/acquire-method.h>
-
#include <iostream>
#include <string>
#include <vector>
diff --git a/methods/rred.cc b/methods/rred.cc
index 79ab8cb52..51af37557 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -10,7 +10,6 @@
#include <apt-pkg/init.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/configuration.h>
@@ -704,8 +703,7 @@ int main(int argc, char **argv)
Patch patch;
if (argc <= 1) {
- RredMethod Mth;
- return Mth.Run();
+ return RredMethod().Run();
}
// Usage: rred -t input output diff ...
diff --git a/methods/rsh.cc b/methods/rsh.cc
index 4d133951f..74a908ef7 100644
--- a/methods/rsh.cc
+++ b/methods/rsh.cc
@@ -17,7 +17,6 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/strutl.h>
#include <stdlib.h>
@@ -547,8 +546,5 @@ bool RSHMethod::Fetch(FetchItem *Itm)
int main(int, const char *argv[])
{
- setlocale(LC_ALL, "");
-
- RSHMethod Mth(flNotDir(argv[0]));
- return Mth.Run();
+ return RSHMethod(flNotDir(argv[0])).Run();
}
diff --git a/methods/rsh.h b/methods/rsh.h
index 64a5cf661..571e38ba6 100644
--- a/methods/rsh.h
+++ b/methods/rsh.h
@@ -54,7 +54,6 @@ class RSHConn
~RSHConn();
};
-#include <apt-pkg/acquire-method.h>
#include "aptmethod.h"
class RSHMethod : public aptMethod
diff --git a/methods/server.cc b/methods/server.cc
index d606f26aa..9db45eb8c 100644
--- a/methods/server.cc
+++ b/methods/server.cc
@@ -10,7 +10,6 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
diff --git a/methods/server.h b/methods/server.h
index 3f6502432..1f90f6bd4 100644
--- a/methods/server.h
+++ b/methods/server.h
@@ -12,7 +12,6 @@
#define APT_SERVER_H
#include <apt-pkg/strutl.h>
-#include <apt-pkg/acquire-method.h>
#include "aptmethod.h"
#include <time.h>
diff --git a/methods/store.cc b/methods/store.cc
index 2ad0f0177..934e1a188 100644
--- a/methods/store.cc
+++ b/methods/store.cc
@@ -14,7 +14,6 @@
#include <config.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/hashes.h>
@@ -152,8 +151,5 @@ bool StoreMethod::Fetch(FetchItem *Itm) /*{{{*/
int main(int, char *argv[])
{
- setlocale(LC_ALL, "");
-
- StoreMethod Mth(flNotDir(argv[0]));
- return Mth.Run();
+ return StoreMethod(flNotDir(argv[0])).Run();
}