[Dctrl-tools-devel] Bug#674836: Please review the included patch
Antti-Juhani Kaijanaho
antti-juhani at kaijanaho.fi
Mon May 28 16:49:02 UTC 2012
Please review the following patch. I intend to release it in the next 2.22.x
series upload. It changes no strings but is otherwise a bit intrusive for a
point-release patch.
From 530812104719d5e75264e60b1e854754f1bb0c1e Mon Sep 17 00:00:00 2001
From: Antti-Juhani Kaijanaho <ajk at debian.org>
Date: Mon, 28 May 2012 19:42:40 +0300
Subject: [PATCH] Fix #674836 (Builds with wrong CFLAGS)
- Upgrade debhelper mode to 9.
- Work around debhelper bug 674912 by not defining a default CFLAGS
in GNUmakefile.
- Since the new Debian build flags make it impossible to use mblen
with -Werror, switch to using mbrlen in tbl-dctrl.c (a good idea
in any case).
- Add a test case (tests/0021.{in,out,sh}) to verify that tbl-dctrl
handles UTF-8 correctly (needed to regression-test the above bugfix).
- As the previous item requires the C.UTF-8 locale, build-depend on
libc-bin >= 2.13
Signed-off-by: Antti-Juhani Kaijanaho <ajk at debian.org>
---
GNUmakefile | 3 +--
debian/changelog | 15 ++++++++++++---
debian/compat | 2 +-
debian/control | 2 +-
tbl-dctrl/tbl-dctrl.c | 21 +++++++++++++--------
tests/0021.in | 2 ++
tests/0021.out | 5 +++++
tests/0021.sh | 5 +++++
8 files changed, 40 insertions(+), 15 deletions(-)
create mode 100644 tests/0021.in
create mode 100644 tests/0021.out
create mode 100644 tests/0021.sh
diff --git a/GNUmakefile b/GNUmakefile
index 3a25b8e..c79aada 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -14,8 +14,7 @@ man8dir = $(mandir)/man8
localedir = $(datarootdir)/locale
CC = gcc
-CFLAGS = -g -Wall -Werror
-ALL_CFLAGS = $(CFLAGS) -std=gnu99 -Ilib \
+ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS) -Wall -Werror -std=gnu99 -Ilib \
-DENABLE_L_DEBUG -D_GNU_SOURCE -DSYSCONF=\"$(sysconfdir)\" \
-DHAVE_GETTEXT -DPACKAGE=\"dctrl-tools\" -DLOCALEDIR=\"$(localedir)\"
diff --git a/debian/changelog b/debian/changelog
index 7a860e8..3b9e32a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,17 @@
dctrl-tools (2.22.2) UNRELEASED; urgency=low
- *
-
- -- Antti-Juhani Kaijanaho <ajk at debian.org> Mon, 28 May 2012 18:05:31 +0300
+ * Closes: #674836 (Builds with wrong CFLAGS), reported by me:
+ - Upgrade debhelper mode to 9.
+ - Work around debhelper bug 674912 by not defining a default CFLAGS
+ in GNUmakefile.
+ - Since the new Debian build flags make it impossible to use mblen
+ with -Werror, switch to using mbrlen in tbl-dctrl.c (a good idea
+ in any case).
+ * Add a test case (tests/0021.{in,out,sh}) to verify that tbl-dctrl
+ handles UTF-8 correctly (needed to regression-test the above bugfix).
+ - As it requires the C.UTF-8 locale, build-depend on libc-bin >= 2.13
+
+ -- Antti-Juhani Kaijanaho <ajk at debian.org> Mon, 28 May 2012 19:36:34 +0300
dctrl-tools (2.22.1) unstable; urgency=low
diff --git a/debian/compat b/debian/compat
index 45a4fb7..ec63514 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-8
+9
diff --git a/debian/control b/debian/control
index 16b2d41..39143d8 100644
--- a/debian/control
+++ b/debian/control
@@ -4,7 +4,7 @@ Priority: optional
Maintainer: dctrl-tools developers <dctrl-tools-devel at lists.alioth.debian.org>
Uploaders: Antti-Juhani Kaijanaho <ajk at debian.org>
Standards-Version: 3.9.3
-Build-Depends: gettext (>= 0.11-0), gcc (>= 3.0), debhelper (>= 8), po4a (>= 0.40)
+Build-Depends: gettext (>= 0.11-0), gcc (>= 3.0), debhelper (>= 9), po4a (>= 0.40), libc-bin (>= 2.13)
Vcs-Git: git://git.debian.org/git/collab-maint/dctrl-tools.git
Vcs-Browser: http://git.debian.org/?p=collab-maint/dctrl-tools.git;a=summary
diff --git a/tbl-dctrl/tbl-dctrl.c b/tbl-dctrl/tbl-dctrl.c
index 848f3f3..b295589 100644
--- a/tbl-dctrl/tbl-dctrl.c
+++ b/tbl-dctrl/tbl-dctrl.c
@@ -1,5 +1,5 @@
/* dctrl-tools - Debian control file inspection tools
- Copyright © 2005, 2006, 2007, 2008, 2009, 2010, 2011 Antti-Juhani Kaijanaho
+ Copyright © 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Antti-Juhani Kaijanaho
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
#include <argp.h>
#include <locale.h>
#include <stdlib.h>
+#include <wchar.h>
#include "misc.h"
#include "msg.h"
#include "i18n.h"
@@ -96,7 +97,8 @@ size_t linewrap(char **res, char const *orig, size_t orig_len,
size_t num_lines = 1;
- mblen(NULL, 0);
+ mbstate_t mbs;
+ memset(&mbs, 0, sizeof mbs);
for (size_t i = 0; i < orig_len; /**/) {
if (orig[i] == '\n') {
i++;
@@ -125,7 +127,7 @@ size_t linewrap(char **res, char const *orig, size_t orig_len,
bpo = i;
bpr = len;
}
- int n = mblen(orig + i, orig_len - i);
+ int n = mbrlen(orig + i, orig_len - i, &mbs);
if (n <= 0) break;
for (size_t j = 0; j < n; j++) INSERT(orig[i+j]);
i += n;
@@ -161,7 +163,8 @@ void print_line(struct arguments *args,
} else if (j > 0) {
fputs(args->delim, stdout);
}
- mblen(NULL, 0);
+ mbstate_t mbs;
+ memset(&mbs, 0, sizeof mbs);
size_t k;
size_t m = 0;
for (k = data[j].inx;
@@ -171,8 +174,9 @@ void print_line(struct arguments *args,
k++;
break;
}
- int n = mblen(data[j].wrapped + k,
- data[j].wrapped_len - k);
+ int n = mbrlen(data[j].wrapped + k,
+ data[j].wrapped_len - k,
+ &mbs);
for (int l = 0; l < n; l++) {
putchar(data[j].wrapped[k+l]);
}
@@ -344,7 +348,8 @@ static size_t mbs_len(char const *mbs, size_t n, char const *fname)
if (n == (size_t)(-1)) n = strlen(mbs);
size_t mlen = 0;
size_t len = 0;
- mblen(NULL, 0);
+ mbstate_t mbstate;
+ memset(&mbstate, 0, sizeof mbstate);
for (size_t k = 0; k < n;/**/) {
if (mbs[k] == '\n') {
if (len > mlen) mlen = len;
@@ -353,7 +358,7 @@ static size_t mbs_len(char const *mbs, size_t n, char const *fname)
continue;
}
len++;
- int delta = mblen(mbs + k, n - k);
+ int delta = mbrlen(mbs + k, n - k, &mbstate);
if (delta <= 0) {
message(L_IMPORTANT, fname,
_("bad multibyte character"));
diff --git a/tests/0021.in b/tests/0021.in
new file mode 100644
index 0000000..b2236bf
--- /dev/null
+++ b/tests/0021.in
@@ -0,0 +1,2 @@
+Foo: äiti
+Bar: 42
diff --git a/tests/0021.out b/tests/0021.out
new file mode 100644
index 0000000..b2af061
--- /dev/null
+++ b/tests/0021.out
@@ -0,0 +1,5 @@
++======+=====+
+| Foo | Bar |
++------+-----+
+| äiti | 42 |
++======+=====+
diff --git a/tests/0021.sh b/tests/0021.sh
new file mode 100644
index 0000000..8b9fa6a
--- /dev/null
+++ b/tests/0021.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -e
+
+LC_ALL=C.UTF-8 $TBL_DCTRL
--
1.7.10
--
Antti-Juhani Kaijanaho, Jyväskylä, Finland
http://antti-juhani.kaijanaho.fi/newblog/
http://www.flickr.com/photos/antti-juhani/
More information about the Dctrl-tools-devel
mailing list