summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2019-09-02 13:00:40 +0200
committerGuillem Jover <guillem@debian.org>2019-10-30 22:02:45 +0100
commit935072fed354c9ddd0704a552be1f6996bfccc10 (patch)
treebf73a3f3257480700b22dff1280ff10cae7543e7
parent15af35e78ad21a4a52a0ea22a689da93ccbf1e0a (diff)
downloaddpkg-935072fed354c9ddd0704a552be1f6996bfccc10.tar.gz
libdpkg: Add new versiondescribe_c() to force a C locale
In some contexts we need output in the C locale, such as log files. We add a new versiondescribe_c() that wraps the locale-dependant versiondescribe() function and switches to the C locale and back to the previous one before returning.
-rw-r--r--debian/changelog1
-rw-r--r--lib/dpkg/dpkg-db.h2
-rw-r--r--lib/dpkg/libdpkg.map1
-rw-r--r--lib/dpkg/parsehelp.c14
4 files changed, 18 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 904ce31d3..e89b28849 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -50,6 +50,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium
- dpkg-deb: Fold two adjacent if conditionals into a single one.
- dpkg: Initialize flagdeppossi in check_conflict().
- libdpkg: Add new C locale switch over support.
+ - libdpkg: Add new versiondescribe_c() to force a C locale.
* Build system:
- Bump minimal Perl version to 5.24.1.
- Add a serial versioning to the m4 files.
diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index 3e9158def..10de6d3e2 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -392,6 +392,8 @@ int parseversion(struct dpkg_version *version, const char *,
struct dpkg_error *err);
const char *versiondescribe(const struct dpkg_version *,
enum versiondisplayepochwhen);
+const char *versiondescribe_c(const struct dpkg_version *version,
+ enum versiondisplayepochwhen vdew);
enum pkg_name_arch_when {
/** Never display arch. */
diff --git a/lib/dpkg/libdpkg.map b/lib/dpkg/libdpkg.map
index 9dd699358..953944752 100644
--- a/lib/dpkg/libdpkg.map
+++ b/lib/dpkg/libdpkg.map
@@ -256,6 +256,7 @@ LIBDPKG_PRIVATE {
dpkg_version_compare;
dpkg_version_relate;
versiondescribe;
+ versiondescribe_c;
parseversion;
# Architecture database
diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
index a9095f1f4..34247269e 100644
--- a/lib/dpkg/parsehelp.c
+++ b/lib/dpkg/parsehelp.c
@@ -188,6 +188,20 @@ const char *versiondescribe
return vb->buf;
}
+const char *
+versiondescribe_c(const struct dpkg_version *version,
+ enum versiondisplayepochwhen vdew)
+{
+ struct dpkg_locale oldloc;
+ const char *str;
+
+ oldloc = dpkg_locale_switch_C();
+ str = versiondescribe(version, vdew);
+ dpkg_locale_switch_back(oldloc);
+
+ return str;
+}
+
/**
* Parse a version string and check for invalid syntax.
*